diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 0000000..2f50c66 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,768 @@ +Notes on the Free Translation Project +************************************* + +Free software is going international! The Free Translation Project is +a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +Quick configuration advice +========================== + +If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias, message inheritance, automatic +charset conversion or plural form handling) as the implementation here. +It is also not possible to offer this additional functionality on top +of a `catgets' implementation. Future versions of GNU `gettext' will +very likely convey even more functionality. So it might be a good idea +to change to GNU `gettext' as soon as possible. + + So you need _not_ provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + +Some packages are "localizable" when properly installed; the programs +they contain can be made to speak your own native language. Most such +packages use GNU `gettext'. Other packages have their own ways to +internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. If not, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is _not_ required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --disable-nls + +will respectively bypass any pre-existing `gettext' to use the +internationalizing routines provided within this package, or else, +_totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + The configuration process will not test for the `catgets' function +and therefore it will not be used. The reason is that even an +emulation of `gettext' on top of `catgets' could not provide all the +extensions of the GNU `gettext' library. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + +As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, +and `CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your country by running the command +`locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + Special advice for Norwegian users: The language code for Norwegian +bokma*l changed from `no' to `nb' recently (in 2003). During the +transition period, while some message catalogs for this language are +installed under `nb' and some older ones under `no', it's recommended +for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and +older translations are used. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +Translating Teams +================= + +For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" +area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + +Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of January +2004. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files af am ar az be bg bs ca cs da de el en en_GB eo es + +----------------------------------------------------+ + a2ps | [] [] [] [] | + aegis | () | + ant-phone | () | + anubis | | + ap-utils | | + aspell | [] | + bash | [] [] [] [] | + batchelor | | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] | + bluez-pin | [] [] [] | + clisp | | + clisp | [] [] [] | + console-tools | [] [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + darkstat | [] () [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | [] [] [] | + enscript | [] [] [] [] | + error | [] [] [] [] [] | + fetchmail | [] () [] [] [] [] | + fileutils | [] [] [] | + findutils | [] [] [] [] [] [] [] | + flex | [] [] [] [] | + fslint | | + gas | [] | + gawk | [] [] [] [] | + gbiff | [] | + gcal | [] | + gcc | [] [] | + gettext | [] [] [] [] [] | + gettext-examples | [] [] [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] [] | + gimp-print | [] [] [] [] [] | + gliv | | + glunarclock | [] [] | + gnubiff | [] | + gnucash | [] () [] [] | + gnucash-glossary | [] () [] | + gnupg | [] () [] [] [] [] | + gpe-aerial | [] | + gpe-beam | [] [] | + gpe-calendar | [] [] | + gpe-clock | [] [] | + gpe-conf | [] [] | + gpe-contacts | [] [] | + gpe-edit | [] | + gpe-go | [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] | + gpe-taskmanager | [] [] | + gpe-timesheet | [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] [] | + gprof | [] [] [] | + gpsdrive | () () () | + gramadoir | [] | + grep | [] [] [] [] [] [] | + gretl | [] | + gtick | [] () | + hello | [] [] [] [] [] [] | + id-utils | [] [] | + indent | [] [] [] [] | + iso_3166 | [] [] [] [] [] [] [] [] [] [] | + iso_3166_1 | [] [] [] [] [] [] | + iso_3166_2 | | + iso_3166_3 | [] | + iso_4217 | [] [] [] [] | + iso_639 | | + jpilot | [] [] [] | + jtag | | + jwhois | [] | + kbd | [] [] [] [] [] | + latrine | () | + ld | [] [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] [] | + libiconv | [] [] [] [] [] | + lifelines | [] () | + lilypond | [] | + lingoteach | | + lingoteach_lessons | () () | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] | + man-db | [] () [] [] () | + minicom | [] [] [] | + mysecretdiary | [] [] [] | + nano | [] () [] [] [] | + nano_1_0 | [] () [] [] [] | + opcodes | [] | + parted | [] [] [] [] [] | + ptx | [] [] [] [] [] | + python | | + radius | [] | + recode | [] [] [] [] [] [] [] | + rpm | [] [] | + screem | | + scrollkeeper | [] [] [] [] [] [] | + sed | [] [] [] [] [] [] | + sh-utils | [] [] [] | + shared-mime-info | | + sharutils | [] [] [] [] [] [] | + silky | () | + skencil | [] () [] | + sketch | [] () [] | + soundtracker | [] [] [] | + sp | [] | + tar | [] [] [] [] | + texinfo | [] [] [] | + textutils | [] [] [] [] | + tin | () () | + tp-robot | | + tuxpaint | [] [] [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux | [] [] [] [] [] | + vorbis-tools | [] [] [] [] | + wastesedge | () | + wdiff | [] [] [] [] | + wget | [] [] [] [] [] [] | + xchat | [] [] [] [] | + xfree86_xkb_xml | [] [] | + xpad | [] | + +----------------------------------------------------+ + af am ar az be bg bs ca cs da de el en en_GB eo es + 4 0 0 1 9 4 1 40 41 60 78 17 1 5 13 68 + + et eu fa fi fr ga gl he hr hu id is it ja ko lg + +-------------------------------------------------+ + a2ps | [] [] [] () () | + aegis | | + ant-phone | [] | + anubis | [] | + ap-utils | [] | + aspell | [] [] | + bash | [] [] | + batchelor | [] [] | + bfd | [] | + binutils | [] [] | + bison | [] [] [] [] | + bluez-pin | [] [] [] [] [] | + clisp | | + clisp | [] | + console-tools | | + coreutils | [] [] [] [] [] [] | + cpio | [] [] [] [] | + darkstat | () [] [] [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] [] [] | + fetchmail | [] | + fileutils | [] [] [] [] [] [] | + findutils | [] [] [] [] [] [] [] [] [] [] [] | + flex | [] [] [] | + fslint | [] | + gas | [] | + gawk | [] [] [] | + gbiff | [] | + gcal | [] | + gcc | [] | + gettext | [] [] [] | + gettext-examples | [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] [] | + gimp-print | [] [] | + gliv | () | + glunarclock | [] [] [] [] | + gnubiff | [] | + gnucash | () [] | + gnucash-glossary | [] | + gnupg | [] [] [] [] [] [] [] | + gpe-aerial | [] | + gpe-beam | [] | + gpe-calendar | [] [] [] | + gpe-clock | [] | + gpe-conf | [] | + gpe-contacts | [] [] | + gpe-edit | [] [] | + gpe-go | [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] | + gpe-sketchbook | [] | + gpe-su | [] | + gpe-taskmanager | [] | + gpe-timesheet | [] [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] | + gprof | [] [] | + gpsdrive | () () () | + gramadoir | [] [] | + grep | [] [] [] [] [] [] [] [] [] [] [] | + gretl | [] [] | + gtick | [] [] [] | + hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] [] | + indent | [] [] [] [] [] [] [] [] [] | + iso_3166 | [] [] [] [] [] [] [] | + iso_3166_1 | [] [] [] [] [] | + iso_3166_2 | | + iso_3166_3 | | + iso_4217 | [] [] [] [] [] [] | + iso_639 | | + jpilot | [] () | + jtag | [] | + jwhois | [] [] [] [] | + kbd | [] | + latrine | [] | + ld | [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] [] [] [] | + libiconv | [] [] [] [] [] [] [] [] [] | + lifelines | () | + lilypond | [] | + lingoteach | [] [] | + lingoteach_lessons | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] [] [] [] [] | + man-db | () () | + minicom | [] [] [] [] | + mysecretdiary | [] [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | [] | + recode | [] [] [] [] [] [] | + rpm | [] [] | + screem | | + scrollkeeper | [] | + sed | [] [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] [] | + shared-mime-info | [] [] [] | + sharutils | [] [] [] [] [] | + silky | () [] () () | + skencil | [] | + sketch | [] | + soundtracker | [] [] | + sp | [] () | + tar | [] [] [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] [] [] | + tin | [] () | + tp-robot | [] | + tuxpaint | [] [] [] [] [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | [] [] | + util-linux | [] [] [] [] () [] | + vorbis-tools | [] | + wastesedge | () | + wdiff | [] [] [] [] [] [] | + wget | [] [] [] [] [] [] [] | + xchat | [] [] [] | + xfree86_xkb_xml | [] [] | + xpad | [] [] | + +-------------------------------------------------+ + et eu fa fi fr ga gl he hr hu id is it ja ko lg + 22 2 1 26 106 28 24 8 10 41 33 1 26 33 12 0 + + lt lv mk mn ms mt nb nl nn no nso pl pt pt_BR ro ru + +-----------------------------------------------------+ + a2ps | [] [] () () [] [] [] | + aegis | () () () | + ant-phone | [] [] | + anubis | [] [] [] [] [] [] | + ap-utils | [] () [] | + aspell | [] | + bash | [] [] [] | + batchelor | [] | + bfd | [] | + binutils | [] | + bison | [] [] [] [] [] | + bluez-pin | [] [] [] | + clisp | | + clisp | [] | + console-tools | [] | + coreutils | [] [] | + cpio | [] [] [] [] [] | + darkstat | [] [] [] [] | + diffutils | [] [] [] [] [] [] | + e2fsprogs | [] | + enscript | [] [] [] [] | + error | [] [] [] | + fetchmail | [] [] () [] | + fileutils | [] [] [] | + findutils | [] [] [] [] [] | + flex | [] [] [] [] | + fslint | [] [] | + gas | | + gawk | [] [] [] | + gbiff | [] [] | + gcal | | + gcc | | + gettext | [] [] [] | + gettext-examples | [] [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] [] | + gimp-print | [] | + gliv | [] [] [] | + glunarclock | [] [] [] [] | + gnubiff | [] | + gnucash | [] [] () [] | + gnucash-glossary | [] [] | + gnupg | [] | + gpe-aerial | [] [] [] [] | + gpe-beam | [] [] [] [] | + gpe-calendar | [] [] [] [] | + gpe-clock | [] [] [] [] | + gpe-conf | [] [] [] [] | + gpe-contacts | [] [] [] [] | + gpe-edit | [] [] [] [] | + gpe-go | [] [] [] | + gpe-login | [] [] [] [] | + gpe-ownerinfo | [] [] [] [] | + gpe-sketchbook | [] [] [] [] | + gpe-su | [] [] [] [] | + gpe-taskmanager | [] [] [] [] | + gpe-timesheet | [] [] [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] [] [] [] | + gphoto2 | [] | + gprof | [] [] | + gpsdrive | () () [] | + gramadoir | () [] | + grep | [] [] [] [] [] | + gretl | | + gtick | [] [] [] | + hello | [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] [] | + indent | [] [] [] [] | + iso_3166 | [] [] [] | + iso_3166_1 | [] [] | + iso_3166_2 | | + iso_3166_3 | [] | + iso_4217 | [] [] [] [] [] [] [] [] | + iso_639 | [] | + jpilot | () () | + jtag | | + jwhois | [] [] [] [] () | + kbd | [] [] [] | + latrine | [] | + ld | | + libc | [] [] [] [] | + libgpewidget | [] [] [] | + libiconv | [] [] [] [] [] | + lifelines | | + lilypond | | + lingoteach | | + lingoteach_lessons | | + lynx | [] [] [] | + m4 | [] [] [] [] [] | + mailutils | [] [] [] | + make | [] [] [] [] | + man-db | [] | + minicom | [] [] [] [] | + mysecretdiary | [] [] [] | + nano | [] [] [] [] [] | + nano_1_0 | [] [] [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] | + ptx | [] [] [] [] [] [] [] [] | + python | | + radius | [] [] | + recode | [] [] [] [] | + rpm | [] [] [] | + screem | | + scrollkeeper | [] [] [] [] [] | + sed | [] [] [] | + sh-utils | [] [] | + shared-mime-info | [] [] | + sharutils | [] [] | + silky | () | + skencil | [] [] | + sketch | [] [] | + soundtracker | | + sp | | + tar | [] [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] | + tin | | + tp-robot | [] | + tuxpaint | [] [] [] [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux | [] [] [] | + vorbis-tools | [] [] [] | + wastesedge | | + wdiff | [] [] [] [] [] | + wget | [] [] [] | + xchat | [] [] [] | + xfree86_xkb_xml | [] [] | + xpad | [] [] | + +-----------------------------------------------------+ + lt lv mk mn ms mt nb nl nn no nso pl pt pt_BR ro ru + 1 2 0 3 12 0 10 69 6 7 1 40 26 36 76 63 + + sk sl sr sv ta th tr uk ven vi wa xh zh_CN zh_TW zu + +-----------------------------------------------------+ + a2ps | [] [] [] [] | 16 + aegis | | 0 + ant-phone | | 3 + anubis | [] [] | 9 + ap-utils | () | 3 + aspell | | 4 + bash | | 9 + batchelor | | 3 + bfd | [] [] | 6 + binutils | [] [] [] | 8 + bison | [] [] | 14 + bluez-pin | [] [] [] | 14 + clisp | | 0 + clisp | | 5 + console-tools | | 3 + coreutils | [] [] [] [] | 16 + cpio | [] [] | 14 + darkstat | [] [] [] () () | 12 + diffutils | [] [] [] | 23 + e2fsprogs | [] [] | 6 + enscript | [] [] | 12 + error | [] [] [] | 15 + fetchmail | [] [] | 11 + fileutils | [] [] [] [] [] | 17 + findutils | [] [] [] [] [] [] | 29 + flex | [] [] | 13 + fslint | | 3 + gas | [] | 3 + gawk | [] [] | 12 + gbiff | | 4 + gcal | [] [] | 4 + gcc | [] | 4 + gettext | [] [] [] [] [] | 16 + gettext-examples | [] [] [] [] [] | 14 + gettext-runtime | [] [] [] [] [] [] [] [] | 22 + gettext-tools | [] [] [] [] [] [] | 14 + gimp-print | [] [] | 10 + gliv | | 3 + glunarclock | [] [] [] | 13 + gnubiff | | 3 + gnucash | [] [] | 9 + gnucash-glossary | [] [] [] | 8 + gnupg | [] [] [] [] | 17 + gpe-aerial | [] | 7 + gpe-beam | [] | 8 + gpe-calendar | [] [] [] [] | 13 + gpe-clock | [] [] [] | 10 + gpe-conf | [] [] | 9 + gpe-contacts | [] [] [] | 11 + gpe-edit | [] [] [] [] [] | 12 + gpe-go | | 5 + gpe-login | [] [] [] [] [] | 13 + gpe-ownerinfo | [] [] [] [] | 13 + gpe-sketchbook | [] [] | 9 + gpe-su | [] [] [] | 10 + gpe-taskmanager | [] [] [] | 10 + gpe-timesheet | [] [] [] [] | 12 + gpe-today | [] [] [] [] [] | 13 + gpe-todo | [] [] [] [] | 12 + gphoto2 | [] [] [] | 11 + gprof | [] [] | 9 + gpsdrive | [] [] | 3 + gramadoir | [] | 5 + grep | [] [] [] [] | 26 + gretl | | 3 + gtick | | 7 + hello | [] [] [] [] [] | 34 + id-utils | [] [] | 12 + indent | [] [] [] [] | 21 + iso_3166 | [] [] [] [] [] [] [] | 27 + iso_3166_1 | [] [] [] | 16 + iso_3166_2 | | 0 + iso_3166_3 | | 2 + iso_4217 | [] [] [] [] [] [] | 24 + iso_639 | | 1 + jpilot | [] [] [] [] [] | 9 + jtag | [] | 2 + jwhois | () [] [] | 11 + kbd | [] [] | 11 + latrine | | 2 + ld | [] [] | 5 + libc | [] [] [] [] | 20 + libgpewidget | [] [] [] [] | 13 + libiconv | [] [] [] [] [] [] [] [] | 27 + lifelines | [] | 2 + lilypond | [] | 3 + lingoteach | | 2 + lingoteach_lessons | () | 0 + lynx | [] [] [] | 14 + m4 | [] [] | 15 + mailutils | | 5 + make | [] [] [] | 16 + man-db | [] | 5 + minicom | | 11 + mysecretdiary | [] [] | 10 + nano | [] [] [] [] | 17 + nano_1_0 | [] [] [] | 17 + opcodes | [] [] | 6 + parted | [] [] [] | 15 + ptx | [] [] | 22 + python | | 0 + radius | | 4 + recode | [] [] [] | 20 + rpm | [] [] | 9 + screem | [] [] | 2 + scrollkeeper | [] [] [] | 15 + sed | [] [] [] [] [] [] | 24 + sh-utils | [] [] | 14 + shared-mime-info | [] [] | 7 + sharutils | [] [] [] [] | 17 + silky | () | 3 + skencil | [] | 6 + sketch | [] | 6 + soundtracker | [] [] | 7 + sp | [] | 3 + tar | [] [] [] [] [] | 24 + texinfo | [] [] [] | 14 + textutils | [] [] [] [] | 16 + tin | | 1 + tp-robot | | 2 + tuxpaint | [] [] [] [] [] | 29 + unicode-han-tra... | | 0 + unicode-transla... | | 2 + util-linux | [] [] | 15 + vorbis-tools | | 8 + wastesedge | | 0 + wdiff | [] [] [] | 18 + wget | [] [] [] [] [] [] [] [] | 24 + xchat | [] [] [] [] [] | 15 + xfree86_xkb_xml | [] [] [] [] [] | 11 + xpad | | 5 + +-----------------------------------------------------+ + 63 teams sk sl sr sv ta th tr uk ven vi wa xh zh_CN zh_TW zu + 131 domains 47 19 28 83 0 0 59 13 1 1 11 0 22 22 0 1373 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If January 2004 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. + +Using `gettext' in new packages +=============================== + +If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +the use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`translation@iro.umontreal.ca' to make the `.pot' files available to +the translation teams. + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e39faea --- /dev/null +++ b/AUTHORS @@ -0,0 +1,14 @@ +VisualBoy and VisualBoyAdvance original development: + +- Forgotten (see the Contact section in the README) + +Current maintainer: + +- Sébastien Guignot aka kxu + +Contributions: + +- Costis : object mosaic, GP32 +- KVA: ARM/THUMB disassembler +- kxu: GTK+ interface +- Yann Parmentier aka kohai: new icons diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..abe1017 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,74 @@ +2004-05-20 kxu + + * src/sdl/SDL.cpp (sdlPollEvents): added SDL_QUIT event support + +2004-05-15 kxu + + * finalized the first release of the GTK+ interface + +2004-05-03 kxu + + * src/elf.cpp (elfCleanUp): fix a missing nullify, causing crashes + +2004-05-01 kxu + + * added gtkmm 2.4 support + +2004-04-25 kxu + + * src/win32/skinButton.cpp: fix skin bugs (patch from Forgotten) + +2004-04-19 kxu + + * src/remote.cpp: added support for z2 (delete break on write) so that gdb can use break on write (patch from Ryan Brown) + +2004-04-18 kxu + + * fix custom controls to use CS_GLOBALCLASS style and fix the GB map view flickering (patch from Forgotten) + +2004-03-30 kxu + + * added the GTK+ interface draft + +2004-03-20 Forgotten + + * src/GBA.cpp: improved memory timing + +2004-03-11 Forgotten + + * src/win32/MainWndFile.cpp: changed import/export battery file to default to battery directory + +2004-03-10 Forgotten + + * src/win32/DirectSound.cpp (class DirectSound): make destructor virtual to avoid problems when deleting + * src/win32/Sound.h (class ISound ): make destructor virtual to avoid problems when changing sound quality + +2004-03-09 Forgotten + + * src/elf.cpp (elfCleanUp): fix corruption on ELF clean up + +2004-03-08 Forgotten + + * src/win32/MapView.cpp (enableButtons): fix radio button bug using keyboard + * src/win32/GBMapView.cpp (OnInitDialog): fix radio button bug using keyboard + * src/win32/MapView.cpp (GetClickAddress): fixes for rot. bgs + +2004-02-29 Forgotten + + * src/win32/skin.cpp (GetSkinData): allow for JPEG and PNG images to also be loaded + +2004-02-24 Forgotten + + * src/admame.cpp: sync code with Scale2x 2.0 + * src/Cheats.cpp (cheatsCheckKeys): improve CodeBreaker 0xDxxxxxxx code support + +2004-02-17 Forgotten + + * src/win32/skinButton.cpp (OnPaint): fix GDI problems with selected bitmap being deleted + * src/win32/ZoomControl.cpp (OnPaint): fix GDI problems with selected bitmap being deleted + * src/win32/PaletteViewControl.cpp (OnPaint): fix GDI problems with selected bitmap being deleted + * src/win32/MemoryViewer.cpp (OnPaint): fix GDI problems with selected bitmap being deleted + * src/win32/BitmapControl.cpp (OnDraw): fix GDI problems with selected bitmap being deleted + * src/win32/VBA.cpp (winSetLanguageOption): patch for searching for base language dll + * elf.cpp (elfRead): fix problem caused by previous memory leak fix + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..4a45a84 --- /dev/null +++ b/INSTALL @@ -0,0 +1,266 @@ +What is this? +------------- + +VisualBoyAdvance is a Nintendo (TM) Gameboy and GameboyAdvance emulator with +debugging capabilities. + +How to compile the source +------------------------- + +1. Unix +------- + +ATTENTION: if you extracted the code from CVS, see the README.CVS first or +your build may fail! + +The following software is needed in order to compile: + +- libpng: http://www.libpng.org/pub/png/libpng.html +- zlib: http://www.gzip.org/zlib/ +- libSDL: http://www.libsdl.org +- nasm (optional for x86 MMX support): http://nasm.sourceforge.net/ +- GCC 3.x: in order to compile VBA, you will GCC 3.x or greater because of + a really bad bug in GCC 2.95 where it allocates an immense amount of + memory in order to compile GBA.cpp. If you really want to test it with + GCC 2.95, try exporting CXXFLAGS=-g to avoid optimizations (or try + different levels of optimization like -O1 or -O0) + +Extra software needed to compile the GTK+ GUI: + +- gtkmm (>= 2.0): http://www.gtkmm.org/ +- libglademm (>= 2.1): http://www.gtkmm.org/ + +Unpack the sources from the tar.gz file, then run the configure script. +The following extra options may be used to configure the generated executables: + + --enable-c-core enable C core (default is no on x86 targets) + --enable-profiling enable profiling (default is yes) + --enable-dev enable development features (default is yes) + --with-mmx use MMX (default is yes on x86 targets) + +GUI selection options: + + --enable-sdl build the SDL interface (default is yes) + --enable-gtk build the GTK+ interface (default is no) + --enable-gtk=2.4 build the GTK+ interface with gtkmm 2.4 + +More options: + + --help display all options + +After configure completes, just issue the make command. If it all goes well, +you will have the emulator compiled in the src directory. Issuing the +make install command will install the executables into the /usr/local/bin +directory (subject to change). + +The emulator code should work in both big and little endian computers. + +See the section after the Windows one for more information on the configure +script. + +The binaries are called this way: +- the SDL interface: VisualBoyAdvance +- the GTK+ interface: gvba + +2. Windows +---------- + +Needed software: +- nasm: see above for URL. Install it in the default directory +- Microsoft Visual C++ 6.0 or greater: to compile + +The win32 directory contains Microsoft Visual Studio workspace files needed +to compile the project with Microsoft Visual C++ 6.0 or greater. + +The gba.dsp workspace compiles the full Windows version and gba_sdl.dsp +compiles the Windows SDL version. + +Solutions for Visual C++ .NET are also available: gba.sln and gba_sdl.sln + +The Windows version contains three possible configurations: +- Debug: full debugging of the emulator is possible +- Release: optimized version for GBA developers +- ReleaseNoDev: optimized version without development features + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6b94fb8 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ +AUTOMAKE_OPTIONS = gnu dist-zip + +CORE_SUBDIRS = m4 src win32 + +EXTRA_SUBDIRS = po + +SUBDIRS = $(CORE_SUBDIRS) @VBA_EXTRA@ + +DIST_SUBDIRS = $(CORE_SUBDIRS) $(EXTRA_SUBDIRS) + +EXTRA_DIST = config.rpath README-win.txt README.CVS VERSION + +ACLOCAL_AMFLAGS = -I m4 diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..d2a7f22 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,559 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +AUTOMAKE_OPTIONS = gnu dist-zip + +CORE_SUBDIRS = m4 src win32 + +EXTRA_SUBDIRS = po + +SUBDIRS = $(CORE_SUBDIRS) @VBA_EXTRA@ + +DIST_SUBDIRS = $(CORE_SUBDIRS) $(EXTRA_SUBDIRS) + +EXTRA_DIST = config.rpath README-win.txt README.CVS VERSION + +ACLOCAL_AMFLAGS = -I m4 +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_SOURCES = + +RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ + ps-recursive install-info-recursive uninstall-info-recursive \ + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ + check-recursive installcheck-recursive +DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure \ + ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL Makefile.am NEWS \ + acinclude.m4 aclocal.m4 compile config.guess config.rpath \ + config.sub configure configure.in depcomp install-sh missing \ + mkinstalldirs +all: all-recursive + +.SUFFIXES: + +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) + +$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +$(ACLOCAL_M4): configure.in acinclude.m4 m4/codeset.m4 m4/gettext.m4 m4/glibc21.m4 m4/iconv.m4 m4/intdiv0.m4 m4/intmax.m4 m4/inttypes-pri.m4 m4/inttypes.m4 m4/inttypes_h.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/longdouble.m4 m4/longlong.m4 m4/nls.m4 m4/po.m4 m4/printf-posix.m4 m4/progtest.m4 m4/signed.m4 m4/size_max.m4 m4/stdint_h.m4 m4/uintmax_t.m4 m4/ulonglong.m4 m4/wchar_t.m4 m4/wint_t.m4 m4/xsize.m4 + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if (etags --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + else \ + include_option=--include; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = . +distdir = $(PACKAGE)-$(VERSION) + +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } + +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkinstalldirs) $(distdir)/po + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + $(am__remove_distdir) + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ + && rm -f $(distdir).tar.gz \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @echo "$(distdir).tar.gz is ready for distribution" | \ + sed 'h;s/./=/g;p;x;p;x' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-generic clean-recursive ctags ctags-recursive dist \ + dist-all dist-gzip dist-zip distcheck distclean \ + distclean-generic distclean-recursive distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am \ + dvi-recursive info info-am info-recursive install install-am \ + install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am pdf-recursive ps ps-am \ + ps-recursive tags tags-recursive uninstall uninstall-am \ + uninstall-info-am uninstall-info-recursive uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..ed0c2ad --- /dev/null +++ b/NEWS @@ -0,0 +1,636 @@ +Version 1.7.2: +Core changes: +- fixed bugs on ELF clean up +- improved CodeBreaker 0xDxxxxxxx code support +- updated Scale2x filter to version 2.0 +- improved memory timing +- added support for z2 (delete break on write) so that gdb can use break on write + +Windows: +- added search for base language dll +- fixed GDI problems with selected bitmap being deleted +- added JPEG and PNG support for skins +- changed import/export battery file to default to battery directory +- fixed the translation bug with viewers +- fixed the GB map view flickering +- fixed skin bugs + +SDL versions: +- now it exits when closing the window + +Other: +- added a new interface using GTK+, which implements a first part of the Windows version + +Version 1.7.1: +Core changes: +- added SWI call (0xf9 in thumb mode) to exit emulator in SDL version +- avoid crash when loading an invalid ELF file +- avoid turning sound on if soundOffFlag is true +- disabled remove intros option +- fixed memory leak in ELF support code +- fixed memory corruption if loading a bigger file than the memory to hold it +- fixed some compile warnings in the profiling code +- merged some big endian fixes into the code +- update battery files more often (a bit after the save memory is last updated) + +Gameboy: +- fixed bug with window support introduced in version 1.7 +- fixed HALT bug when no matching bits for interrupt + +Windows: +- added cartridge save strings to bug report +- changed default button on disassembly views to Go instead of Close +- changed power management/screen saver disabling code again to avoid problems +- fixed compilation problems on VC 7 +- fixed multi-monitor support +- fixed bug loading memory dumps +- fixed crash onb map/oam/tile viewers +- fixed problem 320x240 mode open/save dialogs +- fixed bug where user selected Gameboy colors were reset and not stored +- fixed bug rendering the translator URL +- fixed memory leak in OpenGL code which caused nasty problems +- store throttle value between restarts of the emulator +- updated FAQ and URL links to the new site + +Version 1.7: +Core changes: +- added fixes to video filters done by Flea for Mac OS X +- added/fixed ArcTan/ArcTan2 emulation +- added sound volume .25 and.50 +- added hq2x/lq2x filters +- aded global cheat disable +- some code clean up +- fixed some CBA cheat support +- fixed ARM/Thumb instruction timing, including memory access +- fixed minor bugs in STMDx ARM instructions +- fixed ARM LDRx instructions when base equals dest + +Gameboy: +- added support for 8M roms +- (re)added support for 2-4 playes in SGB mode +- added sprite limit emulation (thanks Ricky of KiGB) +- cancel pending EI when imediately followed by DI +- implemented DI/HALT bug +- implemented STAT write bug during VBLANK or HBLANK when in GB mode +- implemented GDMA delay in GBC mode (thanks TM of GEST) +- fixed priority between OBJ and Window +- fixed some SGB border problems +- fixed window rendering problems in some cases +- fixed CGB initial background palette to white +- fixed initial save memory value to 0xFF instead of 0x00 (thanks TM of GEST) +- fixed LCD interrupts to only occur once per line +- fixed incorrect display when BG is off +- modified interrut delay to 6 clock ticks instead of 2 +- moved scanline update to beginning of HBLANK + + +Windows: +- added predefined Gameboy palettes (thanks Kojote) +- added GBA IO Viewer to view/modify GBA hardware registers +- added menu entry to load most recent save state +- added menu entry to save state into oldest slot +- added option to auto load the most recent save state upon loading +- added fullscreen max scale option +- chnaged the bug report option to be a little more friendly +- enhanced save state submenus to show date/time of when save was made +- enhanced logging window to capture data even if not being displayed +- fixed Direct3D/OpenGL "green" bug with Motion Blur Interframe Blending +- fixed Direct3D full screen with Gameboy roms +- fixed minor bugs when saving images in the different viewers +- fixed power management disabling: should avoid monitor turning off now +- improved cheat input to be more flexible and easy to enter +- migrated whole GUI code to MFC + +Version 1.6a: +Core changes: +- fixed bug introduced in previous fix to CpuFastSet/CpuSet +- fixed slowdown caused by attempt to speed up emulation + +Windows: +- fixed bug when selecting the same render type + +Version 1.6: +Core changes: +- added rewind support (initially disabled) +- added support for slowdown codes +- added emulation of sprite priority bug (thanks PokemonHacker) +- added simple emulation for BIOS call 0x2a +- added enhanced save type detection option (default) +- added DMA hack for an obscure case +- improved loading speed +- fixed sleep/stop state support +- fixed bug caused by rendering optimizations +- fixed crash while debugging startup routines +- fixed DMA emulation +- fixed priority between OBJ Window and regular windows +- fixed thumb disassembly bug +- fixed sound envelope bug when set to 0 to mute sound (thanks PokemonHacker) +- fixed CpuFastSet/CpuSet bugs (thanks PokemonHacker) +- fixed warning message when using AGBPrint +- fixed DMA timings + +Windows: +- added movie recording/playback (joypad movement recording) +- added support for automatic SGB border display +- added option to auto hide menu in full screen mode +- added rewind support +- added bug report menu to provide needed information for solving problems +- added FAQ optin to take to the VBA website FAQ +- menu toggle can now have a customizable accelerator instead of ESC +- fixed bug on GBA cheats showing the wrong enable state (checkbox was ok) +- fixed bug enabling/disabling BG layers (introduced in version 1.5.1) +- fixed export settings to also export viewers settings +- fixed bug saving keyboard settings in INI file +- fixed map viewer click address in some cases +- fixed map viewer rendering for 512x512 screens +- fixed tile viewer click address and tile number in 256 color mode +- allow customize to run in fullscreen mode (exception of 320x240 mode) + +SDL versions: +- added support to turn sound off and change channel enable +- added support for automatic SGB border display +- added rewind support (CTRL+B) +- fixed bug enabling/disabling BG layers (introduced in version 1.5.1) +- fixed typo on pause-when-inactive option which made it not recognized + +Version 1.5.1: + +Core changes: +- minor rendering optimization +- added support for AR codes (thanks parasytic and pokemonhacker) +- no longer allow L+R or U+D to be reported as pressed +- fixed RTC problem on last day of the month +- fixed bug with some cheat codes that caused an invalid ROM patch +- fixed sound mixing problem with DS ratio + +Windows: +- added skin button support +- added AVI sound support (thanks to phaeron) +- all accelerators can now be customized or removed +- fixed full screen problem in OpenGL mode +- fixed some problems with stretch to fit +- main skin region is now optional for pure rectangular skins + +SDL version: +- changed default separator on config file to a equal sign +- changed pause when inactive default to false to fix problems debugging + +Porting: +- added PowerPC assembly code (thanks Jeffrey Lim) + +Version 1.5a: + +Windows: +- fixed skin problems on Win 95/98/Me/2000 +- fixed right-click problem on Win 95/98/Me/2000 +- fixed problem when Gameboy Printer was enabled +- fixed problem on Flash size menu not showing correct setting + +Version 1.5: + +Core changes: +- added AGBPrint support (for developers only) +- added RTC support +- added scanlines filter +- added support for gzip files +- added support for compressed bios files (zip, gzip) +- fixes Flash 1M support + +Gameboy: +- added SGB2 support + +Windows: +- added Gameboy tools (Disassembly, Memory Viewer, Tile Viewer, OAM Viewer, + Map Viewer and Palette Viewer) +- added fullscreen mode confirmation for DirectDraw to avoid problems +- added GDI, Direct3D and OpenGL rendering options +- added skin support (see readme for information on creating skins) +- added support for per game configuration of some settings (see readme for + details) +- changed INI support to use emulator directory instead of Windows directory + +SDL version: +- added support for per game configuration of some settings (see readme for + details) + +Version 1.4: + +Core changes: +- added bilinear and bilinear plus filters +- added interframe blending support +- added support to show speed in fullscreen mode (transparent or opaque) +- added detailed speed display +- added autoframeskip support +- added support for ELF DW_FORM_strp (used by newer GCC versions) +- added support to enable/disable GB/GBC video layers +- fixed crash when loading a second ELF file +- fixed missing EMMS instruction in ADVANCEMAME Scale 2x MMX version +- fixed some timer settings problems (bad copy paste of code) + +Windows version: +- allows AMD CPUs to take advantage of MMX code +- added support to select video mode for fullscreen mode +- added fullscreen triple buffering support +- added support for multiple joypad configuration +- added support to store settings to INI +- added export settings from Registry to INI +- added throttle support (between 5% and 1000%) +- fixed problem displaying error messages in fullscreen mode +- fixed tile viewer to display all tiles in 256 mode +- fixed Visual Studio project files so that they work on other computers +- fixed problem with disable SFX not being read when program starts +- fixed (minimized) screen corruption problem when filter is active in + fullscreen mode and emulator is minimized + +Version 1.3.1: + +Core changes: +- fixed reversed Flash identification for 64k Flash + +Version 1.3: + +Core changes: +- added support for Flash 128K (thanks DesktopMan) +- added checks for out of memory condition +- added sound volume option +- fixed message when failed to write battery file (previously always saying + failure to open file NULL) +- fixed sound mixing ratios specified in 0x4000082 (thanks Damian) +- simulating memory behaviour when no cartridge present (32-bits still + incorrect) +Windows version: +- automatically apply IPS patch if it exists (configurable) +- added save/load support in the memory viewer +- added support for filters in 32-bit mode for all filters +- added AVI writing support (no sound yet) +- can now pause emulator before loading any file +- memory viewer now displays current edit address +- removed some test code introduced at version 1.1 that slows down the emulator +- exporting GSA snapshot defaults title to internal name +- fixed missing check marks on layers menu +- fixed bug showing maker code/name from some old games +SDL version: +- added support for long options +- added support for passing configuration file name +- added profiling support (GMON format - see README) +- added support for filters in 32-bit mode for all filters +- automatically apply IPS patch if it exists +- improved search for configuration file: current directory, user directory, + executable directory (in order) are searched +- fixed configuration problem with saveType and removeIntros +Porting: +- fixed big endian problems in SGB code +- fixed big endian problems with rotated sprites +- fixed big endian sound endianess + +Version 1.2: + +Core changes: +- added MidiKey2Freq bios call (thanks Chris Moeller) +- added AdvanceMAME Scale2x and Simple 2x filters +- added support for higher frameskip (up to 9) +- added C core for portability +- added big endian support +- added support for movement sensor (thanks Parasyte) +- added support for selecting save type available +- fixed another value for the bios protection +- fixed sound envelope reload bug (thanks jaymzj) +- fixed timer counter (not changing the value of the counter unless the timer + overflows or is restarted) +- fixed problem on big endian when setting IO memory reable positions +- fixed reset LCD after disabling forced blank +- speed up now uses frameskip 9 (6 FPS) +- improved message when BIOS function cannot be emulated +Windows changes: +- added freeze recent list option +- added 800x600 support +- support to export GamesharkAdvance save games +- fixed bug when changing directories in the Directories... dialog +SDL version: +- added emulation for motion sensor +- fixed crash when printing void * variables +- fixed crash when -b specified incorrectly +- fixed warning when reading configuration file about disableMMX if compiled + without MMX support +- fixed crash when trying open file that does not exist + +Version 1.1: + +Core changes: +- added DMA logging +- added GBA intro remover +- fixed an ARM bug for opcodes like OP Rd,Rb,Rm ROR Rs where Rs > 0 + and Rs % 32 == 0 +- fixed some minor inconsistencies on the THUMB core (no actual bug reported) +- fixed bug with windows and alpha-bleding the wrong layer +- fixed sound channel 3 volume +- fixed the EEPROM battery save bug +Windows changes: +- added reset buttons to the directories dialog +- added Logging console (for internal GBA logging and console output) +- enhanced Map Viewer with more information about map and clicked spot +- enhanced Tile Viewer with more information about tiles and clicked spot +- added speed up toggle +- fixed a bug configuring hotkeys for some menu options +- fixed a bug where the joypad configuration dialog had strange colors +- fixed a crash when opening the Disassemble window when emulating a GB program + +Version 1.0a: + +Core changes: +- corrected sound mixing to be more like in version 0.9.1 +Windows changes: +- fixed battery file load/save when directory not set +- fixed crashes when directories not set +- fixed crash when passing image from command line in same directory +- updated company list for rom information dialogs + +Version 1.0: + +Core changes: +- semi-transparent objects are now processed correctly when windows enabled +- battery files now written even after resetting +- 16-bit sound rendering +- fixed some LDM/STM instructions when running in user/system mode +- added missing LDM/STM instruction formats +- Div/DivARM BIOS calls work correctly when dividing by 0 +- added sound echo effect +- added sound low pass filter +- added reverse stereo support +Gameboy changes: +- can now edit palette for mono games +Windows changes: +- added option for not stretching viewing data +- added automatic update option for all viewers (every frame) +- added tile viewer +- added disassembler +- added accelerator editor: user can configure almost all menu items hotkeys +- added GDB support (will be improved in the next version) +- memory viewer can now edit memory +- fixed autofire for L/R buttons which was inverted +- fixed dialog keyboard navigation +- fixed bug in map viewer when viewing mode 2 map +- files should now be saved to the correct directory when directories not set +SDL changes: +- fixed autofire for L/R buttons (was not working before) +- added support for sound quality selection + +Version 0.9.1: + +Core changes: +- fixed BG2CNT corruption in some cases +- fixed rendering of sprites with invalid OBJ Mode +- fixed 32-bit access to some IO registers +- fixed some unknown messages when loading ELF files +- fixed small error when doing a 16-bit write to palette RAM +- fixed minor bug in CpuFastSet emulation +- fixed some crashes loading GCC 3.0.4 ELF files +- fixed minor problem with CPSR (to be consistent with documentation) +- added single frame stepping (pauses after drawing the next frame) +- BMP screen capture option +Windows changes: +- fixed add cheat dialog disabled buttons +- fixed bug with 32-bit cheats (Gameshark/Internal) +- multiple selection on cheat list dialogs now supported +- easier enable/disable of cheats +- cheat search dialog shows previous search results +- cheat lists now restore enabled/disabled status correctly +- added some new companies to information dialogs +- Map viewer +- Palette viewer +- Memory viewer +- Sprite viewer +SDL changes: +- added development logging option (bios usage, illegal read, illegal writes) +- call stack information (GCC 3+ (ARM mode only) or ARM SDT) + +Version 0.9a: + +Core changes: +- fixed rotation screen bug introduced in version 0.9 +- fixed some memory write corruption +Windows changes: +- fixed small bug in 320x240 mode +- fixed open dialog when in 640x480 mode + +Version 0.9: + +Core changes: +- support for enabling/disabling graphical layers +- correct sound channel 4 emulation +- support for multiboot files (.MB) +- support for ELF files +- fixed some memory leaks +- fixed LDM/STM instructions (missing formats and wrong behaviour - littleos now works) +- fixed PUSH/POP instructions +- fixed misaligned half word reads +- fixed invalid memory reads +- fixed IO memory readability and register writing +- fixed HuffUnComp missing last bytes bug +- fixed a small DMA bug +- fixed bug in rotation screens (hoffset demo works again) +Gameboy changes: +- correct sound channel 4 emulation +- fixed bug reading joypad when LCD is off +- fixed small bug in SGB code +- fixed bug in SGB Block command +Windows changes: +- can now save GB Printer output as well as print +- 320x240 mode support +- support for more joystick axes and HAT(POV) +- separate directory for GB roms +- option to use old sound synchronization code (to avoid crackle problem) +- fixed add internal code dialog bug when entering multiple codes +- fixed closing dialogs by clicking on X +- fixed handling of root directory for saving +SDL changes: +- GDB remote debugging support (see Readme of SDL version for details) +- YUV support (courtesy of Niels Wagenaar) +- improvements to embedded debugger (locals, break, print, symbols commands) +- console output support (Mappy style and a new one) +- partial ELF support in the internal debugger +- support for HAT buttons + +Version 0.8: + +Core changes: +- correctly initializing IO registers when running without BIOS(Gollum/Costis) +- support for GSA ROM patching codes and button codes +- support for CodeBreakerAdvance codes +- support for separate frameskip for GBA and GB roms +- reworked the cheat system internal (should improve speed a bit) +- added a small interrupt latency to avoid interrupt loop +- fixed 16-bit DMA transfers with decrement options +- fixed semi-transparent OBJ bug +- fixed Gameshark Advance snapshot import +- fixed crash when passing filename without a path on command line +- fixed ARM LDR/STR with ASR shifted register instructions +- fixed some disassembly bugs +- fixed sound mixing (reversed sound) +- fixed misaligned 16-bit reads +Gameboy changes: +- fixed sound mixing (reversed sound) +- fixed vertical scrolling bug (Kefren bars demo) +- fixed speed up bug changing sound quality during emulation +Windows changes: +- disable screen saver when emulating +- added option to pause the emulator when window not active +- added keyboard shortcut for recent files +- added support for more keyboard keys when configuring controls +- added sound recording to a wave file +- fixed Add code dialogs to allow multiple codes entered at once +- fixed DDraw clipping bug (should work when window partially offscreen) +SDL changes: +- added command line flag for frameskip +- added command line support for bios file +- fixed configuration file comments on control configuration + +Version 0.7.1: + +Core changes: +- sound scratch problem fixed +- sound mixing improved +- sound channel 3 new function added +- Gameshark code support fixed for some codes +- all cheat codes are validated for wrong characters +- 64k EEPROM support +- added BIOS calls protection for BIOS memory area +- fixed problem with stop mode and loading a save state +- fixed window behaviour on some undocumented cases (thanks mrquackers) +Windows version: +- added new filters to the menu +- maker name added to ROM information dialogs (thanks to /Fredrik) +- fixed start up x4 problem +- fixed GBA cheat search display problem when showing hex numbers +- added cheat search for GB roms +SDL version: +- fixed debugger disassembled line when on breakpoint +- fixed loading a state with a different sound quality (quality doesn't change) + +Version 0.7a: + +- fixed slowdown/graphic sync problem +- fixed x4 problem +- enabled experimental graphic filters: pixelate and motion blur + (need to use regedit to change filter to 5 or 6 respectively) +- added BIOS calls Stop, IntrWait and SoundBiasReset (missing from 0.7 changes) + +Version 0.7: + +Core GBA emulation: +- emulating GBA windows correctly when they wrap around the screen +- fixed some minor THUMB flag bugs +- fixed blended sprites priority bug +- fixed unimplemented ARM LDM opcode +- not applying SFX to semi-transparent sprites +- completed mode 5 emulation +- disable sfx now takes effect immediately +- screen capture sets the correct extension when name typed +- MOSAIC support in all video modes and sprites +- fixes to several of the reported black screen, hangs and missing opcode +- Gameshark code support +- import function for battery files, code files and game saves +- export function for battery files +Core GB emulation: +- fixed window priority bug (sprites on top of window) +- screen capture now being taken before status message is displayed +- import function for battery files, code files and game saves +- export function for battery files (no RTC saved in this case) +SDL versions: +- fixed some small disassembler bugs +- fixed keyboard shortcuts with modifier keys (Ctrl, Alt, Shift) +- added MMX support (default is off) +- configuration file now in DOS format for the Windows version +- added break on write support for IRAM and WRAM +Linux version specific: +- fixed some bad opcodes + +Version 0.6.0.1: + +- fixed bug with Japanese and Chinese translations +- fixed bug with 8-bit or 16-bit freeze cheat codes +- fixed a small VRAM bug + +Version 0.6: + +- fixed bug with images patched to save into FlashAdvance instead of EEprom +- fixed bug reporting register P1 +- fixed DMA loop bug and timing +- reworked the cheat engine for Gameboy (faster now) +- GB Pocket Printer support +- GB MBC7 support (motion sensor) +- added ROM information dialogs +- now centering dialog boxes +- automatically hiding of mouse in full screen +- Cheat list dialog improved with description for a code +- screen shot menu option +- reset recent list option +- option to disable status messages +- option to automatically save/load cheat list +- menu to save/load cheat list +- using new dialog controls under Windows XP +- language selectable from menu and easy translation + +Version 0.51: + +- fixed bugs introduced in version 0.5 (BIOS access) +- fixed small DMA problem +- fixed Gameboy frame skip bug (caused missing sprites) +- fixed bug in MBC 3 code (boy/girl problem in Pokemon Crystal) +- fixed crash loading more than 3 games without restart +- added MMX version of the graphic filters (exception of TV Mode) +- added status message to some actions (load/save state, reset, screen capture) +- tried to improve message when DirectX missing + +Version 0.5: + +- fixed bug accessing the BIOS (caused apparent hang in some cases) +- reverted the ARM to previous version (sound distortion fixed) +- fixed a bug in the 16-bit and 32-bit cheat search +- fixed a slowdown on GB emulation +- fixed screen capture to only take one shot while the button is pressed +- fixed problem of not saving battery file when using recent menu +- fixed problem starting from double-click on binary image (association) +- fixed missing GB filters when selecting files to open +- removed unimplemented opcode for SWP opcodes +- added auto-fire option for buttons A, B, L and R +- added full screen mode (640x480 only - 320x240 will be enabled later) +- added DirectDraw option for Emulation only (removes filtering problem) and + use video memory (may speed up some machines) +- added graphic filters: TV Mode, 2xSaI, Super 2xSaI and Super Eagle + (adapted from Snex9x code). Note: fast machine needed. +- full screen option to stretch to fit image +- added option to associate emulator with GB and GBA files +- added priority option to avoid problems on some machines +- added dialog with cheats in use +- added option to freeze memory location: infinite money, lives, etc... + +Version 0.4: + +- can now play Gameboy and GameboyAdvance games +- recent menu with 10 recent loaded roms +- save state slots (like Snes9x) +- fixed 24-bit screen capture +- fixed sprite corruption +- added 3 missing BIOS calls (DiffXbitUnfilter calls) +- fixed freeze loading VisualBoy 1.4.10 save game +- fixed reset problems on some CGB games +- fixed a timing issue that caused blinking sprites + +Version 0.3: + +- fixed window bug (vertical lines or missing column) +- fixed some sound mixing problems +- some speed improvements +- cheat search engine (based on Snes9x) +- battery saves are now supported +- save game loading fixed (crash or no sound problem are gone) +- disable special effects option (can speedup some machines) + +Version 0.21: + +- fix to 24-bit mode dark screen problem +- sound on left speaker problem fixed +- some ARM opcodes have been corrected (DarkFader's demos now work) +- rotation bug fix +- mode 3 backdrop color fix diff --git a/README b/README new file mode 100644 index 0000000..83362e2 --- /dev/null +++ b/README @@ -0,0 +1,479 @@ +Welcome to version 1.7.2 of VisualBoyAdvance [SDL]. +This is a GB/GBC/GBA emulator for Windows, Linux, MacOS X and BeOS. + +Features +-------- + +- configurable GB/GBA keys, including joystick support +- option to use BIOS file +- zip/gzip file support +- directory selection for save state, battery and screen capture +- fullscreen mode (selectable resolution) +- video sizes 1x, 2x, 3x and 4x +- graphic filters Normal, TV Mode, 2xSaI, Super 2xSaI and more +- interframe blending support +- same emulation core as VisualBoyAdvance: GB and GBA emulation +- built-in ARM/THUMB assembly debugger +- 10 save states accesible through keyboard +- automatic battery file load/save +- auto-fire support +- pause, reset through keyboard +- 16, 24 and 32 bit desktop support +- GDB remote debugging (see below for information) +- auto frameskipping and throttle +- AGBPrint support for development +- RTC support + +Compiling the sources +--------------------- + +See the INSTALL file for compiling instructions. Please note the following +requisites to compile: + +- GCC must be 3.x or greater in order to compile GBA.cpp with -O2. Earlier + versions have a problem during optimization that requires an absurd + ammount of memory and usually ends up crashing the compiler/computer +- On Windows, Microsoft Visual C++ 6 or later is needed. Please note that + some of the source code will not compile with the shipped header files. + You will need to install the most recent Platform SDK from Microsoft. + +Installing +---------- + +The easiest installation is to place all files in the distribution in the +same directory. + +Per game settings +----------------- + +Version 1.5 introduced the support for per game settings for GBA games. You +can defined the following settings on a per game basis by using an INI file +called vba-over.ini in the same directory as the emulator: + +rtcEnabled=<0 for false, anything else for true> +flashSize=<65536 or 131072> +saveType=<0 for automatic, 1 for EEPROM, 2 for SRAM, 3 for Flash or 4 for +EEPROM+Sensor> + +Use the 4 letter game code to separate settings for each game. Example: + +[ABCD] +rtcEnabled=0 +flashSize=65536 +saveType=0 + +[ABC2] +rtcEnabled=1 +flashSize=131072 +saveType=0 + +Support +------- + +Please support VisualBoyAdvance by making a donation. You can donate money +using PayPal (www.paypal.com). Use the contact form to find how you can +send donations. Also, it is recommended that you use the VisualBoyAdvance +forum on www.ngemu.com message board. + +FAQ +--- + +See online FAQ for more information: http://vba.ngemu.com/faq.shtml + +Please don't email about what you think it is problem before consulting +the FAQ. + +System requirements +------------------- + +Windows: PIII 500Mhz machine for GBA emulation. GB emulation requires far less. + +Linux, MacOS X, BeOS: + SDL (>= 1.2.2) runtime library must be installed prior to running the + program. You can download it from http://www.libsdl.org + +Key combinations during emulation +--------------------------------- + +- F1...F10: load save state 1...10 +- Shift+F1...F10: save state 1...10 +- Alt+1...4: auto-fire A,B,L,R +- Ctrl+1...8: enable/disable graphical layers (BG0, BG1, BG2, BG3, OBJ, WIN0, + WIN1, OBJWIN) +- Ctrl+N: pause on next frame +- Ctrl+R: reset +- Ctrl+P: pause +- Ctrl+B: rewind (if enabled and available) +- F11: enter built-in debugger +- ESC: exit emulator + +Emulation key settings +---------------------- + +- Movement: arrow keys +- Button A: Z +- Button B: X +- Button L: A +- Button R: S +- Button Start: ENTER +- Button Select: BACKSPACE +- Speed up: SPACE +- Screen capture: F12 +- Motion Left: NUMPAD 4 +- Motion Right: NUMPAD 6 +- Motion Up: NUMPAD 8 +- Motion Down: NUMPAD 2 + + +GDB support +----------- + +VisualBoyAdvance now provides GDB remote debugging support. This gives +developers the full power of GDB to debug GBA applications. + +In order to use this, you will need a cross-compiled GDB for either the arm-elf +or arm-thumb-elf target (used for the --target= option of GDB configure +script). + +You can also use GDB frontends like DDD, CodeMedic, etc... or even GDB/Insight +for GUI debugger (if using anything other than GDB/Insight, please make sure +to point to the right GDB executable). + +The emulator provides two transport protocols for remote debugging: + +- TCP: allows debugging through TCP using port 55555 (or any specified) port. + The advantage of using TCP is that it allows true remote debugging but it is + slower compared to the pipe method (pipe method does not work on Windows - + probably a restriction imposed by the CYGWIN port of GDB). +- PIPE: allows debugging through a PIPE between the emulator and GDB. This is a + lot faster than TCP and recommened on Unix systems. + +Using TCP transport +------------------- + +To use the TCP transport, use the flag -Gtcp[:portnum] where portnum is an +optional port number to be used instead of 55555. VBA will wait for a GDB +connection on the specified port (printed on screen). Start GDB by passing the +.elf file, then connect to the emulator by using the command: + +target remote : + +where hostname is the host where the emulator is running and port number is the +printed port number. + +Using PIPE transport +-------------------- + +To use the PIPE transport, start GDB with the .elf file to be debugged. Connect +to the emulator by using the command: + +target remote |/VisualBoyAdvance -Gpipe + +Debugging with GDB +------------------ + +Once you connected to the emulator, you can set breakpoints and debug the +application. But before doing that, you will need to issue the loda command on +GDB to load the code into the emulator. Optionally, you can pass the ELF file +on the emulator's command line (along with the -N option to not parse the debug +information in the emulator) instead of issuing the load command. + +After connecting and optionally loading the file into the debugger, you can +start debugging: add breakpoints, step, etc... + +While using GDB, any console output (see below) will show up in GDB's console. + +If you want to break into the GDB, press F11 and it will give you full command +in GDB again. Pressing ESC will terminate emulation. + +You can also detach GDB from the emulator. + + +Console Output +-------------- + +There are two forms of console output in this version: + +- Mappy style dprint: use the following code (from Mappy's documentation) + to get output: + +- VBA style: use the following code to get output: + // THUMB code + void print(char *s) + { + asm volatile("mov r0, %0;" + "swi 0xff;" + : // no ouput + : "r" (s) + : "r0"); + } + // ARM code + void print(char *s) + { + asm volatile("mov r0, %0;" + "swi 0xff0000;" + : // no ouput + : "r" (s) + : "r0"); + } + +When using GDB, the output will show up in GDB's console. When using the +built-in debugger, output will go to standard out. + +Built-in debugger enhancements +------------------------------ + +The built-in debugger has the following enhancements (need debug enabled ELF +file): +- ELF file support: both multiple and regular. Please report any messages or + problems reading ELF files. C++ classes and some miscellaneous features are + not supported yet. Also, method names may be mangled in C++ code. +- break command: add a breakpoint on a function, line number of file:line + number +- locals command: print the local variables on the current function +- print command: prints the value of a given expression. Valid expression + include *this, ptr->member, var.member, array[0], sizeof(expression), etc... +- symbols command: list information known about a symbol (or symbols that start + with the given name) +- radix command: sets the output radix to eithe decimal, octal or hex. +- file and line number when stopped: the debugger will show the file and line + number (if available) for the current address +- fixes to some breakpoint handling problems +- fixes to break on write function + +Profiling +--------- + +VisualBoyAdvance has profiling support. It produces output in the format +supported by GPROF. You need a cross-compiled binary of GPROF (binutils +GNU package) compiled with --target=arm-thumb-elf (or similar). + +The output will always contain the histogram of PC positions at the specified +frequency even if the code is not compiled with call graph support. + +In order to enable profiling, you need to add a call inside your code +to start it (download vba.s for a ready to use file for GCC): + +void monstartup(u32 lowPC, 32 highPC) + +This will start profiling for the given address region. If the code was also +compiled with -pg, call graphs will be recorded. + +Other calls for fine grain control: + +// control profiling +// 0 - stops profiling +// anyother value starts it +void moncontrol(int mode) + +// stop profiling and output gmon.out file +void moncleanup() + +// record call graph (used by GCC) +// r12 contains previous caller +// r14 contains function that was called +void mcount() + +GCC bugs +-------- + +All versions of GCC previous to the working version 3.3 have bugs when +generating profiling for thumb functions. + +The errors are: +- mov\tip,lr not a valid instruction (typo in gcc/config/arm/arm.h) +- LPxx undefined when linking (missing . before LP causes the problem) + +You can fix these problems by either recompiling GCC (recommended) or by +modifying cc1.exe to fix the problems. + +In the first option, find the given code in gcc/config/arm/arm.h and fix +the typos (remove the extra blackslash from the mov ip,lr instruction and +add the missing dot before LP%d) or change THUMB_FUNCTION_PROFILER to call +ARM_FUNCTION_PROFILER (the recent changes that were performed in CVS). + +If you don't want to compile your own GCC, then you can use an hex editor +to fix the problems. Locate cc1.exe under /lib/gcc-lib// +and find the mov\tip,lr instruction. Change the extra backslash to a space. +Locate the .LP string just before the mov instruction and change it to +.P instead (make sure to place 0 after the P). Then find the text .word +LP%d and change it to .word .P%d. + +Histograms will be output even if the code is not compiled with call graph +support. + +Options configuration +--------------------- + +All configurable options are accessible from the configuration file +VisualBoyAdvance.cfg. + +This file is searched in this order: + +- current directory +- user home directory (defined by HOME environment variable) +- user profile directory (Windows only defined by USERPROFILE directory) +- executable directory (either relative or defined by PATH variable) + +All options are documented in the file supplied with this distribution. + +Command line options (override settings in configuration file) +-------------------------------------------------------------- + + -1, --video-1x 1x + -2, --video-2x 2x + -3, --video-3x 3x + -4, --video-4x 4x + -F, --fullscreen Full screen + -G, --gdb=PROTOCOL GNU Remote Stub mode: + tcp - use TCP at port 55555 + tcp:PORT - use TCP at port PORT + pipe - use pipe transport + -N, --no-debug Don't parse debug information + -S, --flash-size=SIZE Set the Flash size + --flash-64k 0 - 64K Flash + --flash-128k 1 - 128K Flash + -T, --throttle=THROTTLE Set the desired throttle (5...1000) + -Y, --yuv=TYPE Use YUV overlay for drawing: + 0 - YV12 + 1 - UYVY + 2 - YVYU + 3 - YUY2 + 4 - IYUV + -b, --bios=BIOS Use given bios file + -c, --config=FILE Read the given configuration file + -d, --debug Enter debugger + -f, --filter=FILTER Select filter: + --filter-normal 0 - normal mode + --filter-tv-mode 1 - TV Mode + --filter-2xsai 2 - 2xSaI + --filter-super-2xsai 3 - Super 2xSaI + --filter-super-eagle 4 - Super Eagle + --filter-pixelate 5 - Pixelate + --filter-motion-blur 6 - Motion Blur + --filter-advmame 7 - AdvanceMAME Scale2x + --filter-simple2x 8 - Simple2x + --filter-bilinear 9 - Bilinear + --filter-bilinear+ 10 - Bilinear Plus + --filter-scanlines 11 - Scanlines + --filter-hq2x 12 - hq2x + --filter-lq2x 13 - lq2x + -h, --help Print this help + -i, --ips=PATCH Apply given IPS patch + -p, --profile=[HERTZ] Enable profiling + -s, --frameskip=FRAMESKIP Set frame skip (0...9) + -t, --save-type=TYPE Set the available save type + --save-auto 0 - Automatic (EEPROM, SRAM, FLASH) + --save-eeprom 1 - EEPROM + --save-sram 2 - SRAM + --save-flash 3 - FLASH + --save-sensor 4 - EEPROM+Sensor + --save-none 5 - NONE + -v, --verbose=VERBOSE Set verbose logging (trace.log) + 1 - SWI + 2 - Unaligned memory access + 4 - Illegal memory write + 8 - Illegal memory read + 16 - DMA 0 + 32 - DMA 1 + 64 - DMA 2 + 128 - DMA 3 + 256 - Undefined instruction + 512 - AGBPrint messages + +Long options only: + --agb-print Enable AGBPrint support + --auto-frameskip Enable auto frameskipping + --ifb-none No interframe blending + --ifb-motion-blur Interframe motion blur + --ifb-smart Smart interframe blending + --no-agb-print Disable AGBPrint support + --no-auto-frameskip Disable auto frameskipping + --no-ips Do not apply IPS patch + --no-mmx Disable MMX support + --no-pause-when-inactive Don't pause when inactive + --no-rtc Disable RTC support + --no-show-speed Don't show emulation speed + --no-throttle Disable thrrotle + --pause-when-inactive Pause when inactive + --rtc Enable RTC support + --show-speed-normal Show emulation speed + --show-speed-detailed Show detailed speed data + +Known bugs +---------- + +- loading a save state that uses a different sound quality may hang the + emulator. Please only use the 22Khz sound quality save states from the + Windows version with this release +- built-in debugger still has a few bugs +- disassembler contains a few errors. Please report anything wrong you find + +LICENSE +------- + + VisualBoyAdvance - a Gameboy and GameboyAdvance emulator + Copyright (C) 1999-2003 Forgotten + Copyright (C) 2004 Forgotten and the VBA development team + + 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 + +This program also contains code developed by the University of +California and is subject to the extra conditions: + +Copyright (c) 1991, 1998 The Regents of the University of California. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. [rescinded 22 July 1999] +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +Contact +------- + +Please don't email unless you found some bug. Requests will be ignored and +deleted. Also, be descriptive when emailing. You have to tell me what version +of the emulator you are writing about and a good description of the problem. +Remember, there are several interfaces (Windows, SDL and GTK+) and +several systems (Windows, Linux, MacOS X and BeOS). + +Also, there are still people writing about the old VisualBoy which is no longer +supported. Also remember I am not paid to work on VisualBoyAdvance. This is +just a hobby. + +Forgotten (http://vba.ngemu.com/contact.shtml) +kxu + +http://vba.ngemu.com +http://sourceforge.net/projects/vba + +Special Thanks +-------------- + +PokemonHacker for all his help improving the emulator. +Costis for his help fixing some of the graphics bugs. +Snes9x developers for the great emulator and source code. +Kreed for his great graphic filters. +SDL team for this amazing library. +And all users who kindly reported problems. diff --git a/README-win.txt b/README-win.txt new file mode 100644 index 0000000..559edb8 --- /dev/null +++ b/README-win.txt @@ -0,0 +1,242 @@ +Welcome to VisualBoyAdvance version 1.7.2. + +Compiling the sources +--------------------- + +See the INSTALL file for compiling instructions. Please note the following +requisites to compile: + +- GCC must be 3.x or greater in order to compile GBA.cpp with -O2. Earlier + versions have a problem during optimization that requires an absurd + ammount of memory and usually ends up crashing the compiler/computer +- On Windows, Microsoft Visual C++ 6 or later is needed. Please note that + some of the source code will not compile with the shipped header files. + You will need to install the most recent Platform SDK from Microsoft. + +Support +------- + +Please support VisualBoyAdvance by making a donation. You can donate money +using PayPal (www.paypal.com). Use the contact form to find how you can +send donations. Also, it is recommended that you use the VisualBoyAdvance +forum on www.ngemu.com message board. + +Default keys (can be edited in the Options menu) +------------------------------------------------ + +Arrow keys - direction +Z - Button A +X - Button B +A - Button L +S - Button R +Enter - Start +Backspace - Select +Speedup - Space +Capture - F12 + +You can change the configuration above to use a joystick. Go to +Options->Joypad->Configure... menu. + +The 1 thorugh 4 joypads allow you to have different settings which can be +easily switched. + +System requirements +------------------- + +Fast computer (Pentium III 500 Mhz recommended) and Microsoft DirectX 7 or +greater. + +Translations +------------ + +Translations can be done as long as you have Microsoft Visual VC++ on +your computer. + +If you just want to use a translation, place the translation .DLL on +the same directory as the emulator. From the Options->Language menu, +select Other... and type the three letter (or two) language name from +.DLL. For example, VBA_PTB.DLL: type PTB on the dialog. + +These translation files are only for VisualBoyAdvance GUI and messages. +Games will not be translated and cannot be translated by the emulator. + +Skins +----- + +Skins consist of a bitmap (.bmp), a region file (.rgn), a draw rectangle +on the region and an INI file. + +Once you have the bitmap, you the region creator which can be found at +the downloads section of emulator website along with a sample skin. +This allows for irregular skins with holes or any shape. + +Create the INI file like this: +[skin] +image= +region= +draw= +buttons= (optional) + +Then, for each button with n starting a 0: + +[button-] +normal= +down= +over= (optional) +id= +region= (optional) + +The id member can be one of the values found under Tools->Customize to have an +action button. + +If the intended use for the button is to open a menu, it can be one of the +following values: + +MENUFILE - The File Menu +MENUOPTIONS - The Options Menu +MENUCHEAT - The Cheat Menu +MENUTOOLS - The Tools Menu +MENUHELP - The Help Menu + +If the intended use for the button is to provide a joypad button, then the +it can be one of the following values: + +A - A button +B - B button +SEL - SELECT button +START - START button +R - right +L - left +U - up +D - down +BR - RIGHT button (shoulder) +BL - LEFT button (shoulder) +SPEED - speed up button (emulator) +CAPTURE - screen capture (emulator) +GS - GS/AR button (cheating) +UR - up and right combination +UL - up and left combination +DR - down and right combination +DL - down and left combination + +Example: + +[skin] +image=gbc.bmp +regions=gbc.rgn +draw=20,20,144,160 + +Skins are only supported in DirectDraw and GDI modes and are also not supported +in fullscreen mode. + +To avoid scaling problems, please not the following: + +GBA screen size: 240x160 +GBC screen size without border: 160x144 +GBC screen size with border: 256x224 + +Not using multiples to these values will cause distortion on the image drawn +by the emulator. This is not a BUG on the emulator and rather a problem of +the skin size. + +Per game settings +----------------- + +Version 1.5 introduced the support for per game settings for GBA games. You +can defined the following settings on a per game basis by using an INI file +called vba-over.ini in the same directory as the emulator: + +rtcEnabled=<0 for false, anything else for true> +flashSize=<65536 or 131072> +saveType=<0 for automatic, 1 for EEPROM, 2 for SRAM, 3 for Flash or 4 for +EEPROM+Sensor> + +Use the 4 letter game code to separate settings for each game. Example: + +[ABCD] +rtcEnabled=0 +flashSize=65536 +saveType=0 + +[ABC2] +rtcEnabled=1 +flashSize=131072 +saveType=0 + +FAQ +--- + +See online FAQ for more information: http://vba.ngemu.com/faq.shtml + +Please don't email about what you think it is problem before consulting +the FAQ. + +Reporting a crash +----------------- + +If VisualBoyAdvance crashes, please do the following: + +1. Win 95/98/ME: start DrWatson (drwatson.exe) and reproduce the crash. +DrWatson will capture the crash information in a log file (.wlg) file that +needs to be sent to me. Please also open the .wlg file on your machine by +double-clicking and copy the details section into the email. Microsoft +made life harder when you migrate to WinXP (or NT or 2000) by not allowing +DrWatson to read its old file format. + +2. Win NT/2000/XP: make sure DrWatson is the default debugger by executing +drwtsn32.exe -i and then recreate the crash. DrWatson will generate a log file +that needs to be sent to me (usually in c:\Documents and Settings\All Users\ +Documents\DrWatson). Depending on your system configuration, you may be asked +if you want to generate a log file. If so, please click on yes. + +LICENSE +------- + + VisualBoyAdvance - a Gameboy and GameboyAdvance emulator + Copyright (C) 1999-2003 Forgotten + Copyright (C) 2004 Forgotten and the VBA development team + + 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 + +Special Thanks +-------------- + +PokemonHacker for all his help improving the emulator. +Costis for his help fixing some of the graphics bugs. +Snes9x developers for the great emulator and source code. +Gollum for some help and tips. +Kreed for his great graphic filters. +And all users who kindly reported problems. + +Contact +------- + +Please don't email unless you found some bug. Requests will be ignored and +deleted. Also, be descriptive when emailing. You have to tell me what version +of the emulator you are writing about and a good description of the problem. +Remember, there are several interfaces (Windows, SDL and GTK+) and +several systems (Windows, Linux, MacOS X and BeOS). + +Also, there are still people writing about the old VisualBoy which is no longer +supported. Also remember I am not paid to work on VisualBoyAdvance. + +This is just a hobby. + +Forgotten (http://vba.ngemu.com/contact.shtml) +kxu + +http://vba.ngemu.com +http://sourceforge.net/projects/vba diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..07c515e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +VisualBoyAdvance 1.7.2 diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..b8da802 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,802 @@ +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN(AM_PATH_SDL, +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + AC_REQUIRE([AC_CANONICAL_TARGET]) + AC_PATH_PROG(SDL_CONFIG, sdl-config, no) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) +# Configure paths for SMPEG +# Nicolas Vignal 11/19/2000 +# stolen from Sam Lantinga +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SMPEG([MINIMUM-VERSION, [ACTION-IF-FOUND [, +ACTION-IF-NOT-FOUND]]]) +dnl Test for SMPEG, and define SMPEG_CFLAGS and SMPEG_LIBS +dnl +AC_DEFUN(AM_PATH_SMPEG, +[dnl +dnl Get the cflags and libraries from the smpeg-config script +dnl +AC_ARG_WITH(smpeg-prefix,[ --with-smpeg-prefix=PFX Prefix where SMPEG is +installed (optional)], + smpeg_prefix="$withval", smpeg_prefix="") +AC_ARG_WITH(smpeg-exec-prefix,[ --with-smpeg-exec-prefix=PFX Exec prefix +where SMPEG is installed (optional)], + smpeg_exec_prefix="$withval", smpeg_exec_prefix="") +AC_ARG_ENABLE(smpegtest, [ --disable-smpegtest Do not try to compile +and run a test SMPEG program], + , enable_smpegtest=yes) + + if test x$smpeg_exec_prefix != x ; then + smpeg_args="$smpeg_args --exec-prefix=$smpeg_exec_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_exec_prefix/bin/smpeg-config + fi + fi + if test x$smpeg_prefix != x ; then + smpeg_args="$smpeg_args --prefix=$smpeg_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_prefix/bin/smpeg-config + fi + fi + + AC_PATH_PROG(SMPEG_CONFIG, smpeg-config, no) + min_smpeg_version=ifelse([$1], ,0.2.7,$1) + AC_MSG_CHECKING(for SMPEG - version >= $min_smpeg_version) + no_smpeg="" + if test "$SMPEG_CONFIG" = "no" ; then + no_smpeg=yes + else + SMPEG_CFLAGS=`$SMPEG_CONFIG $smpegconf_args --cflags` + SMPEG_LIBS=`$SMPEG_CONFIG $smpegconf_args --libs` + + smpeg_major_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + smpeg_minor_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + smpeg_micro_version=`$SMPEG_CONFIG $smpeg_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_smpegtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SMPEG is sufficiently new. (Also sanity +dnl checks the results of smpeg-config to some extent +dnl + rm -f conf.smpegtest + AC_TRY_RUN([ +#include +#include +#include +#include "smpeg.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.smpegtest"); + */ + { FILE *fp = fopen("conf.smpegtest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_smpeg_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_smpeg_version"); + exit(1); + } + + if (($smpeg_major_version > major) || + (($smpeg_major_version == major) && ($smpeg_minor_version > minor)) || + (($smpeg_major_version == major) && ($smpeg_minor_version == minor) +&& ($smpeg_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'smpeg-config --version' returned %d.%d.%d, but the +minimum version\n", $smpeg_major_version, $smpeg_minor_version, +$smpeg_micro_version); + printf("*** of SMPEG required is %d.%d.%d. If smpeg-config is +correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If smpeg-config was wrong, set the environment variable +SMPEG_CONFIG\n"); + printf("*** to point to the correct copy of smpeg-config, and remove +the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_smpeg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_smpeg" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SMPEG_CONFIG" = "no" ; then + echo "*** The smpeg-config script installed by SMPEG could not be +found" + echo "*** If SMPEG was installed in PREFIX, make sure PREFIX/bin is +in" + echo "*** your path, or set the SMPEG_CONFIG environment variable to +the" + echo "*** full path to smpeg-config." + else + if test -f conf.smpegtest ; then + : + else + echo "*** Could not run SMPEG test program, checking why..." + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "smpeg.h" +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This +usually means" + echo "*** that the run-time linker is not finding SMPEG or +finding the wrong" + echo "*** version of SMPEG. If it is not finding SMPEG, you'll +need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit +/etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run +ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to +remove it, although" + echo "*** you may also be able to get things to work by modifying +LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the +file config.log for the" + echo "*** exact error that occured. This usually means SMPEG was +incorrectly installed" + echo "*** or that you have moved SMPEG since it was installed. In +the latter case, you" + echo "*** may want to edit the smpeg-config script: +$SMPEG_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SMPEG_CFLAGS="" + SMPEG_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SMPEG_CFLAGS) + AC_SUBST(SMPEG_LIBS) + rm -f conf.smpegtest +]) +## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*- +## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit , 1996 +## +## 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. +## +## As a special exception to the GNU General Public License, if you +## distribute this file as part of a program that contains a +## configuration script generated by Autoconf, you may include it under +## the same distribution terms that you use for the rest of that program. + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..f8bdf88 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,4337 @@ +# generated automatically by aclocal 1.7.9 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN(AM_PATH_SDL, +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + AC_REQUIRE([AC_CANONICAL_TARGET]) + AC_PATH_PROG(SDL_CONFIG, sdl-config, no) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) +# Configure paths for SMPEG +# Nicolas Vignal 11/19/2000 +# stolen from Sam Lantinga +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SMPEG([MINIMUM-VERSION, [ACTION-IF-FOUND [, +ACTION-IF-NOT-FOUND]]]) +dnl Test for SMPEG, and define SMPEG_CFLAGS and SMPEG_LIBS +dnl +AC_DEFUN(AM_PATH_SMPEG, +[dnl +dnl Get the cflags and libraries from the smpeg-config script +dnl +AC_ARG_WITH(smpeg-prefix,[ --with-smpeg-prefix=PFX Prefix where SMPEG is +installed (optional)], + smpeg_prefix="$withval", smpeg_prefix="") +AC_ARG_WITH(smpeg-exec-prefix,[ --with-smpeg-exec-prefix=PFX Exec prefix +where SMPEG is installed (optional)], + smpeg_exec_prefix="$withval", smpeg_exec_prefix="") +AC_ARG_ENABLE(smpegtest, [ --disable-smpegtest Do not try to compile +and run a test SMPEG program], + , enable_smpegtest=yes) + + if test x$smpeg_exec_prefix != x ; then + smpeg_args="$smpeg_args --exec-prefix=$smpeg_exec_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_exec_prefix/bin/smpeg-config + fi + fi + if test x$smpeg_prefix != x ; then + smpeg_args="$smpeg_args --prefix=$smpeg_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_prefix/bin/smpeg-config + fi + fi + + AC_PATH_PROG(SMPEG_CONFIG, smpeg-config, no) + min_smpeg_version=ifelse([$1], ,0.2.7,$1) + AC_MSG_CHECKING(for SMPEG - version >= $min_smpeg_version) + no_smpeg="" + if test "$SMPEG_CONFIG" = "no" ; then + no_smpeg=yes + else + SMPEG_CFLAGS=`$SMPEG_CONFIG $smpegconf_args --cflags` + SMPEG_LIBS=`$SMPEG_CONFIG $smpegconf_args --libs` + + smpeg_major_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + smpeg_minor_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + smpeg_micro_version=`$SMPEG_CONFIG $smpeg_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_smpegtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SMPEG is sufficiently new. (Also sanity +dnl checks the results of smpeg-config to some extent +dnl + rm -f conf.smpegtest + AC_TRY_RUN([ +#include +#include +#include +#include "smpeg.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.smpegtest"); + */ + { FILE *fp = fopen("conf.smpegtest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_smpeg_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_smpeg_version"); + exit(1); + } + + if (($smpeg_major_version > major) || + (($smpeg_major_version == major) && ($smpeg_minor_version > minor)) || + (($smpeg_major_version == major) && ($smpeg_minor_version == minor) +&& ($smpeg_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'smpeg-config --version' returned %d.%d.%d, but the +minimum version\n", $smpeg_major_version, $smpeg_minor_version, +$smpeg_micro_version); + printf("*** of SMPEG required is %d.%d.%d. If smpeg-config is +correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If smpeg-config was wrong, set the environment variable +SMPEG_CONFIG\n"); + printf("*** to point to the correct copy of smpeg-config, and remove +the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_smpeg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_smpeg" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SMPEG_CONFIG" = "no" ; then + echo "*** The smpeg-config script installed by SMPEG could not be +found" + echo "*** If SMPEG was installed in PREFIX, make sure PREFIX/bin is +in" + echo "*** your path, or set the SMPEG_CONFIG environment variable to +the" + echo "*** full path to smpeg-config." + else + if test -f conf.smpegtest ; then + : + else + echo "*** Could not run SMPEG test program, checking why..." + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "smpeg.h" +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This +usually means" + echo "*** that the run-time linker is not finding SMPEG or +finding the wrong" + echo "*** version of SMPEG. If it is not finding SMPEG, you'll +need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit +/etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run +ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to +remove it, although" + echo "*** you may also be able to get things to work by modifying +LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the +file config.log for the" + echo "*** exact error that occured. This usually means SMPEG was +incorrectly installed" + echo "*** or that you have moved SMPEG since it was installed. In +the latter case, you" + echo "*** may want to edit the smpeg-config script: +$SMPEG_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SMPEG_CFLAGS="" + SMPEG_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SMPEG_CFLAGS) + AC_SUBST(SMPEG_LIBS) + rm -f conf.smpegtest +]) + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + + +# Do all the work for Automake. -*- Autoconf -*- + +# This macro actually does too much some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 10 + +AC_PREREQ([2.54]) + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG(AMTAR, tar) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl + +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.7.9])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright 2001, 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 2 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# +# Check to make sure that the build environment is sane. +# + +# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# -*- Autoconf -*- + + +# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 3 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# AM_AUX_DIR_EXPAND + +# Copyright 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +# Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50]) + +AC_DEFUN([AM_AUX_DIR_EXPAND], [ +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. + +# Copyright 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# AM_PROG_INSTALL_STRIP + +# Copyright 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# -*- Autoconf -*- +# Copyright (C) 2003 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 1 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# serial 5 -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + : > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # (even with -Werror). So we grep stderr for any message + # that says an option was ignored. + if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +#serial 2 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 2 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 5 + +AC_PREREQ(2.52) + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]) +fi])]) + + +# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 3 + +AC_PREREQ(2.50) + +# AM_PROG_LEX +# ----------- +# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a +# "missing" invocation, for better error output. +AC_DEFUN([AM_PROG_LEX], +[AC_REQUIRE([AM_MISSING_HAS_RUN])dnl +AC_REQUIRE([AC_PROG_LEX])dnl +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi]) + +# gettext.m4 serial 28 (gettext-0.13) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value `$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define(gt_included_intl, ifelse([$1], [external], [no], [yes])) + define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], [])) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Set USE_NLS. + AM_NLS + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH(included-gettext, + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + dnl Add a version number to the cache macros. + define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1))) + define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc]) + define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl]) + + AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc, + [AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings], + gt_cv_func_gnugettext_libc=yes, + gt_cv_func_gnugettext_libc=no)]) + + if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + gt_cv_func_gnugettext_libintl, + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + gt_cv_func_gnugettext_libintl=yes, + gt_cv_func_gnugettext_libintl=no) + dnl Now see whether libintl exists and depends on libiconv. + if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + gt_cv_func_gnugettext_libintl=yes + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if test "$gt_cv_func_gnugettext_libc" = "yes" \ + || { test "$gt_cv_func_gnugettext_libintl" = "yes" \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE(ENABLE_NLS, 1, + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE(HAVE_GETTEXT, 1, + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE(HAVE_DCGETTEXT, 1, + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST(BUILD_INCLUDED_LIBINTL) + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATOBJEXT) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST(DATADIRNAME) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST(INSTOBJEXT) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST(GENCAT) + + dnl For backward compatibility. Some Makefiles may be using this. + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST(INTLOBJS) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST(INTLLIBS) + + dnl Make all documented variables known to autoconf. + AC_SUBST(LIBINTL) + AC_SUBST(LTLIBINTL) + AC_SUBST(POSUB) +]) + + +dnl Checks for all prerequisites of the intl subdirectory, +dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, +dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. +AC_DEFUN([AM_INTL_SUBDIR], +[ + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([AC_ISC_POSIX])dnl + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_C_CONST])dnl + AC_REQUIRE([bh_C_SIGNED])dnl + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_OFF_T])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([jm_AC_TYPE_LONG_LONG])dnl + AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl + AC_REQUIRE([gt_TYPE_WCHAR_T])dnl + AC_REQUIRE([gt_TYPE_WINT_T])dnl + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + AC_REQUIRE([gt_TYPE_INTMAX_T]) + AC_REQUIRE([gt_PRINTF_POSIX]) + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + AC_REQUIRE([jm_GLIBC21])dnl + AC_REQUIRE([gt_INTDIV0])dnl + AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl + AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl + AC_REQUIRE([gt_INTTYPES_PRI])dnl + AC_REQUIRE([gl_XSIZE])dnl + + AC_CHECK_TYPE([ptrdiff_t], , + [AC_DEFINE([ptrdiff_t], [long], + [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) + ]) + AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ +stdlib.h string.h unistd.h sys/param.h]) + AC_CHECK_FUNCS([asprintf fwprintf getcwd getegid geteuid getgid getuid \ +mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \ +strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \ +__fsetlocking]) + + dnl Use the _snprintf function only if it is declared (because on NetBSD it + dnl is defined as a weak alias of snprintf; we prefer to use the latter). + gt_CHECK_DECL(_snprintf, [#include ]) + gt_CHECK_DECL(_snwprintf, [#include ]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL(feof_unlocked, [#include ]) + gt_CHECK_DECL(fgets_unlocked, [#include ]) + gt_CHECK_DECL(getc_unlocked, [#include ]) + + case $gt_cv_func_printf_posix in + *yes) HAVE_POSIX_PRINTF=1 ;; + *) HAVE_POSIX_PRINTF=0 ;; + esac + AC_SUBST([HAVE_POSIX_PRINTF]) + if test "$ac_cv_func_asprintf" = yes; then + HAVE_ASPRINTF=1 + else + HAVE_ASPRINTF=0 + fi + AC_SUBST([HAVE_ASPRINTF]) + if test "$ac_cv_func_snprintf" = yes; then + HAVE_SNPRINTF=1 + else + HAVE_SNPRINTF=0 + fi + AC_SUBST([HAVE_SNPRINTF]) + if test "$ac_cv_func_wprintf" = yes; then + HAVE_WPRINTF=1 + else + HAVE_WPRINTF=0 + fi + AC_SUBST([HAVE_WPRINTF]) + + AM_ICONV + AM_LANGINFO_CODESET + if test $ac_cv_header_locale_h = yes; then + AM_LC_MESSAGES + fi + + dnl intl/plural.c is generated from intl/plural.y. It requires bison, + dnl because plural.y uses bison specific features. It requires at least + dnl bison-1.26 because earlier versions generate a plural.c that doesn't + dnl compile. + dnl bison is only needed for the maintainer (who touches plural.y). But in + dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put + dnl the rule in general Makefile. Now, some people carelessly touch the + dnl files or have a broken "make" program, hence the plural.c rule will + dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not + dnl present or too old. + AC_CHECK_PROGS([INTLBISON], [bison]) + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + dnl Found it, now check the version. + AC_MSG_CHECKING([version of bison]) +changequote(<<,>>)dnl + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) +changequote([,])dnl + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + AC_MSG_RESULT([$ac_prog_version]) + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi +]) + + +dnl gt_CHECK_DECL(FUNC, INCLUDES) +dnl Check whether a function is declared. +AC_DEFUN([gt_CHECK_DECL], +[ + AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, + [AC_TRY_COMPILE([$2], [ +#ifndef $1 + char *p = (char *) $1; +#endif +], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) + if test $ac_cv_have_decl_$1 = yes; then + gt_value=1 + else + gt_value=0 + fi + AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], + [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) + +# po.m4 serial 3 (gettext-0.14) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AM_NLS])dnl + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :) + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU msgfmt. + if test "$GMSGFMT" != ":"; then + dnl If it is no GNU msgfmt we define it as : so that the + dnl Makefiles still can work. + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && + (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` + AC_MSG_RESULT( + [found $GMSGFMT program is not GNU msgfmt; ignore it]) + GMSGFMT=":" + fi + fi + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU xgettext. + if test "$XGETTEXT" != ":"; then + dnl If it is no GNU xgettext we define it as : so that the + dnl Makefiles still can work. + if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + AC_MSG_RESULT( + [found xgettext program is not GNU xgettext; ignore it]) + XGETTEXT=":" + fi + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + fi + + AC_OUTPUT_COMMANDS([ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) + +dnl Postprocesses a Makefile in a directory containing PO files. +AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], +[ + # When this code is run, in config.status, two variables have already been + # set: + # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, + # - LINGUAS is the value of the environment variable LINGUAS at configure + # time. + +changequote(,)dnl + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + # Find a way to echo strings without interpreting backslash. + if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='echo' + else + if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='printf %s\n' + else + echo_func () { + cat < "$ac_file.tmp" + if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + cat >> "$ac_file.tmp" < /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/_/-/g'` + cat >> "$ac_file.tmp" <> "$ac_file.tmp" <, 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE(nls, + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) +]) + +AC_DEFUN([AM_MKINSTALLDIRS], +[ + dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly + dnl find the mkinstalldirs script in another subdir but $(top_srcdir). + dnl Try to locate it. + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + case "$ac_aux_dir" in + /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; + *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; + esac + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + AC_SUBST(MKINSTALLDIRS) +]) + +# progtest.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL(ac_cv_path_$1, +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$]$1) +else + AC_MSG_RESULT(no) +fi +AC_SUBST($1)dnl +]) + +# lib-prefix.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +# lib-link.m4 serial 4 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +# lib-ld.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(acl_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) + +# iconv.m4 serial AM4 (gettext-0.11.3) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_func_iconv=yes) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_lib_iconv=yes + am_cv_func_iconv=yes) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST(LIBICONV) + AC_SUBST(LTLIBICONV) +]) + +AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL(am_cv_proto_iconv, [ + AC_TRY_COMPILE([ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([$]{ac_t:- + }[$]am_cv_proto_iconv) + AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, + [Define as const if the declaration of iconv() needs const.]) + fi +]) + +# isc-posix.m4 serial 2 (gettext-0.11.2) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. + +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) + +# signed.m4 serial 1 (gettext-0.10.40) +dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([bh_C_SIGNED], +[ + AC_CACHE_CHECK([for signed], bh_cv_c_signed, + [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)]) + if test $bh_cv_c_signed = no; then + AC_DEFINE(signed, , + [Define to empty if the C compiler doesn't support this keyword.]) + fi +]) + +# longlong.m4 serial 4 +dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_LONG_LONG if 'long long' works. + +AC_DEFUN([jm_AC_TYPE_LONG_LONG], +[ + AC_CACHE_CHECK([for long long], ac_cv_type_long_long, + [AC_TRY_LINK([long long ll = 1LL; int i = 63;], + [long long llmax = (long long) -1; + return ll << i | ll >> i | llmax / ll | llmax % ll;], + ac_cv_type_long_long=yes, + ac_cv_type_long_long=no)]) + if test $ac_cv_type_long_long = yes; then + AC_DEFINE(HAVE_LONG_LONG, 1, + [Define if you have the 'long long' type.]) + fi +]) + +# longdouble.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether the compiler supports the 'long double' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_LONGDOUBLE], +[ + AC_CACHE_CHECK([for long double], gt_cv_c_long_double, + [if test "$GCC" = yes; then + gt_cv_c_long_double=yes + else + AC_TRY_COMPILE([ + /* The Stardent Vistra knows sizeof(long double), but does not support it. */ + long double foo = 0.0; + /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ + int array [2*(sizeof(long double) >= sizeof(double)) - 1]; + ], , + gt_cv_c_long_double=yes, gt_cv_c_long_double=no) + fi]) + if test $gt_cv_c_long_double = yes; then + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.]) + fi +]) + +# wchar_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether has the 'wchar_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WCHAR_T], +[ + AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, + [AC_TRY_COMPILE([#include + wchar_t foo = (wchar_t)'\0';], , + gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) + if test $gt_cv_c_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) + fi +]) + +# wint_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether has the 'wint_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WINT_T], +[ + AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, + [AC_TRY_COMPILE([#include + wint_t foo = (wchar_t)'\0';], , + gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) + if test $gt_cv_c_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) + fi +]) + +# inttypes_h.m4 serial 5 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_inttypes_h=yes, + jm_ac_cv_header_inttypes_h=no)]) + if test $jm_ac_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) + +# stdint_h.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_STDINT_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_STDINT_H], +[ + AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_stdint_h=yes, + jm_ac_cv_header_stdint_h=no)]) + if test $jm_ac_cv_header_stdint_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) + +# intmax.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether the system has the 'intmax_t' type, but don't attempt to +dnl find a replacement if it is lacking. + +AC_DEFUN([gt_TYPE_INTMAX_T], +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, + [AC_TRY_COMPILE([ +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +#include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +#include +#endif +], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) + if test $gt_cv_c_intmax_t = yes; then + AC_DEFINE(HAVE_INTMAX_T, 1, + [Define if you have the 'intmax_t' type in or .]) + fi +]) + +# printf-posix.m4 serial 2 (gettext-0.13.1) +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether the printf() function supports POSIX/XSI format strings with +dnl positions. + +AC_DEFUN([gt_PRINTF_POSIX], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], + gt_cv_func_printf_posix, + [ + AC_TRY_RUN([ +#include +#include +/* The string "%2$d %1$d", with dollar characters protected from the shell's + dollar expansion (possibly an autoconf bug). */ +static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; +static char buf[100]; +int main () +{ + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); +}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, + [ + AC_EGREP_CPP(notposix, [ +#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ + notposix +#endif + ], gt_cv_func_printf_posix="guessing no", + gt_cv_func_printf_posix="guessing yes") + ]) + ]) + case $gt_cv_func_printf_posix in + *yes) + AC_DEFINE(HAVE_POSIX_PRINTF, 1, + [Define if your printf() function supports format strings with positions.]) + ;; + esac +]) + +# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([jm_GLIBC21], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, + ac_cv_gnu_library_2_1, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2_1=yes, + ac_cv_gnu_library_2_1=no) + ] + ) + AC_SUBST(GLIBC21) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) + +# intdiv0.m4 serial 1 (gettext-0.11.3) +dnl Copyright (C) 2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([gt_INTDIV0], +[ + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + + AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], + gt_cv_int_divbyzero_sigfpe, + [ + AC_TRY_RUN([ +#include +#include + +static void +#ifdef __cplusplus +sigfpe_handler (int sig) +#else +sigfpe_handler (sig) int sig; +#endif +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} +], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, + [ + # Guess based on the CPU. + case "$host_cpu" in + alpha* | i[34567]86 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac + ]) + ]) + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, + [Define if integer division by zero raises signal SIGFPE.]) +]) + +# uintmax_t.m4 serial 7 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +AC_PREREQ(2.13) + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if it is not already defined in or . + +AC_DEFUN([jm_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then + AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to unsigned long or unsigned long long + if and don't define.]) + else + AC_DEFINE(HAVE_UINTMAX_T, 1, + [Define if you have the 'uintmax_t' type in or .]) + fi +]) + +# ulonglong.m4 serial 3 +dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_UNSIGNED_LONG_LONG if 'unsigned long long' works. + +AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG], +[ + AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, + [AC_TRY_LINK([unsigned long long ull = 1ULL; int i = 63;], + [unsigned long long ullmax = (unsigned long long) -1; + return ull << i | ull >> i | ullmax / ull | ullmax % ull;], + ac_cv_type_unsigned_long_long=yes, + ac_cv_type_unsigned_long_long=no)]) + if test $ac_cv_type_unsigned_long_long = yes; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, + [Define if you have the 'unsigned long long' type.]) + fi +]) + +# inttypes.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists and doesn't clash with +# . + +AC_DEFUN([gt_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, + [ + AC_TRY_COMPILE( + [#include +#include ], + [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) + ]) + if test $gt_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, + [Define if exists and doesn't clash with .]) + fi +]) + +# inttypes-pri.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +# Define PRI_MACROS_BROKEN if exists and defines the PRI* +# macros to non-string values. This is the case on AIX 4.3.3. + +AC_DEFUN([gt_INTTYPES_PRI], +[ + AC_REQUIRE([gt_HEADER_INTTYPES_H]) + if test $gt_cv_header_inttypes_h = yes; then + AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], + gt_cv_inttypes_pri_broken, + [ + AC_TRY_COMPILE([#include +#ifdef PRId32 +char *p = PRId32; +#endif +], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) + ]) + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, + [Define if exists and defines unusable PRI* macros.]) + fi +]) + +# xsize.m4 serial 2 +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +AC_DEFUN([gl_XSIZE], +[ + dnl Prerequisites of lib/xsize.h. + AC_REQUIRE([gl_SIZE_MAX]) + AC_CHECK_HEADERS(stdint.h) +]) + +# size_max.m4 serial 2 +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SIZE_MAX], +[ + AC_CHECK_HEADERS(stdint.h) + dnl First test whether the system already has SIZE_MAX. + AC_MSG_CHECKING([for SIZE_MAX]) + result= + AC_EGREP_CPP([Found it], [ +#include +#if HAVE_STDINT_H +#include +#endif +#ifdef SIZE_MAX +Found it +#endif +], result=yes) + if test -z "$result"; then + dnl Define it ourselves. Here we assume that the type 'size_t' is not wider + dnl than the type 'unsigned long'. + dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr', + dnl which is guaranteed to work from LONG_MIN to LONG_MAX. + _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi, + [#include ], result=?) + _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo, + [#include ], result=?) + _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, + [#include ], result=?) + if test "$fits_in_uint" = 1; then + dnl Even though SIZE_MAX fits in an unsigned int, it must be of type + dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. + AC_TRY_COMPILE([#include + extern size_t foo; + extern unsigned long foo; + ], [], fits_in_uint=0) + fi + if test -z "$result"; then + if test "$fits_in_uint" = 1; then + result="$res_hi$res_lo"U + else + result="$res_hi$res_lo"UL + fi + else + dnl Shouldn't happen, but who knows... + result='~(size_t)0' + fi + fi + AC_MSG_RESULT([$result]) + if test "$result" != yes; then + AC_DEFINE_UNQUOTED([SIZE_MAX], [$result], + [Define as the maximum value of type 'size_t', if the system doesn't define it.]) + fi +]) + +# codeset.m4 serial AM1 (gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, + [AC_TRY_LINK([#include ], + [char* cs = nl_langinfo(CODESET);], + am_cv_langinfo_codeset=yes, + am_cv_langinfo_codeset=no) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET, 1, + [Define if you have and nl_langinfo(CODESET).]) + fi +]) + +# lcmessage.m4 serial 3 (gettext-0.11.3) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995. + +# Check whether LC_MESSAGES is available in . + +AC_DEFUN([AM_LC_MESSAGES], +[ + AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, + [AC_TRY_LINK([#include ], [return LC_MESSAGES], + am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + if test $am_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES, 1, + [Define if your file defines LC_MESSAGES.]) + fi +]) + + +dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) +dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page +dnl also defines GSTUFF_PKG_ERRORS on error +AC_DEFUN(PKG_CHECK_MODULES, [ + succeeded=no + + if test -z "$PKG_CONFIG"; then + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + fi + + if test "$PKG_CONFIG" = "no" ; then + echo "*** The pkg-config script could not be found. Make sure it is" + echo "*** in your path, or set the PKG_CONFIG environment variable" + echo "*** to the full path to pkg-config." + echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." + else + PKG_CONFIG_MIN_VERSION=0.9.0 + if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then + AC_MSG_CHECKING(for $2) + + if $PKG_CONFIG --exists "$2" ; then + AC_MSG_RESULT(yes) + succeeded=yes + + AC_MSG_CHECKING($1_CFLAGS) + $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` + AC_MSG_RESULT($$1_CFLAGS) + + AC_MSG_CHECKING($1_LIBS) + $1_LIBS=`$PKG_CONFIG --libs "$2"` + AC_MSG_RESULT($$1_LIBS) + else + $1_CFLAGS="" + $1_LIBS="" + ## If we have a custom action on failure, don't print errors, but + ## do set a variable so people can do so. + $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + ifelse([$4], ,echo $$1_PKG_ERRORS,) + fi + + AC_SUBST($1_CFLAGS) + AC_SUBST($1_LIBS) + else + echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." + echo "*** See http://www.freedesktop.org/software/pkgconfig" + fi + fi + + if test $succeeded = yes; then + ifelse([$3], , :, [$3]) + else + ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) + fi +]) + + + diff --git a/compile b/compile new file mode 100644 index 0000000..ac07cc5 --- /dev/null +++ b/compile @@ -0,0 +1,107 @@ +#! /bin/sh + +# Wrapper for compilers which do not understand `-c -o'. + +# Copyright 1999, 2000 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Usage: +# compile PROGRAM [ARGS]... +# `-o FOO.o' is removed from the args passed to the actual compile. + +# Usage statement added by Billy Biggs . +if [ -z $1 ]; then + echo "Wrapper for compilers which do not understand '-c -o'." + echo "usage: compile PROGRAM [ARGS]..." + echo "'-o FOO.o' is removed from the args passed to the actual compile." + exit 1 +fi + +prog=$1 +shift + +ofile= +cfile= +args= +while test $# -gt 0; do + case "$1" in + -o) + # configure might choose to run compile as `compile cc -o foo foo.c'. + # So we do something ugly here. + ofile=$2 + shift + case "$ofile" in + *.o | *.obj) + ;; + *) + args="$args -o $ofile" + ofile= + ;; + esac + ;; + *.c) + cfile=$1 + args="$args $1" + ;; + *) + args="$args $1" + ;; + esac + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no `-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # `.c' file was seen then we are probably linking. That is also + # ok. + exec "$prog" $args +fi + +# Name of file we expect compiler to create. +cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` + +# Create the lock directory. +# Note: use `[/.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d +while true; do + if mkdir $lockdir > /dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir $lockdir; exit 1" 1 2 15 + +# Run the compile. +"$prog" $args +status=$? + +if test -f "$cofile"; then + mv "$cofile" "$ofile" +fi + +rmdir $lockdir +exit $status diff --git a/config.guess b/config.guess new file mode 100644 index 0000000..6012b39 --- /dev/null +++ b/config.guess @@ -0,0 +1,1298 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-07-12' + +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + eval $set_cc_for_build + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in + big) echo mips-unknown-linux-gnu && exit 0 ;; + little) echo mipsel-unknown-linux-gnu && exit 0 ;; + esac + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev67 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_targets=`cd /; ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-pc-linux-gnu\n", argv[1]); +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-pc-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +eval $set_cc_for_build +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.rpath b/config.rpath new file mode 100644 index 0000000..4db13e5 --- /dev/null +++ b/config.rpath @@ -0,0 +1,548 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2003 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + mingw* | pw32* | os2*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux*) + case $CC in + icc|ecc) + wl='-Wl,' + ;; + ccc) + wl='-Wl,' + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + sco3.2v5*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + case "$host_os" in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = yes; then + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi4*) + ;; + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then + hardcode_direct=no + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10* | hpux11*) + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=no + ;; + ia64*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=no + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + *) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + sco3.2v5*) + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4.2uw2*) + hardcode_direct=yes + hardcode_minus_L=no + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + ;; + sysv5*) + hardcode_libdir_flag_spec= + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +libname_spec='lib$name' +case "$host_os" in + aix3*) + ;; + aix4* | aix5*) + ;; + amigaos*) + ;; + beos*) + ;; + bsdi4*) + ;; + cygwin* | mingw* | pw32*) + shrext=.dll + ;; + darwin* | rhapsody*) + shrext=.dylib + ;; + dgux*) + ;; + freebsd1*) + ;; + freebsd*) + ;; + gnu*) + ;; + hpux9* | hpux10* | hpux11*) + case "$host_cpu" in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux*) + ;; + netbsd*) + ;; + newsos6) + ;; + nto-qnx) + ;; + openbsd*) + ;; + os2*) + libname_spec='$name' + shrext=.dll + ;; + osf3* | osf4* | osf5*) + ;; + sco3.2v5*) + ;; + solaris*) + ;; + sunos4*) + ;; + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + ;; + sysv4*MP*) + ;; + uts4*) + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ + | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ + | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 \ + | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | hppa64 \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ + | we32k | ns16k | clipper | i370 | sh | sh[34] \ + | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp10 | pdp11 \ + | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | mips64vr5000el | mcore | s390 | s390x \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ + | v850 | c4x \ + | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ + | pj | pjl | h8500 | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ + | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ + | xmp-* | ymp-* \ + | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ + | hppa2.0n-* | hppa64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ + | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ + | clipper-* | orion-* \ + | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \ + | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ + | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ + | [cjt]90-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ + | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100644 index 0000000..cdd07e1 --- /dev/null +++ b/configure @@ -0,0 +1,9306 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="src/armdis.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE YACC LEX LEXLIB LEX_OUTPUT_ROOT CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE RANLIB ac_ct_RANLIB NASM CPP EGREP SDL_CONFIG SDL_CFLAGS SDL_LIBS MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB GETTEXT_PACKAGE PKG_CONFIG GTKMM_CFLAGS GTKMM_LIBS GTKMM_CPPFLAGS VBA_EXTRA VBA_SRC_EXTRA VBA_LIBS LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +X features: + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-c-core enable C core (default is no on x86 targets) + --enable-profiling enable profiling (default is yes) + --enable-sdl build the SDL interface (default is yes) + --enable-gtk=[VERSION] build the GTK+ interface (default is no) + --enable-dev enable development features (default is yes) + --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors + --disable-sdltest Do not try to compile and run a test SDL program + --disable-nls do not use Native Language Support + --disable-rpath do not hardcode runtime library paths + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-mmx use MMX (default is yes on x86 targets) + --with-x use the X Window System + --with-sdl-prefix=PFX Prefix where SDL is installed (optional) + --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional) + --with-gnu-ld assume the C compiler uses GNU ld default=no + --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib + --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib + --without-libintl-prefix don't search for libintl in includedir and libdir + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd "$ac_popdir" + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +case "$target" in + i?86-*-*) + VBA_USE_C_CORE=no + VBA_USE_MMX=yes + ;; + *) + VBA_USE_C_CORE=yes + VBA_USE_MMX=no + ;; +esac + +am__api_version="1.7" +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + + # test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=VisualBoyAdvance + VERSION=1.7.2 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. + + + + +# Check whether --enable-c-core or --disable-c-core was given. +if test "${enable_c_core+set}" = set; then + enableval="$enable_c_core" + +else + enable_c_core=$VBA_USE_C_CORE +fi; + +# Check whether --enable-profiling or --disable-profiling was given. +if test "${enable_profiling+set}" = set; then + enableval="$enable_profiling" + +else + enable_profiling=yes +fi; + + +# Check whether --with-mmx or --without-mmx was given. +if test "${with_mmx+set}" = set; then + withval="$with_mmx" + +else + with_mmx=$VBA_USE_MMX +fi; + +# Check whether --enable-sdl or --disable-sdl was given. +if test "${enable_sdl+set}" = set; then + enableval="$enable_sdl" + +else + enable_sdl=yes +fi; + +# Check whether --enable-gtk or --disable-gtk was given. +if test "${enable_gtk+set}" = set; then + enableval="$enable_gtk" + +if test "x$enable_gtk" != xno; then + enable_gtk=yes + if test "x$enableval" = xyes; then + gtk_version=2.0 + else + gtk_version=$enableval + fi +fi + +else + +enable_gtk=no + +fi; + +# Check whether --enable-dev or --disable-dev was given. +if test "${enable_dev+set}" = set; then + enableval="$enable_dev" + +else + enable_dev=yes +fi; + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + : > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # (even with -Werror). So we grep stderr for any message + # that says an option was ignored. + if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX=":" + +if test -z "$LEXLIB" +then + echo "$as_me:$LINENO: checking for yywrap in -lfl" >&5 +echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6 +if test "${ac_cv_lib_fl_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_fl_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_fl_yywrap=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_fl_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6 +if test $ac_cv_lib_fl_yywrap = yes; then + LEXLIB="-lfl" +else + echo "$as_me:$LINENO: checking for yywrap in -ll" >&5 +echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6 +if test "${ac_cv_lib_l_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ll $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_l_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_l_yywrap=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_l_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6 +if test $ac_cv_lib_l_yywrap = yes; then + LEXLIB="-ll" +fi + +fi + +fi + +if test "x$LEX" != "x:"; then + echo "$as_me:$LINENO: checking lex output file root" >&5 +echo $ECHO_N "checking lex output file root... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_root+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +cat >conftest.l <<_ACEOF +%% +%% +_ACEOF +{ (eval echo "$as_me:$LINENO: \"$LEX conftest.l\"") >&5 + (eval $LEX conftest.l) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5 +echo "$as_me: error: cannot find output from $LEX; giving up" >&2;} + { (exit 1); exit 1; }; } +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_root" >&6 +rm -f conftest.l +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5 +echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS=$LIBS +LIBS="$LIBS $LEXLIB" +cat >conftest.$ac_ext <<_ACEOF +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_lex_yytext_pointer=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS +rm -f "${LEX_OUTPUT_ROOT}.c" + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6 +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +cat >>confdefs.h <<\_ACEOF +#define YYTEXT_POINTER 1 +_ACEOF + +fi + +fi +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + : > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # (even with -Werror). So we grep stderr for any message + # that says an option was ignored. + if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +# Extract the first word of "nasm", so it can be a program name with args. +set dummy nasm; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_NASM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $NASM in + [\\/]* | ?:[\\/]*) + ac_cv_path_NASM="$NASM" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_NASM="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +NASM=$ac_cv_path_NASM + +if test -n "$NASM"; then + echo "$as_me:$LINENO: result: $NASM" >&5 +echo "${ECHO_T}$NASM" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + +echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 +echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 +if test "${ac_cv_lib_z_gzopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gzopen (); +int +main () +{ +gzopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_z_gzopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_z_gzopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 +if test $ac_cv_lib_z_gzopen = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +else + { { echo "$as_me:$LINENO: error: *** Cannot compile without zlib." >&5 +echo "$as_me: error: *** Cannot compile without zlib." >&2;} + { (exit 1); exit 1; }; } +fi + + +echo "$as_me:$LINENO: checking for png_create_write_struct in -lpng" >&5 +echo $ECHO_N "checking for png_create_write_struct in -lpng... $ECHO_C" >&6 +if test "${ac_cv_lib_png_png_create_write_struct+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpng -lz $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char png_create_write_struct (); +int +main () +{ +png_create_write_struct (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_png_png_create_write_struct=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_png_png_create_write_struct=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_create_write_struct" >&5 +echo "${ECHO_T}$ac_cv_lib_png_png_create_write_struct" >&6 +if test $ac_cv_lib_png_png_create_write_struct = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPNG 1 +_ACEOF + + LIBS="-lpng $LIBS" + +else + { { echo "$as_me:$LINENO: error: *** Cannot compile without libpng." >&5 +echo "$as_me: error: *** Cannot compile without libpng." >&2;} + { (exit 1); exit 1; }; } +fi + + +echo "$as_me:$LINENO: checking for pthread_yield in -lpthread" >&5 +echo $ECHO_N "checking for pthread_yield in -lpthread... $ECHO_C" >&6 +if test "${ac_cv_lib_pthread_pthread_yield+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_yield (); +int +main () +{ +pthread_yield (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pthread_pthread_yield=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_pthread_pthread_yield=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_yield" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_pthread_yield" >&6 +if test $ac_cv_lib_pthread_pthread_yield = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPTHREAD 1 +_ACEOF + + LIBS="-lpthread $LIBS" + +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for X" >&5 +echo $ECHO_N "checking for X... $ECHO_C" >&6 + + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + +fi; +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else + if test "${ac_cv_have_x+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=no ac_x_libraries=no +rm -fr conftest.dir +if mkdir conftest.dir; then + cd conftest.dir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat >Imakefile <<'_ACEOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +_ACEOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case $ac_im_incroot in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; + esac + case $ac_im_usrlibdir in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; + esac + fi + cd .. + rm -fr conftest.dir +fi + +# Standard set of common directories for X headers. +# Check X11 before X11Rn because it is often a symlink to the current release. +ac_x_header_dirs=' +/usr/X11/include +/usr/X11R6/include +/usr/X11R5/include +/usr/X11R4/include + +/usr/include/X11 +/usr/include/X11R6 +/usr/include/X11R5 +/usr/include/X11R4 + +/usr/local/X11/include +/usr/local/X11R6/include +/usr/local/X11R5/include +/usr/local/X11R4/include + +/usr/local/include/X11 +/usr/local/include/X11R6 +/usr/local/include/X11R5 +/usr/local/include/X11R4 + +/usr/X386/include +/usr/x386/include +/usr/XFree86/include/X11 + +/usr/include +/usr/local/include +/usr/unsupported/include +/usr/athena/include +/usr/local/x11r5/include +/usr/lpp/Xamples/include + +/usr/openwin/include +/usr/openwin/share/include' + +if test "$ac_x_includes" = no; then + # Guess where to find include files, by looking for Intrinsic.h. + # First, try using that file with no special directory specified. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + for ac_dir in $ac_x_header_dirs; do + if test -r "$ac_dir/X11/Intrinsic.h"; then + ac_x_includes=$ac_dir + break + fi +done +fi +rm -f conftest.err conftest.$ac_ext +fi # $ac_x_includes = no + +if test "$ac_x_libraries" = no; then + # Check for the libraries. + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS=$LIBS + LIBS="-lXt $LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +XtMalloc (0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + LIBS=$ac_save_LIBS +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +LIBS=$ac_save_LIBS +for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` +do + # Don't even attempt the hair of trying to link an X program! + for ac_extension in a so sl; do + if test -r $ac_dir/libXt.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi # $ac_x_libraries = no + +if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$as_me:$LINENO: result: $have_x" >&5 +echo "${ECHO_T}$have_x" >&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 +echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6 +fi + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + +for ac_header in malloc.h strings.h unistd.h arpa/inet.h netinet/in.h zutil.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_const=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6 +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_inline=$ac_kw; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6 + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_size_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm *tp; tp->tm_sec; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_struct_tm=sys/time.h +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6 +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for socklen_t" >&5 +echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +socklen_t x; + +int +main () +{ + + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +int accept (int, struct sockaddr *, size_t *); + +int +main () +{ + + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +echo "$as_me:$LINENO: result: size_t" >&5 +echo "${ECHO_T}size_t" >&6 +cat >>confdefs.h <<\_ACEOF +#define socklen_t size_t +_ACEOF + + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +echo "$as_me:$LINENO: result: int" >&5 +echo "${ECHO_T}int" >&6 +cat >>confdefs.h <<\_ACEOF +#define socklen_t int +_ACEOF + + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + + +VBA_LIBS="../gb/libgb.a" + +if test "x$enable_c_core" = xyes; then + CXXFLAGS="$CXXFLAGS -DC_CORE" +fi + +if test "x$enable_profiling" = xyes; then + CXXFLAGS="$CXXFLAGS -DPROFILING" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA prof" + VBA_LIBS="$VBA_LIBS ../prof/libprof.a" +fi + +if test "x$with_mmx" = xyes; then + if test "x$NASM" = x; then + { { echo "$as_me:$LINENO: error: *** Couldn't find nasm program." >&5 +echo "$as_me: error: *** Couldn't find nasm program." >&2;} + { (exit 1); exit 1; }; } + fi + CXXFLAGS="$CXXFLAGS -DMMX" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA i386" + VBA_LIBS="$VBA_LIBS ../i386/lib386.a" +fi + +if test "x$enable_sdl" = xyes || test "x$enable_gtk" = xyes; then + SDL_VERSION=1.2.2 + +# Check whether --with-sdl-prefix or --without-sdl-prefix was given. +if test "${with_sdl_prefix+set}" = set; then + withval="$with_sdl_prefix" + sdl_prefix="$withval" +else + sdl_prefix="" +fi; + +# Check whether --with-sdl-exec-prefix or --without-sdl-exec-prefix was given. +if test "${with_sdl_exec_prefix+set}" = set; then + withval="$with_sdl_exec_prefix" + sdl_exec_prefix="$withval" +else + sdl_exec_prefix="" +fi; +# Check whether --enable-sdltest or --disable-sdltest was given. +if test "${enable_sdltest+set}" = set; then + enableval="$enable_sdltest" + +else + enable_sdltest=yes +fi; + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + + # Extract the first word of "sdl-config", so it can be a program name with args. +set dummy sdl-config; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_SDL_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $SDL_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" + ;; +esac +fi +SDL_CONFIG=$ac_cv_path_SDL_CONFIG + +if test -n "$SDL_CONFIG"; then + echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5 +echo "${ECHO_T}$SDL_CONFIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + min_sdl_version=$SDL_VERSION + echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5 +echo $ECHO_N "checking for SDL - version >= $min_sdl_version... $ECHO_C" >&6 + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + rm -f conf.sdltest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +no_sdl=yes +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + + + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main + +int +main () +{ + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + + { { echo "$as_me:$LINENO: error: *** Couldn't find SDL library (version >= $SDL_VERSION)." >&5 +echo "$as_me: error: *** Couldn't find SDL library (version >= $SDL_VERSION)." >&2;} + { (exit 1); exit 1; }; } + + fi + + + rm -f conf.sdltest + +fi + +if test "x$enable_sdl" = xyes; then + VBA_SRC_EXTRA="$VBA_SRC_EXTRA sdl" +fi + +if test "x$enable_gtk" = xyes; then + ALL_LINGUAS="fr" + + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + case "$ac_aux_dir" in + /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; + *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; + esac + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + + + + echo "$as_me:$LINENO: checking whether NLS is requested" >&5 +echo $ECHO_N "checking whether NLS is requested... $ECHO_C" >&6 + # Check whether --enable-nls or --disable-nls was given. +if test "${enable_nls+set}" = set; then + enableval="$enable_nls" + USE_NLS=$enableval +else + USE_NLS=yes +fi; + echo "$as_me:$LINENO: result: $USE_NLS" >&5 +echo "${ECHO_T}$USE_NLS" >&6 + + + + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_MSGFMT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case "$MSGFMT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test "$MSGFMT" != ":"; then + echo "$as_me:$LINENO: result: $MSGFMT" >&5 +echo "${ECHO_T}$MSGFMT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GMSGFMT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GMSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT=$ac_cv_path_GMSGFMT + +if test -n "$GMSGFMT"; then + echo "$as_me:$LINENO: result: $GMSGFMT" >&5 +echo "${ECHO_T}$GMSGFMT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_XGETTEXT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case "$XGETTEXT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test "$XGETTEXT" != ":"; then + echo "$as_me:$LINENO: result: $XGETTEXT" >&5 +echo "${ECHO_T}$XGETTEXT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + rm -f messages.po + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgmerge", so it can be a program name with args. +set dummy msgmerge; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_MSGMERGE+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case "$MSGMERGE" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1; then + ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" + ;; +esac +fi +MSGMERGE="$ac_cv_path_MSGMERGE" +if test "$MSGMERGE" != ":"; then + echo "$as_me:$LINENO: result: $MSGMERGE" >&5 +echo "${ECHO_T}$MSGMERGE" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + + if test "$GMSGFMT" != ":"; then + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && + (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` + echo "$as_me:$LINENO: result: found $GMSGFMT program is not GNU msgfmt; ignore it" >&5 +echo "${ECHO_T}found $GMSGFMT program is not GNU msgfmt; ignore it" >&6 + GMSGFMT=":" + fi + fi + + if test "$XGETTEXT" != ":"; then + if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + echo "$as_me:$LINENO: result: found xgettext program is not GNU xgettext; ignore it" >&5 +echo "${ECHO_T}found xgettext program is not GNU xgettext; ignore it" >&6 + XGETTEXT=":" + fi + rm -f messages.po + fi + + ac_config_commands="$ac_config_commands default-1" + + + + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by GCC" >&5 +echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${acl_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${acl_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6 +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + echo "$as_me:$LINENO: checking for shared library run path origin" >&5 +echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6 +if test "${acl_cv_rpath+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5 +echo "${ECHO_T}$acl_cv_rpath" >&6 + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath or --disable-rpath was given. +if test "${enable_rpath+set}" = set; then + enableval="$enable_rpath" + : +else + enable_rpath=yes +fi; + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given. +if test "${with_libiconv_prefix+set}" = set; then + withval="$with_libiconv_prefix" + + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi + +fi; + LIBICONV= + LTLIBICONV= + INCICONV= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='iconv ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$hardcode_direct" = yes; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" + ;; + esac + done + fi + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" + done + fi + + + + + + + + + + + + + + + + + + + echo "$as_me:$LINENO: checking whether NLS is requested" >&5 +echo $ECHO_N "checking whether NLS is requested... $ECHO_C" >&6 + # Check whether --enable-nls or --disable-nls was given. +if test "${enable_nls+set}" = set; then + enableval="$enable_nls" + USE_NLS=$enableval +else + USE_NLS=yes +fi; + echo "$as_me:$LINENO: result: $USE_NLS" >&5 +echo "${ECHO_T}$USE_NLS" >&6 + + + + + LIBINTL= + LTLIBINTL= + POSUB= + + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + + + + + + + echo "$as_me:$LINENO: checking for GNU gettext in libc" >&5 +echo $ECHO_N "checking for GNU gettext in libc... $ECHO_C" >&6 +if test "${gt_cv_func_gnugettext1_libc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings; +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_domain_bindings + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + gt_cv_func_gnugettext1_libc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gt_cv_func_gnugettext1_libc=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $gt_cv_func_gnugettext1_libc" >&5 +echo "${ECHO_T}$gt_cv_func_gnugettext1_libc" >&6 + + if test "$gt_cv_func_gnugettext1_libc" != "yes"; then + + + + + + am_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + echo "$as_me:$LINENO: checking for iconv" >&5 +echo $ECHO_N "checking for iconv... $ECHO_C" >&6 +if test "${am_cv_func_iconv+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + am_cv_func_iconv=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$am_save_LIBS" + fi + +fi +echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5 +echo "${ECHO_T}$am_cv_func_iconv" >&6 + if test "$am_cv_func_iconv" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ICONV 1 +_ACEOF + + fi + if test "$am_cv_lib_iconv" = yes; then + echo "$as_me:$LINENO: checking how to link with libiconv" >&5 +echo $ECHO_N "checking how to link with libiconv... $ECHO_C" >&6 + echo "$as_me:$LINENO: result: $LIBICONV" >&5 +echo "${ECHO_T}$LIBICONV" >&6 + else + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libintl-prefix or --without-libintl-prefix was given. +if test "${with_libintl_prefix+set}" = set; then + withval="$with_libintl_prefix" + + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi + +fi; + LIBINTL= + LTLIBINTL= + INCINTL= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='intl ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$hardcode_direct" = yes; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" + ;; + esac + done + fi + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" + done + fi + + echo "$as_me:$LINENO: checking for GNU gettext in libintl" >&5 +echo $ECHO_N "checking for GNU gettext in libintl... $ECHO_C" >&6 +if test "${gt_cv_func_gnugettext1_libintl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (); +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias (0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + gt_cv_func_gnugettext1_libintl=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gt_cv_func_gnugettext1_libintl=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$gt_cv_func_gnugettext1_libintl" != yes && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (); +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + _nl_msg_cat_cntr + *_nl_expand_alias (0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + gt_cv_func_gnugettext1_libintl=yes + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS" +fi +echo "$as_me:$LINENO: result: $gt_cv_func_gnugettext1_libintl" >&5 +echo "${ECHO_T}$gt_cv_func_gnugettext1_libintl" >&6 + fi + + if test "$gt_cv_func_gnugettext1_libc" = "yes" \ + || { test "$gt_cv_func_gnugettext1_libintl" = "yes" \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_NLS 1 +_ACEOF + + else + USE_NLS=no + fi + fi + + echo "$as_me:$LINENO: checking whether to use NLS" >&5 +echo $ECHO_N "checking whether to use NLS... $ECHO_C" >&6 + echo "$as_me:$LINENO: result: $USE_NLS" >&5 +echo "${ECHO_T}$USE_NLS" >&6 + if test "$USE_NLS" = "yes"; then + echo "$as_me:$LINENO: checking where the gettext function comes from" >&5 +echo $ECHO_N "checking where the gettext function comes from... $ECHO_C" >&6 + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext1_libintl" = "yes"; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + echo "$as_me:$LINENO: result: $gt_source" >&5 +echo "${ECHO_T}$gt_source" >&6 + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext1_libintl" = "yes"; then + echo "$as_me:$LINENO: checking how to link with libintl" >&5 +echo $ECHO_N "checking how to link with libintl... $ECHO_C" >&6 + echo "$as_me:$LINENO: result: $LIBINTL" >&5 +echo "${ECHO_T}$LIBINTL" >&6 + + for element in $INCINTL; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + fi + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GETTEXT 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DCGETTEXT 1 +_ACEOF + + fi + + POSUB=po + fi + + + + INTLLIBS="$LIBINTL" + + + + + + + +for ac_header in libintl.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + GETTEXT_PACKAGE=vba-1.7.2 + + + + succeeded=no + + if test -z "$PKG_CONFIG"; then + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG + +if test -n "$PKG_CONFIG"; then + echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +echo "${ECHO_T}$PKG_CONFIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + fi + + if test "$PKG_CONFIG" = "no" ; then + echo "*** The pkg-config script could not be found. Make sure it is" + echo "*** in your path, or set the PKG_CONFIG environment variable" + echo "*** to the full path to pkg-config." + echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." + else + PKG_CONFIG_MIN_VERSION=0.9.0 + if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then + echo "$as_me:$LINENO: checking for gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0" >&5 +echo $ECHO_N "checking for gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0... $ECHO_C" >&6 + + if $PKG_CONFIG --exists "gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0" ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + succeeded=yes + + echo "$as_me:$LINENO: checking GTKMM_CFLAGS" >&5 +echo $ECHO_N "checking GTKMM_CFLAGS... $ECHO_C" >&6 + GTKMM_CFLAGS=`$PKG_CONFIG --cflags "gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0"` + echo "$as_me:$LINENO: result: $GTKMM_CFLAGS" >&5 +echo "${ECHO_T}$GTKMM_CFLAGS" >&6 + + echo "$as_me:$LINENO: checking GTKMM_LIBS" >&5 +echo $ECHO_N "checking GTKMM_LIBS... $ECHO_C" >&6 + GTKMM_LIBS=`$PKG_CONFIG --libs "gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0"` + echo "$as_me:$LINENO: result: $GTKMM_LIBS" >&5 +echo "${ECHO_T}$GTKMM_LIBS" >&6 + else + GTKMM_CFLAGS="" + GTKMM_LIBS="" + ## If we have a custom action on failure, don't print errors, but + ## do set a variable so people can do so. + GTKMM_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0"` + echo $GTKMM_PKG_ERRORS + fi + + + + else + echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." + echo "*** See http://www.freedesktop.org/software/pkgconfig" + fi + fi + + if test $succeeded = yes; then + : + else + { { echo "$as_me:$LINENO: error: Library requirements (gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5 +echo "$as_me: error: Library requirements (gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;} + { (exit 1); exit 1; }; } + fi + + + + if test "x$gtk_version" = x2.0; then + GTKMM_CPPFLAGS="-DGTKMM20" + fi + + VBA_EXTRA="$VBA_EXTRA po" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA gtk" +fi + +if test "x$enable_dev" = xyes; then + CXXFLAGS="$CXXFLAGS -DDEV_VERSION" +fi + +if test "x$enable_sdl" != xyes && test "x$enable_gtk" != xyes; then + { echo "$as_me:$LINENO: WARNING: *** You have chosen not to build any frontend." >&5 +echo "$as_me: WARNING: *** You have chosen not to build any frontend." >&2;} +fi + + + + + + ac_config_files="$ac_config_files Makefile m4/Makefile po/Makefile.in src/Makefile src/gb/Makefile src/gtk/Makefile src/gtk/images/Makefile src/i386/Makefile src/prof/Makefile src/sdl/Makefile win32/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "m4/Makefile" ) CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; + "po/Makefile.in" ) CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; + "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/gb/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gb/Makefile" ;; + "src/gtk/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gtk/Makefile" ;; + "src/gtk/images/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gtk/images/Makefile" ;; + "src/i386/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/i386/Makefile" ;; + "src/prof/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/prof/Makefile" ;; + "src/sdl/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/sdl/Makefile" ;; + "win32/Makefile" ) CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@target@,$target,;t t +s,@target_cpu@,$target_cpu,;t t +s,@target_vendor@,$target_vendor,;t t +s,@target_os@,$target_os,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@AMTAR@,$AMTAR,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@YACC@,$YACC,;t t +s,@LEX@,$LEX,;t t +s,@LEXLIB@,$LEXLIB,;t t +s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t +s,@CXXDEPMODE@,$CXXDEPMODE,;t t +s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t +s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@NASM@,$NASM,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@SDL_CONFIG@,$SDL_CONFIG,;t t +s,@SDL_CFLAGS@,$SDL_CFLAGS,;t t +s,@SDL_LIBS@,$SDL_LIBS,;t t +s,@MKINSTALLDIRS@,$MKINSTALLDIRS,;t t +s,@USE_NLS@,$USE_NLS,;t t +s,@MSGFMT@,$MSGFMT,;t t +s,@GMSGFMT@,$GMSGFMT,;t t +s,@XGETTEXT@,$XGETTEXT,;t t +s,@MSGMERGE@,$MSGMERGE,;t t +s,@LIBICONV@,$LIBICONV,;t t +s,@LTLIBICONV@,$LTLIBICONV,;t t +s,@INTLLIBS@,$INTLLIBS,;t t +s,@LIBINTL@,$LIBINTL,;t t +s,@LTLIBINTL@,$LTLIBINTL,;t t +s,@POSUB@,$POSUB,;t t +s,@GETTEXT_PACKAGE@,$GETTEXT_PACKAGE,;t t +s,@PKG_CONFIG@,$PKG_CONFIG,;t t +s,@GTKMM_CFLAGS@,$GTKMM_CFLAGS,;t t +s,@GTKMM_LIBS@,$GTKMM_LIBS,;t t +s,@GTKMM_CPPFLAGS@,$GTKMM_CPPFLAGS,;t t +s,@VBA_EXTRA@,$VBA_EXTRA,;t t +s,@VBA_SRC_EXTRA@,$VBA_SRC_EXTRA,;t t +s,@VBA_LIBS@,$VBA_LIBS,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + default-1 ) + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..07ea25e --- /dev/null +++ b/configure.in @@ -0,0 +1,181 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(src/armdis.h) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +case "$target" in + i?86-*-*) + VBA_USE_C_CORE=no + VBA_USE_MMX=yes + ;; + *) + VBA_USE_C_CORE=yes + VBA_USE_MMX=no + ;; +esac + +AM_INIT_AUTOMAKE(VisualBoyAdvance, 1.7.2) + +AC_ARG_ENABLE(c-core, + AC_HELP_STRING([--enable-c-core],[enable C core (default is no on x86 targets)]), + , enable_c_core=$VBA_USE_C_CORE) + +AC_ARG_ENABLE(profiling, + AC_HELP_STRING([--enable-profiling],[enable profiling (default is yes)]), + , enable_profiling=yes) + +AC_ARG_WITH(mmx, + AC_HELP_STRING([--with-mmx],[use MMX (default is yes on x86 targets)]), + , with_mmx=$VBA_USE_MMX) + +AC_ARG_ENABLE(sdl, + AC_HELP_STRING([--enable-sdl],[build the SDL interface (default is yes)]), + , enable_sdl=yes) + +AC_ARG_ENABLE(gtk, +[ --enable-gtk=[[VERSION]] build the GTK+ interface (default is no)],[ +if test "x$enable_gtk" != xno; then + enable_gtk=yes + if test "x$enableval" = xyes; then + gtk_version=2.0 + else + gtk_version=$enableval + fi +fi +],[ +enable_gtk=no +]) + +AC_ARG_ENABLE(dev, + AC_HELP_STRING([--enable-dev],[enable development features (default is yes)]), + , enable_dev=yes) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_YACC +AM_PROG_LEX +AC_PROG_CXX +AC_PROG_RANLIB +AC_PATH_PROG(NASM, nasm) + +dnl Checks for libraries. +AC_CHECK_LIB(z, gzopen, + , AC_MSG_ERROR([*** Cannot compile without zlib.])) +AC_CHECK_LIB(png, png_create_write_struct, + , AC_MSG_ERROR([*** Cannot compile without libpng.]), [-lz]) +AC_CHECK_LIB(pthread, pthread_yield) + +dnl Checks for header files. +AC_PATH_X +AC_HEADER_STDC +AC_CHECK_HEADERS(malloc.h strings.h unistd.h arpa/inet.h netinet/in.h zutil.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_STRUCT_TM +AC_MSG_CHECKING(for socklen_t) +AC_TRY_COMPILE([ +#include +socklen_t x; +],[ +],[ +AC_MSG_RESULT(yes) +],[ +AC_TRY_COMPILE([ +#include +int accept (int, struct sockaddr *, size_t *); +],[ +],[ +AC_MSG_RESULT(size_t) +AC_DEFINE(socklen_t,size_t) +],[ +AC_MSG_RESULT(int) +AC_DEFINE(socklen_t,int) +]) +]) + +AC_C_BIGENDIAN + +VBA_LIBS="../gb/libgb.a" + +if test "x$enable_c_core" = xyes; then + CXXFLAGS="$CXXFLAGS -DC_CORE" +fi + +if test "x$enable_profiling" = xyes; then + CXXFLAGS="$CXXFLAGS -DPROFILING" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA prof" + VBA_LIBS="$VBA_LIBS ../prof/libprof.a" +fi + +if test "x$with_mmx" = xyes; then + if test "x$NASM" = x; then + AC_MSG_ERROR([*** Couldn't find nasm program.]) + fi + CXXFLAGS="$CXXFLAGS -DMMX" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA i386" + VBA_LIBS="$VBA_LIBS ../i386/lib386.a" +fi + +if test "x$enable_sdl" = xyes || test "x$enable_gtk" = xyes; then + SDL_VERSION=1.2.2 + AM_PATH_SDL($SDL_VERSION,[ + ],[ + AC_MSG_ERROR([*** Couldn't find SDL library (version >= $SDL_VERSION).]) + ]) +fi + +if test "x$enable_sdl" = xyes; then + VBA_SRC_EXTRA="$VBA_SRC_EXTRA sdl" +fi + +if test "x$enable_gtk" = xyes; then + dnl Internationalisation support. + ALL_LINGUAS="fr" + AM_GNU_GETTEXT(external) + AC_CHECK_HEADERS(libintl.h) + GETTEXT_PACKAGE=vba-1.7.2 + AC_SUBST(GETTEXT_PACKAGE) + + PKG_CHECK_MODULES(GTKMM, gtkmm-$gtk_version >= 2.0.0 libglademm-$gtk_version >= 2.1.0) + AC_SUBST(GTKMM_CFLAGS) + AC_SUBST(GTKMM_LIBS) + if test "x$gtk_version" = x2.0; then + GTKMM_CPPFLAGS="-DGTKMM20" + fi + AC_SUBST(GTKMM_CPPFLAGS) + VBA_EXTRA="$VBA_EXTRA po" + VBA_SRC_EXTRA="$VBA_SRC_EXTRA gtk" +fi + +if test "x$enable_dev" = xyes; then + CXXFLAGS="$CXXFLAGS -DDEV_VERSION" +fi + +if test "x$enable_sdl" != xyes && test "x$enable_gtk" != xyes; then + AC_MSG_WARN([*** You have chosen not to build any frontend.]) +fi + +AC_SUBST(VBA_EXTRA) +AC_SUBST(VBA_SRC_EXTRA) +AC_SUBST(VBA_LIBS) + +dnl Generated files. +AC_CONFIG_FILES([ +Makefile +m4/Makefile +po/Makefile.in +src/Makefile +src/gb/Makefile +src/gtk/Makefile +src/gtk/images/Makefile +src/i386/Makefile +src/prof/Makefile +src/sdl/Makefile +win32/Makefile +]) +AC_OUTPUT diff --git a/depcomp b/depcomp new file mode 100644 index 0000000..edb5d38 --- /dev/null +++ b/depcomp @@ -0,0 +1,479 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000, 2003 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +if test -z "$depfile"; then + base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` + dir=`echo "$object" | sed 's,/.*$,/,'` + if test "$dir" = "$object"; then + dir= + fi + # FIXME: should be _deps on DOS. + depfile="$dir.deps/$base" +fi + +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + tmpdepfile1="$dir.libs/$base.lo.d" + tmpdepfile2="$dir.libs/$base.d" + "$@" -Wc,-MD + else + tmpdepfile1="$dir$base.o.d" + tmpdepfile2="$dir$base.d" + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 diff --git a/install-sh b/install-sh new file mode 100644 index 0000000..398a88e --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + : +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=$mkdirprog + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + : + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + : + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + : + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' + ' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + : + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + : + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/m4/ChangeLog b/m4/ChangeLog new file mode 100644 index 0000000..bea0f7a --- /dev/null +++ b/m4/ChangeLog @@ -0,0 +1,32 @@ +2004-03-29 gettextize + + * codeset.m4: New file, from gettext-0.14.1. + * gettext.m4: New file, from gettext-0.14.1. + * glibc21.m4: New file, from gettext-0.14.1. + * iconv.m4: New file, from gettext-0.14.1. + * intdiv0.m4: New file, from gettext-0.14.1. + * intmax.m4: New file, from gettext-0.14.1. + * inttypes.m4: New file, from gettext-0.14.1. + * inttypes_h.m4: New file, from gettext-0.14.1. + * inttypes-pri.m4: New file, from gettext-0.14.1. + * isc-posix.m4: New file, from gettext-0.14.1. + * lcmessage.m4: New file, from gettext-0.14.1. + * lib-ld.m4: New file, from gettext-0.14.1. + * lib-link.m4: New file, from gettext-0.14.1. + * lib-prefix.m4: New file, from gettext-0.14.1. + * longdouble.m4: New file, from gettext-0.14.1. + * longlong.m4: New file, from gettext-0.14.1. + * nls.m4: New file, from gettext-0.14.1. + * po.m4: New file, from gettext-0.14.1. + * printf-posix.m4: New file, from gettext-0.14.1. + * progtest.m4: New file, from gettext-0.14.1. + * signed.m4: New file, from gettext-0.14.1. + * size_max.m4: New file, from gettext-0.14.1. + * stdint_h.m4: New file, from gettext-0.14.1. + * uintmax_t.m4: New file, from gettext-0.14.1. + * ulonglong.m4: New file, from gettext-0.14.1. + * wchar_t.m4: New file, from gettext-0.14.1. + * wint_t.m4: New file, from gettext-0.14.1. + * xsize.m4: New file, from gettext-0.14.1. + * Makefile.am: New file. + diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..797d0cf --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,29 @@ +EXTRA_DIST = \ + codeset.m4 \ + gettext.m4 \ + glibc21.m4 \ + iconv.m4 \ + intdiv0.m4 \ + intmax.m4 \ + inttypes_h.m4 \ + inttypes.m4 \ + inttypes-pri.m4 \ + isc-posix.m4 \ + lcmessage.m4 \ + lib-ld.m4 \ + lib-link.m4 \ + lib-prefix.m4 \ + longdouble.m4 \ + longlong.m4 \ + nls.m4 \ + po.m4 \ + printf-posix.m4 \ + progtest.m4 \ + signed.m4 \ + size_max.m4 \ + stdint_h.m4 \ + uintmax_t.m4 \ + ulonglong.m4 \ + wchar_t.m4 \ + wint_t.m4 \ + xsize.m4 diff --git a/m4/Makefile.in b/m4/Makefile.in new file mode 100644 index 0000000..631db0e --- /dev/null +++ b/m4/Makefile.in @@ -0,0 +1,322 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +EXTRA_DIST = \ + codeset.m4 \ + gettext.m4 \ + glibc21.m4 \ + iconv.m4 \ + intdiv0.m4 \ + intmax.m4 \ + inttypes_h.m4 \ + inttypes.m4 \ + inttypes-pri.m4 \ + isc-posix.m4 \ + lcmessage.m4 \ + lib-ld.m4 \ + lib-link.m4 \ + lib-prefix.m4 \ + longdouble.m4 \ + longlong.m4 \ + nls.m4 \ + po.m4 \ + printf-posix.m4 \ + progtest.m4 \ + signed.m4 \ + size_max.m4 \ + stdint_h.m4 \ + uintmax_t.m4 \ + ulonglong.m4 \ + wchar_t.m4 \ + wint_t.m4 \ + xsize.m4 + +subdir = m4 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = $(srcdir)/Makefile.in ChangeLog Makefile.am +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu m4/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/m4/codeset.m4 b/m4/codeset.m4 new file mode 100644 index 0000000..59535eb --- /dev/null +++ b/m4/codeset.m4 @@ -0,0 +1,23 @@ +# codeset.m4 serial AM1 (gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, + [AC_TRY_LINK([#include ], + [char* cs = nl_langinfo(CODESET);], + am_cv_langinfo_codeset=yes, + am_cv_langinfo_codeset=no) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET, 1, + [Define if you have and nl_langinfo(CODESET).]) + fi +]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 new file mode 100644 index 0000000..a374f03 --- /dev/null +++ b/m4/gettext.m4 @@ -0,0 +1,487 @@ +# gettext.m4 serial 28 (gettext-0.13) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value `$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define(gt_included_intl, ifelse([$1], [external], [no], [yes])) + define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], [])) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Set USE_NLS. + AM_NLS + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH(included-gettext, + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + dnl Add a version number to the cache macros. + define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1))) + define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc]) + define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl]) + + AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc, + [AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings], + gt_cv_func_gnugettext_libc=yes, + gt_cv_func_gnugettext_libc=no)]) + + if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + gt_cv_func_gnugettext_libintl, + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + gt_cv_func_gnugettext_libintl=yes, + gt_cv_func_gnugettext_libintl=no) + dnl Now see whether libintl exists and depends on libiconv. + if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + gt_cv_func_gnugettext_libintl=yes + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if test "$gt_cv_func_gnugettext_libc" = "yes" \ + || { test "$gt_cv_func_gnugettext_libintl" = "yes" \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE(ENABLE_NLS, 1, + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE(HAVE_GETTEXT, 1, + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE(HAVE_DCGETTEXT, 1, + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST(BUILD_INCLUDED_LIBINTL) + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATOBJEXT) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST(DATADIRNAME) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST(INSTOBJEXT) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST(GENCAT) + + dnl For backward compatibility. Some Makefiles may be using this. + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST(INTLOBJS) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST(INTLLIBS) + + dnl Make all documented variables known to autoconf. + AC_SUBST(LIBINTL) + AC_SUBST(LTLIBINTL) + AC_SUBST(POSUB) +]) + + +dnl Checks for all prerequisites of the intl subdirectory, +dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, +dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. +AC_DEFUN([AM_INTL_SUBDIR], +[ + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([AC_ISC_POSIX])dnl + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_C_CONST])dnl + AC_REQUIRE([bh_C_SIGNED])dnl + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_OFF_T])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([jm_AC_TYPE_LONG_LONG])dnl + AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl + AC_REQUIRE([gt_TYPE_WCHAR_T])dnl + AC_REQUIRE([gt_TYPE_WINT_T])dnl + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + AC_REQUIRE([gt_TYPE_INTMAX_T]) + AC_REQUIRE([gt_PRINTF_POSIX]) + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + AC_REQUIRE([jm_GLIBC21])dnl + AC_REQUIRE([gt_INTDIV0])dnl + AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl + AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl + AC_REQUIRE([gt_INTTYPES_PRI])dnl + AC_REQUIRE([gl_XSIZE])dnl + + AC_CHECK_TYPE([ptrdiff_t], , + [AC_DEFINE([ptrdiff_t], [long], + [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) + ]) + AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ +stdlib.h string.h unistd.h sys/param.h]) + AC_CHECK_FUNCS([asprintf fwprintf getcwd getegid geteuid getgid getuid \ +mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \ +strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \ +__fsetlocking]) + + dnl Use the _snprintf function only if it is declared (because on NetBSD it + dnl is defined as a weak alias of snprintf; we prefer to use the latter). + gt_CHECK_DECL(_snprintf, [#include ]) + gt_CHECK_DECL(_snwprintf, [#include ]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL(feof_unlocked, [#include ]) + gt_CHECK_DECL(fgets_unlocked, [#include ]) + gt_CHECK_DECL(getc_unlocked, [#include ]) + + case $gt_cv_func_printf_posix in + *yes) HAVE_POSIX_PRINTF=1 ;; + *) HAVE_POSIX_PRINTF=0 ;; + esac + AC_SUBST([HAVE_POSIX_PRINTF]) + if test "$ac_cv_func_asprintf" = yes; then + HAVE_ASPRINTF=1 + else + HAVE_ASPRINTF=0 + fi + AC_SUBST([HAVE_ASPRINTF]) + if test "$ac_cv_func_snprintf" = yes; then + HAVE_SNPRINTF=1 + else + HAVE_SNPRINTF=0 + fi + AC_SUBST([HAVE_SNPRINTF]) + if test "$ac_cv_func_wprintf" = yes; then + HAVE_WPRINTF=1 + else + HAVE_WPRINTF=0 + fi + AC_SUBST([HAVE_WPRINTF]) + + AM_ICONV + AM_LANGINFO_CODESET + if test $ac_cv_header_locale_h = yes; then + AM_LC_MESSAGES + fi + + dnl intl/plural.c is generated from intl/plural.y. It requires bison, + dnl because plural.y uses bison specific features. It requires at least + dnl bison-1.26 because earlier versions generate a plural.c that doesn't + dnl compile. + dnl bison is only needed for the maintainer (who touches plural.y). But in + dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put + dnl the rule in general Makefile. Now, some people carelessly touch the + dnl files or have a broken "make" program, hence the plural.c rule will + dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not + dnl present or too old. + AC_CHECK_PROGS([INTLBISON], [bison]) + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + dnl Found it, now check the version. + AC_MSG_CHECKING([version of bison]) +changequote(<<,>>)dnl + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) +changequote([,])dnl + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + AC_MSG_RESULT([$ac_prog_version]) + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi +]) + + +dnl gt_CHECK_DECL(FUNC, INCLUDES) +dnl Check whether a function is declared. +AC_DEFUN([gt_CHECK_DECL], +[ + AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, + [AC_TRY_COMPILE([$2], [ +#ifndef $1 + char *p = (char *) $1; +#endif +], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) + if test $ac_cv_have_decl_$1 = yes; then + gt_value=1 + else + gt_value=0 + fi + AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], + [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 new file mode 100644 index 0000000..9c9f3db --- /dev/null +++ b/m4/glibc21.m4 @@ -0,0 +1,32 @@ +# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([jm_GLIBC21], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, + ac_cv_gnu_library_2_1, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2_1=yes, + ac_cv_gnu_library_2_1=no) + ] + ) + AC_SUBST(GLIBC21) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) diff --git a/m4/iconv.m4 b/m4/iconv.m4 new file mode 100644 index 0000000..c5f3579 --- /dev/null +++ b/m4/iconv.m4 @@ -0,0 +1,103 @@ +# iconv.m4 serial AM4 (gettext-0.11.3) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_func_iconv=yes) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_lib_iconv=yes + am_cv_func_iconv=yes) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST(LIBICONV) + AC_SUBST(LTLIBICONV) +]) + +AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL(am_cv_proto_iconv, [ + AC_TRY_COMPILE([ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([$]{ac_t:- + }[$]am_cv_proto_iconv) + AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, + [Define as const if the declaration of iconv() needs const.]) + fi +]) diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 new file mode 100644 index 0000000..55dddcf --- /dev/null +++ b/m4/intdiv0.m4 @@ -0,0 +1,72 @@ +# intdiv0.m4 serial 1 (gettext-0.11.3) +dnl Copyright (C) 2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([gt_INTDIV0], +[ + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + + AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], + gt_cv_int_divbyzero_sigfpe, + [ + AC_TRY_RUN([ +#include +#include + +static void +#ifdef __cplusplus +sigfpe_handler (int sig) +#else +sigfpe_handler (sig) int sig; +#endif +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} +], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, + [ + # Guess based on the CPU. + case "$host_cpu" in + alpha* | i[34567]86 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac + ]) + ]) + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, + [Define if integer division by zero raises signal SIGFPE.]) +]) diff --git a/m4/intmax.m4 b/m4/intmax.m4 new file mode 100644 index 0000000..dfb08cc --- /dev/null +++ b/m4/intmax.m4 @@ -0,0 +1,32 @@ +# intmax.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether the system has the 'intmax_t' type, but don't attempt to +dnl find a replacement if it is lacking. + +AC_DEFUN([gt_TYPE_INTMAX_T], +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, + [AC_TRY_COMPILE([ +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +#include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +#include +#endif +], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) + if test $gt_cv_c_intmax_t = yes; then + AC_DEFINE(HAVE_INTMAX_T, 1, + [Define if you have the 'intmax_t' type in or .]) + fi +]) diff --git a/m4/inttypes-pri.m4 b/m4/inttypes-pri.m4 new file mode 100644 index 0000000..fd007c3 --- /dev/null +++ b/m4/inttypes-pri.m4 @@ -0,0 +1,32 @@ +# inttypes-pri.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +# Define PRI_MACROS_BROKEN if exists and defines the PRI* +# macros to non-string values. This is the case on AIX 4.3.3. + +AC_DEFUN([gt_INTTYPES_PRI], +[ + AC_REQUIRE([gt_HEADER_INTTYPES_H]) + if test $gt_cv_header_inttypes_h = yes; then + AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], + gt_cv_inttypes_pri_broken, + [ + AC_TRY_COMPILE([#include +#ifdef PRId32 +char *p = PRId32; +#endif +], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) + ]) + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, + [Define if exists and defines unusable PRI* macros.]) + fi +]) diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 new file mode 100644 index 0000000..ab370ff --- /dev/null +++ b/m4/inttypes.m4 @@ -0,0 +1,27 @@ +# inttypes.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists and doesn't clash with +# . + +AC_DEFUN([gt_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, + [ + AC_TRY_COMPILE( + [#include +#include ], + [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) + ]) + if test $gt_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, + [Define if exists and doesn't clash with .]) + fi +]) diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 new file mode 100644 index 0000000..f342eba --- /dev/null +++ b/m4/inttypes_h.m4 @@ -0,0 +1,28 @@ +# inttypes_h.m4 serial 5 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_inttypes_h=yes, + jm_ac_cv_header_inttypes_h=no)]) + if test $jm_ac_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/m4/isc-posix.m4 b/m4/isc-posix.m4 new file mode 100644 index 0000000..1319dd1 --- /dev/null +++ b/m4/isc-posix.m4 @@ -0,0 +1,26 @@ +# isc-posix.m4 serial 2 (gettext-0.11.2) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. + +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) diff --git a/m4/lcmessage.m4 b/m4/lcmessage.m4 new file mode 100644 index 0000000..ffd4008 --- /dev/null +++ b/m4/lcmessage.m4 @@ -0,0 +1,32 @@ +# lcmessage.m4 serial 3 (gettext-0.11.3) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995. + +# Check whether LC_MESSAGES is available in . + +AC_DEFUN([AM_LC_MESSAGES], +[ + AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, + [AC_TRY_LINK([#include ], [return LC_MESSAGES], + am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + if test $am_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES, 1, + [Define if your file defines LC_MESSAGES.]) + fi +]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 new file mode 100644 index 0000000..38aeaec --- /dev/null +++ b/m4/lib-ld.m4 @@ -0,0 +1,112 @@ +# lib-ld.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(acl_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 new file mode 100644 index 0000000..eeb200d --- /dev/null +++ b/m4/lib-link.m4 @@ -0,0 +1,551 @@ +# lib-link.m4 serial 4 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 new file mode 100644 index 0000000..8aff5a9 --- /dev/null +++ b/m4/lib-prefix.m4 @@ -0,0 +1,155 @@ +# lib-prefix.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) diff --git a/m4/longdouble.m4 b/m4/longdouble.m4 new file mode 100644 index 0000000..1333d2f --- /dev/null +++ b/m4/longdouble.m4 @@ -0,0 +1,30 @@ +# longdouble.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether the compiler supports the 'long double' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_LONGDOUBLE], +[ + AC_CACHE_CHECK([for long double], gt_cv_c_long_double, + [if test "$GCC" = yes; then + gt_cv_c_long_double=yes + else + AC_TRY_COMPILE([ + /* The Stardent Vistra knows sizeof(long double), but does not support it. */ + long double foo = 0.0; + /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ + int array [2*(sizeof(long double) >= sizeof(double)) - 1]; + ], , + gt_cv_c_long_double=yes, gt_cv_c_long_double=no) + fi]) + if test $gt_cv_c_long_double = yes; then + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.]) + fi +]) diff --git a/m4/longlong.m4 b/m4/longlong.m4 new file mode 100644 index 0000000..d7d7350 --- /dev/null +++ b/m4/longlong.m4 @@ -0,0 +1,25 @@ +# longlong.m4 serial 4 +dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_LONG_LONG if 'long long' works. + +AC_DEFUN([jm_AC_TYPE_LONG_LONG], +[ + AC_CACHE_CHECK([for long long], ac_cv_type_long_long, + [AC_TRY_LINK([long long ll = 1LL; int i = 63;], + [long long llmax = (long long) -1; + return ll << i | ll >> i | llmax / ll | llmax % ll;], + ac_cv_type_long_long=yes, + ac_cv_type_long_long=no)]) + if test $ac_cv_type_long_long = yes; then + AC_DEFINE(HAVE_LONG_LONG, 1, + [Define if you have the 'long long' type.]) + fi +]) diff --git a/m4/nls.m4 b/m4/nls.m4 new file mode 100644 index 0000000..36bc493 --- /dev/null +++ b/m4/nls.m4 @@ -0,0 +1,49 @@ +# nls.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE(nls, + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) +]) + +AC_DEFUN([AM_MKINSTALLDIRS], +[ + dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly + dnl find the mkinstalldirs script in another subdir but $(top_srcdir). + dnl Try to locate it. + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + case "$ac_aux_dir" in + /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; + *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; + esac + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + AC_SUBST(MKINSTALLDIRS) +]) diff --git a/m4/po.m4 b/m4/po.m4 new file mode 100644 index 0000000..e161998 --- /dev/null +++ b/m4/po.m4 @@ -0,0 +1,426 @@ +# po.m4 serial 3 (gettext-0.14) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AM_NLS])dnl + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :) + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU msgfmt. + if test "$GMSGFMT" != ":"; then + dnl If it is no GNU msgfmt we define it as : so that the + dnl Makefiles still can work. + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && + (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` + AC_MSG_RESULT( + [found $GMSGFMT program is not GNU msgfmt; ignore it]) + GMSGFMT=":" + fi + fi + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU xgettext. + if test "$XGETTEXT" != ":"; then + dnl If it is no GNU xgettext we define it as : so that the + dnl Makefiles still can work. + if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + AC_MSG_RESULT( + [found xgettext program is not GNU xgettext; ignore it]) + XGETTEXT=":" + fi + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + fi + + AC_OUTPUT_COMMANDS([ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) + +dnl Postprocesses a Makefile in a directory containing PO files. +AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], +[ + # When this code is run, in config.status, two variables have already been + # set: + # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, + # - LINGUAS is the value of the environment variable LINGUAS at configure + # time. + +changequote(,)dnl + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + # Find a way to echo strings without interpreting backslash. + if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='echo' + else + if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='printf %s\n' + else + echo_func () { + cat < "$ac_file.tmp" + if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + cat >> "$ac_file.tmp" < /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/_/-/g'` + cat >> "$ac_file.tmp" <> "$ac_file.tmp" < +#include +/* The string "%2$d %1$d", with dollar characters protected from the shell's + dollar expansion (possibly an autoconf bug). */ +static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; +static char buf[100]; +int main () +{ + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); +}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, + [ + AC_EGREP_CPP(notposix, [ +#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ + notposix +#endif + ], gt_cv_func_printf_posix="guessing no", + gt_cv_func_printf_posix="guessing yes") + ]) + ]) + case $gt_cv_func_printf_posix in + *yes) + AC_DEFINE(HAVE_POSIX_PRINTF, 1, + [Define if your printf() function supports format strings with positions.]) + ;; + esac +]) diff --git a/m4/progtest.m4 b/m4/progtest.m4 new file mode 100644 index 0000000..8fe527c --- /dev/null +++ b/m4/progtest.m4 @@ -0,0 +1,91 @@ +# progtest.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL(ac_cv_path_$1, +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$]$1) +else + AC_MSG_RESULT(no) +fi +AC_SUBST($1)dnl +]) diff --git a/m4/signed.m4 b/m4/signed.m4 new file mode 100644 index 0000000..dc1f54f --- /dev/null +++ b/m4/signed.m4 @@ -0,0 +1,19 @@ +# signed.m4 serial 1 (gettext-0.10.40) +dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([bh_C_SIGNED], +[ + AC_CACHE_CHECK([for signed], bh_cv_c_signed, + [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)]) + if test $bh_cv_c_signed = no; then + AC_DEFINE(signed, , + [Define to empty if the C compiler doesn't support this keyword.]) + fi +]) diff --git a/m4/size_max.m4 b/m4/size_max.m4 new file mode 100644 index 0000000..5762fc3 --- /dev/null +++ b/m4/size_max.m4 @@ -0,0 +1,61 @@ +# size_max.m4 serial 2 +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SIZE_MAX], +[ + AC_CHECK_HEADERS(stdint.h) + dnl First test whether the system already has SIZE_MAX. + AC_MSG_CHECKING([for SIZE_MAX]) + result= + AC_EGREP_CPP([Found it], [ +#include +#if HAVE_STDINT_H +#include +#endif +#ifdef SIZE_MAX +Found it +#endif +], result=yes) + if test -z "$result"; then + dnl Define it ourselves. Here we assume that the type 'size_t' is not wider + dnl than the type 'unsigned long'. + dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr', + dnl which is guaranteed to work from LONG_MIN to LONG_MAX. + _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi, + [#include ], result=?) + _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo, + [#include ], result=?) + _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, + [#include ], result=?) + if test "$fits_in_uint" = 1; then + dnl Even though SIZE_MAX fits in an unsigned int, it must be of type + dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. + AC_TRY_COMPILE([#include + extern size_t foo; + extern unsigned long foo; + ], [], fits_in_uint=0) + fi + if test -z "$result"; then + if test "$fits_in_uint" = 1; then + result="$res_hi$res_lo"U + else + result="$res_hi$res_lo"UL + fi + else + dnl Shouldn't happen, but who knows... + result='~(size_t)0' + fi + fi + AC_MSG_RESULT([$result]) + if test "$result" != yes; then + AC_DEFINE_UNQUOTED([SIZE_MAX], [$result], + [Define as the maximum value of type 'size_t', if the system doesn't define it.]) + fi +]) diff --git a/m4/stdint_h.m4 b/m4/stdint_h.m4 new file mode 100644 index 0000000..32ba7ae --- /dev/null +++ b/m4/stdint_h.m4 @@ -0,0 +1,28 @@ +# stdint_h.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_STDINT_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_STDINT_H], +[ + AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_stdint_h=yes, + jm_ac_cv_header_stdint_h=no)]) + if test $jm_ac_cv_header_stdint_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4 new file mode 100644 index 0000000..b5f28d4 --- /dev/null +++ b/m4/uintmax_t.m4 @@ -0,0 +1,32 @@ +# uintmax_t.m4 serial 7 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +AC_PREREQ(2.13) + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if it is not already defined in or . + +AC_DEFUN([jm_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then + AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to unsigned long or unsigned long long + if and don't define.]) + else + AC_DEFINE(HAVE_UINTMAX_T, 1, + [Define if you have the 'uintmax_t' type in or .]) + fi +]) diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4 new file mode 100644 index 0000000..1da8b80 --- /dev/null +++ b/m4/ulonglong.m4 @@ -0,0 +1,25 @@ +# ulonglong.m4 serial 3 +dnl Copyright (C) 1999-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_UNSIGNED_LONG_LONG if 'unsigned long long' works. + +AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG], +[ + AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, + [AC_TRY_LINK([unsigned long long ull = 1ULL; int i = 63;], + [unsigned long long ullmax = (unsigned long long) -1; + return ull << i | ull >> i | ullmax / ull | ullmax % ull;], + ac_cv_type_unsigned_long_long=yes, + ac_cv_type_unsigned_long_long=no)]) + if test $ac_cv_type_unsigned_long_long = yes; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, + [Define if you have the 'unsigned long long' type.]) + fi +]) diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 new file mode 100644 index 0000000..d8fd1ec --- /dev/null +++ b/m4/wchar_t.m4 @@ -0,0 +1,22 @@ +# wchar_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether has the 'wchar_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WCHAR_T], +[ + AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, + [AC_TRY_COMPILE([#include + wchar_t foo = (wchar_t)'\0';], , + gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) + if test $gt_cv_c_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) + fi +]) diff --git a/m4/wint_t.m4 b/m4/wint_t.m4 new file mode 100644 index 0000000..3d8d215 --- /dev/null +++ b/m4/wint_t.m4 @@ -0,0 +1,22 @@ +# wint_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. +dnl Test whether has the 'wint_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WINT_T], +[ + AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, + [AC_TRY_COMPILE([#include + wint_t foo = (wchar_t)'\0';], , + gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) + if test $gt_cv_c_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) + fi +]) diff --git a/m4/xsize.m4 b/m4/xsize.m4 new file mode 100644 index 0000000..9b7cf9b --- /dev/null +++ b/m4/xsize.m4 @@ -0,0 +1,14 @@ +# xsize.m4 serial 2 +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +AC_DEFUN([gl_XSIZE], +[ + dnl Prerequisites of lib/xsize.h. + AC_REQUIRE([gl_SIZE_MAX]) + AC_CHECK_HEADERS(stdint.h) +]) diff --git a/missing b/missing new file mode 100644 index 0000000..6a37006 --- /dev/null +++ b/missing @@ -0,0 +1,336 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing 0.4 - GNU automake" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. + You can get \`$1Help2man' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100644 index 0000000..d2d5f21 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,111 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +errstatus=0 +dirmode="" + +usage="\ +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" 1>&2 + exit 0 + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +case $dirmode in + '') + if mkdir -p -- . 2>/dev/null; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + fi + ;; + *) + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + fi + ;; +esac + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr="" + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# End: +# mkinstalldirs ends here diff --git a/po/ChangeLog b/po/ChangeLog new file mode 100644 index 0000000..ec8abef --- /dev/null +++ b/po/ChangeLog @@ -0,0 +1,11 @@ +2004-03-29 gettextize + + * Makefile.in.in: New file, from gettext-0.14.1. + * boldquot.sed: New file, from gettext-0.14.1. + * en@boldquot.header: New file, from gettext-0.14.1. + * en@quot.header: New file, from gettext-0.14.1. + * insert-header.sin: New file, from gettext-0.14.1. + * quot.sed: New file, from gettext-0.14.1. + * remove-potcdate.sin: New file, from gettext-0.14.1. + * Rules-quot: New file, from gettext-0.14.1. + diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..319a834 --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,368 @@ +# Makefile for PO directory in any package using GNU gettext. +# Copyright (C) 1995-1997, 2000-2004 by Ulrich Drepper +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. +# +# Origin: gettext-0.14 + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +localedir = $(datadir)/locale +gettextsrcdir = $(datadir)/gettext/po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +mkinstalldirs = $(SHELL) $(MKINSTALLDIRS) + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge +MSGMERGE_UPDATE = @MSGMERGE@ --update +MSGINIT = msginit +MSGCONV = msgconv +MSGFILTER = msgfilter + +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +UPDATEPOFILES = @UPDATEPOFILES@ +DUMMYPOFILES = @DUMMYPOFILES@ +DISTFILES.common = Makefile.in.in remove-potcdate.sin \ +$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) +DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \ +$(POFILES) $(GMOFILES) \ +$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) + +POTFILES = \ + +CATALOGS = @CATALOGS@ + +# Makevars gets inserted here. (Don't remove this line!) + +.SUFFIXES: +.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update + +.po.mo: + @echo "$(MSGFMT) -c -o $@ $<"; \ + $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ + +.po.gmo: + @lang=`echo $* | sed -e 's,.*/,,'`; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ + cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo + +.sin.sed: + sed -e '/^#/d' $< > t-$@ + mv t-$@ $@ + + +all: all-@USE_NLS@ + +all-yes: stamp-po +all-no: + +# stamp-po is a timestamp denoting the last time at which the CATALOGS have +# been loosely updated. Its purpose is that when a developer or translator +# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, +# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent +# invocations of "make" will do nothing. This timestamp would not be necessary +# if updating the $(CATALOGS) would always touch them; however, the rule for +# $(POFILES) has been designed to not touch files that don't need to be +# changed. +stamp-po: $(srcdir)/$(DOMAIN).pot + test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) + @echo "touch stamp-po" + @echo timestamp > stamp-poT + @mv stamp-poT stamp-po + +# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', +# otherwise packages like GCC can not be built if only parts of the source +# have been downloaded. + +# This target rebuilds $(DOMAIN).pot; it is an expensive operation. +# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)' + test ! -f $(DOMAIN).po || { \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ + sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ + if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ + else \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + else \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + } + +# This rule has no dependencies: we don't need to update $(DOMAIN).pot at +# every "make" invocation, only create it when it is missing. +# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. +$(srcdir)/$(DOMAIN).pot: + $(MAKE) $(DOMAIN).pot-update + +# This target rebuilds a PO file if $(DOMAIN).pot has changed. +# Note that a PO file is not touched if it doesn't need to be changed. +$(POFILES): $(srcdir)/$(DOMAIN).pot + @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ + if test -f "$(srcdir)/$${lang}.po"; then \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ + cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ + else \ + $(MAKE) $${lang}.po-create; \ + fi + + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + for file in $(DISTFILES.common) Makevars.template; do \ + $(INSTALL_DATA) $(srcdir)/$$file \ + $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + for file in Makevars; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +install-data-no: all +install-data-yes: all + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ + $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ + echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ + fi; \ + done; \ + done + +install-strip: install + +installdirs: installdirs-exec installdirs-data +installdirs-exec: +installdirs-data: installdirs-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + else \ + : ; \ + fi +installdirs-data-no: +installdirs-data-yes: + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + fi; \ + done; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: uninstall-exec uninstall-data +uninstall-exec: +uninstall-data: uninstall-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + for file in $(DISTFILES.common) Makevars.template; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +uninstall-data-no: +uninstall-data-yes: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + done; \ + done + +check: all + +info dvi ps pdf html tags TAGS ctags CTAGS ID: + +mostlyclean: + rm -f remove-potcdate.sed + rm -f stamp-poT + rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f stamp-po $(GMOFILES) + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: + $(MAKE) update-po + @$(MAKE) dist2 +# This is a separate target because 'update-po' must be executed before. +dist2: $(DISTFILES) + dists="$(DISTFILES)"; \ + if test "$(PACKAGE)" = "gettext-tools"; then \ + dists="$$dists Makevars.template"; \ + fi; \ + if test -f $(srcdir)/ChangeLog; then \ + dists="$$dists ChangeLog"; \ + fi; \ + for i in 0 1 2 3 4 5 6 7 8 9; do \ + if test -f $(srcdir)/ChangeLog.$$i; then \ + dists="$$dists ChangeLog.$$i"; \ + fi; \ + done; \ + if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ + for file in $$dists; do \ + if test -f $$file; then \ + cp -p $$file $(distdir); \ + else \ + cp -p $(srcdir)/$$file $(distdir); \ + fi; \ + done + +update-po: Makefile + $(MAKE) $(DOMAIN).pot-update + test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) + $(MAKE) update-gmo + +# General rule for creating PO files. + +.nop.po-create: + @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ + echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ + exit 1 + +# General rule for updating PO files. + +.nop.po-update: + @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ + if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ + cd $(srcdir); \ + if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +$(DUMMYPOFILES): + +update-gmo: Makefile $(GMOFILES) + @: + +Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@ + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \ + $(SHELL) ./config.status + +force: + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..b06efa4 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(GETTEXT_PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = VBA development team + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = undefined + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..e080cd3 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,18 @@ +# List of source files which containing translatable strings. + +src/Cheats.cpp +src/elf.cpp +src/GBA.cpp +src/RTC.cpp +src/Util.cpp +src/gb/gbCheats.cpp +src/gb/gbCodesCB.h +src/gb/gbCodes.h +src/gb/GB.cpp +src/gtk/joypadconfig.cpp +src/gtk/main.cpp +src/gtk/system.cpp +src/gtk/vba.glade +src/gtk/windowcallbacks.cpp +src/gtk/window.cpp +src/prof/prof.cpp diff --git a/po/Rules-quot b/po/Rules-quot new file mode 100644 index 0000000..9c2a995 --- /dev/null +++ b/po/Rules-quot @@ -0,0 +1,47 @@ +# Special Makefile rules for English message catalogs with quotation marks. + +DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot + +.SUFFIXES: .insert-header .po-update-en + +en@quot.po-create: + $(MAKE) en@quot.po-update +en@boldquot.po-create: + $(MAKE) en@boldquot.po-update + +en@quot.po-update: en@quot.po-update-en +en@boldquot.po-update: en@boldquot.po-update-en + +.insert-header.po-update-en: + @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ + if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + ll=`echo $$lang | sed -e 's/@.*//'`; \ + LC_ALL=C; export LC_ALL; \ + cd $(srcdir); \ + if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "creation of $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +en@quot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header + +en@boldquot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header + +mostlyclean: mostlyclean-quot +mostlyclean-quot: + rm -f *.insert-header diff --git a/po/boldquot.sed b/po/boldquot.sed new file mode 100644 index 0000000..4b937aa --- /dev/null +++ b/po/boldquot.sed @@ -0,0 +1,10 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g +s/“/“/g +s/”/”/g +s/‘/‘/g +s/’/’/g diff --git a/po/en@boldquot.header b/po/en@boldquot.header new file mode 100644 index 0000000..fedb6a0 --- /dev/null +++ b/po/en@boldquot.header @@ -0,0 +1,25 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# +# This catalog furthermore displays the text between the quotation marks in +# bold face, assuming the VT100/XTerm escape sequences. +# diff --git a/po/en@quot.header b/po/en@quot.header new file mode 100644 index 0000000..a9647fc --- /dev/null +++ b/po/en@quot.header @@ -0,0 +1,22 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# diff --git a/po/fr.gmo b/po/fr.gmo new file mode 100644 index 0000000..fd5a0ad Binary files /dev/null and b/po/fr.gmo differ diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 0000000..855a341 --- /dev/null +++ b/po/fr.po @@ -0,0 +1,1114 @@ +# French translation for VBA. +# +# Copyright (C) 2004 VBA development team +# This file is distributed under the same license as the VisualBoyAdvance package. +# +# SĂŠbastien Guignot , 2004. +# +msgid "" +msgstr "" +"Project-Id-Version: VisualBoyAdvance 1.7.2\n" +"Report-Msgid-Bugs-To: undefined\n" +"POT-Creation-Date: 2004-05-21 18:02+0200\n" +"PO-Revision-Date: 2004-05-21 18:03+0200\n" +"Last-Translator: SĂŠbastien Guignot \n" +"Language-Team: French <@>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/Cheats.cpp:653 src/Cheats.cpp:658 src/Cheats.cpp:667 src/Cheats.cpp:675 +#, c-format +msgid "Invalid cheat code '%s'" +msgstr "Cheat code incorrect '%s'" + +#: src/Cheats.cpp:694 +#, c-format +msgid "Invalid cheat code address: %08x" +msgstr "Adresse de cheat code incorrecte : %08x" + +#: src/Cheats.cpp:738 src/Cheats.cpp:747 +msgid "Invalid GSA code. Format is XXXXXXXXYYYYYYYY" +msgstr "Code GSA incorrect. Le format est XXXXXXXXYYYYYYYY" + +#: src/Cheats.cpp:773 +#, c-format +msgid "" +"Warning: cheats are for game %s. Current game is %s.\n" +"Codes may not work correctly." +msgstr "" +"Avertissement : les cheats sont pour le jeu %s. Le jeu courant est %s.\n" +"Les codes peuvent ne pas fonctionner correctement." + +#: src/Cheats.cpp:1307 src/Cheats.cpp:1316 src/Cheats.cpp:1323 +#: src/Cheats.cpp:1331 +msgid "Invalid CBA code. Format is XXXXXXXX YYYY." +msgstr "Code CBA incorrect. Le format est XXXXXXXX YYYY." + +#: src/Cheats.cpp:1385 +msgid "" +"Warning: Codes seem to be for a different game.\n" +"Codes may not work correctly." +msgstr "" +"Avertissement : les codes semblent ĂŞtre faits pour un autre jeu.\n" +"Ils peuvent ne pas fonctionner correctement." + +#: src/Cheats.cpp:1545 src/gb/gbCheats.cpp:130 +#, c-format +msgid "Unsupported cheat list version %d" +msgstr "Version de liste de cheats %d non supportĂŠe" + +#: src/Cheats.cpp:1558 src/gb/gbCheats.cpp:143 +#, c-format +msgid "Unsupported cheat list type %d" +msgstr "Type de liste de cheats %d non supportĂŠ" + +#: src/elf.cpp:2814 +#, c-format +msgid "Not a valid ELF file %s" +msgstr "%s n'est pas un fichier ELF correct" + +#: src/GBA.cpp:664 src/GBA.cpp:849 src/GBA.cpp:887 src/Util.cpp:61 +#: src/Util.cpp:270 src/gb/GB.cpp:1662 src/gb/GB.cpp:1679 src/gb/GB.cpp:1696 +#: src/gb/GB.cpp:1719 src/gb/GB.cpp:1736 +#, c-format +msgid "Error creating file %s" +msgstr "Erreur lors de la crĂŠation du fichier %s" + +#: src/GBA.cpp:701 +#, c-format +msgid "Unsupported VisualBoyAdvance save game version %d" +msgstr "Version de sauvegarde VisualBoyAdvance %d non supportĂŠe" + +#: src/GBA.cpp:715 +#, c-format +msgid "Cannot load save game for %s" +msgstr "Impossible de charger la sauvegarde pour %s" + +#: src/GBA.cpp:724 +msgid "Save game is not using the BIOS files" +msgstr "La sauvegarde n'utilise pas de fichier BIOS" + +#: src/GBA.cpp:727 +msgid "Save game is using the BIOS file" +msgstr "La sauvegarde utilise le fichier BIOS" + +#: src/GBA.cpp:807 +#, c-format +msgid "Unsupported save type %d" +msgstr "Type de sauvegarde %d non supportĂŠ" + +#: src/GBA.cpp:922 src/GBA.cpp:989 src/Util.cpp:588 src/Util.cpp:700 +#: src/gb/gbCheats.cpp:400 src/gb/GB.cpp:1977 +#, c-format +msgid "Cannot open file %s" +msgstr "Impossible d'ouvrir le fichier %s" + +#: src/GBA.cpp:957 src/gb/GB.cpp:1991 +#, c-format +msgid "Cannot import snapshot for %s. Current game is %s" +msgstr "Impossible d'importer le snapshot pour %s. Le jeu courant est %s" + +#: src/GBA.cpp:971 src/gb/GB.cpp:2018 +#, c-format +msgid "Unsupported snapshot file %s" +msgstr "Fichier snapshot %s non supportĂŠ" + +#: src/GBA.cpp:1274 src/GBA.cpp:1280 src/GBA.cpp:1329 src/GBA.cpp:1336 +#: src/GBA.cpp:1343 src/GBA.cpp:1350 src/GBA.cpp:1357 src/GBA.cpp:1364 +#: src/GBA.cpp:1371 src/Util.cpp:767 src/Util.cpp:825 src/Util.cpp:933 +#, c-format +msgid "Failed to allocate memory for %s" +msgstr "Échec de l'allocation de mĂŠmoire pour : %s" + +#: src/GBA.cpp:1292 src/Util.cpp:756 src/Util.cpp:802 src/Util.cpp:816 +#: src/Util.cpp:920 +#, c-format +msgid "Error opening image %s" +msgstr "Erreur lors de l'ouverture de l'image %s" + +#: src/GBA.cpp:1606 +#, c-format +msgid "Unsupported ARM mode %02x" +msgstr "Mode ARM %02x non supportĂŠ" + +#: src/GBA.cpp:1839 +#, c-format +msgid "" +"Unsupported BIOS function %02x called from %08x. A BIOS file is needed in " +"order to get correct behaviour." +msgstr "" +"Fonction du BIOS %02x non supportĂŠe appelĂŠe depuis %08x. Un fichier BIOS est " +"nĂŠcessaire pour obtenir un comportement correct." + +#: src/GBA.cpp:2947 +msgid "Invalid BIOS file size" +msgstr "Taille de fichier BIOS incorrecte" + +#: src/RTC.cpp:157 +#, c-format +msgid "Unknown RTC command %02x" +msgstr "Commande RTC %02x inconnue" + +#: src/Util.cpp:596 src/Util.cpp:616 src/Util.cpp:707 src/Util.cpp:727 +#, c-format +msgid "Bad ZIP file %s" +msgstr "Fichier ZIP incorrect : %s" + +#: src/Util.cpp:639 src/Util.cpp:745 +#, c-format +msgid "No image found on ZIP file %s" +msgstr "Pas d'image trouvĂŠe dans le fichier ZIP %s" + +#: src/Util.cpp:783 src/Util.cpp:838 src/Util.cpp:877 src/Util.cpp:946 +#, c-format +msgid "Error reading image %s" +msgstr "Erreur lors de la lecture de l'image %s" + +#: src/Util.cpp:889 +#, c-format +msgid "No image found on RAR file %s" +msgstr "Pas d'image trouvĂŠe dans le fichier RAR %s" + +#: src/gb/gbCheats.cpp:194 src/gb/gbCheats.cpp:304 +msgid "Maximum number of cheats reached." +msgstr "Le nombre maximum de cheats a ĂŠtĂŠ atteint." + +#: src/gb/gbCheats.cpp:200 +#, c-format +msgid "Invalid GameShark code: %s" +msgstr "Code GameShark incorrect : %s" + +#: src/gb/gbCheats.cpp:310 +#, c-format +msgid "Invalid GameGenie code: %s" +msgstr "Code GameGenie incorrect : %s" + +#: src/gb/gbCheats.cpp:355 +#, c-format +msgid "Invalid cheat to remove %d" +msgstr "Cheat Ă  supprimer %d incorrect" + +#: src/gb/gbCodesCB.h:1285 src/gb/gbCodes.h:1404 +#, c-format +msgid "Unknown opcode %02x at %04x" +msgstr "Opcode %02x inconnu Ă  %04x" + +#: src/gb/GB.cpp:1761 src/gb/GB.cpp:1785 src/gb/GB.cpp:1810 src/gb/GB.cpp:1842 +#: src/gb/GB.cpp:1866 +#, c-format +msgid "Failed to read complete save game %s (%d)" +msgstr "La lecture de la sauvegarde %s complète a ĂŠchouĂŠe (%d)" + +#: src/gb/GB.cpp:1818 +#, c-format +msgid "Failed to read RTC from save game %s (continuing)" +msgstr "" +"La lecture de la RTC de la sauvegarde %s a ĂŠchouĂŠ (le chargement se poursuit)" + +#: src/gb/GB.cpp:2195 +#, c-format +msgid "Unsupported VisualBoy save game version %d" +msgstr "Version de sauvegarde VisualBoy %d non supportĂŠe" + +#: src/gb/GB.cpp:2205 +#, c-format +msgid "Cannot load save game for %s. Playing %s" +msgstr "" +"Impossible de charger la sauvegarde pour le jeu %s. Le jeu %s est en cours." + +#: src/gb/GB.cpp:2464 +#, c-format +msgid "Unsupported rom size %02x" +msgstr "Taille de rom %02x non supportĂŠe" + +#: src/gb/GB.cpp:2476 +#, c-format +msgid "Unsupported ram size %02x" +msgstr "Taille de ram %02x non supportĂŠe" + +#: src/gb/GB.cpp:2552 +#, c-format +msgid "Unknown cartridge type %02x" +msgstr "Type de cartouche %02x inconnu" + +#: src/gtk/joypadconfig.cpp:202 src/gtk/joypadconfig.cpp:239 +#: src/gtk/joypadconfig.cpp:257 +msgid "" +msgstr "" + +#: src/gtk/main.cpp:61 +#, c-format +msgid "Try `%s --help' for more information.\n" +msgstr "Pour en savoir davantage, faites: `%s --help'.\n" + +#: src/gtk/main.cpp:65 +#, c-format +msgid "Usage: %s [option ...] [file]\n" +msgstr "Usage: %s [option ...] [fichier]\n" + +#: src/gtk/main.cpp:66 +msgid "" +"\n" +"Options:\n" +" --help Output this help.\n" +" -V, --version Output version information.\n" +msgstr "" +"\n" +"Options:\n" +" --help Affiche cette aide.\n" +" -V, --version Affiche la version.\n" + +#: src/gtk/main.cpp:130 +#, c-format +msgid "VisualBoyAdvance version %s [GTK+]\n" +msgstr "VisualBoyAdvance version %s [GTK+]\n" + +#: src/gtk/vba.glade:7 +msgid "VBA" +msgstr "VBA" + +#: src/gtk/vba.glade:37 +msgid "_File" +msgstr "_Fichier" + +#: src/gtk/vba.glade:46 +msgid "_Open..." +msgstr "_Ouvrir..." + +#: src/gtk/vba.glade:73 +msgid "_Load..." +msgstr "_Charger..." + +#: src/gtk/vba.glade:82 +msgid "_Save..." +msgstr "_Enregistrer..." + +#: src/gtk/vba.glade:91 +msgid "Loa_d game" +msgstr "C_harger une partie" + +#: src/gtk/vba.glade:100 +msgid "Most recent" +msgstr "La plus rĂŠcente" + +#: src/gtk/vba.glade:108 +msgid "Auto load most recent" +msgstr "Chargement automatique de la plus rĂŠcente" + +#: src/gtk/vba.glade:123 src/gtk/vba.glade:240 +msgid "Slot1" +msgstr "Slot1" + +#: src/gtk/vba.glade:132 src/gtk/vba.glade:249 +msgid "Slot2" +msgstr "Slot2" + +#: src/gtk/vba.glade:141 src/gtk/vba.glade:258 +msgid "Slot3" +msgstr "Slot3" + +#: src/gtk/vba.glade:150 src/gtk/vba.glade:267 +msgid "Slot4" +msgstr "Slot4" + +#: src/gtk/vba.glade:159 src/gtk/vba.glade:276 +msgid "Slot5" +msgstr "Slot5" + +#: src/gtk/vba.glade:168 src/gtk/vba.glade:285 +msgid "Slot6" +msgstr "Slot6" + +#: src/gtk/vba.glade:177 src/gtk/vba.glade:294 +msgid "Slot7" +msgstr "Slot7" + +#: src/gtk/vba.glade:186 src/gtk/vba.glade:303 +msgid "Slot8" +msgstr "Slot8" + +#: src/gtk/vba.glade:195 src/gtk/vba.glade:312 +msgid "Slot9" +msgstr "Slot9" + +#: src/gtk/vba.glade:204 src/gtk/vba.glade:321 +msgid "Slot10" +msgstr "Slot10" + +#: src/gtk/vba.glade:217 +msgid "S_ave game" +msgstr "E_nregistrer une partie" + +#: src/gtk/vba.glade:226 +msgid "Oldest slot" +msgstr "La plus ancienne" + +#: src/gtk/vba.glade:340 +msgid "_Pause" +msgstr "_Pause" + +#: src/gtk/vba.glade:350 src/gtk/vba.glade:374 +msgid "_Reset" +msgstr "_Reset" + +#: src/gtk/vba.glade:365 +msgid "Rece_nt" +msgstr "RĂŠcemmen_t ouverts" + +#: src/gtk/vba.glade:382 +msgid "_Freeze" +msgstr "_Freeze" + +#: src/gtk/vba.glade:407 +msgid "_Import" +msgstr "_Importer" + +#: src/gtk/vba.glade:416 src/gtk/vba.glade:437 +msgid "_Battery file..." +msgstr "_Fichier de batterie..." + +#: src/gtk/vba.glade:428 +msgid "E_xport" +msgstr "E_xporter" + +#: src/gtk/vba.glade:455 +msgid "Screen capt_ure..." +msgstr "Capt_ure d'ĂŠcran..." + +#: src/gtk/vba.glade:469 +msgid "_Close" +msgstr "_Fermer" + +#: src/gtk/vba.glade:489 +msgid "_Exit" +msgstr "_Quitter" + +#: src/gtk/vba.glade:514 +msgid "_Options" +msgstr "_Options" + +#: src/gtk/vba.glade:523 +msgid "_Frameskip" +msgstr "_Frameskip" + +#: src/gtk/vba.glade:532 +msgid "_Throttle" +msgstr "_Vitesse" + +#: src/gtk/vba.glade:541 +msgid "_No throttle" +msgstr "_Aucune" + +#: src/gtk/vba.glade:550 src/gtk/vba.glade:1315 +msgid "25%" +msgstr "25%" + +#: src/gtk/vba.glade:560 src/gtk/vba.glade:1324 +msgid "50%" +msgstr "50%" + +#: src/gtk/vba.glade:570 src/gtk/vba.glade:1334 +msgid "100%" +msgstr "100%" + +#: src/gtk/vba.glade:580 +msgid "150%" +msgstr "150%" + +#: src/gtk/vba.glade:590 src/gtk/vba.glade:1344 +msgid "200%" +msgstr "200%" + +#: src/gtk/vba.glade:600 +msgid "_Other..." +msgstr "A_utre..." + +#: src/gtk/vba.glade:620 src/gtk/vba.glade:981 src/gtk/vba.glade:1415 +msgid "_Automatic" +msgstr "_Automatique" + +#: src/gtk/vba.glade:629 +msgid "_0" +msgstr "_0" + +#: src/gtk/vba.glade:639 src/gtk/vba.glade:1753 +msgid "_1" +msgstr "_1" + +#: src/gtk/vba.glade:649 src/gtk/vba.glade:1762 +msgid "_2" +msgstr "_2" + +#: src/gtk/vba.glade:659 src/gtk/vba.glade:1772 +msgid "_3" +msgstr "_3" + +#: src/gtk/vba.glade:669 src/gtk/vba.glade:1782 +msgid "_4" +msgstr "_4" + +#: src/gtk/vba.glade:679 +msgid "_5" +msgstr "_5" + +#: src/gtk/vba.glade:689 +msgid "_6" +msgstr "_6" + +#: src/gtk/vba.glade:699 +msgid "_7" +msgstr "_7" + +#: src/gtk/vba.glade:709 +msgid "_8" +msgstr "_8" + +#: src/gtk/vba.glade:719 +msgid "_9" +msgstr "_9" + +#: src/gtk/vba.glade:733 +msgid "_Video" +msgstr "_VidĂŠo" + +#: src/gtk/vba.glade:742 +msgid "_1x" +msgstr "_1x" + +#: src/gtk/vba.glade:751 +msgid "_2x" +msgstr "_2x" + +#: src/gtk/vba.glade:761 +msgid "_3x" +msgstr "_3x" + +#: src/gtk/vba.glade:771 +msgid "_4x" +msgstr "_4x" + +#: src/gtk/vba.glade:781 +msgid "_5x" +msgstr "_5x" + +#: src/gtk/vba.glade:791 +msgid "_6x" +msgstr "_6x" + +#: src/gtk/vba.glade:807 +msgid "_Layers" +msgstr "_Couches" + +#: src/gtk/vba.glade:816 +msgid "BG0" +msgstr "BG0" + +#: src/gtk/vba.glade:826 +msgid "BG1" +msgstr "BG1" + +#: src/gtk/vba.glade:836 +msgid "BG2" +msgstr "BG2" + +#: src/gtk/vba.glade:846 +msgid "BG3" +msgstr "BG3" + +#: src/gtk/vba.glade:856 +msgid "OBJ" +msgstr "OBJ" + +#: src/gtk/vba.glade:866 +msgid "WIN0" +msgstr "WIN0" + +#: src/gtk/vba.glade:876 +msgid "WIN1" +msgstr "WIN1" + +#: src/gtk/vba.glade:886 +msgid "OBJWIN" +msgstr "OBJWIN" + +#: src/gtk/vba.glade:904 +msgid "_Emulator" +msgstr "_Émulateur" + +#: src/gtk/vba.glade:913 +msgid "Directories..." +msgstr "RĂŠpertoires..." + +#: src/gtk/vba.glade:921 +msgid "Pause when inactive window" +msgstr "Pause lorsque la fenĂŞtre est inactive" + +#: src/gtk/vba.glade:930 +msgid "Show speed" +msgstr "Affichage de la vitesse" + +#: src/gtk/vba.glade:939 src/gtk/vba.glade:1030 +msgid "None" +msgstr "Aucun" + +#: src/gtk/vba.glade:948 +msgid "Percentage" +msgstr "Pourcentage" + +#: src/gtk/vba.glade:958 +msgid "Detailed" +msgstr "DĂŠtaillĂŠ" + +#: src/gtk/vba.glade:972 +msgid "Save type" +msgstr "Type de sauvegarde" + +#: src/gtk/vba.glade:990 +msgid "EEPROM" +msgstr "EEPROM" + +#: src/gtk/vba.glade:1000 +msgid "SRAM" +msgstr "SRAM" + +#: src/gtk/vba.glade:1010 +msgid "Flash" +msgstr "Flash" + +#: src/gtk/vba.glade:1020 +msgid "EEPROM+Sensor" +msgstr "EEPROM+Sensor" + +#: src/gtk/vba.glade:1046 +msgid "Flash 64K" +msgstr "Flash 64K" + +#: src/gtk/vba.glade:1055 +msgid "Flash 128K" +msgstr "Flash 128K" + +#: src/gtk/vba.glade:1075 +msgid "_Select BIOS file..." +msgstr "_SĂŠlectionner un fichier BIOS..." + +#: src/gtk/vba.glade:1083 +msgid "_Use BIOS file" +msgstr "_Utiliser le fichier BIOS" + +#: src/gtk/vba.glade:1098 +msgid "Screenshot format" +msgstr "Format des captures d'ĂŠcran" + +#: src/gtk/vba.glade:1107 +msgid "_PNG" +msgstr "_PNG" + +#: src/gtk/vba.glade:1116 +msgid "_BMP" +msgstr "_BMP" + +#: src/gtk/vba.glade:1134 +msgid "_Sound" +msgstr "_Son" + +#: src/gtk/vba.glade:1143 +msgid "O_ff" +msgstr "_DĂŠsactivĂŠ" + +#: src/gtk/vba.glade:1152 +msgid "_Mute" +msgstr "_Muet" + +#: src/gtk/vba.glade:1162 +msgid "_On" +msgstr "A_ctivĂŠ" + +#: src/gtk/vba.glade:1178 +msgid "Echo" +msgstr "Écho" + +#: src/gtk/vba.glade:1187 +msgid "Low pass filter" +msgstr "Filtre passe-bas" + +#: src/gtk/vba.glade:1196 +msgid "Reverse stereo" +msgstr "StĂŠrĂŠo inversĂŠe" + +#: src/gtk/vba.glade:1211 +msgid "Channel _1" +msgstr "Canal _1" + +#: src/gtk/vba.glade:1220 +msgid "Channel _2" +msgstr "Canal _2" + +#: src/gtk/vba.glade:1229 +msgid "Channel _3" +msgstr "Canal _3" + +#: src/gtk/vba.glade:1238 +msgid "Channel _4" +msgstr "Canal _4" + +#: src/gtk/vba.glade:1247 +msgid "Channel _A" +msgstr "Canal _A" + +#: src/gtk/vba.glade:1256 +msgid "Channel _B" +msgstr "Canal _B" + +#: src/gtk/vba.glade:1271 +msgid "11 _Khz" +msgstr "11 _Khz" + +#: src/gtk/vba.glade:1280 +msgid "22 K_hz" +msgstr "22 K_hz" + +#: src/gtk/vba.glade:1290 +msgid "44 Kh_z" +msgstr "44 Kh_z" + +#: src/gtk/vba.glade:1306 +msgid "_Volume" +msgstr "_Volume" + +#: src/gtk/vba.glade:1354 +msgid "300%" +msgstr "300%" + +#: src/gtk/vba.glade:1364 +msgid "400%" +msgstr "400%" + +#: src/gtk/vba.glade:1382 +msgid "_Gameboy" +msgstr "_Gameboy" + +#: src/gtk/vba.glade:1391 +msgid "_Border" +msgstr "_Bordure" + +#: src/gtk/vba.glade:1400 +msgid "_Printer" +msgstr "_Imprimante" + +#: src/gtk/vba.glade:1424 +msgid "_GBA" +msgstr "_GBA" + +#: src/gtk/vba.glade:1434 +msgid "_CGB/GBC" +msgstr "_CGB/GBC" + +#: src/gtk/vba.glade:1444 +msgid "_SGB" +msgstr "_SGB" + +#: src/gtk/vba.glade:1454 +msgid "SGB_2" +msgstr "SGB_2" + +#: src/gtk/vba.glade:1464 +msgid "G_B" +msgstr "G_B" + +#: src/gtk/vba.glade:1478 +msgid "F_ilter" +msgstr "_Filtre" + +#: src/gtk/vba.glade:1487 +msgid "Interframe _blending" +msgstr "Interframe _blending" + +#: src/gtk/vba.glade:1496 src/gtk/vba.glade:1535 +msgid "_None" +msgstr "Aucu_n" + +#: src/gtk/vba.glade:1505 +msgid "_Smart" +msgstr "_Smart" + +#: src/gtk/vba.glade:1515 src/gtk/vba.glade:1594 +msgid "_Motion Blur" +msgstr "_Motion Blur" + +#: src/gtk/vba.glade:1544 +msgid "_TV Mode" +msgstr "_TV Mode" + +#: src/gtk/vba.glade:1554 +msgid "_2xSaI" +msgstr "_2xSaI" + +#: src/gtk/vba.glade:1564 +msgid "_Super 2xSaI" +msgstr "_Super 2xSaI" + +#: src/gtk/vba.glade:1574 +msgid "Super _Eagle" +msgstr "Super _Eagle" + +#: src/gtk/vba.glade:1584 +msgid "_Pixelate" +msgstr "_Pixelate" + +#: src/gtk/vba.glade:1604 +msgid "_AdvanceMAME 2x" +msgstr "_AdvanceMAME 2x" + +#: src/gtk/vba.glade:1614 +msgid "S_imple 2x" +msgstr "S_imple 2x" + +#: src/gtk/vba.glade:1624 +msgid "Bilinea_r" +msgstr "Bilinea_r" + +#: src/gtk/vba.glade:1634 +msgid "Bilinear Pl_us" +msgstr "Bilinear Pl_us" + +#: src/gtk/vba.glade:1644 +msgid "S_canlines" +msgstr "S_canlines" + +#: src/gtk/vba.glade:1654 +msgid "h_q2x" +msgstr "h_q2x" + +#: src/gtk/vba.glade:1664 +msgid "_lq2x" +msgstr "_lq2x" + +#: src/gtk/vba.glade:1680 +msgid "_Disable MMX" +msgstr "_DĂŠsactiver MMX" + +#: src/gtk/vba.glade:1693 +msgid "_Joypad" +msgstr "_Joypad" + +#: src/gtk/vba.glade:1702 +msgid "_Configure" +msgstr "_Configurer" + +#: src/gtk/vba.glade:1711 +msgid "_1..." +msgstr "_1..." + +#: src/gtk/vba.glade:1719 +msgid "_2..." +msgstr "_2..." + +#: src/gtk/vba.glade:1727 +msgid "_3..." +msgstr "_3..." + +#: src/gtk/vba.glade:1735 +msgid "_4..." +msgstr "_4..." + +#: src/gtk/vba.glade:1798 +msgid "_Autofire" +msgstr "_Autofire" + +#: src/gtk/vba.glade:1807 +msgid "_A" +msgstr "_A" + +#: src/gtk/vba.glade:1817 +msgid "_B" +msgstr "_B" + +#: src/gtk/vba.glade:1827 +msgid "_L" +msgstr "_L" + +#: src/gtk/vba.glade:1837 +msgid "_R" +msgstr "_R" + +#: src/gtk/vba.glade:1859 +msgid "_Tools" +msgstr "Ou_tils" + +#: src/gtk/vba.glade:1868 +msgid "_GDB" +msgstr "_GDB" + +#: src/gtk/vba.glade:1877 +msgid "_Wait connection..." +msgstr "_Attendre une connexion..." + +#: src/gtk/vba.glade:1885 +msgid "_Load and wait..." +msgstr "_Charger et attendre..." + +#: src/gtk/vba.glade:1893 +msgid "_Break" +msgstr "_Break" + +#: src/gtk/vba.glade:1901 +msgid "_Disconnect" +msgstr "_DĂŠconnecter" + +#: src/gtk/vba.glade:1917 +msgid "_Help" +msgstr "_Aide" + +#: src/gtk/vba.glade:1926 +msgid "_About" +msgstr "À _propos" + +#: src/gtk/vba.glade:1967 +msgid "About VBA" +msgstr "À propos de VBA" + +#: src/gtk/vba.glade:2054 +msgid "An emulator for Gameboy(TM) and GameboyAdvance(TM)." +msgstr "Émulateur pour Gameboy™ et GameboyAdvance™." + +#: src/gtk/vba.glade:2076 +msgid "Special thanks to Yann Parmentier aka \"kohai\" for the icons." +msgstr "" +"Remerciements spĂŠciaux Ă  Yann Parmentier aka \"kohai\" pour les icĂ´nes." + +#: src/gtk/vba.glade:2098 +msgid "" +"Copyright (C) 2004 Forgotten and the VBA development team" +msgstr "" +"Copyright Š 2004 Forgotten et l'ĂŠquipe de dĂŠveloppement de VBA" + +#: src/gtk/vba.glade:2120 +msgid "Throttle" +msgstr "Vitesse" + +#: src/gtk/vba.glade:2191 +msgid "Throttle : " +msgstr "Vitesse : " + +#: src/gtk/vba.glade:2231 +msgid " %" +msgstr " %" + +#: src/gtk/vba.glade:2262 +msgid "Directories" +msgstr "RĂŠpertoires" + +#: src/gtk/vba.glade:2328 +msgid "GBA roms : " +msgstr "Roms GBA : " + +#: src/gtk/vba.glade:2358 src/gtk/vba.glade:2511 src/gtk/vba.glade:2612 +#: src/gtk/vba.glade:2713 src/gtk/vba.glade:2790 src/gtk/vba.glade:2921 +#: src/gtk/vba.glade:3207 src/gtk/vba.glade:3229 src/gtk/vba.glade:3251 +#: src/gtk/vba.glade:3273 src/gtk/vba.glade:3295 src/gtk/vba.glade:3317 +#: src/gtk/vba.glade:3339 src/gtk/vba.glade:3361 src/gtk/vba.glade:3383 +#: src/gtk/vba.glade:3405 src/gtk/vba.glade:3427 +msgid "*" +msgstr "*" + +#: src/gtk/vba.glade:2429 +msgid "GB roms : " +msgstr "Roms GB : " + +#: src/gtk/vba.glade:2481 +msgid "Batteries : " +msgstr "Batteries : " + +#: src/gtk/vba.glade:2582 +msgid "Saves : " +msgstr "Sauvegardes : " + +#: src/gtk/vba.glade:2683 +msgid "Captures : " +msgstr "Captures : " + +#: src/gtk/vba.glade:2841 +msgid "Joypad config" +msgstr "Configuration du joypad" + +#: src/gtk/vba.glade:2937 +msgid "Down : " +msgstr "Bas : " + +#: src/gtk/vba.glade:2961 +msgid "Left : " +msgstr "Gauche : " + +#: src/gtk/vba.glade:2985 +msgid "Right : " +msgstr "Droite : " + +#: src/gtk/vba.glade:3009 +msgid "Button A : " +msgstr "Bouton A : " + +#: src/gtk/vba.glade:3033 +msgid "Button B : " +msgstr "Bouton B : " + +#: src/gtk/vba.glade:3057 +msgid "Button L : " +msgstr "Bouton L : " + +#: src/gtk/vba.glade:3081 +msgid "Button R : " +msgstr "Bouton R : " + +#: src/gtk/vba.glade:3105 +msgid "Select : " +msgstr "Select : " + +#: src/gtk/vba.glade:3129 +msgid "Start : " +msgstr "Start : " + +#: src/gtk/vba.glade:3153 +msgid "Speed : " +msgstr "Speed : " + +#: src/gtk/vba.glade:3177 +msgid "Capture : " +msgstr "Capture : " + +#: src/gtk/vba.glade:3443 +msgid "Up : " +msgstr "Haut : " + +#: src/gtk/vba.glade:3477 +msgid "TCP port" +msgstr "Port TCP" + +#: src/gtk/vba.glade:3548 +msgid "Port : " +msgstr "Port : " + +#: src/gtk/windowcallbacks.cpp:80 src/gtk/windowcallbacks.cpp:94 +msgid "Load game" +msgstr "Charger une partie" + +#: src/gtk/windowcallbacks.cpp:109 src/gtk/windowcallbacks.cpp:163 +msgid "VisualBoyAdvance save game" +msgstr "Sauvegarde VisualBoyAdvance" + +#: src/gtk/windowcallbacks.cpp:131 src/gtk/windowcallbacks.cpp:146 +msgid "Save game" +msgstr "Enregistrer une partie" + +#: src/gtk/windowcallbacks.cpp:181 src/gtk/windowcallbacks.cpp:466 +#: src/gtk/windowcallbacks.cpp:585 +msgid "File already exists. Overwrite it?" +msgstr "Le fichier existe dĂŠjĂ . Voulez-vous l'ĂŠcraser ?" + +#: src/gtk/windowcallbacks.cpp:318 src/gtk/windowcallbacks.cpp:332 +msgid "Import battery file" +msgstr "Importer un fichier de batterie" + +#: src/gtk/windowcallbacks.cpp:347 src/gtk/windowcallbacks.cpp:424 +msgid "Battery file" +msgstr "Fichier de batterie" + +#: src/gtk/windowcallbacks.cpp:351 src/gtk/windowcallbacks.cpp:428 +msgid "Flash save" +msgstr "Sauvegarde de flash" + +#: src/gtk/windowcallbacks.cpp:362 +msgid "" +"Importing a battery file will erase any saved games and reset the emulator. " +"Do you want to continue?" +msgstr "" +"Importer un fichier de batterie va effacer les parties sauvegardĂŠes dans le " +"jeu et redĂŠmarrer le jeu. Voulez-vous continuer ?" + +#: src/gtk/windowcallbacks.cpp:380 +#, c-format +msgid "Failed to import battery file %s." +msgstr "L'importation du fichier de batterie %s a ĂŠchouĂŠ" + +#: src/gtk/windowcallbacks.cpp:392 src/gtk/windowcallbacks.cpp:407 +msgid "Export battery file" +msgstr "Exporter un fichier de batterie" + +#: src/gtk/windowcallbacks.cpp:494 +#, c-format +msgid "Failed to export battery file %s." +msgstr "L'exportation du fichier de batterie %s a ĂŠchouĂŠ" + +#: src/gtk/windowcallbacks.cpp:506 src/gtk/windowcallbacks.cpp:521 +msgid "Save screenshot" +msgstr "Enregistrer la capture d'ĂŠcran" + +#: src/gtk/windowcallbacks.cpp:538 +msgid "PNG image" +msgstr "Image PNG" + +#: src/gtk/windowcallbacks.cpp:542 +msgid "BMP image" +msgstr "Image BMP" + +#: src/gtk/windowcallbacks.cpp:824 src/gtk/windowcallbacks.cpp:844 +msgid "Select directory" +msgstr "SĂŠlectionner un rĂŠpertoire" + +#: src/gtk/windowcallbacks.cpp:872 src/gtk/windowcallbacks.cpp:882 +msgid "Select BIOS file" +msgstr "_SĂŠlectionner un fichier BIOS..." + +#: src/gtk/windowcallbacks.cpp:898 +msgid "All files" +msgstr "Tous les fichiers" + +#: src/gtk/windowcallbacks.cpp:902 +msgid "Gameboy Advance BIOS" +msgstr "BIOS Gameboy Advance" + +#: src/gtk/windowcallbacks.cpp:1336 +msgid "Only GBA images are supported." +msgstr "Seules les images GBA sont supportĂŠes." + +#: src/gtk/window.cpp:1427 +#, c-format +msgid "Unknown file type %s" +msgstr "Type de fichier inconnu %s" + +#: src/gtk/window.cpp:1708 src/gtk/window.cpp:1722 +msgid "Open" +msgstr "Ouvrir" + +#: src/gtk/window.cpp:1749 +msgid "All Gameboy Advance files" +msgstr "Tous les fichiers Gameboy Advance" + +#: src/gtk/window.cpp:1756 +msgid "Gameboy Advance files" +msgstr "Fichiers Gameboy Advance" + +#: src/gtk/window.cpp:1763 +msgid "Gameboy files" +msgstr "Fichiers Gameboy" + +#: src/gtk/window.cpp:1793 +msgid "Loaded battery" +msgstr "Batterie chargĂŠe" + +#: src/gtk/window.cpp:1812 +msgid "Saved battery" +msgstr "Batterie enregistrĂŠe" + +#: src/gtk/window.cpp:1870 src/gtk/window.cpp:1917 +msgid "----/--/-- --:--:--" +msgstr "--/--/---- --:--:--" + +#: src/gtk/window.cpp:1902 +msgid "%Y/%m/%d %H:%M:%S" +msgstr "%d/%m/%Y %H:%M:%S" + +#: src/prof/prof.cpp:143 +msgid "No space for profiling buffer(s)\n" +msgstr "Pas de place pour le(s) tampon(s) de profil\n" diff --git a/po/insert-header.sin b/po/insert-header.sin new file mode 100644 index 0000000..b26de01 --- /dev/null +++ b/po/insert-header.sin @@ -0,0 +1,23 @@ +# Sed script that inserts the file called HEADER before the header entry. +# +# At each occurrence of a line starting with "msgid ", we execute the following +# commands. At the first occurrence, insert the file. At the following +# occurrences, do nothing. The distinction between the first and the following +# occurrences is achieved by looking at the hold space. +/^msgid /{ +x +# Test if the hold space is empty. +s/m/m/ +ta +# Yes it was empty. First occurrence. Read the file. +r HEADER +# Output the file's contents by reading the next line. But don't lose the +# current line while doing this. +g +N +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/po/quot.sed b/po/quot.sed new file mode 100644 index 0000000..0122c46 --- /dev/null +++ b/po/quot.sed @@ -0,0 +1,6 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g diff --git a/po/remove-potcdate.sin b/po/remove-potcdate.sin new file mode 100644 index 0000000..2436c49 --- /dev/null +++ b/po/remove-potcdate.sin @@ -0,0 +1,19 @@ +# Sed script that remove the POT-Creation-Date line in the header entry +# from a POT file. +# +# The distinction between the first and the following occurrences of the +# pattern is achieved by looking at the hold space. +/^"POT-Creation-Date: .*"$/{ +x +# Test if the hold space is empty. +s/P/P/ +ta +# Yes it was empty. First occurrence. Remove the line. +g +d +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/po/stamp-po b/po/stamp-po new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/po/stamp-po @@ -0,0 +1 @@ +timestamp diff --git a/po/vba-1.7.2.pot b/po/vba-1.7.2.pot new file mode 100644 index 0000000..dbea162 --- /dev/null +++ b/po/vba-1.7.2.pot @@ -0,0 +1,1096 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR VBA development team +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: undefined\n" +"POT-Creation-Date: 2004-05-21 18:02+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/Cheats.cpp:653 src/Cheats.cpp:658 src/Cheats.cpp:667 src/Cheats.cpp:675 +#, c-format +msgid "Invalid cheat code '%s'" +msgstr "" + +#: src/Cheats.cpp:694 +#, c-format +msgid "Invalid cheat code address: %08x" +msgstr "" + +#: src/Cheats.cpp:738 src/Cheats.cpp:747 +msgid "Invalid GSA code. Format is XXXXXXXXYYYYYYYY" +msgstr "" + +#: src/Cheats.cpp:773 +#, c-format +msgid "" +"Warning: cheats are for game %s. Current game is %s.\n" +"Codes may not work correctly." +msgstr "" + +#: src/Cheats.cpp:1307 src/Cheats.cpp:1316 src/Cheats.cpp:1323 +#: src/Cheats.cpp:1331 +msgid "Invalid CBA code. Format is XXXXXXXX YYYY." +msgstr "" + +#: src/Cheats.cpp:1385 +msgid "" +"Warning: Codes seem to be for a different game.\n" +"Codes may not work correctly." +msgstr "" + +#: src/Cheats.cpp:1545 src/gb/gbCheats.cpp:130 +#, c-format +msgid "Unsupported cheat list version %d" +msgstr "" + +#: src/Cheats.cpp:1558 src/gb/gbCheats.cpp:143 +#, c-format +msgid "Unsupported cheat list type %d" +msgstr "" + +#: src/elf.cpp:2814 +#, c-format +msgid "Not a valid ELF file %s" +msgstr "" + +#: src/GBA.cpp:664 src/GBA.cpp:849 src/GBA.cpp:887 src/Util.cpp:61 +#: src/Util.cpp:270 src/gb/GB.cpp:1662 src/gb/GB.cpp:1679 src/gb/GB.cpp:1696 +#: src/gb/GB.cpp:1719 src/gb/GB.cpp:1736 +#, c-format +msgid "Error creating file %s" +msgstr "" + +#: src/GBA.cpp:701 +#, c-format +msgid "Unsupported VisualBoyAdvance save game version %d" +msgstr "" + +#: src/GBA.cpp:715 +#, c-format +msgid "Cannot load save game for %s" +msgstr "" + +#: src/GBA.cpp:724 +msgid "Save game is not using the BIOS files" +msgstr "" + +#: src/GBA.cpp:727 +msgid "Save game is using the BIOS file" +msgstr "" + +#: src/GBA.cpp:807 +#, c-format +msgid "Unsupported save type %d" +msgstr "" + +#: src/GBA.cpp:922 src/GBA.cpp:989 src/Util.cpp:588 src/Util.cpp:700 +#: src/gb/gbCheats.cpp:400 src/gb/GB.cpp:1977 +#, c-format +msgid "Cannot open file %s" +msgstr "" + +#: src/GBA.cpp:957 src/gb/GB.cpp:1991 +#, c-format +msgid "Cannot import snapshot for %s. Current game is %s" +msgstr "" + +#: src/GBA.cpp:971 src/gb/GB.cpp:2018 +#, c-format +msgid "Unsupported snapshot file %s" +msgstr "" + +#: src/GBA.cpp:1274 src/GBA.cpp:1280 src/GBA.cpp:1329 src/GBA.cpp:1336 +#: src/GBA.cpp:1343 src/GBA.cpp:1350 src/GBA.cpp:1357 src/GBA.cpp:1364 +#: src/GBA.cpp:1371 src/Util.cpp:767 src/Util.cpp:825 src/Util.cpp:933 +#, c-format +msgid "Failed to allocate memory for %s" +msgstr "" + +#: src/GBA.cpp:1292 src/Util.cpp:756 src/Util.cpp:802 src/Util.cpp:816 +#: src/Util.cpp:920 +#, c-format +msgid "Error opening image %s" +msgstr "" + +#: src/GBA.cpp:1606 +#, c-format +msgid "Unsupported ARM mode %02x" +msgstr "" + +#: src/GBA.cpp:1839 +#, c-format +msgid "" +"Unsupported BIOS function %02x called from %08x. A BIOS file is needed in " +"order to get correct behaviour." +msgstr "" + +#: src/GBA.cpp:2947 +msgid "Invalid BIOS file size" +msgstr "" + +#: src/RTC.cpp:157 +#, c-format +msgid "Unknown RTC command %02x" +msgstr "" + +#: src/Util.cpp:596 src/Util.cpp:616 src/Util.cpp:707 src/Util.cpp:727 +#, c-format +msgid "Bad ZIP file %s" +msgstr "" + +#: src/Util.cpp:639 src/Util.cpp:745 +#, c-format +msgid "No image found on ZIP file %s" +msgstr "" + +#: src/Util.cpp:783 src/Util.cpp:838 src/Util.cpp:877 src/Util.cpp:946 +#, c-format +msgid "Error reading image %s" +msgstr "" + +#: src/Util.cpp:889 +#, c-format +msgid "No image found on RAR file %s" +msgstr "" + +#: src/gb/gbCheats.cpp:194 src/gb/gbCheats.cpp:304 +msgid "Maximum number of cheats reached." +msgstr "" + +#: src/gb/gbCheats.cpp:200 +#, c-format +msgid "Invalid GameShark code: %s" +msgstr "" + +#: src/gb/gbCheats.cpp:310 +#, c-format +msgid "Invalid GameGenie code: %s" +msgstr "" + +#: src/gb/gbCheats.cpp:355 +#, c-format +msgid "Invalid cheat to remove %d" +msgstr "" + +#: src/gb/gbCodesCB.h:1285 src/gb/gbCodes.h:1404 +#, c-format +msgid "Unknown opcode %02x at %04x" +msgstr "" + +#: src/gb/GB.cpp:1761 src/gb/GB.cpp:1785 src/gb/GB.cpp:1810 src/gb/GB.cpp:1842 +#: src/gb/GB.cpp:1866 +#, c-format +msgid "Failed to read complete save game %s (%d)" +msgstr "" + +#: src/gb/GB.cpp:1818 +#, c-format +msgid "Failed to read RTC from save game %s (continuing)" +msgstr "" + +#: src/gb/GB.cpp:2195 +#, c-format +msgid "Unsupported VisualBoy save game version %d" +msgstr "" + +#: src/gb/GB.cpp:2205 +#, c-format +msgid "Cannot load save game for %s. Playing %s" +msgstr "" + +#: src/gb/GB.cpp:2464 +#, c-format +msgid "Unsupported rom size %02x" +msgstr "" + +#: src/gb/GB.cpp:2476 +#, c-format +msgid "Unsupported ram size %02x" +msgstr "" + +#: src/gb/GB.cpp:2552 +#, c-format +msgid "Unknown cartridge type %02x" +msgstr "" + +#: src/gtk/joypadconfig.cpp:202 src/gtk/joypadconfig.cpp:239 +#: src/gtk/joypadconfig.cpp:257 +msgid "" +msgstr "" + +#: src/gtk/main.cpp:61 +#, c-format +msgid "Try `%s --help' for more information.\n" +msgstr "" + +#: src/gtk/main.cpp:65 +#, c-format +msgid "Usage: %s [option ...] [file]\n" +msgstr "" + +#: src/gtk/main.cpp:66 +msgid "" +"\n" +"Options:\n" +" --help Output this help.\n" +" -V, --version Output version information.\n" +msgstr "" + +#: src/gtk/main.cpp:130 +#, c-format +msgid "VisualBoyAdvance version %s [GTK+]\n" +msgstr "" + +#: src/gtk/vba.glade:7 +msgid "VBA" +msgstr "" + +#: src/gtk/vba.glade:37 +msgid "_File" +msgstr "" + +#: src/gtk/vba.glade:46 +msgid "_Open..." +msgstr "" + +#: src/gtk/vba.glade:73 +msgid "_Load..." +msgstr "" + +#: src/gtk/vba.glade:82 +msgid "_Save..." +msgstr "" + +#: src/gtk/vba.glade:91 +msgid "Loa_d game" +msgstr "" + +#: src/gtk/vba.glade:100 +msgid "Most recent" +msgstr "" + +#: src/gtk/vba.glade:108 +msgid "Auto load most recent" +msgstr "" + +#: src/gtk/vba.glade:123 src/gtk/vba.glade:240 +msgid "Slot1" +msgstr "" + +#: src/gtk/vba.glade:132 src/gtk/vba.glade:249 +msgid "Slot2" +msgstr "" + +#: src/gtk/vba.glade:141 src/gtk/vba.glade:258 +msgid "Slot3" +msgstr "" + +#: src/gtk/vba.glade:150 src/gtk/vba.glade:267 +msgid "Slot4" +msgstr "" + +#: src/gtk/vba.glade:159 src/gtk/vba.glade:276 +msgid "Slot5" +msgstr "" + +#: src/gtk/vba.glade:168 src/gtk/vba.glade:285 +msgid "Slot6" +msgstr "" + +#: src/gtk/vba.glade:177 src/gtk/vba.glade:294 +msgid "Slot7" +msgstr "" + +#: src/gtk/vba.glade:186 src/gtk/vba.glade:303 +msgid "Slot8" +msgstr "" + +#: src/gtk/vba.glade:195 src/gtk/vba.glade:312 +msgid "Slot9" +msgstr "" + +#: src/gtk/vba.glade:204 src/gtk/vba.glade:321 +msgid "Slot10" +msgstr "" + +#: src/gtk/vba.glade:217 +msgid "S_ave game" +msgstr "" + +#: src/gtk/vba.glade:226 +msgid "Oldest slot" +msgstr "" + +#: src/gtk/vba.glade:340 +msgid "_Pause" +msgstr "" + +#: src/gtk/vba.glade:350 src/gtk/vba.glade:374 +msgid "_Reset" +msgstr "" + +#: src/gtk/vba.glade:365 +msgid "Rece_nt" +msgstr "" + +#: src/gtk/vba.glade:382 +msgid "_Freeze" +msgstr "" + +#: src/gtk/vba.glade:407 +msgid "_Import" +msgstr "" + +#: src/gtk/vba.glade:416 src/gtk/vba.glade:437 +msgid "_Battery file..." +msgstr "" + +#: src/gtk/vba.glade:428 +msgid "E_xport" +msgstr "" + +#: src/gtk/vba.glade:455 +msgid "Screen capt_ure..." +msgstr "" + +#: src/gtk/vba.glade:469 +msgid "_Close" +msgstr "" + +#: src/gtk/vba.glade:489 +msgid "_Exit" +msgstr "" + +#: src/gtk/vba.glade:514 +msgid "_Options" +msgstr "" + +#: src/gtk/vba.glade:523 +msgid "_Frameskip" +msgstr "" + +#: src/gtk/vba.glade:532 +msgid "_Throttle" +msgstr "" + +#: src/gtk/vba.glade:541 +msgid "_No throttle" +msgstr "" + +#: src/gtk/vba.glade:550 src/gtk/vba.glade:1315 +msgid "25%" +msgstr "" + +#: src/gtk/vba.glade:560 src/gtk/vba.glade:1324 +msgid "50%" +msgstr "" + +#: src/gtk/vba.glade:570 src/gtk/vba.glade:1334 +msgid "100%" +msgstr "" + +#: src/gtk/vba.glade:580 +msgid "150%" +msgstr "" + +#: src/gtk/vba.glade:590 src/gtk/vba.glade:1344 +msgid "200%" +msgstr "" + +#: src/gtk/vba.glade:600 +msgid "_Other..." +msgstr "" + +#: src/gtk/vba.glade:620 src/gtk/vba.glade:981 src/gtk/vba.glade:1415 +msgid "_Automatic" +msgstr "" + +#: src/gtk/vba.glade:629 +msgid "_0" +msgstr "" + +#: src/gtk/vba.glade:639 src/gtk/vba.glade:1753 +msgid "_1" +msgstr "" + +#: src/gtk/vba.glade:649 src/gtk/vba.glade:1762 +msgid "_2" +msgstr "" + +#: src/gtk/vba.glade:659 src/gtk/vba.glade:1772 +msgid "_3" +msgstr "" + +#: src/gtk/vba.glade:669 src/gtk/vba.glade:1782 +msgid "_4" +msgstr "" + +#: src/gtk/vba.glade:679 +msgid "_5" +msgstr "" + +#: src/gtk/vba.glade:689 +msgid "_6" +msgstr "" + +#: src/gtk/vba.glade:699 +msgid "_7" +msgstr "" + +#: src/gtk/vba.glade:709 +msgid "_8" +msgstr "" + +#: src/gtk/vba.glade:719 +msgid "_9" +msgstr "" + +#: src/gtk/vba.glade:733 +msgid "_Video" +msgstr "" + +#: src/gtk/vba.glade:742 +msgid "_1x" +msgstr "" + +#: src/gtk/vba.glade:751 +msgid "_2x" +msgstr "" + +#: src/gtk/vba.glade:761 +msgid "_3x" +msgstr "" + +#: src/gtk/vba.glade:771 +msgid "_4x" +msgstr "" + +#: src/gtk/vba.glade:781 +msgid "_5x" +msgstr "" + +#: src/gtk/vba.glade:791 +msgid "_6x" +msgstr "" + +#: src/gtk/vba.glade:807 +msgid "_Layers" +msgstr "" + +#: src/gtk/vba.glade:816 +msgid "BG0" +msgstr "" + +#: src/gtk/vba.glade:826 +msgid "BG1" +msgstr "" + +#: src/gtk/vba.glade:836 +msgid "BG2" +msgstr "" + +#: src/gtk/vba.glade:846 +msgid "BG3" +msgstr "" + +#: src/gtk/vba.glade:856 +msgid "OBJ" +msgstr "" + +#: src/gtk/vba.glade:866 +msgid "WIN0" +msgstr "" + +#: src/gtk/vba.glade:876 +msgid "WIN1" +msgstr "" + +#: src/gtk/vba.glade:886 +msgid "OBJWIN" +msgstr "" + +#: src/gtk/vba.glade:904 +msgid "_Emulator" +msgstr "" + +#: src/gtk/vba.glade:913 +msgid "Directories..." +msgstr "" + +#: src/gtk/vba.glade:921 +msgid "Pause when inactive window" +msgstr "" + +#: src/gtk/vba.glade:930 +msgid "Show speed" +msgstr "" + +#: src/gtk/vba.glade:939 src/gtk/vba.glade:1030 +msgid "None" +msgstr "" + +#: src/gtk/vba.glade:948 +msgid "Percentage" +msgstr "" + +#: src/gtk/vba.glade:958 +msgid "Detailed" +msgstr "" + +#: src/gtk/vba.glade:972 +msgid "Save type" +msgstr "" + +#: src/gtk/vba.glade:990 +msgid "EEPROM" +msgstr "" + +#: src/gtk/vba.glade:1000 +msgid "SRAM" +msgstr "" + +#: src/gtk/vba.glade:1010 +msgid "Flash" +msgstr "" + +#: src/gtk/vba.glade:1020 +msgid "EEPROM+Sensor" +msgstr "" + +#: src/gtk/vba.glade:1046 +msgid "Flash 64K" +msgstr "" + +#: src/gtk/vba.glade:1055 +msgid "Flash 128K" +msgstr "" + +#: src/gtk/vba.glade:1075 +msgid "_Select BIOS file..." +msgstr "" + +#: src/gtk/vba.glade:1083 +msgid "_Use BIOS file" +msgstr "" + +#: src/gtk/vba.glade:1098 +msgid "Screenshot format" +msgstr "" + +#: src/gtk/vba.glade:1107 +msgid "_PNG" +msgstr "" + +#: src/gtk/vba.glade:1116 +msgid "_BMP" +msgstr "" + +#: src/gtk/vba.glade:1134 +msgid "_Sound" +msgstr "" + +#: src/gtk/vba.glade:1143 +msgid "O_ff" +msgstr "" + +#: src/gtk/vba.glade:1152 +msgid "_Mute" +msgstr "" + +#: src/gtk/vba.glade:1162 +msgid "_On" +msgstr "" + +#: src/gtk/vba.glade:1178 +msgid "Echo" +msgstr "" + +#: src/gtk/vba.glade:1187 +msgid "Low pass filter" +msgstr "" + +#: src/gtk/vba.glade:1196 +msgid "Reverse stereo" +msgstr "" + +#: src/gtk/vba.glade:1211 +msgid "Channel _1" +msgstr "" + +#: src/gtk/vba.glade:1220 +msgid "Channel _2" +msgstr "" + +#: src/gtk/vba.glade:1229 +msgid "Channel _3" +msgstr "" + +#: src/gtk/vba.glade:1238 +msgid "Channel _4" +msgstr "" + +#: src/gtk/vba.glade:1247 +msgid "Channel _A" +msgstr "" + +#: src/gtk/vba.glade:1256 +msgid "Channel _B" +msgstr "" + +#: src/gtk/vba.glade:1271 +msgid "11 _Khz" +msgstr "" + +#: src/gtk/vba.glade:1280 +msgid "22 K_hz" +msgstr "" + +#: src/gtk/vba.glade:1290 +msgid "44 Kh_z" +msgstr "" + +#: src/gtk/vba.glade:1306 +msgid "_Volume" +msgstr "" + +#: src/gtk/vba.glade:1354 +msgid "300%" +msgstr "" + +#: src/gtk/vba.glade:1364 +msgid "400%" +msgstr "" + +#: src/gtk/vba.glade:1382 +msgid "_Gameboy" +msgstr "" + +#: src/gtk/vba.glade:1391 +msgid "_Border" +msgstr "" + +#: src/gtk/vba.glade:1400 +msgid "_Printer" +msgstr "" + +#: src/gtk/vba.glade:1424 +msgid "_GBA" +msgstr "" + +#: src/gtk/vba.glade:1434 +msgid "_CGB/GBC" +msgstr "" + +#: src/gtk/vba.glade:1444 +msgid "_SGB" +msgstr "" + +#: src/gtk/vba.glade:1454 +msgid "SGB_2" +msgstr "" + +#: src/gtk/vba.glade:1464 +msgid "G_B" +msgstr "" + +#: src/gtk/vba.glade:1478 +msgid "F_ilter" +msgstr "" + +#: src/gtk/vba.glade:1487 +msgid "Interframe _blending" +msgstr "" + +#: src/gtk/vba.glade:1496 src/gtk/vba.glade:1535 +msgid "_None" +msgstr "" + +#: src/gtk/vba.glade:1505 +msgid "_Smart" +msgstr "" + +#: src/gtk/vba.glade:1515 src/gtk/vba.glade:1594 +msgid "_Motion Blur" +msgstr "" + +#: src/gtk/vba.glade:1544 +msgid "_TV Mode" +msgstr "" + +#: src/gtk/vba.glade:1554 +msgid "_2xSaI" +msgstr "" + +#: src/gtk/vba.glade:1564 +msgid "_Super 2xSaI" +msgstr "" + +#: src/gtk/vba.glade:1574 +msgid "Super _Eagle" +msgstr "" + +#: src/gtk/vba.glade:1584 +msgid "_Pixelate" +msgstr "" + +#: src/gtk/vba.glade:1604 +msgid "_AdvanceMAME 2x" +msgstr "" + +#: src/gtk/vba.glade:1614 +msgid "S_imple 2x" +msgstr "" + +#: src/gtk/vba.glade:1624 +msgid "Bilinea_r" +msgstr "" + +#: src/gtk/vba.glade:1634 +msgid "Bilinear Pl_us" +msgstr "" + +#: src/gtk/vba.glade:1644 +msgid "S_canlines" +msgstr "" + +#: src/gtk/vba.glade:1654 +msgid "h_q2x" +msgstr "" + +#: src/gtk/vba.glade:1664 +msgid "_lq2x" +msgstr "" + +#: src/gtk/vba.glade:1680 +msgid "_Disable MMX" +msgstr "" + +#: src/gtk/vba.glade:1693 +msgid "_Joypad" +msgstr "" + +#: src/gtk/vba.glade:1702 +msgid "_Configure" +msgstr "" + +#: src/gtk/vba.glade:1711 +msgid "_1..." +msgstr "" + +#: src/gtk/vba.glade:1719 +msgid "_2..." +msgstr "" + +#: src/gtk/vba.glade:1727 +msgid "_3..." +msgstr "" + +#: src/gtk/vba.glade:1735 +msgid "_4..." +msgstr "" + +#: src/gtk/vba.glade:1798 +msgid "_Autofire" +msgstr "" + +#: src/gtk/vba.glade:1807 +msgid "_A" +msgstr "" + +#: src/gtk/vba.glade:1817 +msgid "_B" +msgstr "" + +#: src/gtk/vba.glade:1827 +msgid "_L" +msgstr "" + +#: src/gtk/vba.glade:1837 +msgid "_R" +msgstr "" + +#: src/gtk/vba.glade:1859 +msgid "_Tools" +msgstr "" + +#: src/gtk/vba.glade:1868 +msgid "_GDB" +msgstr "" + +#: src/gtk/vba.glade:1877 +msgid "_Wait connection..." +msgstr "" + +#: src/gtk/vba.glade:1885 +msgid "_Load and wait..." +msgstr "" + +#: src/gtk/vba.glade:1893 +msgid "_Break" +msgstr "" + +#: src/gtk/vba.glade:1901 +msgid "_Disconnect" +msgstr "" + +#: src/gtk/vba.glade:1917 +msgid "_Help" +msgstr "" + +#: src/gtk/vba.glade:1926 +msgid "_About" +msgstr "" + +#: src/gtk/vba.glade:1967 +msgid "About VBA" +msgstr "" + +#: src/gtk/vba.glade:2054 +msgid "An emulator for Gameboy(TM) and GameboyAdvance(TM)." +msgstr "" + +#: src/gtk/vba.glade:2076 +msgid "Special thanks to Yann Parmentier aka \"kohai\" for the icons." +msgstr "" + +#: src/gtk/vba.glade:2098 +msgid "" +"Copyright (C) 2004 Forgotten and the VBA development team" +msgstr "" + +#: src/gtk/vba.glade:2120 +msgid "Throttle" +msgstr "" + +#: src/gtk/vba.glade:2191 +msgid "Throttle : " +msgstr "" + +#: src/gtk/vba.glade:2231 +msgid " %" +msgstr "" + +#: src/gtk/vba.glade:2262 +msgid "Directories" +msgstr "" + +#: src/gtk/vba.glade:2328 +msgid "GBA roms : " +msgstr "" + +#: src/gtk/vba.glade:2358 src/gtk/vba.glade:2511 src/gtk/vba.glade:2612 +#: src/gtk/vba.glade:2713 src/gtk/vba.glade:2790 src/gtk/vba.glade:2921 +#: src/gtk/vba.glade:3207 src/gtk/vba.glade:3229 src/gtk/vba.glade:3251 +#: src/gtk/vba.glade:3273 src/gtk/vba.glade:3295 src/gtk/vba.glade:3317 +#: src/gtk/vba.glade:3339 src/gtk/vba.glade:3361 src/gtk/vba.glade:3383 +#: src/gtk/vba.glade:3405 src/gtk/vba.glade:3427 +msgid "*" +msgstr "" + +#: src/gtk/vba.glade:2429 +msgid "GB roms : " +msgstr "" + +#: src/gtk/vba.glade:2481 +msgid "Batteries : " +msgstr "" + +#: src/gtk/vba.glade:2582 +msgid "Saves : " +msgstr "" + +#: src/gtk/vba.glade:2683 +msgid "Captures : " +msgstr "" + +#: src/gtk/vba.glade:2841 +msgid "Joypad config" +msgstr "" + +#: src/gtk/vba.glade:2937 +msgid "Down : " +msgstr "" + +#: src/gtk/vba.glade:2961 +msgid "Left : " +msgstr "" + +#: src/gtk/vba.glade:2985 +msgid "Right : " +msgstr "" + +#: src/gtk/vba.glade:3009 +msgid "Button A : " +msgstr "" + +#: src/gtk/vba.glade:3033 +msgid "Button B : " +msgstr "" + +#: src/gtk/vba.glade:3057 +msgid "Button L : " +msgstr "" + +#: src/gtk/vba.glade:3081 +msgid "Button R : " +msgstr "" + +#: src/gtk/vba.glade:3105 +msgid "Select : " +msgstr "" + +#: src/gtk/vba.glade:3129 +msgid "Start : " +msgstr "" + +#: src/gtk/vba.glade:3153 +msgid "Speed : " +msgstr "" + +#: src/gtk/vba.glade:3177 +msgid "Capture : " +msgstr "" + +#: src/gtk/vba.glade:3443 +msgid "Up : " +msgstr "" + +#: src/gtk/vba.glade:3477 +msgid "TCP port" +msgstr "" + +#: src/gtk/vba.glade:3548 +msgid "Port : " +msgstr "" + +#: src/gtk/windowcallbacks.cpp:80 src/gtk/windowcallbacks.cpp:94 +msgid "Load game" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:109 src/gtk/windowcallbacks.cpp:163 +msgid "VisualBoyAdvance save game" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:131 src/gtk/windowcallbacks.cpp:146 +msgid "Save game" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:181 src/gtk/windowcallbacks.cpp:466 +#: src/gtk/windowcallbacks.cpp:585 +msgid "File already exists. Overwrite it?" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:318 src/gtk/windowcallbacks.cpp:332 +msgid "Import battery file" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:347 src/gtk/windowcallbacks.cpp:424 +msgid "Battery file" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:351 src/gtk/windowcallbacks.cpp:428 +msgid "Flash save" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:362 +msgid "" +"Importing a battery file will erase any saved games and reset the emulator. " +"Do you want to continue?" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:380 +#, c-format +msgid "Failed to import battery file %s." +msgstr "" + +#: src/gtk/windowcallbacks.cpp:392 src/gtk/windowcallbacks.cpp:407 +msgid "Export battery file" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:494 +#, c-format +msgid "Failed to export battery file %s." +msgstr "" + +#: src/gtk/windowcallbacks.cpp:506 src/gtk/windowcallbacks.cpp:521 +msgid "Save screenshot" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:538 +msgid "PNG image" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:542 +msgid "BMP image" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:824 src/gtk/windowcallbacks.cpp:844 +msgid "Select directory" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:872 src/gtk/windowcallbacks.cpp:882 +msgid "Select BIOS file" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:898 +msgid "All files" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:902 +msgid "Gameboy Advance BIOS" +msgstr "" + +#: src/gtk/windowcallbacks.cpp:1336 +msgid "Only GBA images are supported." +msgstr "" + +#: src/gtk/window.cpp:1427 +#, c-format +msgid "Unknown file type %s" +msgstr "" + +#: src/gtk/window.cpp:1708 src/gtk/window.cpp:1722 +msgid "Open" +msgstr "" + +#: src/gtk/window.cpp:1749 +msgid "All Gameboy Advance files" +msgstr "" + +#: src/gtk/window.cpp:1756 +msgid "Gameboy Advance files" +msgstr "" + +#: src/gtk/window.cpp:1763 +msgid "Gameboy files" +msgstr "" + +#: src/gtk/window.cpp:1793 +msgid "Loaded battery" +msgstr "" + +#: src/gtk/window.cpp:1812 +msgid "Saved battery" +msgstr "" + +#: src/gtk/window.cpp:1870 src/gtk/window.cpp:1917 +msgid "----/--/-- --:--:--" +msgstr "" + +#: src/gtk/window.cpp:1902 +msgid "%Y/%m/%d %H:%M:%S" +msgstr "" + +#: src/prof/prof.cpp:143 +msgid "No space for profiling buffer(s)\n" +msgstr "" diff --git a/src/2xSaI.cpp b/src/2xSaI.cpp new file mode 100644 index 0000000..61eb116 --- /dev/null +++ b/src/2xSaI.cpp @@ -0,0 +1,1274 @@ +#include "System.h" +#include "Port.h" + +extern "C" +{ + +#ifdef MMX + void _2xSaILine (u8 *srcPtr, u8 *deltaPtr, u32 srcPitch, + u32 width, u8 *dstPtr, u32 dstPitch); + void _2xSaISuperEagleLine (u8 *srcPtr, u8 *deltaPtr, + u32 srcPitch, u32 width, + u8 *dstPtr, u32 dstPitch); + void _2xSaISuper2xSaILine (u8 *srcPtr, u8 *deltaPtr, + u32 srcPitch, u32 width, + u8 *dstPtr, u32 dstPitch); + void Init_2xSaIMMX (u32 BitFormat); + void BilinearMMX (u16 * A, u16 * B, u16 * C, u16 * D, + u16 * dx, u16 * dy, u8 *dP); + void BilinearMMXGrid0 (u16 * A, u16 * B, u16 * C, u16 * D, + u16 * dx, u16 * dy, u8 *dP); + void BilinearMMXGrid1 (u16 * A, u16 * B, u16 * C, u16 * D, + u16 * dx, u16 * dy, u8 *dP); + void EndMMX (); + + bool cpu_mmx = 1; +#endif +} +static u32 colorMask = 0xF7DEF7DE; +static u32 lowPixelMask = 0x08210821; +static u32 qcolorMask = 0xE79CE79C; +static u32 qlowpixelMask = 0x18631863; +static u32 redblueMask = 0xF81F; +static u32 greenMask = 0x7E0; + +u32 qRGB_COLOR_MASK[2] = { 0xF7DEF7DE, 0xF7DEF7DE }; + +extern void hq2x_init(unsigned); + +int Init_2xSaI(u32 BitFormat) +{ + if(systemColorDepth == 16) { + if (BitFormat == 565) { + colorMask = 0xF7DEF7DE; + lowPixelMask = 0x08210821; + qcolorMask = 0xE79CE79C; + qlowpixelMask = 0x18631863; + redblueMask = 0xF81F; + greenMask = 0x7E0; + qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE; + hq2x_init(16); + } else if (BitFormat == 555) { + colorMask = 0x7BDE7BDE; + lowPixelMask = 0x04210421; + qcolorMask = 0x739C739C; + qlowpixelMask = 0x0C630C63; + redblueMask = 0x7C1F; + greenMask = 0x3E0; + qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE; + hq2x_init(15); + } else { + return 0; + } + } else if(systemColorDepth == 32) { + colorMask = 0xfefefe; + lowPixelMask = 0x010101; + qcolorMask = 0xfcfcfc; + qlowpixelMask = 0x030303; + qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe; + hq2x_init(32); + } else + return 0; + +#ifdef MMX + Init_2xSaIMMX (BitFormat); +#endif + + return 1; +} + +static inline int GetResult1 (u32 A, u32 B, u32 C, u32 D, + u32 /* E */) +{ + int x = 0; + int y = 0; + int r = 0; + + if (A == C) + x += 1; + else if (B == C) + y += 1; + if (A == D) + x += 1; + else if (B == D) + y += 1; + if (x <= 1) + r += 1; + if (y <= 1) + r -= 1; + return r; +} + +static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D, + u32 /* E */) +{ + int x = 0; + int y = 0; + int r = 0; + + if (A == C) + x += 1; + else if (B == C) + y += 1; + if (A == D) + x += 1; + else if (B == D) + y += 1; + if (x <= 1) + r -= 1; + if (y <= 1) + r += 1; + return r; +} + +static inline int GetResult (u32 A, u32 B, u32 C, u32 D) +{ + int x = 0; + int y = 0; + int r = 0; + + if (A == C) + x += 1; + else if (B == C) + y += 1; + if (A == D) + x += 1; + else if (B == D) + y += 1; + if (x <= 1) + r += 1; + if (y <= 1) + r -= 1; + return r; +} + +static inline u32 INTERPOLATE (u32 A, u32 B) +{ + if (A != B) { + return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + + (A & B & lowPixelMask)); + } else + return A; +} + +static inline u32 Q_INTERPOLATE (u32 A, u32 B, u32 C, u32 D) +{ + register u32 x = ((A & qcolorMask) >> 2) + + ((B & qcolorMask) >> 2) + + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2); + register u32 y = (A & qlowpixelMask) + + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); + + y = (y >> 2) & qlowpixelMask; + return x + y; +} + +static inline int GetResult1_32 (u32 A, u32 B, u32 C, u32 D, + u32 /* E */) +{ + int x = 0; + int y = 0; + int r = 0; + + if (A == C) + x += 1; + else if (B == C) + y += 1; + if (A == D) + x += 1; + else if (B == D) + y += 1; + if (x <= 1) + r += 1; + if (y <= 1) + r -= 1; + return r; +} + +static inline int GetResult2_32 (u32 A, u32 B, u32 C, u32 D, + u32 /* E */) +{ + int x = 0; + int y = 0; + int r = 0; + + if (A == C) + x += 1; + else if (B == C) + y += 1; + if (A == D) + x += 1; + else if (B == D) + y += 1; + if (x <= 1) + r -= 1; + if (y <= 1) + r += 1; + return r; +} + +#define BLUE_MASK565 0x001F001F +#define RED_MASK565 0xF800F800 +#define GREEN_MASK565 0x07E007E0 + +#define BLUE_MASK555 0x001F001F +#define RED_MASK555 0x7C007C00 +#define GREEN_MASK555 0x03E003E0 + +void Super2xSaI (u8 *srcPtr, u32 srcPitch, + u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, + int width, int height) +{ + u16 *bP; + u8 *dP; + u32 inc_bP; + u32 Nextline = srcPitch >> 1; +#ifdef MMX + if (cpu_mmx) { + for (; height; height--) { + _2xSaISuper2xSaILine (srcPtr, deltaPtr, srcPitch, width, + dstPtr, dstPitch); + srcPtr += srcPitch; + dstPtr += dstPitch * 2; + deltaPtr += srcPitch; + } + } else +#endif + { + inc_bP = 1; + + for (; height; height--) { + bP = (u16 *) srcPtr; + dP = (u8 *) dstPtr; + + for (u32 finish = width; finish; finish -= inc_bP) { + u32 color4, color5, color6; + u32 color1, color2, color3; + u32 colorA0, colorA1, colorA2, colorA3, + colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; + u32 product1a, product1b, product2a, product2b; + + //--------------------------------------- B1 B2 + // 4 5 6 S2 + // 1 2 3 S1 + // A1 A2 + + colorB0 = *(bP - Nextline - 1); + colorB1 = *(bP - Nextline); + colorB2 = *(bP - Nextline + 1); + colorB3 = *(bP - Nextline + 2); + + color4 = *(bP - 1); + color5 = *(bP); + color6 = *(bP + 1); + colorS2 = *(bP + 2); + + color1 = *(bP + Nextline - 1); + color2 = *(bP + Nextline); + color3 = *(bP + Nextline + 1); + colorS1 = *(bP + Nextline + 2); + + colorA0 = *(bP + Nextline + Nextline - 1); + colorA1 = *(bP + Nextline + Nextline); + colorA2 = *(bP + Nextline + Nextline + 1); + colorA3 = *(bP + Nextline + Nextline + 2); + + //-------------------------------------- + if (color2 == color6 && color5 != color3) { + product2b = product1b = color2; + } else if (color5 == color3 && color2 != color6) { + product2b = product1b = color5; + } else if (color5 == color3 && color2 == color6) { + register int r = 0; + + r += GetResult (color6, color5, color1, colorA1); + r += GetResult (color6, color5, color4, colorB1); + r += GetResult (color6, color5, colorA2, colorS1); + r += GetResult (color6, color5, colorB2, colorS2); + + if (r > 0) + product2b = product1b = color6; + else if (r < 0) + product2b = product1b = color5; + else { + product2b = product1b = INTERPOLATE (color5, color6); + } + } else { + if (color6 == color3 && color3 == colorA1 + && color2 != colorA2 && color3 != colorA0) + product2b = + Q_INTERPOLATE (color3, color3, color3, color2); + else if (color5 == color2 && color2 == colorA2 + && colorA1 != color3 && color2 != colorA3) + product2b = + Q_INTERPOLATE (color2, color2, color2, color3); + else + product2b = INTERPOLATE (color2, color3); + + if (color6 == color3 && color6 == colorB1 + && color5 != colorB2 && color6 != colorB0) + product1b = + Q_INTERPOLATE (color6, color6, color6, color5); + else if (color5 == color2 && color5 == colorB2 + && colorB1 != color6 && color5 != colorB3) + product1b = + Q_INTERPOLATE (color6, color5, color5, color5); + else + product1b = INTERPOLATE (color5, color6); + } + + if (color5 == color3 && color2 != color6 && color4 == color5 + && color5 != colorA2) + product2a = INTERPOLATE (color2, color5); + else + if (color5 == color1 && color6 == color5 + && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE (color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 + && color2 != colorB2) + product1a = INTERPOLATE (color2, color5); + else + if (color4 == color2 && color3 == color2 + && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE (color2, color5); + else + product1a = color5; + +#ifdef WORDS_BIGENDIAN + product1a = (product1a << 16) | product1b; + product2a = (product2a << 16) | product2b; +#else + product1a = product1a | (product1b << 16); + product2a = product2a | (product2b << 16); +#endif + + *((u32 *) dP) = product1a; + *((u32 *) (dP + dstPitch)) = product2a; + + bP += inc_bP; + dP += sizeof (u32); + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + deltaPtr += srcPitch; + } // endof: for (; height; height--) + } +} + +void Super2xSaI32 (u8 *srcPtr, u32 srcPitch, + u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, + int width, int height) +{ + u32 *bP; + u32 *dP; + u32 inc_bP; + u32 Nextline = srcPitch >> 2; + inc_bP = 1; + + for (; height; height--) { + bP = (u32 *) srcPtr; + dP = (u32 *) dstPtr; + + for (u32 finish = width; finish; finish -= inc_bP) { + u32 color4, color5, color6; + u32 color1, color2, color3; + u32 colorA0, colorA1, colorA2, colorA3, + colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; + u32 product1a, product1b, product2a, product2b; + + //--------------------------------------- B1 B2 + // 4 5 6 S2 + // 1 2 3 S1 + // A1 A2 + + colorB0 = *(bP - Nextline - 1); + colorB1 = *(bP - Nextline); + colorB2 = *(bP - Nextline + 1); + colorB3 = *(bP - Nextline + 2); + + color4 = *(bP - 1); + color5 = *(bP); + color6 = *(bP + 1); + colorS2 = *(bP + 2); + + color1 = *(bP + Nextline - 1); + color2 = *(bP + Nextline); + color3 = *(bP + Nextline + 1); + colorS1 = *(bP + Nextline + 2); + + colorA0 = *(bP + Nextline + Nextline - 1); + colorA1 = *(bP + Nextline + Nextline); + colorA2 = *(bP + Nextline + Nextline + 1); + colorA3 = *(bP + Nextline + Nextline + 2); + + //-------------------------------------- + if (color2 == color6 && color5 != color3) { + product2b = product1b = color2; + } else if (color5 == color3 && color2 != color6) { + product2b = product1b = color5; + } else if (color5 == color3 && color2 == color6) { + register int r = 0; + + r += GetResult (color6, color5, color1, colorA1); + r += GetResult (color6, color5, color4, colorB1); + r += GetResult (color6, color5, colorA2, colorS1); + r += GetResult (color6, color5, colorB2, colorS2); + + if (r > 0) + product2b = product1b = color6; + else if (r < 0) + product2b = product1b = color5; + else { + product2b = product1b = INTERPOLATE (color5, color6); + } + } else { + if (color6 == color3 && color3 == colorA1 + && color2 != colorA2 && color3 != colorA0) + product2b = + Q_INTERPOLATE (color3, color3, color3, color2); + else if (color5 == color2 && color2 == colorA2 + && colorA1 != color3 && color2 != colorA3) + product2b = + Q_INTERPOLATE (color2, color2, color2, color3); + else + product2b = INTERPOLATE (color2, color3); + + if (color6 == color3 && color6 == colorB1 + && color5 != colorB2 && color6 != colorB0) + product1b = + Q_INTERPOLATE (color6, color6, color6, color5); + else if (color5 == color2 && color5 == colorB2 + && colorB1 != color6 && color5 != colorB3) + product1b = + Q_INTERPOLATE (color6, color5, color5, color5); + else + product1b = INTERPOLATE (color5, color6); + } + + if (color5 == color3 && color2 != color6 && color4 == color5 + && color5 != colorA2) + product2a = INTERPOLATE (color2, color5); + else + if (color5 == color1 && color6 == color5 + && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE (color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 + && color2 != colorB2) + product1a = INTERPOLATE (color2, color5); + else + if (color4 == color2 && color3 == color2 + && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE (color2, color5); + else + product1a = color5; + *(dP) = product1a; + *(dP+1) = product1b; + *(dP + (dstPitch >> 2)) = product2a; + *(dP + (dstPitch >> 2) + 1) = product2b; + + bP += inc_bP; + dP += 2; + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + // deltaPtr += srcPitch; + } // endof: for (; height; height--) +} + +void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *dP; + u16 *bP; + u16 *xP; + u32 inc_bP; + +#ifdef MMX + if (cpu_mmx) { + for (; height; height--) { + _2xSaISuperEagleLine (srcPtr, deltaPtr, srcPitch, width, + dstPtr, dstPitch); + srcPtr += srcPitch; + dstPtr += dstPitch * 2; + deltaPtr += srcPitch; + } + } else +#endif + { + inc_bP = 1; + + u32 Nextline = srcPitch >> 1; + + for (; height; height--) { + bP = (u16 *) srcPtr; + xP = (u16 *) deltaPtr; + dP = dstPtr; + for (u32 finish = width; finish; finish -= inc_bP) { + u32 color4, color5, color6; + u32 color1, color2, color3; + u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; + u32 product1a, product1b, product2a, product2b; + + colorB1 = *(bP - Nextline); + colorB2 = *(bP - Nextline + 1); + + color4 = *(bP - 1); + color5 = *(bP); + color6 = *(bP + 1); + colorS2 = *(bP + 2); + + color1 = *(bP + Nextline - 1); + color2 = *(bP + Nextline); + color3 = *(bP + Nextline + 1); + colorS1 = *(bP + Nextline + 2); + + colorA1 = *(bP + Nextline + Nextline); + colorA2 = *(bP + Nextline + Nextline + 1); + + // -------------------------------------- + if (color2 == color6 && color5 != color3) { + product1b = product2a = color2; + if ((color1 == color2) || (color6 == colorB2)) { + product1a = INTERPOLATE (color2, color5); + product1a = INTERPOLATE (color2, product1a); + // product1a = color2; + } else { + product1a = INTERPOLATE (color5, color6); + } + + if ((color6 == colorS2) || (color2 == colorA1)) { + product2b = INTERPOLATE (color2, color3); + product2b = INTERPOLATE (color2, product2b); + // product2b = color2; + } else { + product2b = INTERPOLATE (color2, color3); + } + } else if (color5 == color3 && color2 != color6) { + product2b = product1a = color5; + + if ((colorB1 == color5) || (color3 == colorS1)) { + product1b = INTERPOLATE (color5, color6); + product1b = INTERPOLATE (color5, product1b); + // product1b = color5; + } else { + product1b = INTERPOLATE (color5, color6); + } + + if ((color3 == colorA2) || (color4 == color5)) { + product2a = INTERPOLATE (color5, color2); + product2a = INTERPOLATE (color5, product2a); + // product2a = color5; + } else { + product2a = INTERPOLATE (color2, color3); + } + + } else if (color5 == color3 && color2 == color6) { + register int r = 0; + + r += GetResult (color6, color5, color1, colorA1); + r += GetResult (color6, color5, color4, colorB1); + r += GetResult (color6, color5, colorA2, colorS1); + r += GetResult (color6, color5, colorB2, colorS2); + + if (r > 0) { + product1b = product2a = color2; + product1a = product2b = INTERPOLATE (color5, color6); + } else if (r < 0) { + product2b = product1a = color5; + product1b = product2a = INTERPOLATE (color5, color6); + } else { + product2b = product1a = color5; + product1b = product2a = color2; + } + } else { + product2b = product1a = INTERPOLATE (color2, color6); + product2b = + Q_INTERPOLATE (color3, color3, color3, product2b); + product1a = + Q_INTERPOLATE (color5, color5, color5, product1a); + + product2a = product1b = INTERPOLATE (color5, color3); + product2a = + Q_INTERPOLATE (color2, color2, color2, product2a); + product1b = + Q_INTERPOLATE (color6, color6, color6, product1b); + + // product1a = color5; + // product1b = color6; + // product2a = color2; + // product2b = color3; + } +#ifdef WORDS_BIGENDIAN + product1a = (product1a << 16) | product1b; + product2a = (product2a << 16) | product2b; +#else + product1a = product1a | (product1b << 16); + product2a = product2a | (product2b << 16); +#endif + + *((u32 *) dP) = product1a; + *((u32 *) (dP + dstPitch)) = product2a; + *xP = color5; + + bP += inc_bP; + xP += inc_bP; + dP += sizeof (u32); + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + deltaPtr += srcPitch; + } // endof: for (height; height; height--) + } +} + +void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dP; + u32 *bP; + u32 *xP; + u32 inc_bP; + + inc_bP = 1; + + u32 Nextline = srcPitch >> 2; + + for (; height; height--) { + bP = (u32 *) srcPtr; + xP = (u32 *) deltaPtr; + dP = (u32 *)dstPtr; + for (u32 finish = width; finish; finish -= inc_bP) { + u32 color4, color5, color6; + u32 color1, color2, color3; + u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; + u32 product1a, product1b, product2a, product2b; + + colorB1 = *(bP - Nextline); + colorB2 = *(bP - Nextline + 1); + + color4 = *(bP - 1); + color5 = *(bP); + color6 = *(bP + 1); + colorS2 = *(bP + 2); + + color1 = *(bP + Nextline - 1); + color2 = *(bP + Nextline); + color3 = *(bP + Nextline + 1); + colorS1 = *(bP + Nextline + 2); + + colorA1 = *(bP + Nextline + Nextline); + colorA2 = *(bP + Nextline + Nextline + 1); + + // -------------------------------------- + if (color2 == color6 && color5 != color3) { + product1b = product2a = color2; + if ((color1 == color2) || (color6 == colorB2)) { + product1a = INTERPOLATE (color2, color5); + product1a = INTERPOLATE (color2, product1a); + // product1a = color2; + } else { + product1a = INTERPOLATE (color5, color6); + } + + if ((color6 == colorS2) || (color2 == colorA1)) { + product2b = INTERPOLATE (color2, color3); + product2b = INTERPOLATE (color2, product2b); + // product2b = color2; + } else { + product2b = INTERPOLATE (color2, color3); + } + } else if (color5 == color3 && color2 != color6) { + product2b = product1a = color5; + + if ((colorB1 == color5) || (color3 == colorS1)) { + product1b = INTERPOLATE (color5, color6); + product1b = INTERPOLATE (color5, product1b); + // product1b = color5; + } else { + product1b = INTERPOLATE (color5, color6); + } + + if ((color3 == colorA2) || (color4 == color5)) { + product2a = INTERPOLATE (color5, color2); + product2a = INTERPOLATE (color5, product2a); + // product2a = color5; + } else { + product2a = INTERPOLATE (color2, color3); + } + + } else if (color5 == color3 && color2 == color6) { + register int r = 0; + + r += GetResult (color6, color5, color1, colorA1); + r += GetResult (color6, color5, color4, colorB1); + r += GetResult (color6, color5, colorA2, colorS1); + r += GetResult (color6, color5, colorB2, colorS2); + + if (r > 0) { + product1b = product2a = color2; + product1a = product2b = INTERPOLATE (color5, color6); + } else if (r < 0) { + product2b = product1a = color5; + product1b = product2a = INTERPOLATE (color5, color6); + } else { + product2b = product1a = color5; + product1b = product2a = color2; + } + } else { + product2b = product1a = INTERPOLATE (color2, color6); + product2b = + Q_INTERPOLATE (color3, color3, color3, product2b); + product1a = + Q_INTERPOLATE (color5, color5, color5, product1a); + + product2a = product1b = INTERPOLATE (color5, color3); + product2a = + Q_INTERPOLATE (color2, color2, color2, product2a); + product1b = + Q_INTERPOLATE (color6, color6, color6, product1b); + + // product1a = color5; + // product1b = color6; + // product2a = color2; + // product2b = color3; + } + *(dP) = product1a; + *(dP+1) = product1b; + *(dP + (dstPitch >> 2)) = product2a; + *(dP + (dstPitch >> 2) +1) = product2b; + *xP = color5; + + bP += inc_bP; + xP += inc_bP; + dP += 2; + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + deltaPtr += srcPitch; + } // endof: for (height; height; height--) +} + +void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *dP; + u16 *bP; + u32 inc_bP; + +#ifdef MMX + if (cpu_mmx) { + for (; height; height -= 1) { + _2xSaILine (srcPtr, deltaPtr, srcPitch, width, dstPtr, dstPitch); + srcPtr += srcPitch; + dstPtr += dstPitch * 2; + deltaPtr += srcPitch; + } + } else +#endif + { + inc_bP = 1; + + u32 Nextline = srcPitch >> 1; + + for (; height; height--) { + bP = (u16 *) srcPtr; + dP = dstPtr; + + for (u32 finish = width; finish; finish -= inc_bP) { + + register u32 colorA, colorB; + u32 colorC, colorD, + colorE, colorF, colorG, colorH, + colorI, colorJ, colorK, colorL, + + colorM, colorN, colorO, colorP; + u32 product, product1, product2; + + //--------------------------------------- + // Map of the pixels: I|E F|J + // G|A B|K + // H|C D|L + // M|N O|P + colorI = *(bP - Nextline - 1); + colorE = *(bP - Nextline); + colorF = *(bP - Nextline + 1); + colorJ = *(bP - Nextline + 2); + + colorG = *(bP - 1); + colorA = *(bP); + colorB = *(bP + 1); + colorK = *(bP + 2); + + colorH = *(bP + Nextline - 1); + colorC = *(bP + Nextline); + colorD = *(bP + Nextline + 1); + colorL = *(bP + Nextline + 2); + + colorM = *(bP + Nextline + Nextline - 1); + colorN = *(bP + Nextline + Nextline); + colorO = *(bP + Nextline + Nextline + 1); + colorP = *(bP + Nextline + Nextline + 2); + + if ((colorA == colorD) && (colorB != colorC)) { + if (((colorA == colorE) && (colorB == colorL)) || + ((colorA == colorC) && (colorA == colorF) + && (colorB != colorE) && (colorB == colorJ))) { + product = colorA; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if (((colorA == colorG) && (colorC == colorO)) || + ((colorA == colorB) && (colorA == colorH) + && (colorG != colorC) && (colorC == colorM))) { + product1 = colorA; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + product2 = colorA; + } else if ((colorB == colorC) && (colorA != colorD)) { + if (((colorB == colorF) && (colorA == colorH)) || + ((colorB == colorE) && (colorB == colorD) + && (colorA != colorF) && (colorA == colorI))) { + product = colorB; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if (((colorC == colorH) && (colorA == colorF)) || + ((colorC == colorG) && (colorC == colorD) + && (colorA != colorH) && (colorA == colorI))) { + product1 = colorC; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + product2 = colorB; + } else if ((colorA == colorD) && (colorB == colorC)) { + if (colorA == colorB) { + product = colorA; + product1 = colorA; + product2 = colorA; + } else { + register int r = 0; + + product1 = INTERPOLATE (colorA, colorC); + product = INTERPOLATE (colorA, colorB); + + r += + GetResult1 (colorA, colorB, colorG, colorE, + colorI); + r += + GetResult2 (colorB, colorA, colorK, colorF, + colorJ); + r += + GetResult2 (colorB, colorA, colorH, colorN, + colorM); + r += + GetResult1 (colorA, colorB, colorL, colorO, + colorP); + + if (r > 0) + product2 = colorA; + else if (r < 0) + product2 = colorB; + else { + product2 = + Q_INTERPOLATE (colorA, colorB, colorC, + colorD); + } + } + } else { + product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD); + + if ((colorA == colorC) && (colorA == colorF) + && (colorB != colorE) && (colorB == colorJ)) { + product = colorA; + } else if ((colorB == colorE) && (colorB == colorD) + && (colorA != colorF) && (colorA == colorI)) { + product = colorB; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if ((colorA == colorB) && (colorA == colorH) + && (colorG != colorC) && (colorC == colorM)) { + product1 = colorA; + } else if ((colorC == colorG) && (colorC == colorD) + && (colorA != colorH) && (colorA == colorI)) { + product1 = colorC; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + } + +#ifdef WORDS_BIGENDIAN + product = (colorA << 16) | product ; + product1 = (product1 << 16) | product2 ; +#else + product = colorA | (product << 16); + product1 = product1 | (product2 << 16); +#endif + *((s32 *) dP) = product; + *((u32 *) (dP + dstPitch)) = product1; + + bP += inc_bP; + dP += sizeof (u32); + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + deltaPtr += srcPitch; + } // endof: for (height; height; height--) + } +} + +void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dP; + u32 *bP; + u32 inc_bP = 1; + + u32 Nextline = srcPitch >> 2; + + for (; height; height--) { + bP = (u32 *) srcPtr; + dP = (u32 *) dstPtr; + + for (u32 finish = width; finish; finish -= inc_bP) { + register u32 colorA, colorB; + u32 colorC, colorD, + colorE, colorF, colorG, colorH, + colorI, colorJ, colorK, colorL, + + colorM, colorN, colorO, colorP; + u32 product, product1, product2; + + //--------------------------------------- + // Map of the pixels: I|E F|J + // G|A B|K + // H|C D|L + // M|N O|P + colorI = *(bP - Nextline - 1); + colorE = *(bP - Nextline); + colorF = *(bP - Nextline + 1); + colorJ = *(bP - Nextline + 2); + + colorG = *(bP - 1); + colorA = *(bP); + colorB = *(bP + 1); + colorK = *(bP + 2); + + colorH = *(bP + Nextline - 1); + colorC = *(bP + Nextline); + colorD = *(bP + Nextline + 1); + colorL = *(bP + Nextline + 2); + + colorM = *(bP + Nextline + Nextline - 1); + colorN = *(bP + Nextline + Nextline); + colorO = *(bP + Nextline + Nextline + 1); + colorP = *(bP + Nextline + Nextline + 2); + + if ((colorA == colorD) && (colorB != colorC)) { + if (((colorA == colorE) && (colorB == colorL)) || + ((colorA == colorC) && (colorA == colorF) + && (colorB != colorE) && (colorB == colorJ))) { + product = colorA; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if (((colorA == colorG) && (colorC == colorO)) || + ((colorA == colorB) && (colorA == colorH) + && (colorG != colorC) && (colorC == colorM))) { + product1 = colorA; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + product2 = colorA; + } else if ((colorB == colorC) && (colorA != colorD)) { + if (((colorB == colorF) && (colorA == colorH)) || + ((colorB == colorE) && (colorB == colorD) + && (colorA != colorF) && (colorA == colorI))) { + product = colorB; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if (((colorC == colorH) && (colorA == colorF)) || + ((colorC == colorG) && (colorC == colorD) + && (colorA != colorH) && (colorA == colorI))) { + product1 = colorC; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + product2 = colorB; + } else if ((colorA == colorD) && (colorB == colorC)) { + if (colorA == colorB) { + product = colorA; + product1 = colorA; + product2 = colorA; + } else { + register int r = 0; + + product1 = INTERPOLATE (colorA, colorC); + product = INTERPOLATE (colorA, colorB); + + r += + GetResult1 (colorA, colorB, colorG, colorE, + colorI); + r += + GetResult2 (colorB, colorA, colorK, colorF, + colorJ); + r += + GetResult2 (colorB, colorA, colorH, colorN, + colorM); + r += + GetResult1 (colorA, colorB, colorL, colorO, + colorP); + + if (r > 0) + product2 = colorA; + else if (r < 0) + product2 = colorB; + else { + product2 = + Q_INTERPOLATE (colorA, colorB, colorC, + colorD); + } + } + } else { + product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD); + + if ((colorA == colorC) && (colorA == colorF) + && (colorB != colorE) && (colorB == colorJ)) { + product = colorA; + } else if ((colorB == colorE) && (colorB == colorD) + && (colorA != colorF) && (colorA == colorI)) { + product = colorB; + } else { + product = INTERPOLATE (colorA, colorB); + } + + if ((colorA == colorB) && (colorA == colorH) + && (colorG != colorC) && (colorC == colorM)) { + product1 = colorA; + } else if ((colorC == colorG) && (colorC == colorD) + && (colorA != colorH) && (colorA == colorI)) { + product1 = colorC; + } else { + product1 = INTERPOLATE (colorA, colorC); + } + } + *(dP) = colorA; + *(dP + 1) = product; + *(dP + (dstPitch >> 2)) = product1; + *(dP + (dstPitch >> 2) + 1) = product2; + + bP += inc_bP; + dP += 2; + } // end of for ( finish= width etc..) + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + // deltaPtr += srcPitch; + } // endof: for (height; height; height--) +} + +static u32 Bilinear (u32 A, u32 B, u32 x) +{ + unsigned long areaA, areaB; + unsigned long result; + + if (A == B) + return A; + + areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits + areaA = 0x20 - areaB; + + A = (A & redblueMask) | ((A & greenMask) << 16); + B = (B & redblueMask) | ((B & greenMask) << 16); + + result = ((areaA * A) + (areaB * B)) >> 5; + + return (result & redblueMask) | ((result >> 16) & greenMask); +} + +static u32 Bilinear4 (u32 A, u32 B, u32 C, u32 D, u32 x, + u32 y) +{ + unsigned long areaA, areaB, areaC, areaD; + unsigned long result, xy; + + x = (x >> 11) & 0x1f; + y = (y >> 11) & 0x1f; + xy = (x * y) >> 5; + + A = (A & redblueMask) | ((A & greenMask) << 16); + B = (B & redblueMask) | ((B & greenMask) << 16); + C = (C & redblueMask) | ((C & greenMask) << 16); + D = (D & redblueMask) | ((D & greenMask) << 16); + + areaA = 0x20 + xy - x - y; + areaB = x - xy; + areaC = y - xy; + areaD = xy; + + result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5; + + return (result & redblueMask) | ((result >> 16) & greenMask); +} + +void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, + u32 dstWidth, u32 dstHeight, int width, int height) +{ + u8 *dP; + u16 *bP; + + u32 w; + u32 h; + u32 dw; + u32 dh; + u32 hfinish; + u32 wfinish; + + u32 Nextline = srcPitch >> 1; + + wfinish = (width - 1) << 16; // convert to fixed point + dw = wfinish / (dstWidth - 1); + hfinish = (height - 1) << 16; // convert to fixed point + dh = hfinish / (dstHeight - 1); + + for (h = 0; h < hfinish; h += dh) { + u32 y1, y2; + + y1 = h & 0xffff; // fraction part of fixed point + bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch)); + dP = dstPtr; + y2 = 0x10000 - y1; + + w = 0; + + for (; w < wfinish;) { + u32 A, B, C, D; + u32 E, F, G, H; + u32 I, J, K, L; + u32 x1, x2, a1, f1, f2; + u32 position, product1; + + position = w >> 16; + A = bP[position]; // current pixel + B = bP[position + 1]; // next pixel + C = bP[position + Nextline]; + D = bP[position + Nextline + 1]; + E = bP[position - Nextline]; + F = bP[position - Nextline + 1]; + G = bP[position - 1]; + H = bP[position + Nextline - 1]; + I = bP[position + 2]; + J = bP[position + Nextline + 2]; + K = bP[position + Nextline + Nextline]; + L = bP[position + Nextline + Nextline + 1]; + + x1 = w & 0xffff; // fraction part of fixed point + x2 = 0x10000 - x1; + + /*0*/ + if (A == B && C == D && A == C) + product1 = A; + else /*1*/ if (A == D && B != C) { + f1 = (x1 >> 1) + (0x10000 >> 2); + f2 = (y1 >> 1) + (0x10000 >> 2); + if (y1 <= f1 && A == J && A != E) // close to B + { + a1 = f1 - y1; + product1 = Bilinear (A, B, a1); + } else if (y1 >= f1 && A == G && A != L) // close to C + { + a1 = y1 - f1; + product1 = Bilinear (A, C, a1); + } + else if (x1 >= f2 && A == E && A != J) // close to B + { + a1 = x1 - f2; + product1 = Bilinear (A, B, a1); + } + else if (x1 <= f2 && A == L && A != G) // close to C + { + a1 = f2 - x1; + product1 = Bilinear (A, C, a1); + } + else if (y1 >= x1) // close to C + { + a1 = y1 - x1; + product1 = Bilinear (A, C, a1); + } + else if (y1 <= x1) // close to B + { + a1 = x1 - y1; + product1 = Bilinear (A, B, a1); + } + } + else + /*2*/ + if (B == C && A != D) + { + f1 = (x1 >> 1) + (0x10000 >> 2); + f2 = (y1 >> 1) + (0x10000 >> 2); + if (y2 >= f1 && B == H && B != F) // close to A + { + a1 = y2 - f1; + product1 = Bilinear (B, A, a1); + } + else if (y2 <= f1 && B == I && B != K) // close to D + { + a1 = f1 - y2; + product1 = Bilinear (B, D, a1); + } + else if (x2 >= f2 && B == F && B != H) // close to A + { + a1 = x2 - f2; + product1 = Bilinear (B, A, a1); + } + else if (x2 <= f2 && B == K && B != I) // close to D + { + a1 = f2 - x2; + product1 = Bilinear (B, D, a1); + } + else if (y2 >= x1) // close to A + { + a1 = y2 - x1; + product1 = Bilinear (B, A, a1); + } + else if (y2 <= x1) // close to D + { + a1 = x1 - y2; + product1 = Bilinear (B, D, a1); + } + } + /*3*/ + else + { + product1 = Bilinear4 (A, B, C, D, x1, y1); + } + + //end First Pixel + *(u32 *) dP = product1; + dP += 2; + w += dw; + } + dstPtr += dstPitch; + } +} + diff --git a/src/AutoBuild.h b/src/AutoBuild.h new file mode 100644 index 0000000..33d813b --- /dev/null +++ b/src/AutoBuild.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __AUTOBUILD_H__ +#define __AUTOBUILD_H__ +#ifndef VERSION +#define VERSION "1.7.2 re-recording v19.4" +#endif +//change the FALSE to TRUE for autoincrement of build number +#define INCREMENT_VERSION FALSE +#define FILEVER 1,7,2,560 +#define PRODUCTVER 1,7,2,560 +#define STRFILEVER "1, 7, 2, 560\0" +#define STRPRODUCTVER "1, 7, 2, 560\0" +#endif //__AUTOBUILD_H__ diff --git a/src/CheatSearch.cpp b/src/CheatSearch.cpp new file mode 100644 index 0000000..ca344ab --- /dev/null +++ b/src/CheatSearch.cpp @@ -0,0 +1,329 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include + +#include "CheatSearch.h" + +CheatSearchBlock cheatSearchBlocks[4]; + +CheatSearchData cheatSearchData = { + 0, + cheatSearchBlocks +}; + +static bool cheatSearchEQ(u32 a, u32 b) +{ + return a == b; +} + +static bool cheatSearchNE(u32 a, u32 b) +{ + return a != b; +} + +static bool cheatSearchLT(u32 a, u32 b) +{ + return a < b; +} + +static bool cheatSearchLE(u32 a, u32 b) +{ + return a <= b; +} + +static bool cheatSearchGT(u32 a, u32 b) +{ + return a > b; +} + +static bool cheatSearchGE(u32 a, u32 b) +{ + return a >= b; +} + +static bool cheatSearchSignedEQ(s32 a, s32 b) +{ + return a == b; +} + +static bool cheatSearchSignedNE(s32 a, s32 b) +{ + return a != b; +} + +static bool cheatSearchSignedLT(s32 a, s32 b) +{ + return a < b; +} + +static bool cheatSearchSignedLE(s32 a, s32 b) +{ + return a <= b; +} + +static bool cheatSearchSignedGT(s32 a, s32 b) +{ + return a > b; +} + +static bool cheatSearchSignedGE(s32 a, s32 b) +{ + return a >= b; +} + +static bool (*cheatSearchFunc[])(u32,u32) = { + cheatSearchEQ, + cheatSearchNE, + cheatSearchLT, + cheatSearchLE, + cheatSearchGT, + cheatSearchGE +}; + +static bool (*cheatSearchSignedFunc[])(s32,s32) = { + cheatSearchSignedEQ, + cheatSearchSignedNE, + cheatSearchSignedLT, + cheatSearchSignedLE, + cheatSearchSignedGT, + cheatSearchSignedGE +}; + +void cheatSearchCleanup(CheatSearchData *cs) +{ + int count = cs->count; + + for(int i = 0; i < count; i++) { + free(cs->blocks[i].saved); + free(cs->blocks[i].bits); + } + cs->count = 0; +} + +void cheatSearchStart(const CheatSearchData *cs) +{ + int count = cs->count; + + for(int i = 0; i < count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + + memset(block->bits, 0xff, block->size >> 3); + memcpy(block->saved, block->data, block->size); + } +} + +s32 cheatSearchSignedRead(u8 *data, int off, int size) +{ + u32 res = data[off++]; + + switch(size) { + case BITS_8: + res <<= 24; + return ((s32)res) >> 24; + case BITS_16: + res |= ((u32)data[off++])<<8; + res <<= 16; + return ((s32)res) >> 16; + case BITS_32: + res |= ((u32)data[off++])<<8; + res |= ((u32)data[off++])<<16; + res |= ((u32)data[off++])<<24; + return (s32)res; + } + return (s32)res; +} + +u32 cheatSearchRead(u8 *data, int off, int size) +{ + u32 res = data[off++]; + if(size == BITS_16) + res |= ((u32)data[off++])<<8; + else if(size == BITS_32) { + res |= ((u32)data[off++])<<8; + res |= ((u32)data[off++])<<16; + res |= ((u32)data[off++])<<24; + } + return res; +} + +void cheatSearch(const CheatSearchData *cs, int compare, int size, + bool isSigned) +{ + if(compare < 0 || compare > SEARCH_GE) + return; + int inc = 1; + if(size == BITS_16) + inc = 2; + else if(size == BITS_32) + inc = 4; + + if(isSigned) { + bool (*func)(s32,s32) = cheatSearchSignedFunc[compare]; + + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + int size2 = block->size; + u8 *bits = block->bits; + u8 *data = block->data; + u8 *saved = block->saved; + + for(int j = 0; j < size2; j += inc) { + if(IS_BIT_SET(bits, j)) { + s32 a = cheatSearchSignedRead(data, j, size); + s32 b = cheatSearchSignedRead(saved,j, size); + + if(!func(a, b)) { + CLEAR_BIT(bits, j); + if(size == BITS_16) + CLEAR_BIT(bits, j+1); + if(size == BITS_32) { + CLEAR_BIT(bits, j+2); + CLEAR_BIT(bits, j+3); + } + } + } + } + } + } else { + bool (*func)(u32,u32) = cheatSearchFunc[compare]; + + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + int size2 = block->size; + u8 *bits = block->bits; + u8 *data = block->data; + u8 *saved = block->saved; + + for(int j = 0; j < size2; j += inc) { + if(IS_BIT_SET(bits, j)) { + u32 a = cheatSearchRead(data, j, size); + u32 b = cheatSearchRead(saved,j, size); + + if(!func(a, b)) { + CLEAR_BIT(bits, j); + if(size == BITS_16) + CLEAR_BIT(bits, j+1); + if(size == BITS_32) { + CLEAR_BIT(bits, j+2); + CLEAR_BIT(bits, j+3); + } + } + } + } + } + } +} + +void cheatSearchValue(const CheatSearchData *cs, int compare, int size, + bool isSigned, u32 value) +{ + if(compare < 0 || compare > SEARCH_GE) + return; + int inc = 1; + if(size == BITS_16) + inc = 2; + else if(size == BITS_32) + inc = 4; + + if(isSigned) { + bool (*func)(s32,s32) = cheatSearchSignedFunc[compare]; + + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + int size2 = block->size; + u8 *bits = block->bits; + u8 *data = block->data; + + for(int j = 0; j < size2; j += inc) { + if(IS_BIT_SET(bits, j)) { + s32 a = cheatSearchSignedRead(data, j, size); + s32 b = (s32)value; + + if(!func(a, b)) { + CLEAR_BIT(bits, j); + if(size == BITS_16) + CLEAR_BIT(bits, j+1); + if(size == BITS_32) { + CLEAR_BIT(bits, j+2); + CLEAR_BIT(bits, j+3); + } + } + } + } + } + } else { + bool (*func)(u32,u32) = cheatSearchFunc[compare]; + + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + int size2 = block->size; + u8 *bits = block->bits; + u8 *data = block->data; + + for(int j = 0; j < size2; j += inc) { + if(IS_BIT_SET(bits, j)) { + u32 a = cheatSearchRead(data, j, size); + + if(!func(a, value)) { + CLEAR_BIT(bits, j); + if(size == BITS_16) + CLEAR_BIT(bits, j+1); + if(size == BITS_32) { + CLEAR_BIT(bits, j+2); + CLEAR_BIT(bits, j+3); + } + } + } + } + } + } +} + +int cheatSearchGetCount(const CheatSearchData *cs, int size) +{ + int res = 0; + int inc = 1; + if(size == BITS_16) + inc = 2; + else if(size == BITS_32) + inc = 4; + + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + + int size2 = block->size; + u8 *bits = block->bits; + for(int j = 0; j < size2; j += inc) { + if(IS_BIT_SET(bits, j)) + res++; + } + } + return res; +} + +void cheatSearchUpdateValues(const CheatSearchData *cs) +{ + for(int i = 0; i < cs->count; i++) { + CheatSearchBlock *block = &cs->blocks[i]; + + memcpy(block->saved, block->data, block->size); + } +} + diff --git a/src/CheatSearch.h b/src/CheatSearch.h new file mode 100644 index 0000000..10db35d --- /dev/null +++ b/src/CheatSearch.h @@ -0,0 +1,73 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_CHEATSEARCH_H +#define VBA_CHEATSEARCH_H + +#include "System.h" + +struct CheatSearchBlock { + int size; + u32 offset; + u8 *bits; + u8 *data; + u8 *saved; +}; + +struct CheatSearchData { + int count; + CheatSearchBlock *blocks; +}; + +enum { + SEARCH_EQ, + SEARCH_NE, + SEARCH_LT, + SEARCH_LE, + SEARCH_GT, + SEARCH_GE +}; + +enum { + BITS_8, + BITS_16, + BITS_32 +}; + +#define SET_BIT(bits,off) \ + (bits)[(off) >> 3] |= (1 << ((off) & 7)) + +#define CLEAR_BIT(bits, off) \ + (bits)[(off) >> 3] &= ~(1 << ((off) & 7)) + +#define IS_BIT_SET(bits, off) \ + (bits)[(off) >> 3] & (1 << ((off) & 7)) + +extern CheatSearchData cheatSearchData; +extern void cheatSearchCleanup(CheatSearchData *cs); +extern void cheatSearchStart(const CheatSearchData *cs); +extern void cheatSearch(const CheatSearchData *cs, int compare, int size, + bool isSigned); +extern void cheatSearchValue(const CheatSearchData *cs, int compare, int size, + bool isSigned, u32 value); +extern int cheatSearchGetCount(const CheatSearchData *cs, int size); +extern void cheatSearchUpdateValues(const CheatSearchData *cs); +extern s32 cheatSearchSignedRead(u8 *data, int off, int size); +extern u32 cheatSearchRead(u8 *data, int off, int size); +#endif diff --git a/src/Cheats.cpp b/src/Cheats.cpp new file mode 100644 index 0000000..49d0f92 --- /dev/null +++ b/src/Cheats.cpp @@ -0,0 +1,1674 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include + +#include "GBA.h" +#include "GBAinline.h" +#include "Cheats.h" +#include "Globals.h" +#include "NLS.h" +#include "Util.h" + +/** + * Gameshark code types: + * + * NNNNNNNN 001DC0DE - ID code for the game (game 4 character name) from ROM + * DEADFACE XXXXXXXX - changes decryption seeds + * 0AAAAAAA 000000YY - 8-bit constant write + * 1AAAAAAA 0000YYYY - 16-bit constant write + * 2AAAAAAA YYYYYYYY - 32-bit constant write + * 3AAAAAAA YYYYYYYY - ?? + * 6AAAAAAA 0000YYYY - 16-bit ROM Patch (address >> 1) + * 6AAAAAAA 1000YYYY - 16-bit ROM Patch ? (address >> 1) + * 6AAAAAAA 2000YYYY - 16-bit ROM Patch ? (address >> 1) + * 8A1AAAAA 000000YY - 8-bit button write + * 8A2AAAAA 0000YYYY - 16-bit button write + * 8A3AAAAA YYYYYYYY - 32-bit button write + * 80F00000 0000YYYY - button slow motion + * DAAAAAAA 0000YYYY - if address contains 16-bit value enable next code + * FAAAAAAA 0000YYYY - Master code function + * + * CodeBreaker codes types: + * + * 0000AAAA 000Y - Game CRC (Y are flags: 8 - CRC, 2 - DI) + * 1AAAAAAA YYYY - Master Code function (store address at ((YYYY << 0x16) + * + 0x08000100)) + * 2AAAAAAA YYYY - 16-bit or + * 3AAAAAAA YYYY - 8-bit constant write + * 4AAAAAAA YYYY - Slide code + * XXXXCCCC IIII (C is count and I is address increment, X is value incr.) + * 5AAAAAAA CCCC - Super code (Write bytes to address, CCCC is count) + * BBBBBBBB BBBB + * 6AAAAAAA YYYY - 16-bit and + * 7AAAAAAA YYYY - if address contains 16-bit value enable next code + * 8AAAAAAA YYYY - 16-bit constant write + * 9AAAAAAA YYYY - change decryption (when first code only?) + * AAAAAAAA YYYY - if address does not contain 16-bit value enable next code + * BAAAAAAA YYYY - if 16-bit < YYYY + * CAAAAAAA YYYY - if 16-bit > YYYY + * D0000020 YYYY - if button keys equal value enable next code + * EAAAAAAA YYYY - increase value stored in address + */ +#define UNKNOWN_CODE -1 +#define INT_8_BIT_WRITE 0 +#define INT_16_BIT_WRITE 1 +#define INT_32_BIT_WRITE 2 +#define GSA_16_BIT_ROM_PATCH 3 +#define GSA_8_BIT_GS_WRITE 4 +#define GSA_16_BIT_GS_WRITE 5 +#define GSA_32_BIT_GS_WRITE 6 +#define CBA_IF_KEYS_PRESSED 7 +#define CBA_IF_TRUE 8 +#define CBA_SLIDE_CODE 9 +#define CBA_IF_FALSE 10 +#define CBA_AND 11 +#define GSA_8_BIT_GS_WRITE2 12 +#define GSA_16_BIT_GS_WRITE2 13 +#define GSA_32_BIT_GS_WRITE2 14 +#define GSA_16_BIT_ROM_PATCH2 15 +#define GSA_8_BIT_SLIDE 16 +#define GSA_16_BIT_SLIDE 17 +#define GSA_32_BIT_SLIDE 18 +#define GSA_8_BIT_IF_TRUE 19 +#define GSA_32_BIT_IF_TRUE 20 +#define GSA_8_BIT_IF_FALSE 21 +#define GSA_32_BIT_IF_FALSE 22 +#define GSA_8_BIT_FILL 23 +#define GSA_16_BIT_FILL 24 +#define GSA_8_BIT_IF_TRUE2 25 +#define GSA_16_BIT_IF_TRUE2 26 +#define GSA_32_BIT_IF_TRUE2 27 +#define GSA_8_BIT_IF_FALSE2 28 +#define GSA_16_BIT_IF_FALSE2 29 +#define GSA_32_BIT_IF_FALSE2 30 +#define GSA_SLOWDOWN 31 +#define CBA_ADD 32 +#define CBA_OR 33 +#define CBA_LT 34 +#define CBA_GT 35 +#define CBA_SUPER 36 + +CheatsData cheatsList[100]; +int cheatsNumber = 0; + +u8 cheatsCBASeedBuffer[0x30]; +u32 cheatsCBASeed[4]; +u32 cheatsCBATemporaryValue = 0; +u16 cheatsCBATable[256]; +bool cheatsCBATableGenerated = false; + +u8 cheatsCBACurrentSeed[12] = { + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +#define CHEAT_IS_HEX(a) ( ((a)>='A' && (a) <='F') || ((a) >='0' && (a) <= '9')) + +#define CHEAT_PATCH_ROM_16BIT(a,v) \ + WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v); + +static bool isMultilineWithData(int i) +{ + // we consider it a multiline code if it has more than one line of data + // otherwise, it can still be considered a single code + if(i < cheatsNumber && i >= 0) + switch(cheatsList[i].size) { + case INT_8_BIT_WRITE: + case INT_16_BIT_WRITE: + case INT_32_BIT_WRITE: + case GSA_16_BIT_ROM_PATCH: + case GSA_8_BIT_GS_WRITE: + case GSA_16_BIT_GS_WRITE: + case GSA_32_BIT_GS_WRITE: + case CBA_AND: + case CBA_IF_KEYS_PRESSED: + case CBA_IF_TRUE: + case CBA_IF_FALSE: + case GSA_8_BIT_IF_TRUE: + case GSA_32_BIT_IF_TRUE: + case GSA_8_BIT_IF_FALSE: + case GSA_32_BIT_IF_FALSE: + case GSA_8_BIT_FILL: + case GSA_16_BIT_FILL: + case GSA_8_BIT_IF_TRUE2: + case GSA_16_BIT_IF_TRUE2: + case GSA_32_BIT_IF_TRUE2: + case GSA_8_BIT_IF_FALSE2: + case GSA_16_BIT_IF_FALSE2: + case GSA_32_BIT_IF_FALSE2: + case GSA_SLOWDOWN: + case CBA_ADD: + case CBA_OR: + return false; + // the codes below have two lines of data + case CBA_SLIDE_CODE: + case GSA_8_BIT_GS_WRITE2: + case GSA_16_BIT_GS_WRITE2: + case GSA_32_BIT_GS_WRITE2: + case GSA_16_BIT_ROM_PATCH2: + case GSA_8_BIT_SLIDE: + case GSA_16_BIT_SLIDE: + case GSA_32_BIT_SLIDE: + case CBA_LT: + case CBA_GT: + case CBA_SUPER: + return true; + } + return false; +} + +static int getCodeLength(int num) +{ + if(num >= cheatsNumber || num < 0) + return 1; + + // this is for all the codes that are true multiline + switch(cheatsList[num].size) { + case INT_8_BIT_WRITE: + case INT_16_BIT_WRITE: + case INT_32_BIT_WRITE: + case GSA_16_BIT_ROM_PATCH: + case GSA_8_BIT_GS_WRITE: + case GSA_16_BIT_GS_WRITE: + case GSA_32_BIT_GS_WRITE: + case CBA_AND: + case GSA_8_BIT_FILL: + case GSA_16_BIT_FILL: + case GSA_SLOWDOWN: + case CBA_ADD: + case CBA_OR: + return 1; + case CBA_IF_KEYS_PRESSED: + case CBA_IF_TRUE: + case CBA_IF_FALSE: + case CBA_SLIDE_CODE: + case GSA_8_BIT_GS_WRITE2: + case GSA_16_BIT_GS_WRITE2: + case GSA_32_BIT_GS_WRITE2: + case GSA_16_BIT_ROM_PATCH2: + case GSA_8_BIT_SLIDE: + case GSA_16_BIT_SLIDE: + case GSA_32_BIT_SLIDE: + case GSA_8_BIT_IF_TRUE: + case GSA_32_BIT_IF_TRUE: + case GSA_8_BIT_IF_FALSE: + case GSA_32_BIT_IF_FALSE: + case CBA_LT: + case CBA_GT: + return 2; + case GSA_8_BIT_IF_TRUE2: + case GSA_16_BIT_IF_TRUE2: + case GSA_32_BIT_IF_TRUE2: + case GSA_8_BIT_IF_FALSE2: + case GSA_16_BIT_IF_FALSE2: + case GSA_32_BIT_IF_FALSE2: + return 3; + case CBA_SUPER: + return (cheatsList[num].value+5)/6; + } + return 1; +} + +int cheatsCheckKeys(u32 keys, u32 extended) +{ + int ticks = 0; + for(int i = 0; i < cheatsNumber; i++) { + if(!cheatsList[i].enabled) { + // make sure we skip other lines in this code + i += getCodeLength(i)-1; + continue; + } + switch(cheatsList[i].size) { + case INT_8_BIT_WRITE: + CPUWriteByte(cheatsList[i].address, cheatsList[i].value); + break; + case INT_16_BIT_WRITE: + CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value); + break; + case INT_32_BIT_WRITE: + CPUWriteMemory(cheatsList[i].address, cheatsList[i].value); + break; + case GSA_16_BIT_ROM_PATCH: + if((cheatsList[i].status & 1) == 0) { + if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) { + cheatsList[i].oldValue = CPUReadHalfWord(cheatsList[i].address); + cheatsList[i].status |= 1; + CHEAT_PATCH_ROM_16BIT(cheatsList[i].address, cheatsList[i].value); + } + } + break; + case GSA_8_BIT_GS_WRITE: + if(extended & 4) { + CPUWriteByte(cheatsList[i].address, cheatsList[i].value); + } + break; + case GSA_16_BIT_GS_WRITE: + if(extended & 4) { + CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value); + } + break; + case GSA_32_BIT_GS_WRITE: + if(extended & 4) { + CPUWriteMemory(cheatsList[i].address, cheatsList[i].value); + } + break; + case CBA_IF_KEYS_PRESSED: + { + u16 value = cheatsList[i].value; + u32 addr = cheatsList[i].address; + if((addr & 0x30) == 0x20) { + if((keys & value) != value) { + i++; + } + } else if((addr & 0x30) == 0x10) { + if((keys & value) == value) { + i++; + } + } + } + break; + case CBA_IF_TRUE: + if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) { + i++; + } + break; + case CBA_SLIDE_CODE: + { + u32 address = cheatsList[i].address; + u16 value = cheatsList[i].value; + i++; + if(i < cheatsNumber) { + int count = (cheatsList[i].address & 0xFFFF); + u16 vinc = (cheatsList[i].address >> 16) & 0xFFFF; + int inc = cheatsList[i].value; + + for(int x = 0; x < count; x++) { + CPUWriteHalfWord(address, value); + address += inc; + value += vinc; + } + } + } + break; + case CBA_IF_FALSE: + if(CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) { + i++; + } + break; + case CBA_AND: + CPUWriteHalfWord(cheatsList[i].address, + CPUReadHalfWord(cheatsList[i].address) & + cheatsList[i].value); + break; + case GSA_8_BIT_GS_WRITE2: + i++; + if(i < cheatsNumber) { + if(extended & 4) { + CPUWriteByte(cheatsList[i-1].value, cheatsList[i].address); + } + } + break; + case GSA_16_BIT_GS_WRITE2: + i++; + if(i < cheatsNumber) { + if(extended & 4) { + CPUWriteHalfWord(cheatsList[i-1].value, cheatsList[i].address); + } + } + break; + case GSA_32_BIT_GS_WRITE2: + i++; + if(i < cheatsNumber) { + if(extended & 4) { + CPUWriteMemory(cheatsList[i-1].value, cheatsList[i].address); + } + } + break; + case GSA_16_BIT_ROM_PATCH2: + i++; + if(i < cheatsNumber) { + if((cheatsList[i-1].status & 1) == 0) { + u32 addr = ((cheatsList[i-1].value & 0x00FFFFFF) << 1) + 0x8000000; + if(CPUReadHalfWord(addr) != (cheatsList[i].address & 0xFFFF)) { + cheatsList[i-1].oldValue = CPUReadHalfWord(addr); + cheatsList[i-1].status |= 1; + CHEAT_PATCH_ROM_16BIT(addr,cheatsList[i].address & 0xFFFF); + } + } + } + break; + case GSA_8_BIT_SLIDE: + i++; + if(i < cheatsNumber) { + u32 addr = cheatsList[i-1].value; + u8 value = cheatsList[i].address; + int vinc = (cheatsList[i].value >> 24) & 255; + int count = (cheatsList[i].value >> 16) & 255; + int ainc = (cheatsList[i].value & 0xffff); + while(count > 0) { + CPUWriteByte(addr, value); + value += vinc; + addr += ainc; + count--; + } + } + break; + case GSA_16_BIT_SLIDE: + i++; + if(i < cheatsNumber) { + u32 addr = cheatsList[i-1].value; + u16 value = cheatsList[i].address; + int vinc = (cheatsList[i].value >> 24) & 255; + int count = (cheatsList[i].value >> 16) & 255; + int ainc = (cheatsList[i].value & 0xffff)*2; + while(count > 0) { + CPUWriteHalfWord(addr, value); + value += vinc; + addr += ainc; + count--; + } + } + break; + case GSA_32_BIT_SLIDE: + i++; + if(i < cheatsNumber) { + u32 addr = cheatsList[i-1].value; + u32 value = cheatsList[i].address; + int vinc = (cheatsList[i].value >> 24) & 255; + int count = (cheatsList[i].value >> 16) & 255; + int ainc = (cheatsList[i].value & 0xffff)*4; + while(count > 0) { + CPUWriteMemory(addr, value); + value += vinc; + addr += ainc; + count--; + } + } + break; + case GSA_8_BIT_IF_TRUE: + if(CPUReadByte(cheatsList[i].address) != cheatsList[i].value) { + i++; + } + break; + case GSA_32_BIT_IF_TRUE: + if(CPUReadMemory(cheatsList[i].address) != cheatsList[i].value) { + i++; + } + break; + case GSA_8_BIT_IF_FALSE: + if(CPUReadByte(cheatsList[i].address) == cheatsList[i].value) { + i++; + } + break; + case GSA_32_BIT_IF_FALSE: + if(CPUReadMemory(cheatsList[i].address) == cheatsList[i].value) { + i++; + } + break; + case GSA_8_BIT_FILL: + { + u32 addr = cheatsList[i].address; + u8 v = cheatsList[i].value & 0xff; + u32 end = addr + (cheatsList[i].value >> 8); + do { + CPUWriteByte(addr, v); + addr++; + } while (addr <= end); + } + break; + case GSA_16_BIT_FILL: + { + u32 addr = cheatsList[i].address; + u16 v = cheatsList[i].value & 0xffff; + u32 end = addr + ((cheatsList[i].value >> 16) << 1); + do { + CPUWriteHalfWord(addr, v); + addr+=2; + } while (addr <= end); + } + break; + case GSA_8_BIT_IF_TRUE2: + if(CPUReadByte(cheatsList[i].address) != cheatsList[i].value) { + i+=2; + } + break; + case GSA_16_BIT_IF_TRUE2: + if(CPUReadHalfWord(cheatsList[i].address) != cheatsList[i].value) { + i+=2; + } + break; + case GSA_32_BIT_IF_TRUE2: + if(CPUReadMemory(cheatsList[i].address) != cheatsList[i].value) { + i+=2; + } + break; + case GSA_8_BIT_IF_FALSE2: + if(CPUReadByte(cheatsList[i].address) == cheatsList[i].value) { + i+=2; + } + break; + case GSA_16_BIT_IF_FALSE2: + if(CPUReadHalfWord(cheatsList[i].address) == cheatsList[i].value) { + i+=2; + } + break; + case GSA_32_BIT_IF_FALSE2: + if(CPUReadMemory(cheatsList[i].address) == cheatsList[i].value) { + i+=2; + } + break; + case GSA_SLOWDOWN: + // check if button was pressed and released, if so toggle our state + if((cheatsList[i].status & 4) && !(extended & 4)) + cheatsList[i].status ^= 1; + if(extended & 4) + cheatsList[i].status |= 4; + else + cheatsList[i].status &= ~4; + + if(cheatsList[i].status & 1) + ticks += 2*256*((cheatsList[i].value >> 8) & 255); + break; + case CBA_ADD: + CPUWriteHalfWord(cheatsList[i].address, + CPUReadHalfWord(cheatsList[i].address) + + (u16)cheatsList[i].value); + break; + case CBA_OR: + CPUWriteHalfWord(cheatsList[i].address, + CPUReadHalfWord(cheatsList[i].address) | + cheatsList[i].value); + break; + case CBA_LT: + if(CPUReadHalfWord(cheatsList[i].address) >= cheatsList[i].value) + i++; + break; + case CBA_GT: + if(CPUReadHalfWord(cheatsList[i].address) <= cheatsList[i].value) + i++; + break; + case CBA_SUPER: + { + int count = 2*cheatsList[i].value; + u32 address = cheatsList[i].address; + for(int x = 0; x < count; x++) { + u8 b; + int res = x % 6; + if(res < 4) + b = (cheatsList[i].address >> (24-8*res)) & 0xFF; + else + b = (cheatsList[i].value >> (8 - 8*(res-4))) & 0x0FF; + CPUWriteByte(address, b); + address++; + if(x && !res) + i++; + } + if(count % 6) + i++; + } + break; + } + } + return ticks; +} + +void cheatsAdd(const char *codeStr, + const char *desc, + u32 address, + u32 value, + int code, + int size) +{ + if(cheatsNumber < 100) { + int x = cheatsNumber; + cheatsList[x].code = code; + cheatsList[x].size = size; + cheatsList[x].address = address; + cheatsList[x].value = value; + strcpy(cheatsList[x].codestring, codeStr); + strcpy(cheatsList[x].desc, desc); + cheatsList[x].enabled = true; + cheatsList[x].status = 0; + + // we only store the old value for this simple codes. ROM patching + // is taken care when it actually patches the ROM + switch(cheatsList[x].size) { + case INT_8_BIT_WRITE: + cheatsList[x].oldValue = CPUReadByte(address); + break; + case INT_16_BIT_WRITE: + cheatsList[x].oldValue = CPUReadHalfWord(address); + break; + case INT_32_BIT_WRITE: + cheatsList[x].oldValue = CPUReadMemory(address); + break; + } + cheatsNumber++; + } +} + +void cheatsDelete(int number, bool restore) +{ + if(number < cheatsNumber && number >= 0) { + int x = number; + + if(restore) { + switch(cheatsList[x].size) { + case INT_8_BIT_WRITE: + CPUWriteByte(cheatsList[x].address, (u8)cheatsList[x].oldValue); + break; + case INT_16_BIT_WRITE: + CPUWriteHalfWord(cheatsList[x].address, (u16)cheatsList[x].oldValue); + break; + case INT_32_BIT_WRITE: + CPUWriteMemory(cheatsList[x].address, cheatsList[x].oldValue); + break; + case GSA_16_BIT_ROM_PATCH: + if(cheatsList[x].status & 1) { + cheatsList[x].status &= ~1; + CHEAT_PATCH_ROM_16BIT(cheatsList[x].address, + cheatsList[x].oldValue); + } + break; + case GSA_16_BIT_ROM_PATCH2: + if(cheatsList[x].status & 1) { + cheatsList[x].status &= ~1; + CHEAT_PATCH_ROM_16BIT(((cheatsList[x].value & 0x00FFFFFF) << 1)+ + 0x8000000, + cheatsList[x].oldValue); + } + break; + } + } + if((x+1) < cheatsNumber) { + memcpy(&cheatsList[x], &cheatsList[x+1], sizeof(CheatsData)* + (cheatsNumber-x-1)); + } + cheatsNumber--; + } +} + +void cheatsDeleteAll(bool restore) +{ + for(int i = cheatsNumber-1; i >= 0; i--) { + cheatsDelete(i, restore); + } +} + +void cheatsEnable(int i) +{ + if(i >= 0 && i < cheatsNumber) { + cheatsList[i].enabled = true; + } +} + +void cheatsDisable(int i) +{ + if(i >= 0 && i < cheatsNumber) { + switch(cheatsList[i].size) { + case GSA_16_BIT_ROM_PATCH: + if(cheatsList[i].status & 1) { + cheatsList[i].status &= ~1; + CHEAT_PATCH_ROM_16BIT(cheatsList[i].address, + cheatsList[i].oldValue); + } + break; + case GSA_16_BIT_ROM_PATCH2: + if(cheatsList[i].status & 1) { + cheatsList[i].status &= ~1; + CHEAT_PATCH_ROM_16BIT(((cheatsList[i].value & 0x00FFFFFF) << 1)+ + 0x8000000, + cheatsList[i].oldValue); + } + break; + } + cheatsList[i].enabled = false; + } +} + +bool cheatsVerifyCheatCode(const char *code, const char *desc) +{ + int len = strlen(code); + if(len != 11 && len != 13 && len != 17) { + systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code); + return false; + } + + if(code[8] != ':') { + systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code); + return false; + } + + int i; + for(i = 0; i < 8; i++) { + if(!CHEAT_IS_HEX(code[i])) { + // wrong cheat + systemMessage(MSG_INVALID_CHEAT_CODE, + N_("Invalid cheat code '%s'"), code); + return false; + } + } + for(i = 9; i < len; i++) { + if(!CHEAT_IS_HEX(code[i])) { + // wrong cheat + systemMessage(MSG_INVALID_CHEAT_CODE, + N_("Invalid cheat code '%s'"), code); + return false; + } + } + + u32 address = 0; + u32 value = 0; + + char buffer[10]; + strncpy(buffer, code, 8); + buffer[8] = 0; + sscanf(buffer, "%x", &address); + + switch(address >> 24) { + case 2: + case 3: + break; + default: + systemMessage(MSG_INVALID_CHEAT_CODE_ADDRESS, + N_("Invalid cheat code address: %08x"), + address); + return false; + } + + strncpy(buffer, &code[9], 8); + sscanf(buffer, "%x", &value); + int type = 0; + if(len == 13) + type = 1; + if(len == 17) + type = 2; + cheatsAdd(code, desc, address, value, type, type); + return true; +} + +void cheatsAddCheatCode(const char *code, const char *desc) +{ + cheatsVerifyCheatCode(code, desc); +} + +void cheatsDecryptGSACode(u32& address, u32& value, bool v3) +{ + u32 rollingseed = 0xC6EF3720; + u32 seeds_v1[] = { 0x09F4FBBD, 0x9681884A, 0x352027E9, 0xF3DEE5A7 }; + u32 seeds_v3[] = { 0x7AA9648F, 0x7FAE6994, 0xC0EFAAD5, 0x42712C57 }; + u32 *seeds = v3 ? seeds_v3 : seeds_v1; + + int bitsleft = 32; + while (bitsleft > 0) { + value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^ + ((address >> 5) + seeds[3])); + address -= ((((value << 4) + seeds[0]) ^ (value + rollingseed)) ^ + ((value >> 5) + seeds[1])); + rollingseed -= 0x9E3779B9; + bitsleft--; + } +} + +void cheatsAddGSACode(const char *code, const char *desc, bool v3) +{ + if(strlen(code) != 16) { + // wrong cheat + systemMessage(MSG_INVALID_GSA_CODE, + N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY")); + return; + } + + int i; + for(i = 0; i < 16; i++) { + if(!CHEAT_IS_HEX(code[i])) { + // wrong cheat + systemMessage(MSG_INVALID_GSA_CODE, + N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY")); + return; + } + } + + char buffer[10]; + strncpy(buffer, code, 8); + buffer[8] = 0; + u32 address; + sscanf(buffer, "%x", &address); + strncpy(buffer, &code[8], 8); + buffer[8] = 0; + u32 value; + sscanf(buffer, "%x", &value); + + cheatsDecryptGSACode(address, value, v3); + + if(value == 0x1DC0DE) { + u32 gamecode = READ32LE(((u32 *)&rom[0xac])); + if(gamecode != address) { + char buffer[5]; + *((u32 *)buffer) = address; + buffer[4] = 0; + char buffer2[5]; + *((u32 *)buffer2) = READ32LE(((u32 *)&rom[0xac])); + buffer2[4] = 0; + systemMessage(MSG_GBA_CODE_WARNING, N_("Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly."), + buffer, buffer2); + } + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, v3 ? 257 : 256, + UNKNOWN_CODE); + return; + } + if(isMultilineWithData(cheatsNumber-1)) { + cheatsAdd(code, desc, address, value, v3 ? 257 : 256, UNKNOWN_CODE); + return; + } + if(v3) { + int type = (address >> 25) & 127; + u32 addr = (address & 0x00F00000) << 4 | (address & 0x0003FFFF); + switch(type) { + case 0x00: + if(address == 0) { + type = (value >> 25) & 127; + addr = (value & 0x00F00000) << 4 | (value & 0x0003FFFF); + switch(type) { + case 0x04: + cheatsAdd(code, desc, 0, value & 0x00FFFFFF, 257, GSA_SLOWDOWN); + break; + case 0x08: + cheatsAdd(code, desc, 0, addr, 257, GSA_8_BIT_GS_WRITE2); + break; + case 0x09: + cheatsAdd(code, desc, 0, addr, 257, GSA_16_BIT_GS_WRITE2); + break; + case 0x0a: + cheatsAdd(code, desc, 0, addr, 257, GSA_32_BIT_GS_WRITE2); + break; + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + cheatsAdd(code, desc, 0, value & 0x00FFFFFF, 257, GSA_16_BIT_ROM_PATCH2); + break; + case 0x40: + cheatsAdd(code, desc, 0, addr, 257, GSA_8_BIT_SLIDE); + break; + case 0x41: + cheatsAdd(code, desc, 0, addr, 257, GSA_16_BIT_SLIDE); + break; + case 0x42: + cheatsAdd(code, desc, 0, addr, 257, GSA_32_BIT_SLIDE); + break; + default: + cheatsAdd(code, desc, address, value, 257, UNKNOWN_CODE); + break; + } + } else + cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_FILL); + break; + case 0x01: + cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_FILL); + break; + case 0x02: + cheatsAdd(code, desc, addr, value, 257, INT_32_BIT_WRITE); + break; + case 0x04: + cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_TRUE); + break; + case 0x05: + cheatsAdd(code, desc, addr, value, 257, CBA_IF_TRUE); + break; + case 0x06: + cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_TRUE); + break; + case 0x08: + cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_FALSE); + break; + case 0x09: + cheatsAdd(code, desc, addr, value, 257, CBA_IF_FALSE); + break; + case 0x0a: + cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_FALSE); + break; + case 0x24: + cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_TRUE2); + break; + case 0x25: + cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_IF_TRUE2); + break; + case 0x26: + cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_TRUE2); + break; + case 0x28: + cheatsAdd(code, desc, addr, value, 257, GSA_8_BIT_IF_FALSE2); + break; + case 0x29: + cheatsAdd(code, desc, addr, value, 257, GSA_16_BIT_IF_FALSE2); + break; + case 0x2a: + cheatsAdd(code, desc, addr, value, 257, GSA_32_BIT_IF_FALSE2); + break; + default: + cheatsAdd(code, desc, address, value, 257, UNKNOWN_CODE); + break; + } + } else { + int type = (address >> 28) & 15; + switch(type) { + case 0: + case 1: + case 2: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256, type); + break; + case 6: + address <<= 1; + type = (address >> 28) & 15; + if(type == 0x0c) { + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256, + GSA_16_BIT_ROM_PATCH); + break; + } + // unsupported code + cheatsAdd(code, desc, address, value, 256, + UNKNOWN_CODE); + break; + case 8: + switch((address >> 20) & 15) { + case 1: + cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256, + GSA_8_BIT_GS_WRITE); + break; + case 2: + cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256, + GSA_16_BIT_GS_WRITE); + break; + case 3: + cheatsAdd(code, desc, address & 0x0F0FFFFF, value, 256, + GSA_32_BIT_GS_WRITE); + case 15: + cheatsAdd(code, desc, 0, value & 0xFF00, 256, GSA_SLOWDOWN); + break; + default: + // unsupported code + cheatsAdd(code, desc, address, value, 256, + UNKNOWN_CODE); + break; + } + break; + case 0x0d: + if(address != 0xDEADFACE) { + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 256, + CBA_IF_TRUE); + } else + cheatsAdd(code, desc, address, value, 256, + UNKNOWN_CODE); + break; + default: + // unsupported code + cheatsAdd(code, desc, address, value, 256, + UNKNOWN_CODE); + break; + } + } +} + +bool cheatsImportGSACodeFile(const char *name, int game, bool v3) +{ + FILE *f = fopen(name, "rb"); + if(!f) + return false; + + int games = 0; + int len = 0; + fseek(f, 0x1e, SEEK_CUR); + fread(&games, 1, 4, f); + bool found = false; + int g = 0; + while(games > 0) { + if(g == game) { + found = true; + break; + } + fread(&len, 1, 4, f); + fseek(f,len,SEEK_CUR); + int codes = 0; + fread(&codes, 1, 4, f); + while(codes > 0) { + fread(&len, 1, 4, f); + fseek(f, len, SEEK_CUR); + fseek(f, 8, SEEK_CUR); + fread(&len, 1, 4, f); + fseek(f, len*12, SEEK_CUR); + codes--; + } + games--; + g++; + } + if(found) { + char desc[256]; + char code[17]; + fread(&len, 1, 4, f); + fseek(f, len, SEEK_CUR); + int codes = 0; + fread(&codes, 1, 4, f); + while(codes > 0) { + fread(&len, 1, 4, f); + fread(desc, 1, len, f); + desc[len] =0; + desc[31] = 0; + fread(&len, 1, 4, f); + fseek(f, len, SEEK_CUR); + fseek(f, 4, SEEK_CUR); + fread(&len, 1, 4, f); + while(len) { + fseek(f, 4, SEEK_CUR); + fread(code, 1, 8, f); + fseek(f, 4, SEEK_CUR); + fread(&code[8], 1, 8, f); + code[16] = 0; + cheatsAddGSACode(code, desc, v3); + len -= 2; + } + codes--; + } + } + fclose(f); + return false; +} + +void cheatsCBAReverseArray(u8 *array, u8 *dest) +{ + dest[0] = array[3]; + dest[1] = array[2]; + dest[2] = array[1]; + dest[3] = array[0]; + dest[4] = array[5]; + dest[5] = array[4]; +} + +void chatsCBAScramble(u8 *array, int count, u8 b) +{ + u8 *x = array + (count >> 3); + u8 *y = array + (b >> 3); + u32 z = *x & (1 << (count & 7)); + u32 x0 = (*x & (~(1 << (count & 7)))); + if (z != 0) + z = 1; + if ((*y & (1 << (b & 7))) != 0) + x0 |= (1 << (count & 7)); + *x = x0; + u32 temp = *y & (~(1 << (b & 7))); + if (z != 0) + temp |= (1 << (b & 7)); + *y = temp; +} + +u32 cheatsCBAGetValue(u8 *array) +{ + return array[0] | array[1]<<8 | array[2] << 16 | array[3]<<24; +} + +u16 cheatsCBAGetData(u8 *array) +{ + return array[4] | array[5]<<8; +} + +void cheatsCBAArrayToValue(u8 *array, u8 *dest) +{ + dest[0] = array[3]; + dest[1] = array[2]; + dest[2] = array[1]; + dest[3] = array[0]; + dest[4] = array[5]; + dest[5] = array[4]; +} + +void cheatsCBAParseSeedCode(u32 address, u32 value, u32 *array) +{ + array[0] = 1; + array[1] = value & 0xFF; + array[2] = (address >> 0x10) & 0xFF; + array[3] = (value >> 8) & 0xFF; + array[4] = (address >> 0x18) & 0x0F; + array[5] = address & 0xFFFF; + array[6] = address; + array[7] = value; +} + +u32 cheatsCBAEncWorker() +{ + u32 x = (cheatsCBATemporaryValue * 0x41c64e6d) + 0x3039; + u32 y = (x * 0x41c64e6d) + 0x3039; + u32 z = x >> 0x10; + x = ((y >> 0x10) & 0x7fff) << 0x0f; + z = (z << 0x1e) | x; + x = (y * 0x41c64e6d) + 0x3039; + cheatsCBATemporaryValue = x; + return z | ((x >> 0x10) & 0x7fff); +} + +#define ROR(v, s) \ + (((v) >> (s)) | (((v) & ((1 << (s))-1)) << (32 - (s)))) + +u32 cheatsCBACalcIndex(u32 x, u32 y) +{ + if(y != 0) { + if(y == 1) + x = 0; + else if(x == y) + x = 0; + if(y < 1) + return x; + else if(x < y) + return x; + u32 x0 = 1; + + while(y < 0x10000000) { + if(y < x) { + y = y << 4; + x0 = x0 << 4; + } else break; + } + + while(y < 0x80000000) { + if(y < x) { + y = y << 1; + x0 = x0 << 1; + } else break; + } + + loop: + u32 z = 0; + if(x >= y) + x -= y; + if(x >= (y >> 1)) { + x -= (y >> 1); + z |= ROR(x0, 1); + } + if(x >= (y >> 2)) { + x -= (y >> 2); + z |= ROR(x0, 2); + } + if(x >= (y >> 3)) { + x -= (y >> 3); + z |= ROR(x0, 3); + } + + u32 temp = x0; + + if(x != 0) { + x0 = x0 >> 4; + if(x0 != 0) { + y = y >> 4; + goto loop; + } + } + + z = z & 0xe0000000; + + if(z != 0) { + if((temp & 7) == 0) + return x; + } else + return x; + + if((z & ROR(temp, 3)) != 0) + x += y >> 3; + if((z & ROR(temp, 2)) != 0) + x += y >> 2; + if((z & ROR(temp, 1)) != 0) + x += y >> 1; + return x; + } else { + } + // should not happen in the current code + return 0; +} + +void cheatsCBAUpdateSeedBuffer(u32 a, u8 *buffer, int count) +{ + int i; + for(i = 0; i < count; i++) + buffer[i] = i; + for(i = 0; (u32)i < a; i++) { + u32 a = cheatsCBACalcIndex(cheatsCBAEncWorker(), count); + u32 b = cheatsCBACalcIndex(cheatsCBAEncWorker(), count); + u32 t = buffer[a]; + buffer[a] = buffer[b]; + buffer[b] = t; + } +} + +void cheatsCBAChangeEncryption(u32 *seed) +{ + int i; + + cheatsCBATemporaryValue = (seed[1] ^ 0x1111); + cheatsCBAUpdateSeedBuffer(0x50, cheatsCBASeedBuffer, 0x30); + cheatsCBATemporaryValue = 0x4efad1c3; + + for(i = 0; (u32)i < seed[4]; i++) { + cheatsCBATemporaryValue = cheatsCBAEncWorker(); + } + cheatsCBASeed[2] = cheatsCBAEncWorker(); + cheatsCBASeed[3] = cheatsCBAEncWorker(); + + cheatsCBATemporaryValue = seed[3] ^ 0xf254; + + for(i = 0; (u32)i < seed[3]; i++) { + cheatsCBATemporaryValue = cheatsCBAEncWorker(); + } + + cheatsCBASeed[0] = cheatsCBAEncWorker(); + cheatsCBASeed[1] = cheatsCBAEncWorker(); + + *((u32 *)&cheatsCBACurrentSeed[0]) = seed[6]; + *((u32 *)&cheatsCBACurrentSeed[4]) = seed[7]; + *((u32 *)&cheatsCBACurrentSeed[8]) = 0; +} + +u16 cheatsCBAGenValue(u32 x, u32 y, u32 z) +{ + y <<= 0x10; + z <<= 0x10; + x <<= 0x18; + u32 x0 = (int)y >> 0x10; + z = (int)z >> 0x10; + x = (int)x >> 0x10; + for(int i = 0; i < 8; i++) { + u32 temp = z ^ x; + if ((int)temp >= 0) { + temp = z << 0x11; + } + else { + temp = z << 0x01; + temp ^= x0; + temp = temp << 0x10; + } + z = (int)temp >> 0x10; + temp = x << 0x11; + x = (int)temp >> 0x10; + } + return z & 0xffff; +} + +void cheatsCBAGenTable() { + for (int i = 0; i < 0x100; i++) { + cheatsCBATable[i] = cheatsCBAGenValue(i, 0x1021, 0); + } + cheatsCBATableGenerated = true; +} + +u16 cheatsCBACalcCRC(u8 *rom, int count) +{ + u32 crc = 0xffffffff; + + if (count & 3) { + // 0x08000EAE + } else { + count = (count >> 2) - 1; + if(count != -1) { + while(count != -1) { + crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18) + ^ *rom++]) << 0x10) >> 0x10; + crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18) + ^ *rom++]) << 0x10) >> 0x10; + crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18) + ^ *rom++]) << 0x10) >> 0x10; + crc = (((crc << 0x08) ^ cheatsCBATable[(((u32)crc << 0x10) >> 0x18) + ^ *rom++]) << 0x10) >> 0x10; + count--; + } + } + } + return crc & 0xffff; +} + +void cheatsCBADecrypt(u8 *decrypt) +{ + u8 buffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + u8 *array = &buffer[1]; + + cheatsCBAReverseArray(decrypt, array); + + for(int count = 0x2f; count >= 0; count--) { + chatsCBAScramble(array, count, cheatsCBASeedBuffer[count]); + } + cheatsCBAArrayToValue(array, decrypt); + *((u32 *)decrypt) = cheatsCBAGetValue(decrypt) ^ + cheatsCBASeed[0]; + *((u16 *)(decrypt+4)) = (cheatsCBAGetData(decrypt) ^ + cheatsCBASeed[1]) & 0xffff; + + cheatsCBAReverseArray(decrypt, array); + + u32 cs = cheatsCBAGetValue(cheatsCBACurrentSeed); + for(int i = 0; i <= 4; i++) { + array[i] = ((cs >> 8) ^ array[i+1]) ^ array[i] ; + } + + array[5] = (cs >> 8) ^ array[5]; + + for(int j = 5; j >=0; j--) { + array[j] = (cs ^ array[j-1]) ^ array[j]; + } + + cheatsCBAArrayToValue(array, decrypt); + + *((u32 *)decrypt) = cheatsCBAGetValue(decrypt) + ^ cheatsCBASeed[2]; + *((u16 *)(decrypt+4)) = (cheatsCBAGetData(decrypt) + ^ cheatsCBASeed[3]) & 0xffff; +} + +int cheatsCBAGetCount() +{ + int count = 0; + for(int i = 0; i < cheatsNumber; i++) { + if(cheatsList[i].code == 512) + count++; + } + return count; +} + +bool cheatsCBAShouldDecrypt() +{ + for(int i = 0; i < cheatsNumber; i++) { + if(cheatsList[i].code == 512) { + return (cheatsList[i].codestring[0] == '9'); + } + } + return false; +} + +void cheatsAddCBACode(const char *code, const char *desc) +{ + if(strlen(code) != 13) { + // wrong cheat + systemMessage(MSG_INVALID_CBA_CODE, + N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); + return; + } + + int i; + for(i = 0; i < 8; i++) { + if(!CHEAT_IS_HEX(code[i])) { + // wrong cheat + systemMessage(MSG_INVALID_CBA_CODE, + N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); + return; + } + } + + if(code[8] != ' ') { + systemMessage(MSG_INVALID_CBA_CODE, + N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); + return; + } + + for(i = 9; i < 13; i++) { + if(!CHEAT_IS_HEX(code[i])) { + // wrong cheat + systemMessage(MSG_INVALID_CBA_CODE, + N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); + return; + } + } + + char buffer[10]; + strncpy(buffer, code, 8); + buffer[8] = 0; + u32 address; + sscanf(buffer, "%x", &address); + strncpy(buffer, &code[9], 4); + buffer[4] = 0; + u32 value; + sscanf(buffer, "%x", &value); + + u8 array[8] = { + address & 255, + (address >> 8) & 255, + (address >> 16) & 255, + (address >> 24) & 255, + (value & 255), + (value >> 8) & 255, + 0, + 0 + }; + + if(cheatsCBAGetCount() == 0 && + (address >> 28) == 9) { + u32 seed[8]; + cheatsCBAParseSeedCode(address, value, seed); + cheatsCBAChangeEncryption(seed); + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, UNKNOWN_CODE); + } else { + if(cheatsCBAShouldDecrypt()) + cheatsCBADecrypt(array); + + address = READ32LE(((u32 *)array)); + value = READ16LE(((u16 *)&array[4])); + + int type = (address >> 28) & 15; + + if(isMultilineWithData(cheatsNumber-1)) { + cheatsAdd(code, desc, address, value, 512, UNKNOWN_CODE); + return; + } + + switch(type) { + case 0x00: + { + if(!cheatsCBATableGenerated) + cheatsCBAGenTable(); + u32 crc = cheatsCBACalcCRC(rom, 0x10000); + if(crc != address) { + systemMessage(MSG_CBA_CODE_WARNING, + N_("Warning: Codes seem to be for a different game.\nCodes may not work correctly.")); + } + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + UNKNOWN_CODE); + } + break; + case 0x02: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_OR); + break; + case 0x03: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + INT_8_BIT_WRITE); + break; + case 0x04: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_SLIDE_CODE); + break; + case 0x05: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_SUPER); + break; + case 0x06: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_AND); + break; + case 0x07: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_IF_TRUE); + break; + case 0x08: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + INT_16_BIT_WRITE); + break; + case 0x0a: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_IF_FALSE); + break; + case 0x0b: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_LT); + break; + case 0x0c: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_GT); + break; + case 0x0d: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_IF_KEYS_PRESSED); + break; + case 0x0e: + cheatsAdd(code, desc, address & 0x0FFFFFFF, value, 512, + CBA_ADD); + break; + default: + // unsupported code + cheatsAdd(code, desc, address & 0xFFFFFFFF, value, 512, + UNKNOWN_CODE); + break; + } + } +} + +void cheatsSaveGame(gzFile file) +{ + utilWriteInt(file, cheatsNumber); + + utilGzWrite(file, cheatsList, sizeof(cheatsList)); +} + +void cheatsReadGame(gzFile file) +{ + cheatsNumber = 0; + + cheatsNumber = utilReadInt(file); + + utilGzRead(file, cheatsList, sizeof(cheatsList)); + + bool firstCodeBreaker = true; + + for(int i = 0; i < cheatsNumber; i++) { + cheatsList[i].status = 0; + if(!cheatsList[i].codestring[0]) { + switch(cheatsList[i].size) { + case 0: + sprintf(cheatsList[i].codestring, "%08x:%02x", cheatsList[i].address, + cheatsList[i].value); + break; + case 1: + sprintf(cheatsList[i].codestring, "%08x:%04x", cheatsList[i].address, + cheatsList[i].value); + break; + case 2: + sprintf(cheatsList[i].codestring, "%08x:%08x", cheatsList[i].address, + cheatsList[i].value); + break; + } + } + + if(cheatsList[i].enabled) { + cheatsEnable(i); + } + + if(cheatsList[i].code == 512 && firstCodeBreaker) { + firstCodeBreaker = false; + char buffer[10]; + strncpy(buffer, cheatsList[i].codestring, 8); + buffer[8] = 0; + u32 address; + sscanf(buffer, "%x", &address); + if((address >> 28) == 9) { + strncpy(buffer, &cheatsList[i].codestring[9], 4); + buffer[4] = 0; + u32 value; + sscanf(buffer, "%x", &value); + + u32 seed[8]; + cheatsCBAParseSeedCode(address, value, seed); + cheatsCBAChangeEncryption(seed); + } + } + } +} + +void cheatsSaveCheatList(const char *file) +{ + if(cheatsNumber == 0) + return; + FILE *f = fopen(file, "wb"); + if(f == NULL) + return; + int version = 1; + fwrite(&version, 1, sizeof(version), f); + int type = 0; + fwrite(&type, 1, sizeof(type), f); + fwrite(&cheatsNumber, 1, sizeof(cheatsNumber), f); + fwrite(cheatsList, 1, sizeof(cheatsList), f); + fclose(f); +} + +bool cheatsLoadCheatList(const char *file) +{ + cheatsNumber = 0; + + int count = 0; + + FILE *f = fopen(file, "rb"); + + if(f == NULL) + return false; + + int version = 0; + + if(fread(&version, 1, sizeof(version), f) != sizeof(version)) { + fclose(f); + return false; + } + + if(version != 1) { + systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION, + N_("Unsupported cheat list version %d"), version); + fclose(f); + return false; + } + + int type = 0; + if(fread(&type, 1, sizeof(type), f) != sizeof(type)) { + fclose(f); + return false; + } + + if(type != 0) { + systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE, + N_("Unsupported cheat list type %d"), type); + fclose(f); + return false; + } + + if(fread(&count, 1, sizeof(count), f) != sizeof(count)) { + fclose(f); + return false; + } + + if(fread(cheatsList, 1, sizeof(cheatsList), f) != sizeof(cheatsList)) { + fclose(f); + return false; + } + + bool firstCodeBreaker = true; + + for(int i = 0; i < count; i++) { + cheatsList[i].status = 0; // remove old status as it is not used + if(!cheatsList[i].codestring[0]) { + switch(cheatsList[i].size) { + case 0: + sprintf(cheatsList[i].codestring, "%08x:%02x", cheatsList[i].address, + cheatsList[i].value); + break; + case 1: + sprintf(cheatsList[i].codestring, "%08x:%04x", cheatsList[i].address, + cheatsList[i].value); + break; + case 2: + sprintf(cheatsList[i].codestring, "%08x:%08x", cheatsList[i].address, + cheatsList[i].value); + break; + } + } + + if(cheatsList[i].code == 512 && firstCodeBreaker) { + firstCodeBreaker = false; + char buffer[10]; + strncpy(buffer, cheatsList[i].codestring, 8); + buffer[8] = 0; + u32 address; + sscanf(buffer, "%x", &address); + if((address >> 28) == 9) { + strncpy(buffer, &cheatsList[i].codestring[9], 4); + buffer[4] = 0; + u32 value; + sscanf(buffer, "%x", &value); + + u32 seed[8]; + cheatsCBAParseSeedCode(address, value, seed); + cheatsCBAChangeEncryption(seed); + } + } + } + cheatsNumber = count; + fclose(f); + return true; +} + +extern int *extCpuLoopTicks; +extern int *extClockTicks; +extern int *extTicks; +extern int cpuSavedTicks; + +extern void debuggerBreakOnWrite(u32 *, u32, u32, int); + +#define CPU_BREAK_LOOP \ + cpuSavedTicks = cpuSavedTicks - *extCpuLoopTicks;\ + *extCpuLoopTicks = *extClockTicks;\ + *extTicks = *extClockTicks; + +void cheatsWriteMemory(u32 *address, u32 value, u32 mask) +{ +#ifdef BKPT_SUPPORT +#ifdef SDL + if(cheatsNumber == 0) { + debuggerBreakOnWrite(address, *address, value, 2); + CPU_BREAK_LOOP; + *address = value; + return; + } +#endif +#endif +} + +void cheatsWriteHalfWord(u16 *address, u16 value, u16 mask) +{ +#ifdef BKPT_SUPPORT +#ifdef SDL + if(cheatsNumber == 0) { + debuggerBreakOnWrite((u32 *)address, *address, value, 1); + CPU_BREAK_LOOP; + *address = value; + return; + } +#endif +#endif +} + +#if defined BKPT_SUPPORT && defined SDL +void cheatsWriteByte(u8 *address, u8 value) +#else +void cheatsWriteByte(u8 *, u8) +#endif +{ +#ifdef BKPT_SUPPORT +#ifdef SDL + if(cheatsNumber == 0) { + debuggerBreakOnWrite((u32 *)address, *address, value, 0); + CPU_BREAK_LOOP; + *address = value; + return; + } +#endif +#endif +} diff --git a/src/Cheats.h b/src/Cheats.h new file mode 100644 index 0000000..f689349 --- /dev/null +++ b/src/Cheats.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef GBA_CHEATS_H +#define GBA_CHEATS_H + +struct CheatsData { + int code; + int size; + int status; + bool enabled; + u32 address; + u32 value; + u32 oldValue; + char codestring[20]; + char desc[32]; +}; + +extern void cheatsAdd(const char *,const char *,u32,u32,int,int); +extern void cheatsAddCheatCode(const char *code, const char *desc); +extern void cheatsAddGSACode(const char *code, const char *desc, bool v3); +extern void cheatsAddCBACode(const char *code, const char *desc); +extern bool cheatsImportGSACodeFile(const char *name, int game, bool v3); +extern void cheatsDelete(int number, bool restore); +extern void cheatsDeleteAll(bool restore); +extern void cheatsEnable(int number); +extern void cheatsDisable(int number); +extern void cheatsSaveGame(gzFile file); +extern void cheatsReadGame(gzFile file); +extern void cheatsSaveCheatList(const char *file); +extern bool cheatsLoadCheatList(const char *file); +extern void cheatsWriteMemory(u32 *, u32, u32); +extern void cheatsWriteHalfWord(u16 *, u16, u16); +extern void cheatsWriteByte(u8 *, u8); +extern int cheatsCheckKeys(u32,u32); +extern int cheatsNumber; +extern CheatsData cheatsList[100]; +#endif // GBA_CHEATS_H diff --git a/src/EEprom.cpp b/src/EEprom.cpp new file mode 100644 index 0000000..f002956 --- /dev/null +++ b/src/EEprom.cpp @@ -0,0 +1,206 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "EEprom.h" +#include "Util.h" +#include + +extern int cpuDmaCount; + +int eepromMode = EEPROM_IDLE; +int eepromByte = 0; +int eepromBits = 0; +int eepromAddress = 0; +u8 eepromData[0x2000]; +u8 eepromBuffer[16]; +bool eepromInUse = false; +int eepromSize = 512; + +variable_desc eepromSaveData[] = { + { &eepromMode, sizeof(int) }, + { &eepromByte, sizeof(int) }, + { &eepromBits , sizeof(int) }, + { &eepromAddress , sizeof(int) }, + { &eepromInUse, sizeof(bool) }, + { &eepromData[0], 512 }, + { &eepromBuffer[0], 16 }, + { NULL, 0 } +}; + +void eepromReset() +{ + eepromMode = EEPROM_IDLE; + eepromByte = 0; + eepromBits = 0; + eepromAddress = 0; + eepromInUse = false; + eepromSize = 512; +} + +void eepromErase() +{ + memset(eepromData, 0, 0x2000*sizeof(u8)); + eepromMode = EEPROM_IDLE; + eepromByte = 0; + eepromBits = 0; + eepromAddress = 0; + eepromData[0x2000]; + memset(eepromBuffer, 0, 16*sizeof(u8)); + eepromInUse = false; + eepromSize = 512; + +} + +void eepromSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, eepromSaveData); + utilWriteInt(gzFile, eepromSize); + utilGzWrite(gzFile, eepromData, 0x2000); +} + +void eepromReadGame(gzFile gzFile, int version) +{ + utilReadData(gzFile, eepromSaveData); + if(version >= SAVE_GAME_VERSION_3) { + eepromSize = utilReadInt(gzFile); + utilGzRead(gzFile, eepromData, 0x2000); + } else { + // prior to 0.7.1, only 4K EEPROM was supported + eepromSize = 512; + } +} + + +int eepromRead(u32 /* address */) +{ + switch(eepromMode) { + case EEPROM_IDLE: + case EEPROM_READADDRESS: + case EEPROM_WRITEDATA: + return 1; + case EEPROM_READDATA: + { + eepromBits++; + if(eepromBits == 4) { + eepromMode = EEPROM_READDATA2; + eepromBits = 0; + eepromByte = 0; + } + return 0; + } + case EEPROM_READDATA2: + { + int data = 0; + int address = eepromAddress << 3; + int mask = 1 << (7 - (eepromBits & 7)); + data = (eepromData[address+eepromByte] & mask) ? 1 : 0; + eepromBits++; + if((eepromBits & 7) == 0) + eepromByte++; + if(eepromBits == 0x40) + eepromMode = EEPROM_IDLE; + return data; + } + default: + return 0; + } + return 1; +} + +void eepromWrite(u32 /* address */, u8 value) +{ + if(cpuDmaCount == 0) + return; + int bit = value & 1; + switch(eepromMode) { + case EEPROM_IDLE: + eepromByte = 0; + eepromBits = 1; + eepromBuffer[eepromByte] = bit; + eepromMode = EEPROM_READADDRESS; + break; + case EEPROM_READADDRESS: + eepromBuffer[eepromByte] <<= 1; + eepromBuffer[eepromByte] |= bit; + eepromBits++; + if((eepromBits & 7) == 0) { + eepromByte++; + } + if(cpuDmaCount == 0x11 || cpuDmaCount == 0x51) { + if(eepromBits == 0x11) { + eepromInUse = true; + eepromSize = 0x2000; + eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) | + ((eepromBuffer[1] & 0xFF)); + if(!(eepromBuffer[0] & 0x40)) { + eepromBuffer[0] = bit; + eepromBits = 1; + eepromByte = 0; + eepromMode = EEPROM_WRITEDATA; + } else { + eepromMode = EEPROM_READDATA; + eepromByte = 0; + eepromBits = 0; + } + } + } else { + if(eepromBits == 9) { + eepromInUse = true; + eepromAddress = (eepromBuffer[0] & 0x3F); + if(!(eepromBuffer[0] & 0x40)) { + eepromBuffer[0] = bit; + eepromBits = 1; + eepromByte = 0; + eepromMode = EEPROM_WRITEDATA; + } else { + eepromMode = EEPROM_READDATA; + eepromByte = 0; + eepromBits = 0; + } + } + } + break; + case EEPROM_READDATA: + case EEPROM_READDATA2: + // should we reset here? + eepromMode = EEPROM_IDLE; + break; + case EEPROM_WRITEDATA: + eepromBuffer[eepromByte] <<= 1; + eepromBuffer[eepromByte] |= bit; + eepromBits++; + if((eepromBits & 7) == 0) { + eepromByte++; + } + if(eepromBits == 0x40) { + eepromInUse = true; + // write data; + for(int i = 0; i < 8; i++) { + eepromData[(eepromAddress << 3) + i] = eepromBuffer[i]; + } + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } else if(eepromBits == 0x41) { + eepromMode = EEPROM_IDLE; + eepromByte = 0; + eepromBits = 0; + } + break; + } +} + diff --git a/src/EEprom.h b/src/EEprom.h new file mode 100644 index 0000000..d6c414c --- /dev/null +++ b/src/EEprom.h @@ -0,0 +1,39 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_EEPROM_H +#define VBA_EEPROM_H + +extern void eepromSaveGame(gzFile gzFile); +extern void eepromReadGame(gzFile gzFile, int version); +extern int eepromRead(u32 address); +extern void eepromWrite(u32 address, u8 value); +extern void eepromReset(); +extern void eepromErase(); +extern u8 eepromData[0x2000]; +extern bool eepromInUse; +extern int eepromSize; + +#define EEPROM_IDLE 0 +#define EEPROM_READADDRESS 1 +#define EEPROM_READDATA 2 +#define EEPROM_READDATA2 3 +#define EEPROM_WRITEDATA 4 + +#endif // VBA_EEPROM_H diff --git a/src/Flash.cpp b/src/Flash.cpp new file mode 100644 index 0000000..4ec23ee --- /dev/null +++ b/src/Flash.cpp @@ -0,0 +1,258 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include "GBA.h" +#include "Globals.h" +#include "Flash.h" +#include "Sram.h" +#include "Util.h" + +#define FLASH_READ_ARRAY 0 +#define FLASH_CMD_1 1 +#define FLASH_CMD_2 2 +#define FLASH_AUTOSELECT 3 +#define FLASH_CMD_3 4 +#define FLASH_CMD_4 5 +#define FLASH_CMD_5 6 +#define FLASH_ERASE_COMPLETE 7 +#define FLASH_PROGRAM 8 +#define FLASH_SETBANK 9 + +u8 flashSaveMemory[0x20000]; +int flashState = FLASH_READ_ARRAY; +int flashReadState = FLASH_READ_ARRAY; +int flashSize = 0x10000; +int flashDeviceID = 0x1b; +int flashManufacturerID = 0x32; +int flashBank = 0; + +static variable_desc flashSaveData[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSaveMemory[0], 0x10000 }, + { NULL, 0 } +}; + +static variable_desc flashSaveData2[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSize, sizeof(int) }, + { &flashSaveMemory[0], 0x20000 }, + { NULL, 0 } +}; + +static variable_desc flashSaveData3[] = { + { &flashState, sizeof(int) }, + { &flashReadState, sizeof(int) }, + { &flashSize, sizeof(int) }, + { &flashBank, sizeof(int) }, + { &flashSaveMemory[0], 0x20000 }, + { NULL, 0 } +}; + +void flashReset() +{ + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + flashBank = 0; +} + +void flashErase() +{ + memset(flashSaveMemory, 0, 0x20000*sizeof(u8)); + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + flashSize = 0x10000; + flashDeviceID = 0x1b; + flashManufacturerID = 0x32; + flashBank = 0; +} + +void flashSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, flashSaveData3); +} + +void flashReadGame(gzFile gzFile, int version) +{ + if(version < SAVE_GAME_VERSION_5) + utilReadData(gzFile, flashSaveData); + else if(version < SAVE_GAME_VERSION_7) { + utilReadData(gzFile, flashSaveData2); + flashBank = 0; + flashSetSize(flashSize); + } else { + utilReadData(gzFile, flashSaveData3); + } +} + +void flashSetSize(int size) +{ + // log("Setting flash size to %d\n", size); + flashSize = size; + if(size == 0x10000) { + flashDeviceID = 0x1b; + flashManufacturerID = 0x32; + } else { + flashDeviceID = 0x13; //0x09; + flashManufacturerID = 0x62; //0xc2; + } +} + +u8 flashRead(u32 address) +{ + // log("Reading %08x from %08x\n", address, reg[15].I); + // log("Current read state is %d\n", flashReadState); + address &= 0xFFFF; + + switch(flashReadState) { + case FLASH_READ_ARRAY: + return flashSaveMemory[(flashBank << 16) + address]; + case FLASH_AUTOSELECT: + switch(address & 0xFF) { + case 0: + // manufacturer ID + return flashManufacturerID; + case 1: + // device ID + return flashDeviceID; + } + break; + case FLASH_ERASE_COMPLETE: + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + return 0xFF; + }; + return 0; +} + +void flashSaveDecide(u32 address, u8 byte) +{ + // log("Deciding save type %08x\n", address); + if(address == 0x0e005555) { + saveType = 2; + cpuSaveGameFunc = flashWrite; + } else { + saveType = 1; + cpuSaveGameFunc = sramWrite; + } + + (*cpuSaveGameFunc)(address, byte); +} + +void flashWrite(u32 address, u8 byte) +{ + // log("Writing %02x at %08x\n", byte, address); + // log("Current state is %d\n", flashState); + address &= 0xFFFF; + switch(flashState) { + case FLASH_READ_ARRAY: + if(address == 0x5555 && byte == 0xAA) + flashState = FLASH_CMD_1; + break; + case FLASH_CMD_1: + if(address == 0x2AAA && byte == 0x55) + flashState = FLASH_CMD_2; + else + flashState = FLASH_READ_ARRAY; + break; + case FLASH_CMD_2: + if(address == 0x5555) { + if(byte == 0x90) { + flashState = FLASH_AUTOSELECT; + flashReadState = FLASH_AUTOSELECT; + } else if(byte == 0x80) { + flashState = FLASH_CMD_3; + } else if(byte == 0xF0) { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } else if(byte == 0xA0) { + flashState = FLASH_PROGRAM; + } else if(byte == 0xB0 && flashSize == 0x20000) { + flashState = FLASH_SETBANK; + } else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + } else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + break; + case FLASH_CMD_3: + if(address == 0x5555 && byte == 0xAA) { + flashState = FLASH_CMD_4; + } else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + break; + case FLASH_CMD_4: + if(address == 0x2AAA && byte == 0x55) { + flashState = FLASH_CMD_5; + } else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + break; + case FLASH_CMD_5: + if(byte == 0x30) { + // SECTOR ERASE + memset(&flashSaveMemory[(flashBank << 16) + (address & 0xF000)], + 0, + 0x1000); + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + flashReadState = FLASH_ERASE_COMPLETE; + } else if(byte == 0x10) { + // CHIP ERASE + memset(flashSaveMemory, 0, flashSize); + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + flashReadState = FLASH_ERASE_COMPLETE; + } else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + break; + case FLASH_AUTOSELECT: + if(byte == 0xF0) { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } else if(address == 0x5555 && byte == 0xAA) + flashState = FLASH_CMD_1; + else { + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + } + break; + case FLASH_PROGRAM: + flashSaveMemory[(flashBank<<16)+address] = byte; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + break; + case FLASH_SETBANK: + if(address == 0) { + flashBank = (byte & 1); + } + flashState = FLASH_READ_ARRAY; + flashReadState = FLASH_READ_ARRAY; + break; + } +} diff --git a/src/Flash.h b/src/Flash.h new file mode 100644 index 0000000..b6a4108 --- /dev/null +++ b/src/Flash.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_FLASH_H +#define VBA_FLASH_H + +extern void flashSaveGame(gzFile gzFile); +extern void flashReadGame(gzFile gzFile, int version); +extern u8 flashRead(u32 address); +extern void flashWrite(u32 address, u8 byte); +extern u8 flashSaveMemory[0x20000]; +extern void flashSaveDecide(u32 address, u8 byte); +extern void flashReset(); +extern void flashErase(); +extern void flashSetSize(int size); + +extern int flashSize; +#endif // VBA_FLASH_H diff --git a/src/GBA.cpp b/src/GBA.cpp new file mode 100644 index 0000000..765ef81 --- /dev/null +++ b/src/GBA.cpp @@ -0,0 +1,4282 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if (defined(WIN32) && !defined(SDL)) +# include "win32/stdafx.h" +# include "win32/vba.h" +#endif + +#include +#include +#include +#include +#include + +#include "GBA.h" +#include "GBAinline.h" +#include "Globals.h" +#include "Gfx.h" +#include "EEprom.h" +#include "Flash.h" +#include "Sound.h" +#include "Sram.h" +#include "bios.h" +#include "unzip.h" +#include "Cheats.h" +#include "NLS.h" +#include "elf.h" +#include "Util.h" +#include "Port.h" +#include "agbprint.h" +#ifdef PROFILING +#include "prof/prof.h" +#endif +#include "movie.h" + +#define UPDATE_REG(address, value) WRITE16LE(((u16 *)&ioMem[address]),value) + +#ifdef __GNUC__ +#define _stricmp strcasecmp +#endif + +#define CPU_BREAK_LOOP \ + cpuSavedTicks = cpuSavedTicks - *extCpuLoopTicks;\ + *extCpuLoopTicks = *extClockTicks; + +#define CPU_BREAK_LOOP_2 \ + cpuSavedTicks = cpuSavedTicks - *extCpuLoopTicks;\ + *extCpuLoopTicks = *extClockTicks;\ + *extTicks = *extClockTicks; + +extern int emulating; + +int cpuDmaTicksToUpdate = 0; +int cpuDmaCount = 0; +bool cpuDmaHack = 0; +u32 cpuDmaLast = 0; +int dummyAddress = 0; + +int *extCpuLoopTicks = NULL; +int *extClockTicks = NULL; +int *extTicks = NULL; + +#if (defined(WIN32) && !defined(SDL)) +HANDLE mapROM; // shared memory handles +HANDLE mapWORKRAM; +HANDLE mapBIOS; +HANDLE mapIRAM; +HANDLE mapPALETTERAM; +HANDLE mapVRAM; +HANDLE mapOAM; +HANDLE mapPIX; +HANDLE mapIOMEM; +#endif + +int gbaSaveType = 0; // used to remember the save type on reset +bool intState = false; +bool stopState = false; +bool holdState = false; +int holdType = 0; +bool cpuSramEnabled = true; +bool cpuFlashEnabled = true; +bool cpuEEPROMEnabled = true; +bool cpuEEPROMSensorEnabled = false; + +#ifdef PROFILING +int profilingTicks = 0; +int profilingTicksReload = 0; +static char *profilBuffer = NULL; +static int profilSize = 0; +static u32 profilLowPC = 0; +static int profilScale = 0; +#endif +bool freezeWorkRAM[0x40000]; +bool freezeInternalRAM[0x8000]; +int lcdTicks = 960; +bool timer0On = false; +int timer0Ticks = 0; +int timer0Reload = 0; +int timer0ClockReload = 0; +bool timer1On = false; +int timer1Ticks = 0; +int timer1Reload = 0; +int timer1ClockReload = 0; +bool timer2On = false; +int timer2Ticks = 0; +int timer2Reload = 0; +int timer2ClockReload = 0; +bool timer3On = false; +int timer3Ticks = 0; +int timer3Reload = 0; +int timer3ClockReload = 0; +u32 dma0Source = 0; +u32 dma0Dest = 0; +u32 dma1Source = 0; +u32 dma1Dest = 0; +u32 dma2Source = 0; +u32 dma2Dest = 0; +u32 dma3Source = 0; +u32 dma3Dest = 0; +void (*cpuSaveGameFunc)(u32,u8) = flashSaveDecide; +void (*renderLine)() = mode0RenderLine; +bool fxOn = false; +bool windowOn = false; +int frameCount = 0; +char buffer[1024]; +FILE *out = NULL; +u32 lastTime = 0; +int count = 0; +bool prefetchActive = false, prefetchPrevActive = false, prefetchApplies = false; + +static bool pauseAfterFrameAdvance = false; + +int capture = 0; +int capturePrevious = 0; +int captureNumber = 0; + +const int TIMER_TICKS[4] = { + 1, + 64, + 256, + 1024 +}; + +const int thumbCycles[] = { +// 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 4 + 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 5 + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 6 + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 7 + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 8 + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 9 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // a + 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 4, 1, 1, // b + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // c + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, // d + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // e + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 // f +}; + +const int gamepakRamWaitState[4] = { 4, 3, 2, 8 }; +const int gamepakWaitState[8] = { 4, 3, 2, 8, 4, 3, 2, 8 }; +const int gamepakWaitState0[8] = { 2, 2, 2, 2, 1, 1, 1, 1 }; +const int gamepakWaitState1[8] = { 4, 4, 4, 4, 1, 1, 1, 1 }; +const int gamepakWaitState2[8] = { 8, 8, 8, 8, 1, 1, 1, 1 }; + +int memoryWait[16] = + { 0, 0, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 0 }; +int memoryWait32[16] = + { 0, 0, 9, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 0 }; +int memoryWaitSeq[16] = + { 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 4, 4, 8, 8, 4, 0 }; +int memoryWaitSeq32[16] = + { 2, 0, 3, 0, 0, 2, 2, 0, 4, 4, 8, 8, 16, 16, 8, 0 }; +int memoryWaitFetch[16] = + { 3, 0, 3, 0, 0, 1, 1, 0, 4, 4, 4, 4, 4, 4, 4, 0 }; +int memoryWaitFetch32[16] = + { 6, 0, 6, 0, 0, 2, 2, 0, 8, 8, 8, 8, 8, 8, 8, 0 }; + +const int cpuMemoryWait[16] = { + 0, 0, 2, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 0, 0 +}; +const int cpuMemoryWait32[16] = { + 0, 0, 3, 0, 0, 0, 0, 0, + 3, 3, 3, 3, 3, 3, 0, 0 +}; + +const bool memory32[16] = + { true, false, false, true, true, false, false, true, false, false, false, false, false, false, true, false}; + +u8 biosProtected[4]; + +#ifdef WORDS_BIGENDIAN +bool cpuBiosSwapped = false; +#endif + +u32 myROM[] = { +0xEA000006, +0xEA000093, +0xEA000006, +0x00000000, +0x00000000, +0x00000000, +0xEA000088, +0x00000000, +0xE3A00302, +0xE1A0F000, +0xE92D5800, +0xE55EC002, +0xE28FB03C, +0xE79BC10C, +0xE14FB000, +0xE92D0800, +0xE20BB080, +0xE38BB01F, +0xE129F00B, +0xE92D4004, +0xE1A0E00F, +0xE12FFF1C, +0xE8BD4004, +0xE3A0C0D3, +0xE129F00C, +0xE8BD0800, +0xE169F00B, +0xE8BD5800, +0xE1B0F00E, +0x0000009C, +0x0000009C, +0x0000009C, +0x0000009C, +0x000001F8, +0x000001F0, +0x000000AC, +0x000000A0, +0x000000FC, +0x00000168, +0xE12FFF1E, +0xE1A03000, +0xE1A00001, +0xE1A01003, +0xE2113102, +0x42611000, +0xE033C040, +0x22600000, +0xE1B02001, +0xE15200A0, +0x91A02082, +0x3AFFFFFC, +0xE1500002, +0xE0A33003, +0x20400002, +0xE1320001, +0x11A020A2, +0x1AFFFFF9, +0xE1A01000, +0xE1A00003, +0xE1B0C08C, +0x22600000, +0x42611000, +0xE12FFF1E, +0xE92D0010, +0xE1A0C000, +0xE3A01001, +0xE1500001, +0x81A000A0, +0x81A01081, +0x8AFFFFFB, +0xE1A0000C, +0xE1A04001, +0xE3A03000, +0xE1A02001, +0xE15200A0, +0x91A02082, +0x3AFFFFFC, +0xE1500002, +0xE0A33003, +0x20400002, +0xE1320001, +0x11A020A2, +0x1AFFFFF9, +0xE0811003, +0xE1B010A1, +0xE1510004, +0x3AFFFFEE, +0xE1A00004, +0xE8BD0010, +0xE12FFF1E, +0xE0010090, +0xE1A01741, +0xE2611000, +0xE3A030A9, +0xE0030391, +0xE1A03743, +0xE2833E39, +0xE0030391, +0xE1A03743, +0xE2833C09, +0xE283301C, +0xE0030391, +0xE1A03743, +0xE2833C0F, +0xE28330B6, +0xE0030391, +0xE1A03743, +0xE2833C16, +0xE28330AA, +0xE0030391, +0xE1A03743, +0xE2833A02, +0xE2833081, +0xE0030391, +0xE1A03743, +0xE2833C36, +0xE2833051, +0xE0030391, +0xE1A03743, +0xE2833CA2, +0xE28330F9, +0xE0000093, +0xE1A00840, +0xE12FFF1E, +0xE3A00001, +0xE3A01001, +0xE92D4010, +0xE3A0C301, +0xE3A03000, +0xE3A04001, +0xE3500000, +0x1B000004, +0xE5CC3301, +0xEB000002, +0x0AFFFFFC, +0xE8BD4010, +0xE12FFF1E, +0xE5CC3208, +0xE15C20B8, +0xE0110002, +0x10200002, +0x114C00B8, +0xE5CC4208, +0xE12FFF1E, +0xE92D500F, +0xE3A00301, +0xE1A0E00F, +0xE510F004, +0xE8BD500F, +0xE25EF004, +0xE59FD044, +0xE92D5000, +0xE14FC000, +0xE10FE000, +0xE92D5000, +0xE3A0C302, +0xE5DCE09C, +0xE35E00A5, +0x1A000004, +0x05DCE0B4, +0x021EE080, +0xE28FE004, +0x159FF018, +0x059FF018, +0xE59FD018, +0xE8BD5000, +0xE169F00C, +0xE8BD5000, +0xE25EF004, +0x03007FF0, +0x09FE2000, +0x09FFC000, +0x03007FE0 +}; + +variable_desc saveGameStruct[] = { + { &DISPCNT , sizeof(u16) }, + { &DISPSTAT , sizeof(u16) }, + { &VCOUNT , sizeof(u16) }, + { &BG0CNT , sizeof(u16) }, + { &BG1CNT , sizeof(u16) }, + { &BG2CNT , sizeof(u16) }, + { &BG3CNT , sizeof(u16) }, + { &BG0HOFS , sizeof(u16) }, + { &BG0VOFS , sizeof(u16) }, + { &BG1HOFS , sizeof(u16) }, + { &BG1VOFS , sizeof(u16) }, + { &BG2HOFS , sizeof(u16) }, + { &BG2VOFS , sizeof(u16) }, + { &BG3HOFS , sizeof(u16) }, + { &BG3VOFS , sizeof(u16) }, + { &BG2PA , sizeof(u16) }, + { &BG2PB , sizeof(u16) }, + { &BG2PC , sizeof(u16) }, + { &BG2PD , sizeof(u16) }, + { &BG2X_L , sizeof(u16) }, + { &BG2X_H , sizeof(u16) }, + { &BG2Y_L , sizeof(u16) }, + { &BG2Y_H , sizeof(u16) }, + { &BG3PA , sizeof(u16) }, + { &BG3PB , sizeof(u16) }, + { &BG3PC , sizeof(u16) }, + { &BG3PD , sizeof(u16) }, + { &BG3X_L , sizeof(u16) }, + { &BG3X_H , sizeof(u16) }, + { &BG3Y_L , sizeof(u16) }, + { &BG3Y_H , sizeof(u16) }, + { &WIN0H , sizeof(u16) }, + { &WIN1H , sizeof(u16) }, + { &WIN0V , sizeof(u16) }, + { &WIN1V , sizeof(u16) }, + { &WININ , sizeof(u16) }, + { &WINOUT , sizeof(u16) }, + { &MOSAIC , sizeof(u16) }, + { &BLDMOD , sizeof(u16) }, + { &COLEV , sizeof(u16) }, + { &COLY , sizeof(u16) }, + { &DM0SAD_L , sizeof(u16) }, + { &DM0SAD_H , sizeof(u16) }, + { &DM0DAD_L , sizeof(u16) }, + { &DM0DAD_H , sizeof(u16) }, + { &DM0CNT_L , sizeof(u16) }, + { &DM0CNT_H , sizeof(u16) }, + { &DM1SAD_L , sizeof(u16) }, + { &DM1SAD_H , sizeof(u16) }, + { &DM1DAD_L , sizeof(u16) }, + { &DM1DAD_H , sizeof(u16) }, + { &DM1CNT_L , sizeof(u16) }, + { &DM1CNT_H , sizeof(u16) }, + { &DM2SAD_L , sizeof(u16) }, + { &DM2SAD_H , sizeof(u16) }, + { &DM2DAD_L , sizeof(u16) }, + { &DM2DAD_H , sizeof(u16) }, + { &DM2CNT_L , sizeof(u16) }, + { &DM2CNT_H , sizeof(u16) }, + { &DM3SAD_L , sizeof(u16) }, + { &DM3SAD_H , sizeof(u16) }, + { &DM3DAD_L , sizeof(u16) }, + { &DM3DAD_H , sizeof(u16) }, + { &DM3CNT_L , sizeof(u16) }, + { &DM3CNT_H , sizeof(u16) }, + { &TM0D , sizeof(u16) }, + { &TM0CNT , sizeof(u16) }, + { &TM1D , sizeof(u16) }, + { &TM1CNT , sizeof(u16) }, + { &TM2D , sizeof(u16) }, + { &TM2CNT , sizeof(u16) }, + { &TM3D , sizeof(u16) }, + { &TM3CNT , sizeof(u16) }, + { &P1 , sizeof(u16) }, + { &IE , sizeof(u16) }, + { &IF , sizeof(u16) }, + { &IME , sizeof(u16) }, + { &holdState, sizeof(bool) }, + { &holdType, sizeof(int) }, + { &lcdTicks, sizeof(int) }, + { &timer0On , sizeof(bool) }, + { &timer0Ticks , sizeof(int) }, + { &timer0Reload , sizeof(int) }, + { &timer0ClockReload , sizeof(int) }, + { &timer1On , sizeof(bool) }, + { &timer1Ticks , sizeof(int) }, + { &timer1Reload , sizeof(int) }, + { &timer1ClockReload , sizeof(int) }, + { &timer2On , sizeof(bool) }, + { &timer2Ticks , sizeof(int) }, + { &timer2Reload , sizeof(int) }, + { &timer2ClockReload , sizeof(int) }, + { &timer3On , sizeof(bool) }, + { &timer3Ticks , sizeof(int) }, + { &timer3Reload , sizeof(int) }, + { &timer3ClockReload , sizeof(int) }, + { &dma0Source , sizeof(u32) }, + { &dma0Dest , sizeof(u32) }, + { &dma1Source , sizeof(u32) }, + { &dma1Dest , sizeof(u32) }, + { &dma2Source , sizeof(u32) }, + { &dma2Dest , sizeof(u32) }, + { &dma3Source , sizeof(u32) }, + { &dma3Dest , sizeof(u32) }, + { &fxOn, sizeof(bool) }, + { &windowOn, sizeof(bool) }, + { &N_FLAG , sizeof(bool) }, + { &C_FLAG , sizeof(bool) }, + { &Z_FLAG , sizeof(bool) }, + { &V_FLAG , sizeof(bool) }, + { &armState , sizeof(bool) }, + { &armIrqEnable , sizeof(bool) }, + { &armNextPC , sizeof(u32) }, + { &armMode , sizeof(int) }, + { &saveType , sizeof(int) }, + { NULL, 0 } +}; + +//int cpuLoopTicks = 0; +int cpuSavedTicks = 0; + +#ifdef PROFILING +void cpuProfil(char *buf, int size, u32 lowPC, int scale) +{ + profilBuffer = buf; + profilSize = size; + profilLowPC = lowPC; + profilScale = scale; +} + +void cpuEnableProfiling(int hz) +{ + if(hz == 0) + hz = 100; + profilingTicks = profilingTicksReload = 16777216 / hz; + profSetHertz(hz); +} +#endif + +inline int CPUUpdateTicksAccess32(u32 address) +{ + return memoryWait32[(address>>24)&15]; +} + +inline int CPUUpdateTicksAccess16(u32 address) +{ + return memoryWait[(address>>24)&15]; +} + +inline int CPUUpdateTicksAccessSeq32(u32 address) +{ + return memoryWaitSeq32[(address>>24)&15]; +} + +inline int CPUUpdateTicksAccessSeq16(u32 address) +{ + return memoryWaitSeq[(address>>24)&15]; +} + +inline int CPUUpdateTicks() +{ + int cpuLoopTicks = lcdTicks; + + if(soundTicks < cpuLoopTicks) + cpuLoopTicks = soundTicks; + + if(timer0On && !(TM0CNT & 4) && (timer0Ticks < cpuLoopTicks)) { + cpuLoopTicks = timer0Ticks; + } + if(timer1On && !(TM1CNT & 4) && (timer1Ticks < cpuLoopTicks)) { + cpuLoopTicks = timer1Ticks; + } + if(timer2On && !(TM2CNT & 4) && (timer2Ticks < cpuLoopTicks)) { + cpuLoopTicks = timer2Ticks; + } + if(timer3On && !(TM3CNT & 4) && (timer3Ticks < cpuLoopTicks)) { + cpuLoopTicks = timer3Ticks; + } +#ifdef PROFILING + if(profilingTicksReload != 0) { + if(profilingTicks < cpuLoopTicks) { + cpuLoopTicks = profilingTicks; + } + } +#endif + cpuSavedTicks = cpuLoopTicks; + return cpuLoopTicks; +} + +void CPUUpdateWindow0() +{ + int x00 = WIN0H>>8; + int x01 = WIN0H & 255; + + if(x00 <= x01) { + for(int i = 0; i < 240; i++) { + gfxInWin0[i] = (i >= x00 && i < x01); + } + } else { + for(int i = 0; i < 240; i++) { + gfxInWin0[i] = (i >= x00 || i < x01); + } + } +} + +void CPUUpdateWindow1() +{ + int x00 = WIN1H>>8; + int x01 = WIN1H & 255; + + if(x00 <= x01) { + for(int i = 0; i < 240; i++) { + gfxInWin1[i] = (i >= x00 && i < x01); + } + } else { + for(int i = 0; i < 240; i++) { + gfxInWin1[i] = (i >= x00 || i < x01); + } + } +} + +extern u32 line0[240]; +extern u32 line1[240]; +extern u32 line2[240]; +extern u32 line3[240]; + +#define CLEAR_ARRAY(a) \ + {\ + u32 *array = (a);\ + for(int i = 0; i < 240; i++) {\ + *array++ = 0x80000000;\ + }\ + }\ + +void CPUUpdateRenderBuffers(bool force) +{ + if(!(layerEnable & 0x0100) || force) { + CLEAR_ARRAY(line0); + } + if(!(layerEnable & 0x0200) || force) { + CLEAR_ARRAY(line1); + } + if(!(layerEnable & 0x0400) || force) { + CLEAR_ARRAY(line2); + } + if(!(layerEnable & 0x0800) || force) { + CLEAR_ARRAY(line3); + } +} + +bool CPUWriteStateToStream(gzFile gzFile) +{ + utilWriteInt(gzFile, SAVE_GAME_VERSION); + + utilGzWrite(gzFile, &rom[0xa0], 16); + + utilWriteInt(gzFile, useBios); + + utilGzWrite(gzFile, ®[0], sizeof(reg)); + + utilWriteData(gzFile, saveGameStruct); + + // new to version 0.7.1 + utilWriteInt(gzFile, stopState); + // new to version 0.8 + utilWriteInt(gzFile, intState); + + utilGzWrite(gzFile, internalRAM, 0x8000); + utilGzWrite(gzFile, paletteRAM, 0x400); + utilGzWrite(gzFile, workRAM, 0x40000); + utilGzWrite(gzFile, vram, 0x20000); + utilGzWrite(gzFile, oam, 0x400); + utilGzWrite(gzFile, pix, 4*241*162); + utilGzWrite(gzFile, ioMem, 0x400); + + eepromSaveGame(gzFile); + flashSaveGame(gzFile); + soundSaveGame(gzFile); + + cheatsSaveGame(gzFile); + + // version 1.5 + rtcSaveGame(gzFile); + + + // SAVE_GAME_VERSION_9 (new to re-recording version which is based on 1.72) + { +#if (defined(WIN32) && !defined(SDL)) + utilGzWrite(gzFile, &theApp.sensorX, sizeof(theApp.sensorX)); + utilGzWrite(gzFile, &theApp.sensorY, sizeof(theApp.sensorY)); +#else + extern int sensorX, sensorY; // from SDL.cpp + utilGzWrite(gzFile, &sensorX, sizeof(sensorX)); + utilGzWrite(gzFile, &sensorY, sizeof(sensorY)); +#endif + bool8 movieActive = VBAMovieActive(); + utilGzWrite(gzFile, &movieActive, sizeof(movieActive)); + if(movieActive) + { + uint8* movie_freeze_buf = NULL; + uint32 movie_freeze_size = 0; + + VBAMovieFreeze(&movie_freeze_buf, &movie_freeze_size); + if(movie_freeze_buf) + { + utilGzWrite(gzFile, &movie_freeze_size, sizeof(movie_freeze_size)); + utilGzWrite(gzFile, movie_freeze_buf, movie_freeze_size); + delete [] movie_freeze_buf; + } + else + { + systemMessage(0, N_("Failed to save movie snapshot.")); + return false; + } + } +#if (defined(WIN32) && !defined(SDL)) + utilGzWrite(gzFile, &theApp.globalFrameCount, sizeof(theApp.globalFrameCount)); +#else + int dummy = 0; + utilGzWrite(gzFile, &dummy, sizeof(dummy)); +#endif + } + + // SAVE_GAME_VERSION_10 + { + utilGzWrite(gzFile, memoryWait, 16*sizeof(int)); + utilGzWrite(gzFile, memoryWait32, 16*sizeof(int)); + utilGzWrite(gzFile, memoryWaitSeq, 16*sizeof(int)); + utilGzWrite(gzFile, memoryWaitSeq32, 16*sizeof(int)); + utilGzWrite(gzFile, memoryWaitFetch, 16*sizeof(int)); + utilGzWrite(gzFile, memoryWaitFetch32, 16*sizeof(int)); + } + + // SAVE_GAME_VERSION_11 + { + utilGzWrite(gzFile, &prefetchActive, sizeof(bool)); + utilGzWrite(gzFile, &prefetchPrevActive, sizeof(bool)); + utilGzWrite(gzFile, &prefetchApplies, sizeof(bool)); + } + + // SAVE_GAME_VERSION_12 + { + utilGzWrite(gzFile, &memLagTempEnabled, sizeof(bool)); // necessary + utilGzWrite(gzFile, &speedHack, sizeof(bool)); // just in case it's ever used... + } + + + return true; +} + +bool CPUWriteState(const char *file) +{ + gzFile gzFile = utilGzOpen(file, "wb"); + + if(gzFile == NULL) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), file); + return false; + } + + bool res = CPUWriteStateToStream(gzFile); + + utilGzClose(gzFile); + + return res; +} + +bool CPUWriteMemState(char *memory, int available) +{ + gzFile gzFile = utilMemGzOpen(memory, available, "w"); + + if(gzFile == NULL) { + return false; + } + + bool res = CPUWriteStateToStream(gzFile); + + long pos = utilGzMemTell(gzFile)+8; + + if(pos >= (available)) + res = false; + + utilGzClose(gzFile); + + return res; +} + +static int tempStateID = 0; +static int tempFailCount = 0; +static bool backupSafe = true; + +bool CPUReadStateFromStream(gzFile gzFile) +{ + bool ub; + char tempBackupName [128]; + if(backupSafe) + { + sprintf(tempBackupName, "gbatempsave%d.sav", tempStateID++); + CPUWriteState(tempBackupName); + } + + int version = utilReadInt(gzFile); + + if(version > SAVE_GAME_VERSION || version < SAVE_GAME_VERSION_1) { + systemMessage(MSG_UNSUPPORTED_VBA_SGM, + N_("Unsupported VisualBoyAdvance save game version %d"), + version); + goto failedLoad; + } + + u8 romname[17]; + + utilGzRead(gzFile, romname, 16); + + if(memcmp(&rom[0xa0], romname, 16) != 0) { + romname[16]=0; + for(int i = 0; i < 16; i++) + if(romname[i] < 32) + romname[i] = 32; + systemMessage(MSG_CANNOT_LOAD_SGM, N_("Cannot load save game for %s"), romname); + goto failedLoad; + } + + ub = utilReadInt(gzFile) ? true : false; + + if(ub != useBios) { + if(useBios) + systemMessage(MSG_SAVE_GAME_NOT_USING_BIOS, + N_("Save game is not using the BIOS files")); + else + systemMessage(MSG_SAVE_GAME_USING_BIOS, + N_("Save game is using the BIOS file")); + goto failedLoad; + } + + utilGzRead(gzFile, ®[0], sizeof(reg)); + + utilReadData(gzFile, saveGameStruct); + + if(version < SAVE_GAME_VERSION_3) + stopState = false; + else + stopState = utilReadInt(gzFile) ? true : false; + + if(version < SAVE_GAME_VERSION_4) + intState = false; + else + intState = utilReadInt(gzFile) ? true : false; + + utilGzRead(gzFile, internalRAM, 0x8000); + utilGzRead(gzFile, paletteRAM, 0x400); + utilGzRead(gzFile, workRAM, 0x40000); + utilGzRead(gzFile, vram, 0x20000); + utilGzRead(gzFile, oam, 0x400); + if(version < SAVE_GAME_VERSION_6) + utilGzRead(gzFile, pix, 4*240*160); + else + utilGzRead(gzFile, pix, 4*241*162); + utilGzRead(gzFile, ioMem, 0x400); + + eepromReadGame(gzFile, version); + flashReadGame(gzFile, version); + soundReadGame(gzFile, version); + + if(version > SAVE_GAME_VERSION_1) { + cheatsReadGame(gzFile); + } + if(version > SAVE_GAME_VERSION_6) { + rtcReadGame(gzFile); + } + + if(version <= SAVE_GAME_VERSION_7) { + u32 temp; +#define SWAP(a,b,c) \ + temp = (a);\ + (a) = (b)<<16|(c);\ + (b) = (temp) >> 16;\ + (c) = (temp) & 0xFFFF; + + SWAP(dma0Source, DM0SAD_H, DM0SAD_L); + SWAP(dma0Dest, DM0DAD_H, DM0DAD_L); + SWAP(dma1Source, DM1SAD_H, DM1SAD_L); + SWAP(dma1Dest, DM1DAD_H, DM1DAD_L); + SWAP(dma2Source, DM2SAD_H, DM2SAD_L); + SWAP(dma2Dest, DM2DAD_H, DM2DAD_L); + SWAP(dma3Source, DM3SAD_H, DM3SAD_L); + SWAP(dma3Dest, DM3DAD_H, DM3DAD_L); + } + + // set pointers! + layerEnable = layerSettings & DISPCNT; + + CPUUpdateRender(); + CPUUpdateRenderBuffers(true); + CPUUpdateWindow0(); + CPUUpdateWindow1(); + gbaSaveType = 0; + switch(saveType) { + case 0: + cpuSaveGameFunc = flashSaveDecide; + break; + case 1: + cpuSaveGameFunc = sramWrite; + gbaSaveType = 1; + break; + case 2: + cpuSaveGameFunc = flashWrite; + gbaSaveType = 2; + break; + default: + systemMessage(MSG_UNSUPPORTED_SAVE_TYPE, + N_("Unsupported save type %d"), saveType); + break; + } + if(eepromInUse) + gbaSaveType = 3; + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + if(version >= SAVE_GAME_VERSION_9) // new to re-recording version: + { +#if (defined(WIN32) && !defined(SDL)) + utilGzRead(gzFile, &theApp.sensorX, sizeof(theApp.sensorX)); + utilGzRead(gzFile, &theApp.sensorY, sizeof(theApp.sensorY)); +#else + extern int sensorX, sensorY; // from SDL.cpp + utilGzRead(gzFile, &sensorX, sizeof(sensorX)); + utilGzRead(gzFile, &sensorY, sizeof(sensorY)); +#endif + bool8 movieSnapshot; + utilGzRead(gzFile, &movieSnapshot, sizeof(movieSnapshot)); + if(VBAMovieActive() && !movieSnapshot) + { + systemMessage(0, N_("Can't load a non-movie snapshot while a movie is active.")); + goto failedLoad; + } +#if (defined(WIN32) && !defined(SDL)) + extern bool8 loadedMovieSnapshot; + loadedMovieSnapshot = movieSnapshot; +#endif + if(movieSnapshot) // even if a movie isn't active we still want to parse through this in case other stuff is added later on in the save format + { + uint32 movieInputDataSize = 0; + utilGzRead(gzFile, &movieInputDataSize, sizeof(movieInputDataSize)); + uint8* local_movie_data = new uint8 [movieInputDataSize]; + int readBytes = utilGzRead(gzFile, local_movie_data, movieInputDataSize); + if(readBytes != movieInputDataSize) + { + systemMessage(0, N_("Corrupt movie snapshot.")); + if(local_movie_data) delete [] local_movie_data; + goto failedLoad; + } + int code = VBAMovieUnfreeze(local_movie_data, movieInputDataSize); + if(local_movie_data) delete [] local_movie_data; + if(code != SUCCESS && VBAMovieActive()) + { + char errStr [1024]; + strcpy(errStr, "Failed to load movie snapshot"); + switch(code) + { + case NOT_FROM_THIS_MOVIE: strcat(errStr, ";\nSnapshot not from this movie"); break; + case NOT_FROM_A_MOVIE: strcat(errStr, ";\nNot a movie snapshot"); break;// shouldn't get here... + case INVALID_FRAME: strcat(errStr, ";\nInvalid frame number"); break; + case WRONG_FORMAT: strcat(errStr, ";\nWrong format"); break; + } + strcat(errStr, "."); + systemMessage(0, N_(errStr)); + goto failedLoad; + } + } +#if (defined(WIN32) && !defined(SDL)) + utilGzRead(gzFile, &theApp.globalFrameCount, sizeof(theApp.globalFrameCount)); +#else + int dummy; + utilGzRead(gzFile, &dummy, sizeof(dummy)); +#endif + } + if(version >= SAVE_GAME_VERSION_10) + { + utilGzRead(gzFile, memoryWait, 16*sizeof(int)); + utilGzRead(gzFile, memoryWait32, 16*sizeof(int)); + utilGzRead(gzFile, memoryWaitSeq, 16*sizeof(int)); + utilGzRead(gzFile, memoryWaitSeq32, 16*sizeof(int)); + utilGzRead(gzFile, memoryWaitFetch, 16*sizeof(int)); + utilGzRead(gzFile, memoryWaitFetch32, 16*sizeof(int)); + } + if(version >= SAVE_GAME_VERSION_11) + { + utilGzRead(gzFile, &prefetchActive, sizeof(bool)); + //if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600); + //if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600); + utilGzRead(gzFile, &prefetchPrevActive, sizeof(bool)); + utilGzRead(gzFile, &prefetchApplies, sizeof(bool)); + } + if(version >= SAVE_GAME_VERSION_12) + { + utilGzRead(gzFile, &memLagTempEnabled, sizeof(bool)); // necessary + utilGzRead(gzFile, &speedHack, sizeof(bool)); // just in case it's ever used... + } + + + if(backupSafe) + { + remove(tempBackupName); + tempFailCount = 0; + } + VBAUpdateFrameCountDisplay(); + return true; + +failedLoad: + if(backupSafe) + { + tempFailCount++; + if(tempFailCount < 3) // fail no more than 2 times in a row + CPUReadState(tempBackupName); + remove(tempBackupName); + } + return false; +} + +bool CPUReadMemState(char *memory, int available) +{ + gzFile gzFile = utilMemGzOpen(memory, available, "r"); + + backupSafe = false; + bool res = CPUReadStateFromStream(gzFile); + backupSafe = true; + + utilGzClose(gzFile); + + return res; +} + +bool CPUReadState(const char * file) +{ + gzFile gzFile = utilGzOpen(file, "rb"); + + if(gzFile == NULL) + return false; + + bool res = CPUReadStateFromStream(gzFile); + + utilGzClose(gzFile); + + return res; +} + +bool CPUExportEepromFile(const char *fileName) +{ + if(eepromInUse) { + FILE *file = fopen(fileName, "wb"); + + if(!file) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), + fileName); + return false; + } + + for(int i = 0; i < eepromSize;) { + for(int j = 0; j < 8; j++) { + if(fwrite(&eepromData[i+7-j], 1, 1, file) != 1) { + fclose(file); + return false; + } + } + i += 8; + } + fclose(file); + } + return true; +} + +bool CPUWriteBatteryToStream(gzFile gzFile) +{ + if(!gzFile) + return false; + + utilWriteInt(gzFile, SAVE_GAME_VERSION); + + // for simplicity, we put both types of battery files should be in the stream, even if one's empty + eepromSaveGame(gzFile); + flashSaveGame(gzFile); + + return true; +} + +bool CPUWriteBatteryFile(const char *fileName) +{ + if(gbaSaveType == 0) { + if(eepromInUse) + gbaSaveType = 3; + else switch(saveType) { + case 1: + gbaSaveType = 1; + break; + case 2: + gbaSaveType = 2; + break; + } + } + + if(gbaSaveType) { + FILE *file = fopen(fileName, "wb"); + + if(!file) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), + fileName); + return false; + } + + // only save if Flash/Sram in use or EEprom in use + if(gbaSaveType != 3) { + if(gbaSaveType == 2) { + if(fwrite(flashSaveMemory, 1, flashSize, file) != (size_t)flashSize) { + fclose(file); + return false; + } + } else { + if(fwrite(flashSaveMemory, 1, 0x10000, file) != 0x10000) { + fclose(file); + return false; + } + } + } else { + if(fwrite(eepromData, 1, eepromSize, file) != (size_t)eepromSize) { + fclose(file); + return false; + } + } + fclose(file); + } + + return true; +} + +bool CPUReadGSASnapshot(const char *fileName) +{ + int i; + FILE *file = fopen(fileName, "rb"); + + if(!file) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName); + return false; + } + + // check file size to know what we should read + fseek(file, 0, SEEK_END); + + // long size = ftell(file); + fseek(file, 0x0, SEEK_SET); + fread(&i, 1, 4, file); + fseek(file, i, SEEK_CUR); // Skip SharkPortSave + fseek(file, 4, SEEK_CUR); // skip some sort of flag + fread(&i, 1, 4, file); // name length + fseek(file, i, SEEK_CUR); // skip name + fread(&i, 1, 4, file); // desc length + fseek(file, i, SEEK_CUR); // skip desc + fread(&i, 1, 4, file); // notes length + fseek(file, i, SEEK_CUR); // skip notes + int saveSize; + fread(&saveSize, 1, 4, file); // read length + saveSize -= 0x1c; // remove header size + char buffer[17]; + char buffer2[17]; + fread(buffer, 1, 16, file); + buffer[16] = 0; + for(i = 0; i < 16; i++) + if(buffer[i] < 32) + buffer[i] = 32; + memcpy(buffer2, &rom[0xa0], 16); + buffer2[16] = 0; + for(i = 0; i < 16; i++) + if(buffer2[i] < 32) + buffer2[i] = 32; + if(memcmp(buffer, buffer2, 16)) { + systemMessage(MSG_CANNOT_IMPORT_SNAPSHOT_FOR, + N_("Cannot import snapshot for %s. Current game is %s"), + buffer, + buffer2); + fclose(file); + return false; + } + fseek(file, 12, SEEK_CUR); // skip some flags + if(saveSize >= 65536) { + if(fread(flashSaveMemory, 1, saveSize, file) != (size_t)saveSize) { + fclose(file); + return false; + } + } else { + systemMessage(MSG_UNSUPPORTED_SNAPSHOT_FILE, + N_("Unsupported snapshot file %s"), + fileName); + fclose(file); + return false; + } + fclose(file); + CPUReset(); + return true; +} + +bool CPUWriteGSASnapshot(const char *fileName, + const char *title, + const char *desc, + const char *notes) +{ + FILE *file = fopen(fileName, "wb"); + + if(!file) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName); + return false; + } + + u8 buffer[17]; + + utilPutDword(buffer, 0x0d); // SharkPortSave length + fwrite(buffer, 1, 4, file); + fwrite("SharkPortSave", 1, 0x0d, file); + utilPutDword(buffer, 0x000f0000); + fwrite(buffer, 1, 4, file); // save type 0x000f0000 = GBA save + utilPutDword(buffer, strlen(title)); + fwrite(buffer, 1, 4, file); // title length + fwrite(title, 1, strlen(title), file); + utilPutDword(buffer, strlen(desc)); + fwrite(buffer, 1, 4, file); // desc length + fwrite(desc, 1, strlen(desc), file); + utilPutDword(buffer, strlen(notes)); + fwrite(buffer, 1, 4, file); // notes length + fwrite(notes, 1, strlen(notes), file); + int saveSize = 0x10000; + if(gbaSaveType == 2) + saveSize = flashSize; + int totalSize = saveSize + 0x1c; + + utilPutDword(buffer, totalSize); // length of remainder of save - CRC + fwrite(buffer, 1, 4, file); + + char temp[0x2001c]; + memset(temp, 0, 28); + memcpy(temp, &rom[0xa0], 16); // copy internal name + temp[0x10] = rom[0xbe]; // reserved area (old checksum) + temp[0x11] = rom[0xbf]; // reserved area (old checksum) + temp[0x12] = rom[0xbd]; // complement check + temp[0x13] = rom[0xb0]; // maker + temp[0x14] = 1; // 1 save ? + memcpy(&temp[0x1c], flashSaveMemory, saveSize); // copy save + fwrite(temp, 1, totalSize, file); // write save + header + u32 crc = 0; + + for(int i = 0; i < totalSize; i++) { + crc += ((u32)temp[i] << (crc % 0x18)); + } + + utilPutDword(buffer, crc); + fwrite(buffer, 1, 4, file); // CRC? + + fclose(file); + return true; +} + +bool CPUImportEepromFile(const char *fileName) +{ + FILE *file = fopen(fileName, "rb"); + + if(!file) + return false; + + // check file size to know what we should read + fseek(file, 0, SEEK_END); + + long size = ftell(file); + fseek(file, 0, SEEK_SET); + if(size == 512 || size == 0x2000) { + if(fread(eepromData, 1, size, file) != (size_t)size) { + fclose(file); + return false; + } + for(int i = 0; i < size;) { + u8 tmp = eepromData[i]; + eepromData[i] = eepromData[7-i]; + eepromData[7-i] = tmp; + i++; + tmp = eepromData[i]; + eepromData[i] = eepromData[7-i]; + eepromData[7-i] = tmp; + i++; + tmp = eepromData[i]; + eepromData[i] = eepromData[7-i]; + eepromData[7-i] = tmp; + i++; + tmp = eepromData[i]; + eepromData[i] = eepromData[7-i]; + eepromData[7-i] = tmp; + i++; + i += 4; + } + } else + return false; + fclose(file); + return true; +} + +bool CPUReadBatteryFromStream(gzFile gzFile) +{ + if(!gzFile) + return false; + + int version = utilReadInt(gzFile); + + // for simplicity, we put both types of battery files should be in the stream, even if one's empty + eepromReadGame(gzFile, version); + flashReadGame(gzFile, version); + + return true; +} + +bool CPUReadBatteryFile(const char *fileName) +{ + FILE *file = fopen(fileName, "rb"); + + if(!file) + return false; + + // check file size to know what we should read + fseek(file, 0, SEEK_END); + + long size = ftell(file); + fseek(file, 0, SEEK_SET); + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + if(size == 512 || size == 0x2000) { + if(fread(eepromData, 1, size, file) != (size_t)size) { + fclose(file); + return false; + } + } else { + if(size == 0x20000) { + if(fread(flashSaveMemory, 1, 0x20000, file) != 0x20000) { + fclose(file); + return false; + } + flashSetSize(0x20000); + } else { + if(fread(flashSaveMemory, 1, 0x10000, file) != 0x10000) { + fclose(file); + return false; + } + flashSetSize(0x10000); + } + } + fclose(file); + return true; +} + +bool CPUWritePNGFile(const char *fileName) +{ + return utilWritePNGFile(fileName, 240, 160, pix); +} + +bool CPUWriteBMPFile(const char *fileName) +{ + return utilWriteBMPFile(fileName, 240, 160, pix); +} + +bool CPUIsZipFile(const char * file) +{ + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".zip") == 0) + return true; + } + } + + return false; +} + +bool CPUIsGBAImage(const char * file) +{ + cpuIsMultiBoot = false; + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".gba") == 0) + return true; + if(_stricmp(p, ".agb") == 0) + return true; + if(_stricmp(p, ".bin") == 0) + return true; + if(_stricmp(p, ".elf") == 0) + return true; + if(_stricmp(p, ".mb") == 0) { + cpuIsMultiBoot = true; + return true; + } + } + } + + return false; +} + +bool CPUIsGBABios(const char * file) +{ + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".gba") == 0) + return true; + if(_stricmp(p, ".agb") == 0) + return true; + if(_stricmp(p, ".bin") == 0) + return true; + if(_stricmp(p, ".bios") == 0) + return true; + } + } + + return false; +} + +bool CPUIsELF(const char *file) +{ + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".elf") == 0) + return true; + } + } + return false; +} + +void CPUCleanUp() +{ +#if (defined(WIN32) && !defined(SDL)) + theApp.globalFrameCount = 0; +#endif + +#ifdef PROFILING + if(profilingTicksReload) { + profCleanup(); + } +#endif + +#if (defined(WIN32) && !defined(SDL)) + #define FreeMappedMem(name,mapName,offset) \ + if(name != NULL) { \ + UnmapViewOfFile((name) - (offset)); \ + name = NULL; \ + CloseHandle(mapName); \ + } +#else + #define FreeMappedMem(name,mapName,offset) \ + if(name != NULL) { \ + free(name); \ + name = NULL; \ + } +#endif + + FreeMappedMem(rom, mapROM, 0); + FreeMappedMem(vram, mapVRAM, 0); + FreeMappedMem(paletteRAM, mapPALETTERAM, 0); + FreeMappedMem(internalRAM, mapIRAM, 0); + FreeMappedMem(workRAM, mapWORKRAM, 0); + FreeMappedMem(bios, mapBIOS, 0); + FreeMappedMem(pix, mapPIX, 4); + FreeMappedMem(oam, mapOAM, 0); + FreeMappedMem(ioMem, mapIOMEM, 0); + + eepromErase(); + flashErase(); + + elfCleanUp(); + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + emulating = 0; +} + +int CPULoadRom(const char *szFile) +{ + int size = 0x2000000; + + if(rom != NULL) { + CPUCleanUp(); + } + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + +#if (defined(WIN32) && !defined(SDL)) + #define AllocMappedMem(name,mapName,nameStr,size,useCalloc,offset) \ + mapName = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (size)+(offset), nameStr); \ + if((mapName) && GetLastError() == ERROR_ALREADY_EXISTS) { \ + CloseHandle(mapName); \ + mapName = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (size)+(offset), NULL); \ + } \ + name = (u8 *)MapViewOfFile(mapName, FILE_MAP_WRITE, 0, 0, 0) + (offset); \ + if((name) == NULL) { \ + systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), nameStr); \ + CPUCleanUp(); \ + return 0; \ + } \ + memset(name, 0, size); +#else + #define AllocMappedMem(name,mapName,nameStr,size,useCalloc,offset) \ + name = (u8 *)(useCalloc ? calloc(1,size) : malloc(size)); \ + if((name) == NULL) { \ + systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), nameStr); \ + CPUCleanUp(); \ + return 0; \ + } \ + memset(name, 0, size); +#endif + + AllocMappedMem(rom,mapROM,"vbaROM",0x2000000,false,0); + + AllocMappedMem(workRAM,mapWORKRAM,"vbaWORKRAM",0x40000,true,0); + + u8 *whereToLoad = rom; + if(cpuIsMultiBoot) + whereToLoad = workRAM; + + if(CPUIsELF(szFile)) { + FILE *f = fopen(szFile, "rb"); + if(!f) { + systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), + szFile); + free(rom); + rom = NULL; + free(workRAM); + workRAM = NULL; + return 0; + } + bool res = elfRead(szFile, size, f); + if(!res || size == 0) { + free(rom); + rom = NULL; + free(workRAM); + workRAM = NULL; + elfCleanUp(); + return 0; + } + } else if(!utilLoad(szFile, + utilIsGBAImage, + whereToLoad, + size)) { + free(rom); + rom = NULL; + free(workRAM); + workRAM = NULL; + return 0; + } + + u16 *temp = (u16 *)(rom+((size+1)&~1)); + int i; + for(i = (size+1)&~1; i < 0x2000000; i+=2) { + WRITE16LE(temp, (i >> 1) & 0xFFFF); + temp++; + } + + AllocMappedMem(bios,mapBIOS,"vbaBIOS",0x4000,true,0); + + AllocMappedMem(internalRAM,mapIRAM,"vbaIRAM",0x8000,true,0); + + AllocMappedMem(paletteRAM,mapPALETTERAM,"vbaPALETTERAM",0x400,true,0); + + AllocMappedMem(vram,mapVRAM,"vbaVRAM",0x20000,true,0); + + AllocMappedMem(oam,mapOAM,"vbaOAM",0x400,true,0); + + // HACK: +4 at start to accomodate the 2xSaI filter reading out of bounds of the leftmost pixel + AllocMappedMem(pix,mapPIX,"vbaPIX",4 * 241 * 162,true,4); + + AllocMappedMem(ioMem,mapIOMEM,"vbaIOMEM",0x400,true,0); + + CPUUpdateRenderBuffers(true); + + return size; +} + +void CPUUpdateRender() +{ + switch(DISPCNT & 7) { + case 0: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode0RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode0RenderLineNoWindow; + else + renderLine = mode0RenderLineAll; + break; + case 1: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode1RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode1RenderLineNoWindow; + else + renderLine = mode1RenderLineAll; + break; + case 2: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode2RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode2RenderLineNoWindow; + else + renderLine = mode2RenderLineAll; + break; + case 3: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode3RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode3RenderLineNoWindow; + else + renderLine = mode3RenderLineAll; + break; + case 4: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode4RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode4RenderLineNoWindow; + else + renderLine = mode4RenderLineAll; + break; + case 5: + if((!fxOn && !windowOn && !(layerEnable & 0x8000)) || + cpuDisableSfx) + renderLine = mode5RenderLine; + else if(fxOn && !windowOn && !(layerEnable & 0x8000)) + renderLine = mode5RenderLineNoWindow; + else + renderLine = mode5RenderLineAll; + default: + break; + } +} + +void CPUUpdateCPSR() +{ + u32 CPSR = reg[16].I & 0x40; + if(N_FLAG) + CPSR |= 0x80000000; + if(Z_FLAG) + CPSR |= 0x40000000; + if(C_FLAG) + CPSR |= 0x20000000; + if(V_FLAG) + CPSR |= 0x10000000; + if(!armState) + CPSR |= 0x00000020; + if(!armIrqEnable) + CPSR |= 0x80; + CPSR |= (armMode & 0x1F); + reg[16].I = CPSR; +} + +void CPUUpdateFlags(bool breakLoop) +{ + u32 CPSR = reg[16].I; + + N_FLAG = (CPSR & 0x80000000) ? true: false; + Z_FLAG = (CPSR & 0x40000000) ? true: false; + C_FLAG = (CPSR & 0x20000000) ? true: false; + V_FLAG = (CPSR & 0x10000000) ? true: false; + armState = (CPSR & 0x20) ? false : true; + armIrqEnable = (CPSR & 0x80) ? false : true; + if(breakLoop) { + if(armIrqEnable && (IF & IE) && (IME & 1)) { + CPU_BREAK_LOOP_2; + } + } +} + +void CPUUpdateFlags() +{ + CPUUpdateFlags(true); +} + +#ifdef WORDS_BIGENDIAN +static void CPUSwap(volatile u32 *a, volatile u32 *b) +{ + volatile u32 c = *b; + *b = *a; + *a = c; +} +#else +static void CPUSwap(u32 *a, u32 *b) +{ + u32 c = *b; + *b = *a; + *a = c; +} +#endif + +void CPUSwitchMode(int mode, bool saveState, bool breakLoop) +{ + // if(armMode == mode) + // return; + + CPUUpdateCPSR(); + + switch(armMode) { + case 0x10: + case 0x1F: + reg[R13_USR].I = reg[13].I; + reg[R14_USR].I = reg[14].I; + reg[17].I = reg[16].I; + break; + case 0x11: + CPUSwap(®[R8_FIQ].I, ®[8].I); + CPUSwap(®[R9_FIQ].I, ®[9].I); + CPUSwap(®[R10_FIQ].I, ®[10].I); + CPUSwap(®[R11_FIQ].I, ®[11].I); + CPUSwap(®[R12_FIQ].I, ®[12].I); + reg[R13_FIQ].I = reg[13].I; + reg[R14_FIQ].I = reg[14].I; + reg[SPSR_FIQ].I = reg[17].I; + break; + case 0x12: + reg[R13_IRQ].I = reg[13].I; + reg[R14_IRQ].I = reg[14].I; + reg[SPSR_IRQ].I = reg[17].I; + break; + case 0x13: + reg[R13_SVC].I = reg[13].I; + reg[R14_SVC].I = reg[14].I; + reg[SPSR_SVC].I = reg[17].I; + break; + case 0x17: + reg[R13_ABT].I = reg[13].I; + reg[R14_ABT].I = reg[14].I; + reg[SPSR_ABT].I = reg[17].I; + break; + case 0x1b: + reg[R13_UND].I = reg[13].I; + reg[R14_UND].I = reg[14].I; + reg[SPSR_UND].I = reg[17].I; + break; + } + + u32 CPSR = reg[16].I; + u32 SPSR = reg[17].I; + + switch(mode) { + case 0x10: + case 0x1F: + reg[13].I = reg[R13_USR].I; + reg[14].I = reg[R14_USR].I; + reg[16].I = SPSR; + break; + case 0x11: + CPUSwap(®[8].I, ®[R8_FIQ].I); + CPUSwap(®[9].I, ®[R9_FIQ].I); + CPUSwap(®[10].I, ®[R10_FIQ].I); + CPUSwap(®[11].I, ®[R11_FIQ].I); + CPUSwap(®[12].I, ®[R12_FIQ].I); + reg[13].I = reg[R13_FIQ].I; + reg[14].I = reg[R14_FIQ].I; + if(saveState) + reg[17].I = CPSR; + else + reg[17].I = reg[SPSR_FIQ].I; + break; + case 0x12: + reg[13].I = reg[R13_IRQ].I; + reg[14].I = reg[R14_IRQ].I; + reg[16].I = SPSR; + if(saveState) + reg[17].I = CPSR; + else + reg[17].I = reg[SPSR_IRQ].I; + break; + case 0x13: + reg[13].I = reg[R13_SVC].I; + reg[14].I = reg[R14_SVC].I; + reg[16].I = SPSR; + if(saveState) + reg[17].I = CPSR; + else + reg[17].I = reg[SPSR_SVC].I; + break; + case 0x17: + reg[13].I = reg[R13_ABT].I; + reg[14].I = reg[R14_ABT].I; + reg[16].I = SPSR; + if(saveState) + reg[17].I = CPSR; + else + reg[17].I = reg[SPSR_ABT].I; + break; + case 0x1b: + reg[13].I = reg[R13_UND].I; + reg[14].I = reg[R14_UND].I; + reg[16].I = SPSR; + if(saveState) + reg[17].I = CPSR; + else + reg[17].I = reg[SPSR_UND].I; + break; + default: + systemMessage(MSG_UNSUPPORTED_ARM_MODE, N_("Unsupported ARM mode %02x"), mode); + break; + } + armMode = mode; + CPUUpdateFlags(breakLoop); + CPUUpdateCPSR(); +} + +void CPUSwitchMode(int mode, bool saveState) +{ + CPUSwitchMode(mode, saveState, true); +} + +void CPUUndefinedException() +{ + u32 PC = reg[15].I; + bool savedArmState = armState; + CPUSwitchMode(0x1b, true, false); + reg[14].I = PC - (savedArmState ? 4 : 2); + reg[15].I = 0x04; + armState = true; + armIrqEnable = false; + armNextPC = 0x04; + reg[15].I += 4; +} + +void CPUSoftwareInterrupt() +{ + u32 PC = reg[15].I; + bool savedArmState = armState; + CPUSwitchMode(0x13, true, false); + reg[14].I = PC - (savedArmState ? 4 : 2); + reg[15].I = 0x08; + armState = true; + armIrqEnable = false; + armNextPC = 0x08; + reg[15].I += 4; +} + +void CPUSoftwareInterrupt(int comment) +{ + static bool disableMessage = false; + if(armState) comment >>= 16; +#ifdef BKPT_SUPPORT + if(comment == 0xff) { + extern void (*dbgOutput)(char *, u32); + dbgOutput(NULL, reg[0].I); + return; + } +#endif +#ifdef PROFILING + if(comment == 0xfe) { + profStartup(reg[0].I, reg[1].I); + return; + } + if(comment == 0xfd) { + profControl(reg[0].I); + return; + } + if(comment == 0xfc) { + profCleanup(); + return; + } + if(comment == 0xfb) { + profCount(); + return; + } +#endif + if(comment == 0xfa) { + agbPrintFlush(); + return; + } +#ifdef SDL + if(comment == 0xf9) { + emulating = 0; + CPU_BREAK_LOOP_2; + return; + } +#endif + if(useBios) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment, + armState ? armNextPC - 4: armNextPC -2, + reg[0].I, + reg[1].I, + reg[2].I, + VCOUNT); + } +#endif + CPUSoftwareInterrupt(); + return; + } + // This would be correct, but it causes problems if uncommented + // else { + // biosProtected = 0xe3a02004; + // } + + switch(comment) { + case 0x00: + BIOS_SoftReset(); + break; + case 0x01: + BIOS_RegisterRamReset(); + break; + case 0x02: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Halt: (VCOUNT = %2d)\n", + VCOUNT); + } +#endif + holdState = true; + holdType = -1; + break; + case 0x03: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Stop: (VCOUNT = %2d)\n", + VCOUNT); + } +#endif + holdState = true; + holdType = -1; + stopState = true; + break; + case 0x04: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("IntrWait: 0x%08x,0x%08x (VCOUNT = %2d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + CPUSoftwareInterrupt(); + break; + case 0x05: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("VBlankIntrWait: (VCOUNT = %2d)\n", + VCOUNT); + } +#endif + CPUSoftwareInterrupt(); + break; + case 0x06: + CPUSoftwareInterrupt(); + break; + case 0x07: + CPUSoftwareInterrupt(); + break; + case 0x08: + BIOS_Sqrt(); + break; + case 0x09: + BIOS_ArcTan(); + break; + case 0x0A: + BIOS_ArcTan2(); + break; + case 0x0B: + BIOS_CpuSet(); + break; + case 0x0C: + BIOS_CpuFastSet(); + break; + case 0x0E: + BIOS_BgAffineSet(); + break; + case 0x0F: + BIOS_ObjAffineSet(); + break; + case 0x10: + BIOS_BitUnPack(); + break; + case 0x11: + BIOS_LZ77UnCompWram(); + break; + case 0x12: + BIOS_LZ77UnCompVram(); + break; + case 0x13: + BIOS_HuffUnComp(); + break; + case 0x14: + BIOS_RLUnCompWram(); + break; + case 0x15: + BIOS_RLUnCompVram(); + break; + case 0x16: + BIOS_Diff8bitUnFilterWram(); + break; + case 0x17: + BIOS_Diff8bitUnFilterVram(); + break; + case 0x18: + BIOS_Diff16bitUnFilter(); + break; + case 0x19: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("SoundBiasSet: 0x%08x (VCOUNT = %2d)\n", + reg[0].I, + VCOUNT); + } +#endif + if(reg[0].I) + systemSoundPause(); + else + { +#if (defined(WIN32) && !defined(SDL)) + if(!theApp.frameAdvanceMuteNow) +#endif + systemSoundResume(); + } + break; + case 0x1F: + BIOS_MidiKey2Freq(); + break; + case 0x2A: + BIOS_SndDriverJmpTableCopy(); + // let it go, because we don't really emulate this function // FIXME (?) + default: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("SWI: %08x at %08x (0x%08x,0x%08x,0x%08x,VCOUNT = %2d)\n", comment, + armState ? armNextPC - 4: armNextPC -2, + reg[0].I, + reg[1].I, + reg[2].I, + VCOUNT); + } +#endif + + if(!disableMessage) { + systemMessage(MSG_UNSUPPORTED_BIOS_FUNCTION, + N_("Unsupported BIOS function %02x called from %08x. A BIOS file is needed in order to get correct behaviour."), + comment, + armMode ? armNextPC - 4: armNextPC - 2); + disableMessage = true; + } + break; + } +} + +void CPUCompareVCOUNT() +{ + if(VCOUNT == (DISPSTAT >> 8)) { + DISPSTAT |= 4; + UPDATE_REG(0x04, DISPSTAT); + + if(DISPSTAT & 0x20) { + IF |= 4; + UPDATE_REG(0x202, IF); + } + } else { + DISPSTAT &= 0xFFFB; + UPDATE_REG(0x4, DISPSTAT); + } +} + +void doDMA(u32 &s, u32 &d, u32 si, u32 di, u32 c, int transfer32) +{ + int sm = s >> 24; + int dm = d >> 24; + + int sc = c; + + cpuDmaCount = c; + + if(transfer32) { + s &= 0xFFFFFFFC; + if(s < 0x02000000 && (reg[15].I >> 24)) { + while(c != 0) { + CPUWriteMemory(d, 0); + d += di; + c--; + } + } else { + while(c != 0) { + CPUWriteMemory(d, CPUReadMemory(s)); + d += di; + s += si; + c--; + } + } + } else { + s &= 0xFFFFFFFE; + si = (int)si >> 1; + di = (int)di >> 1; + if(s < 0x02000000 && (reg[15].I >> 24)) { + while(c != 0) { + CPUWriteHalfWord(d, 0); + d += di; + c--; + } + } else { + while(c != 0) { + cpuDmaLast = CPUReadHalfWord(s); + CPUWriteHalfWord(d, cpuDmaLast); + d += di; + s += si; + c--; + } + } + } + + cpuDmaCount = 0; + + int sw = 1+memoryWaitSeq[sm & 15]; + int dw = 1+memoryWaitSeq[dm & 15]; + + int totalTicks = 0; + + if(transfer32) { + if(!memory32[sm & 15]) + sw <<= 1; + if(!memory32[dm & 15]) + dw <<= 1; + } + + totalTicks = (sw+dw)*sc; + + cpuDmaTicksToUpdate += totalTicks; + + if(*extCpuLoopTicks >= 0) { + CPU_BREAK_LOOP; + } +} + +void CPUCheckDMA(int reason, int dmamask) +{ + cpuDmaHack = 0; + // DMA 0 + if((DM0CNT_H & 0x8000) && (dmamask & 1)) { + if(((DM0CNT_H >> 12) & 3) == reason) { + u32 sourceIncrement = 4; + u32 destIncrement = 4; + switch((DM0CNT_H >> 7) & 3) { + case 0: + break; + case 1: + sourceIncrement = (u32)-4; + break; + case 2: + sourceIncrement = 0; + break; + } + switch((DM0CNT_H >> 5) & 3) { + case 0: + break; + case 1: + destIncrement = (u32)-4; + break; + case 2: + destIncrement = 0; + break; + } +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA0) { + int count = (DM0CNT_L ? DM0CNT_L : 0x4000) << 1; + if(DM0CNT_H & 0x0400) + count <<= 1; + log("DMA0: s=%08x d=%08x c=%04x count=%08x\n", dma0Source, dma0Dest, + DM0CNT_H, + count); + } +#endif + doDMA(dma0Source, dma0Dest, sourceIncrement, destIncrement, + DM0CNT_L ? DM0CNT_L : 0x4000, + DM0CNT_H & 0x0400); + cpuDmaHack = 1; + if(DM0CNT_H & 0x4000) { + IF |= 0x0100; + UPDATE_REG(0x202, IF); + } + + if(((DM0CNT_H >> 5) & 3) == 3) { + dma0Dest = DM0DAD_L | (DM0DAD_H << 16); + } + + if(!(DM0CNT_H & 0x0200) || (reason == 0)) { + DM0CNT_H &= 0x7FFF; + UPDATE_REG(0xBA, DM0CNT_H); + } + } + } + + // DMA 1 + if((DM1CNT_H & 0x8000) && (dmamask & 2)) { + if(((DM1CNT_H >> 12) & 3) == reason) { + u32 sourceIncrement = 4; + u32 destIncrement = 4; + switch((DM1CNT_H >> 7) & 3) { + case 0: + break; + case 1: + sourceIncrement = (u32)-4; + break; + case 2: + sourceIncrement = 0; + break; + } + switch((DM1CNT_H >> 5) & 3) { + case 0: + break; + case 1: + destIncrement = (u32)-4; + break; + case 2: + destIncrement = 0; + break; + } + if(reason == 3) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA1) { + log("DMA1: s=%08x d=%08x c=%04x count=%08x\n", dma1Source, dma1Dest, + DM1CNT_H, + 16); + } +#endif + doDMA(dma1Source, dma1Dest, sourceIncrement, 0, 4, + 0x0400); + } else { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA1) { + int count = (DM1CNT_L ? DM1CNT_L : 0x4000) << 1; + if(DM1CNT_H & 0x0400) + count <<= 1; + log("DMA1: s=%08x d=%08x c=%04x count=%08x\n", dma1Source, dma1Dest, + DM1CNT_H, + count); + } +#endif + doDMA(dma1Source, dma1Dest, sourceIncrement, destIncrement, + DM1CNT_L ? DM1CNT_L : 0x4000, + DM1CNT_H & 0x0400); + } + cpuDmaHack = 1; + + if(DM1CNT_H & 0x4000) { + IF |= 0x0200; + UPDATE_REG(0x202, IF); + } + + if(((DM1CNT_H >> 5) & 3) == 3) { + dma1Dest = DM1DAD_L | (DM1DAD_H << 16); + } + + if(!(DM1CNT_H & 0x0200) || (reason == 0)) { + DM1CNT_H &= 0x7FFF; + UPDATE_REG(0xC6, DM1CNT_H); + } + } + } + + // DMA 2 + if((DM2CNT_H & 0x8000) && (dmamask & 4)) { + if(((DM2CNT_H >> 12) & 3) == reason) { + u32 sourceIncrement = 4; + u32 destIncrement = 4; + switch((DM2CNT_H >> 7) & 3) { + case 0: + break; + case 1: + sourceIncrement = (u32)-4; + break; + case 2: + sourceIncrement = 0; + break; + } + switch((DM2CNT_H >> 5) & 3) { + case 0: + break; + case 1: + destIncrement = (u32)-4; + break; + case 2: + destIncrement = 0; + break; + } + if(reason == 3) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA2) { + int count = (4) << 2; + log("DMA2: s=%08x d=%08x c=%04x count=%08x\n", dma2Source, dma2Dest, + DM2CNT_H, + count); + } +#endif + doDMA(dma2Source, dma2Dest, sourceIncrement, 0, 4, + 0x0400); + } else { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA2) { + int count = (DM2CNT_L ? DM2CNT_L : 0x4000) << 1; + if(DM2CNT_H & 0x0400) + count <<= 1; + log("DMA2: s=%08x d=%08x c=%04x count=%08x\n", dma2Source, dma2Dest, + DM2CNT_H, + count); + } +#endif + doDMA(dma2Source, dma2Dest, sourceIncrement, destIncrement, + DM2CNT_L ? DM2CNT_L : 0x4000, + DM2CNT_H & 0x0400); + } + cpuDmaHack = 1; + if(DM2CNT_H & 0x4000) { + IF |= 0x0400; + UPDATE_REG(0x202, IF); + } + + if(((DM2CNT_H >> 5) & 3) == 3) { + dma2Dest = DM2DAD_L | (DM2DAD_H << 16); + } + + if(!(DM2CNT_H & 0x0200) || (reason == 0)) { + DM2CNT_H &= 0x7FFF; + UPDATE_REG(0xD2, DM2CNT_H); + } + } + } + + // DMA 3 + if((DM3CNT_H & 0x8000) && (dmamask & 8)) { + if(((DM3CNT_H >> 12) & 3) == reason) { + u32 sourceIncrement = 4; + u32 destIncrement = 4; + switch((DM3CNT_H >> 7) & 3) { + case 0: + break; + case 1: + sourceIncrement = (u32)-4; + break; + case 2: + sourceIncrement = 0; + break; + } + switch((DM3CNT_H >> 5) & 3) { + case 0: + break; + case 1: + destIncrement = (u32)-4; + break; + case 2: + destIncrement = 0; + break; + } +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_DMA3) { + int count = (DM3CNT_L ? DM3CNT_L : 0x10000) << 1; + if(DM3CNT_H & 0x0400) + count <<= 1; + log("DMA3: s=%08x d=%08x c=%04x count=%08x\n", dma3Source, dma3Dest, + DM3CNT_H, + count); + } +#endif + doDMA(dma3Source, dma3Dest, sourceIncrement, destIncrement, + DM3CNT_L ? DM3CNT_L : 0x10000, + DM3CNT_H & 0x0400); + if(DM3CNT_H & 0x4000) { + IF |= 0x0800; + UPDATE_REG(0x202, IF); + } + + if(((DM3CNT_H >> 5) & 3) == 3) { + dma3Dest = DM3DAD_L | (DM3DAD_H << 16); + } + + if(!(DM3CNT_H & 0x0200) || (reason == 0)) { + DM3CNT_H &= 0x7FFF; + UPDATE_REG(0xDE, DM3CNT_H); + } + } + } + cpuDmaHack = 0; +} + +void CPUUpdateRegister(u32 address, u16 value) +{ + switch(address) { + case 0x00: + { + bool change = ((DISPCNT ^ value) & 0x80) ? true : false; + bool changeBG = ((DISPCNT ^ value) & 0x0F00) ? true : false; + DISPCNT = (value & 0xFFF7); + UPDATE_REG(0x00, DISPCNT); + layerEnable = layerSettings & value; + windowOn = (layerEnable & 0x6000) ? true : false; + if(change && !((value & 0x80))) { + if(!(DISPSTAT & 1)) { + lcdTicks = 960; + // VCOUNT = 0; + // UPDATE_REG(0x06, VCOUNT); + DISPSTAT &= 0xFFFC; + UPDATE_REG(0x04, DISPSTAT); + CPUCompareVCOUNT(); + } + // (*renderLine)(); + } + CPUUpdateRender(); + // we only care about changes in BG0-BG3 + if(changeBG) + CPUUpdateRenderBuffers(false); + // CPUUpdateTicks(); + } + break; + case 0x04: + DISPSTAT = (value & 0xFF38) | (DISPSTAT & 7); + UPDATE_REG(0x04, DISPSTAT); + break; + case 0x06: + // not writable + break; + case 0x08: + BG0CNT = (value & 0xDFCF); + UPDATE_REG(0x08, BG0CNT); + break; + case 0x0A: + BG1CNT = (value & 0xDFCF); + UPDATE_REG(0x0A, BG1CNT); + break; + case 0x0C: + BG2CNT = (value & 0xFFCF); + UPDATE_REG(0x0C, BG2CNT); + break; + case 0x0E: + BG3CNT = (value & 0xFFCF); + UPDATE_REG(0x0E, BG3CNT); + break; + case 0x10: + BG0HOFS = value & 511; + UPDATE_REG(0x10, BG0HOFS); + break; + case 0x12: + BG0VOFS = value & 511; + UPDATE_REG(0x12, BG0VOFS); + break; + case 0x14: + BG1HOFS = value & 511; + UPDATE_REG(0x14, BG1HOFS); + break; + case 0x16: + BG1VOFS = value & 511; + UPDATE_REG(0x16, BG1VOFS); + break; + case 0x18: + BG2HOFS = value & 511; + UPDATE_REG(0x18, BG2HOFS); + break; + case 0x1A: + BG2VOFS = value & 511; + UPDATE_REG(0x1A, BG2VOFS); + break; + case 0x1C: + BG3HOFS = value & 511; + UPDATE_REG(0x1C, BG3HOFS); + break; + case 0x1E: + BG3VOFS = value & 511; + UPDATE_REG(0x1E, BG3VOFS); + break; + case 0x20: + BG2PA = value; + UPDATE_REG(0x20, BG2PA); + break; + case 0x22: + BG2PB = value; + UPDATE_REG(0x22, BG2PB); + break; + case 0x24: + BG2PC = value; + UPDATE_REG(0x24, BG2PC); + break; + case 0x26: + BG2PD = value; + UPDATE_REG(0x26, BG2PD); + break; + case 0x28: + BG2X_L = value; + UPDATE_REG(0x28, BG2X_L); + gfxBG2Changed |= 1; + break; + case 0x2A: + BG2X_H = (value & 0xFFF); + UPDATE_REG(0x2A, BG2X_H); + gfxBG2Changed |= 1; + break; + case 0x2C: + BG2Y_L = value; + UPDATE_REG(0x2C, BG2Y_L); + gfxBG2Changed |= 2; + break; + case 0x2E: + BG2Y_H = value & 0xFFF; + UPDATE_REG(0x2E, BG2Y_H); + gfxBG2Changed |= 2; + break; + case 0x30: + BG3PA = value; + UPDATE_REG(0x30, BG3PA); + break; + case 0x32: + BG3PB = value; + UPDATE_REG(0x32, BG3PB); + break; + case 0x34: + BG3PC = value; + UPDATE_REG(0x34, BG3PC); + break; + case 0x36: + BG3PD = value; + UPDATE_REG(0x36, BG3PD); + break; + case 0x38: + BG3X_L = value; + UPDATE_REG(0x38, BG3X_L); + gfxBG3Changed |= 1; + break; + case 0x3A: + BG3X_H = value & 0xFFF; + UPDATE_REG(0x3A, BG3X_H); + gfxBG3Changed |= 1; + break; + case 0x3C: + BG3Y_L = value; + UPDATE_REG(0x3C, BG3Y_L); + gfxBG3Changed |= 2; + break; + case 0x3E: + BG3Y_H = value & 0xFFF; + UPDATE_REG(0x3E, BG3Y_H); + gfxBG3Changed |= 2; + break; + case 0x40: + WIN0H = value; + UPDATE_REG(0x40, WIN0H); + CPUUpdateWindow0(); + break; + case 0x42: + WIN1H = value; + UPDATE_REG(0x42, WIN1H); + CPUUpdateWindow1(); + break; + case 0x44: + WIN0V = value; + UPDATE_REG(0x44, WIN0V); + break; + case 0x46: + WIN1V = value; + UPDATE_REG(0x46, WIN1V); + break; + case 0x48: + WININ = value & 0x3F3F; + UPDATE_REG(0x48, WININ); + break; + case 0x4A: + WINOUT = value & 0x3F3F; + UPDATE_REG(0x4A, WINOUT); + break; + case 0x4C: + MOSAIC = value; + UPDATE_REG(0x4C, MOSAIC); + break; + case 0x50: + BLDMOD = value & 0x3FFF; + UPDATE_REG(0x50, BLDMOD); + fxOn = ((BLDMOD>>6)&3) != 0; + CPUUpdateRender(); + break; + case 0x52: + COLEV = value & 0x1F1F; + UPDATE_REG(0x52, COLEV); + break; + case 0x54: + COLY = value & 0x1F; + UPDATE_REG(0x54, COLY); + break; + case 0x60: + case 0x62: + case 0x64: + case 0x68: + case 0x6c: + case 0x70: + case 0x72: + case 0x74: + case 0x78: + case 0x7c: + case 0x80: + case 0x84: + soundEvent(address&0xFF, (u8)(value & 0xFF)); + soundEvent((address&0xFF)+1, (u8)(value>>8)); + break; + case 0x82: + case 0x88: + case 0xa0: + case 0xa2: + case 0xa4: + case 0xa6: + case 0x90: + case 0x92: + case 0x94: + case 0x96: + case 0x98: + case 0x9a: + case 0x9c: + case 0x9e: + soundEvent(address&0xFF, value); + break; + case 0xB0: + DM0SAD_L = value; + UPDATE_REG(0xB0, DM0SAD_L); + break; + case 0xB2: + DM0SAD_H = value & 0x07FF; + UPDATE_REG(0xB2, DM0SAD_H); + break; + case 0xB4: + DM0DAD_L = value; + UPDATE_REG(0xB4, DM0DAD_L); + break; + case 0xB6: + DM0DAD_H = value & 0x07FF; + UPDATE_REG(0xB6, DM0DAD_H); + break; + case 0xB8: + DM0CNT_L = value & 0x3FFF; + UPDATE_REG(0xB8, 0); + break; + case 0xBA: + { + bool start = ((DM0CNT_H ^ value) & 0x8000) ? true : false; + value &= 0xF7E0; + + DM0CNT_H = value; + UPDATE_REG(0xBA, DM0CNT_H); + + if(start && (value & 0x8000)) { + dma0Source = DM0SAD_L | (DM0SAD_H << 16); + dma0Dest = DM0DAD_L | (DM0DAD_H << 16); + CPUCheckDMA(0, 1); + } + } + break; + case 0xBC: + DM1SAD_L = value; + UPDATE_REG(0xBC, DM1SAD_L); + break; + case 0xBE: + DM1SAD_H = value & 0x0FFF; + UPDATE_REG(0xBE, DM1SAD_H); + break; + case 0xC0: + DM1DAD_L = value; + UPDATE_REG(0xC0, DM1DAD_L); + break; + case 0xC2: + DM1DAD_H = value & 0x07FF; + UPDATE_REG(0xC2, DM1DAD_H); + break; + case 0xC4: + DM1CNT_L = value & 0x3FFF; + UPDATE_REG(0xC4, 0); + break; + case 0xC6: + { + bool start = ((DM1CNT_H ^ value) & 0x8000) ? true : false; + value &= 0xF7E0; + + DM1CNT_H = value; + UPDATE_REG(0xC6, DM1CNT_H); + + if(start && (value & 0x8000)) { + dma1Source = DM1SAD_L | (DM1SAD_H << 16); + dma1Dest = DM1DAD_L | (DM1DAD_H << 16); + CPUCheckDMA(0, 2); + } + } + break; + case 0xC8: + DM2SAD_L = value; + UPDATE_REG(0xC8, DM2SAD_L); + break; + case 0xCA: + DM2SAD_H = value & 0x0FFF; + UPDATE_REG(0xCA, DM2SAD_H); + break; + case 0xCC: + DM2DAD_L = value; + UPDATE_REG(0xCC, DM2DAD_L); + break; + case 0xCE: + DM2DAD_H = value & 0x07FF; + UPDATE_REG(0xCE, DM2DAD_H); + break; + case 0xD0: + DM2CNT_L = value & 0x3FFF; + UPDATE_REG(0xD0, 0); + break; + case 0xD2: + { + bool start = ((DM2CNT_H ^ value) & 0x8000) ? true : false; + + value &= 0xF7E0; + + DM2CNT_H = value; + UPDATE_REG(0xD2, DM2CNT_H); + + if(start && (value & 0x8000)) { + dma2Source = DM2SAD_L | (DM2SAD_H << 16); + dma2Dest = DM2DAD_L | (DM2DAD_H << 16); + + CPUCheckDMA(0, 4); + } + } + break; + case 0xD4: + DM3SAD_L = value; + UPDATE_REG(0xD4, DM3SAD_L); + break; + case 0xD6: + DM3SAD_H = value & 0x0FFF; + UPDATE_REG(0xD6, DM3SAD_H); + break; + case 0xD8: + DM3DAD_L = value; + UPDATE_REG(0xD8, DM3DAD_L); + break; + case 0xDA: + DM3DAD_H = value & 0x0FFF; + UPDATE_REG(0xDA, DM3DAD_H); + break; + case 0xDC: + DM3CNT_L = value; + UPDATE_REG(0xDC, 0); + break; + case 0xDE: + { + bool start = ((DM3CNT_H ^ value) & 0x8000) ? true : false; + + value &= 0xFFE0; + + DM3CNT_H = value; + UPDATE_REG(0xDE, DM3CNT_H); + + if(start && (value & 0x8000)) { + dma3Source = DM3SAD_L | (DM3SAD_H << 16); + dma3Dest = DM3DAD_L | (DM3DAD_H << 16); + CPUCheckDMA(0,8); + } + } + break; + case 0x100: + timer0Reload = value; + break; + case 0x102: + timer0Ticks = timer0ClockReload = TIMER_TICKS[value & 3]; + if(!timer0On && (value & 0x80)) { + // reload the counter + TM0D = timer0Reload; + if(timer0ClockReload == 1) + timer0Ticks = 0x10000 - TM0D; + UPDATE_REG(0x100, TM0D); + } + timer0On = value & 0x80 ? true : false; + TM0CNT = value & 0xC7; + UPDATE_REG(0x102, TM0CNT); + // CPUUpdateTicks(); + break; + case 0x104: + timer1Reload = value; + break; + case 0x106: + timer1Ticks = timer1ClockReload = TIMER_TICKS[value & 3]; + if(!timer1On && (value & 0x80)) { + // reload the counter + TM1D = timer1Reload; + if(timer1ClockReload == 1) + timer1Ticks = 0x10000 - TM1D; + UPDATE_REG(0x104, TM1D); + } + timer1On = value & 0x80 ? true : false; + TM1CNT = value & 0xC7; + UPDATE_REG(0x106, TM1CNT); + break; + case 0x108: + timer2Reload = value; + break; + case 0x10A: + timer2Ticks = timer2ClockReload = TIMER_TICKS[value & 3]; + if(!timer2On && (value & 0x80)) { + // reload the counter + TM2D = timer2Reload; + if(timer2ClockReload == 1) + timer2Ticks = 0x10000 - TM2D; + UPDATE_REG(0x108, TM2D); + } + timer2On = value & 0x80 ? true : false; + TM2CNT = value & 0xC7; + UPDATE_REG(0x10A, TM2CNT); + break; + case 0x10C: + timer3Reload = value; + break; + case 0x10E: + timer3Ticks = timer3ClockReload = TIMER_TICKS[value & 3]; + if(!timer3On && (value & 0x80)) { + // reload the counter + TM3D = timer3Reload; + if(timer3ClockReload == 1) + timer3Ticks = 0x10000 - TM3D; + UPDATE_REG(0x10C, TM3D); + } + timer3On = value & 0x80 ? true : false; + TM3CNT = value & 0xC7; + UPDATE_REG(0x10E, TM3CNT); + break; + case 0x128: + if(value & 0x80) { + value &= 0xff7f; + if(value & 1 && (value & 0x4000)) { + UPDATE_REG(0x12a, 0xFF); + IF |= 0x80; + UPDATE_REG(0x202, IF); + value &= 0x7f7f; + } + } + UPDATE_REG(0x128, value); + break; + case 0x130: + P1 |= (value & 0x3FF); + UPDATE_REG(0x130, P1); + break; + case 0x132: + UPDATE_REG(0x132, value & 0xC3FF); + break; + case 0x200: + IE = value & 0x3FFF; + UPDATE_REG(0x200, IE); + if((IME & 1) && (IF & IE) && armIrqEnable) { + CPU_BREAK_LOOP_2; + } + break; + case 0x202: + IF ^= (value & IF); + UPDATE_REG(0x202, IF); + break; + case 0x204: + { + int i; + memoryWait[0x0e] = memoryWaitSeq[0x0e] = gamepakRamWaitState[value & 3]; + + if(!speedHack) { + memoryWait[0x08] = memoryWait[0x09] = gamepakWaitState[(value >> 2) & 7]; + memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = + gamepakWaitState0[(value >> 2) & 7]; + + memoryWait[0x0a] = memoryWait[0x0b] = gamepakWaitState[(value >> 5) & 7]; + memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] = + gamepakWaitState1[(value >> 5) & 7]; + + memoryWait[0x0c] = memoryWait[0x0d] = gamepakWaitState[(value >> 8) & 7]; + memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] = + gamepakWaitState2[(value >> 8) & 7]; + } else { + memoryWait[0x08] = memoryWait[0x09] = 4; + memoryWaitSeq[0x08] = memoryWaitSeq[0x09] = 2; + + memoryWait[0x0a] = memoryWait[0x0b] = 4; + memoryWaitSeq[0x0a] = memoryWaitSeq[0x0b] = 4; + + memoryWait[0x0c] = memoryWait[0x0d] = 4; + memoryWaitSeq[0x0c] = memoryWaitSeq[0x0d] = 8; + } + for(i = 0; i < 16; i++) { + memoryWaitFetch32[i] = memoryWait32[i] = memoryWait[i] * + (memory32[i] ? 1 : 2); + memoryWaitFetch[i] = memoryWait[i]; + } + memoryWaitFetch32[3] += 1; + memoryWaitFetch32[2] += 3; + + prefetchActive = false; + prefetchApplies = false; + if(value & 0x4000) { + for(i = 8; i < 16; i++) { + memoryWaitFetch32[i] = 2*cpuMemoryWait[i]; + memoryWaitFetch[i] = cpuMemoryWait[i]; + } + if(((value & 3) == 3)) + { + if(!memLagTempEnabled) + { + memoryWaitFetch[8]--; // hack to prevent inaccurately extreme lag at some points of many games (possibly from no pre-fetch emulation) + /// FIXME: how correct is this? Should it set the fetch to 0 or change fetch32 or anything else? + + prefetchActive = true; + } + prefetchApplies = true; + } + } + //if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600); + //if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600); + prefetchPrevActive = prefetchActive; + + UPDATE_REG(0x204, value); + } + break; + case 0x208: + IME = value & 1; + UPDATE_REG(0x208, IME); + if((IME & 1) && (IF & IE) && armIrqEnable) { + CPU_BREAK_LOOP_2; + } + break; + case 0x300: + if(value != 0) + value &= 0xFFFE; + UPDATE_REG(0x300, value); + break; + default: + UPDATE_REG(address&0x3FE, value); + break; + } +} + +void CPUWriteHalfWord(u32 address, u16 value) +{ +#ifdef DEV_VERSION + if(address & 1) { + if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned halfword write: %04x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } + } +#endif + + switch(address >> 24) { + case 2: +#ifdef SDL + if(*((u16 *)&freezeWorkRAM[address & 0x3FFFE])) + cheatsWriteHalfWord((u16 *)&workRAM[address & 0x3FFFE], + value, + *((u16 *)&freezeWorkRAM[address & 0x3FFFE])); + else +#endif + WRITE16LE(((u16 *)&workRAM[address & 0x3FFFE]),value); + break; + case 3: +#ifdef SDL + if(*((u16 *)&freezeInternalRAM[address & 0x7ffe])) + cheatsWriteHalfWord((u16 *)&internalRAM[address & 0x7ffe], + value, + *((u16 *)&freezeInternalRAM[address & 0x7ffe])); + else +#endif + WRITE16LE(((u16 *)&internalRAM[address & 0x7ffe]), value); + break; + case 4: + CPUUpdateRegister(address & 0x3fe, value); + break; + case 5: + WRITE16LE(((u16 *)&paletteRAM[address & 0x3fe]), value); + break; + case 6: + if(address & 0x10000) + WRITE16LE(((u16 *)&vram[address & 0x17ffe]), value); + else + WRITE16LE(((u16 *)&vram[address & 0x1fffe]), value); + break; + case 7: + WRITE16LE(((u16 *)&oam[address & 0x3fe]), value); + break; + case 8: + case 9: + if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) { + if(!rtcWrite(address, value)) + goto unwritable; + } else if(!agbPrintWrite(address, value)) goto unwritable; + break; + case 13: + if(cpuEEPROMEnabled) { + eepromWrite(address, (u8)value); + break; + } + goto unwritable; + case 14: + if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) { + (*cpuSaveGameFunc)(address, (u8)value); + break; + } + goto unwritable; + default: + unwritable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal halfword write: %04x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } +#endif + break; + } +} + +void CPUWriteByte(u32 address, u8 b) +{ + switch(address >> 24) { + case 2: +#ifdef SDL + if(freezeWorkRAM[address & 0x3FFFF]) + cheatsWriteByte(&workRAM[address & 0x3FFFF], b); + else +#endif + workRAM[address & 0x3FFFF] = b; + break; + case 3: +#ifdef SDL + if(freezeInternalRAM[address & 0x7fff]) + cheatsWriteByte(&internalRAM[address & 0x7fff], b); + else +#endif + internalRAM[address & 0x7fff] = b; + break; + case 4: + switch(address & 0x3FF) { + case 0x301: + if(b == 0x80) + stopState = true; + holdState = 1; + holdType = -1; + break; + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x68: + case 0x69: + case 0x6c: + case 0x6d: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x78: + case 0x79: + case 0x7c: + case 0x7d: + case 0x80: + case 0x81: + case 0x84: + case 0x85: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9a: + case 0x9b: + case 0x9c: + case 0x9d: + case 0x9e: + case 0x9f: + soundEvent(address&0xFF, b); + break; + default: + // if(address & 1) { + // CPUWriteHalfWord(address-1, (CPUReadHalfWord(address-1)&0x00FF)|((int)b<<8)); + // } else + if(address & 1) + CPUUpdateRegister(address & 0x3fe, + ((READ16LE(((u16 *)&ioMem[address & 0x3fe]))) + & 0x00FF) | + b<<8); + else + CPUUpdateRegister(address & 0x3fe, + ((READ16LE(((u16 *)&ioMem[address & 0x3fe])) & 0xFF00) | b)); + } + break; + case 5: + // no need to switch + *((u16 *)&paletteRAM[address & 0x3FE]) = (b << 8) | b; + break; + case 6: + // no need to switch + if(address & 0x10000) + *((u16 *)&vram[address & 0x17FFE]) = (b << 8) | b; + else + *((u16 *)&vram[address & 0x1FFFE]) = (b << 8) | b; + break; + case 7: + // no need to switch + *((u16 *)&oam[address & 0x3FE]) = (b << 8) | b; + break; + case 13: + if(cpuEEPROMEnabled) { + eepromWrite(address, b); + break; + } + goto unwritable; + case 14: + if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) { + (*cpuSaveGameFunc)(address, b); + break; + } + // default + default: + unwritable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal byte write: %02x to %08x from %08x\n", + b, + address, + armMode ? armNextPC - 4 : armNextPC -2 ); + } +#endif + break; + } +} + +u8 cpuBitsSet[256]; +u8 cpuLowestBitSet[256]; + +void CPUInit(const char *biosFileName, bool useBiosFile) +{ +#ifdef WORDS_BIGENDIAN + if(!cpuBiosSwapped) { + for(unsigned int i = 0; i < sizeof(myROM)/4; i++) { + WRITE32LE(&myROM[i], myROM[i]); + } + cpuBiosSwapped = true; + } +#endif + gbaSaveType = 0; + eepromInUse = 0; + saveType = 0; + useBios = false; + + if(useBiosFile) { + int size = 0x4000; + if(utilLoad(biosFileName, + CPUIsGBABios, + bios, + size)) { + if(size == 0x4000) + useBios = true; + else + systemMessage(MSG_INVALID_BIOS_FILE_SIZE, N_("Invalid BIOS file size")); + } + } + + if(!useBios) { + memcpy(bios, myROM, sizeof(myROM)); + } + + int i = 0; + + biosProtected[0] = 0x00; + biosProtected[1] = 0xf0; + biosProtected[2] = 0x29; + biosProtected[3] = 0xe1; + + for(i = 0; i < 256; i++) { + int count = 0; + int j; + for(j = 0; j < 8; j++) + if(i & (1 << j)) + count++; + cpuBitsSet[i] = count; + + for(j = 0; j < 8; j++) + if(i & (1 << j)) + break; + cpuLowestBitSet[i] = j; + } + + for(i = 0; i < 0x400; i++) + ioReadable[i] = true; + for(i = 0x10; i < 0x48; i++) + ioReadable[i] = false; + for(i = 0x4c; i < 0x50; i++) + ioReadable[i] = false; + for(i = 0x54; i < 0x60; i++) + ioReadable[i] = false; + for(i = 0x8c; i < 0x90; i++) + ioReadable[i] = false; + for(i = 0xa0; i < 0xb8; i++) + ioReadable[i] = false; + for(i = 0xbc; i < 0xc4; i++) + ioReadable[i] = false; + for(i = 0xc8; i < 0xd0; i++) + ioReadable[i] = false; + for(i = 0xd4; i < 0xdc; i++) + ioReadable[i] = false; + for(i = 0xe0; i < 0x100; i++) + ioReadable[i] = false; + for(i = 0x110; i < 0x120; i++) + ioReadable[i] = false; + for(i = 0x12c; i < 0x130; i++) + ioReadable[i] = false; + for(i = 0x138; i < 0x140; i++) + ioReadable[i] = false; + for(i = 0x144; i < 0x150; i++) + ioReadable[i] = false; + for(i = 0x15c; i < 0x200; i++) + ioReadable[i] = false; + for(i = 0x20c; i < 0x300; i++) + ioReadable[i] = false; + for(i = 0x304; i < 0x400; i++) + ioReadable[i] = false; + + *((u16 *)&rom[0x1fe209c]) = 0xdffa; // SWI 0xFA + *((u16 *)&rom[0x1fe209e]) = 0x4770; // BX LR + + { + int origMemoryWaitFetch[16] = { 3, 0, 3, 0, 0, 1, 1, 0, 4, 4, 4, 4, 4, 4, 4, 0 }; + int origMemoryWaitFetch32[16] = { 6, 0, 6, 0, 0, 2, 2, 0, 8, 8, 8, 8, 8, 8, 8, 0 }; + memcpy(memoryWaitFetch, origMemoryWaitFetch, 16*sizeof(int)); + memcpy(memoryWaitFetch32, origMemoryWaitFetch32, 16*sizeof(int)); + } + +} + +void CPUReset() +{ +#if (defined(WIN32) && !defined(SDL)) + theApp.globalFrameCount = 0; +#endif + VBAMovieSignalReset(); + + if(gbaSaveType == 0) { + if(eepromInUse) + gbaSaveType = 3; + else + switch(saveType) { + case 1: + gbaSaveType = 1; + break; + case 2: + gbaSaveType = 2; + break; + } + } + + rtcReset(); + // clean registers + memset(®[0], 0, sizeof(reg)); + // clean OAM + memset(oam, 0, 0x400); + // clean palette + memset(paletteRAM, 0, 0x400); + // clean picture + memset(pix, 0, 4*160*240); + // clean vram + memset(vram, 0, 0x20000); + // clean io memory + memset(ioMem, 0, 0x400); + // clean RAM + memset(internalRAM, 0, 0x8000); /// FIXME: is it unsafe to erase ALL of this? Even the init code doesn't. + memset(workRAM, 0, 0x40000); /// ditto + + DISPCNT = 0x0080; + DISPSTAT = 0x0000; + VCOUNT = 0x0000; + BG0CNT = 0x0000; + BG1CNT = 0x0000; + BG2CNT = 0x0000; + BG3CNT = 0x0000; + BG0HOFS = 0x0000; + BG0VOFS = 0x0000; + BG1HOFS = 0x0000; + BG1VOFS = 0x0000; + BG2HOFS = 0x0000; + BG2VOFS = 0x0000; + BG3HOFS = 0x0000; + BG3VOFS = 0x0000; + BG2PA = 0x0100; + BG2PB = 0x0000; + BG2PC = 0x0000; + BG2PD = 0x0100; + BG2X_L = 0x0000; + BG2X_H = 0x0000; + BG2Y_L = 0x0000; + BG2Y_H = 0x0000; + BG3PA = 0x0100; + BG3PB = 0x0000; + BG3PC = 0x0000; + BG3PD = 0x0100; + BG3X_L = 0x0000; + BG3X_H = 0x0000; + BG3Y_L = 0x0000; + BG3Y_H = 0x0000; + WIN0H = 0x0000; + WIN1H = 0x0000; + WIN0V = 0x0000; + WIN1V = 0x0000; + WININ = 0x0000; + WINOUT = 0x0000; + MOSAIC = 0x0000; + BLDMOD = 0x0000; + COLEV = 0x0000; + COLY = 0x0000; + DM0SAD_L = 0x0000; + DM0SAD_H = 0x0000; + DM0DAD_L = 0x0000; + DM0DAD_H = 0x0000; + DM0CNT_L = 0x0000; + DM0CNT_H = 0x0000; + DM1SAD_L = 0x0000; + DM1SAD_H = 0x0000; + DM1DAD_L = 0x0000; + DM1DAD_H = 0x0000; + DM1CNT_L = 0x0000; + DM1CNT_H = 0x0000; + DM2SAD_L = 0x0000; + DM2SAD_H = 0x0000; + DM2DAD_L = 0x0000; + DM2DAD_H = 0x0000; + DM2CNT_L = 0x0000; + DM2CNT_H = 0x0000; + DM3SAD_L = 0x0000; + DM3SAD_H = 0x0000; + DM3DAD_L = 0x0000; + DM3DAD_H = 0x0000; + DM3CNT_L = 0x0000; + DM3CNT_H = 0x0000; + TM0D = 0x0000; + TM0CNT = 0x0000; + TM1D = 0x0000; + TM1CNT = 0x0000; + TM2D = 0x0000; + TM2CNT = 0x0000; + TM3D = 0x0000; + TM3CNT = 0x0000; + P1 = 0x03FF; + IE = 0x0000; + IF = 0x0000; + IME = 0x0000; + + armMode = 0x1F; + + if(cpuIsMultiBoot) { + reg[13].I = 0x03007F00; + reg[15].I = 0x02000000; + reg[16].I = 0x00000000; + reg[R13_IRQ].I = 0x03007FA0; + reg[R13_SVC].I = 0x03007FE0; + armIrqEnable = true; + } else { + if(useBios && !skipBios) { + reg[15].I = 0x00000000; + armMode = 0x13; + armIrqEnable = false; + } else { + reg[13].I = 0x03007F00; + reg[15].I = 0x08000000; + reg[16].I = 0x00000000; + reg[R13_IRQ].I = 0x03007FA0; + reg[R13_SVC].I = 0x03007FE0; + armIrqEnable = true; + } + } + armState = true; + C_FLAG = V_FLAG = N_FLAG = Z_FLAG = false; + UPDATE_REG(0x00, DISPCNT); + UPDATE_REG(0x20, BG2PA); + UPDATE_REG(0x26, BG2PD); + UPDATE_REG(0x30, BG3PA); + UPDATE_REG(0x36, BG3PD); + UPDATE_REG(0x130, P1); + UPDATE_REG(0x88, 0x200); + + // disable FIQ + reg[16].I |= 0x40; + + CPUUpdateCPSR(); + + armNextPC = reg[15].I; + reg[15].I += 4; + + // reset internal state + holdState = false; + holdType = 0; + + biosProtected[0] = 0x00; + biosProtected[1] = 0xf0; + biosProtected[2] = 0x29; + biosProtected[3] = 0xe1; + + BIOS_RegisterRamReset(); + + lcdTicks = 960; + timer0On = false; + timer0Ticks = 0; + timer0Reload = 0; + timer0ClockReload = 0; + timer1On = false; + timer1Ticks = 0; + timer1Reload = 0; + timer1ClockReload = 0; + timer2On = false; + timer2Ticks = 0; + timer2Reload = 0; + timer2ClockReload = 0; + timer3On = false; + timer3Ticks = 0; + timer3Reload = 0; + timer3ClockReload = 0; + dma0Source = 0; + dma0Dest = 0; + dma1Source = 0; + dma1Dest = 0; + dma2Source = 0; + dma2Dest = 0; + dma3Source = 0; + dma3Dest = 0; + cpuSaveGameFunc = flashSaveDecide; + renderLine = mode0RenderLine; + fxOn = false; + windowOn = false; + frameCount = 0; + saveType = 0; + layerEnable = DISPCNT & layerSettings; + + CPUUpdateRenderBuffers(true); + + for(int i = 0; i < 256; i++) { + map[i].address = (u8 *)&dummyAddress; + map[i].mask = 0; + } + + map[0].address = bios; + map[0].mask = 0x3FFF; + map[2].address = workRAM; + map[2].mask = 0x3FFFF; + map[3].address = internalRAM; + map[3].mask = 0x7FFF; + map[4].address = ioMem; + map[4].mask = 0x3FF; + map[5].address = paletteRAM; + map[5].mask = 0x3FF; + map[6].address = vram; + map[6].mask = 0x1FFFF; + map[7].address = oam; + map[7].mask = 0x3FF; + map[8].address = rom; + map[8].mask = 0x1FFFFFF; + map[9].address = rom; + map[9].mask = 0x1FFFFFF; + map[10].address = rom; + map[10].mask = 0x1FFFFFF; + map[12].address = rom; + map[12].mask = 0x1FFFFFF; + map[14].address = flashSaveMemory; + map[14].mask = 0xFFFF; + + eepromReset(); + flashReset(); + + soundReset(); + + CPUUpdateWindow0(); + CPUUpdateWindow1(); + + // make sure registers are correctly initialized if not using BIOS + if(!useBios) { + if(cpuIsMultiBoot) + BIOS_RegisterRamReset(0xfe); + else + BIOS_RegisterRamReset(0xff); + } else { + if(cpuIsMultiBoot) + BIOS_RegisterRamReset(0xfe); + } + + switch(cpuSaveType) { + case 0: // automatic + cpuSramEnabled = true; + cpuFlashEnabled = true; + cpuEEPROMEnabled = true; + cpuEEPROMSensorEnabled = false; + break; + case 1: // EEPROM + cpuSramEnabled = false; + cpuFlashEnabled = false; + cpuEEPROMEnabled = true; + cpuEEPROMSensorEnabled = false; + break; + case 2: // SRAM + cpuSramEnabled = true; + cpuFlashEnabled = false; + cpuEEPROMEnabled = false; + cpuEEPROMSensorEnabled = false; + cpuSaveGameFunc = sramWrite; + break; + case 3: // FLASH + cpuSramEnabled = false; + cpuFlashEnabled = true; + cpuEEPROMEnabled = false; + cpuEEPROMSensorEnabled = false; + cpuSaveGameFunc = flashWrite; + break; + case 4: // EEPROM+Sensor + cpuSramEnabled = false; + cpuFlashEnabled = false; + cpuEEPROMEnabled = true; + cpuEEPROMSensorEnabled = true; + break; + case 5: // NONE + cpuSramEnabled = false; + cpuFlashEnabled = false; + cpuEEPROMEnabled = false; + cpuEEPROMSensorEnabled = false; + break; + } + +#if (defined(WIN32) && !defined(SDL)) + theApp.sensorX = theApp.sensorY = 2047; +#else + extern int sensorX, sensorY; // from SDL.cpp + sensorX = sensorY = 2047; +#endif + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + lastTime = systemGetClock(); +} + +void CPUInterrupt() +{ + u32 PC = reg[15].I; + bool savedState = armState; + CPUSwitchMode(0x12, true, false); + reg[14].I = PC; + if(!savedState) + reg[14].I += 2; + reg[15].I = 0x18; + armState = true; + armIrqEnable = false; + + armNextPC = reg[15].I; + reg[15].I += 4; + + // if(!holdState) + biosProtected[0] = 0x02; + biosProtected[1] = 0xc0; + biosProtected[2] = 0x5e; + biosProtected[3] = 0xe5; +} + +void TogglePrefetchHack() +{ + memLagTempEnabled = !memLagTempEnabled; + + if(emulating) + { + extern bool prefetchActive, prefetchPrevActive, prefetchApplies; + if(prefetchApplies && prefetchActive == memLagTempEnabled) + { + prefetchActive = !prefetchActive; + //if(prefetchActive && !prefetchPrevActive) systemScreenMessage("pre-fetch enabled",3,600); + //if(!prefetchActive && prefetchPrevActive) systemScreenMessage("pre-fetch disabled",3,600); + extern int memoryWaitFetch [16]; + if(prefetchActive) memoryWaitFetch[8]--; + else memoryWaitFetch[8]++; + prefetchPrevActive = prefetchActive; + } + } +} + +void SetPrefetchHack(bool set) +{ + if(memLagTempEnabled == set) + TogglePrefetchHack(); +} + +#ifdef SDL +void log(const char *defaultMsg, ...) +{ + char buffer[2048]; + va_list valist; + + va_start(valist, defaultMsg); + vsprintf(buffer, defaultMsg, valist); + + if(out == NULL) { + out = fopen("trace.log","w"); + } + + fputs(buffer, out); + + va_end(valist); +} +#else +extern void winlog(const char *, ...); +#endif + +static bool frameBoundary = false; + +void CPULoop(int ticks) +{ + int clockTicks; + int cpuLoopTicks = 0; + int timerOverflow = 0; + // variables used by the CPU core + + extCpuLoopTicks = &cpuLoopTicks; + extClockTicks = &clockTicks; + extTicks = &ticks; + + cpuLoopTicks = CPUUpdateTicks(); + if(cpuLoopTicks > ticks) { + cpuLoopTicks = ticks; + cpuSavedTicks = ticks; + } + + if(intState) { + cpuLoopTicks = 5; + cpuSavedTicks = 5; + } + + for(;;) { +#ifndef FINAL_VERSION + if(systemDebug) { + if(systemDebug >= 10 && !holdState) { + CPUUpdateCPSR(); + sprintf(buffer, "R00=%08x R01=%08x R02=%08x R03=%08x R04=%08x R05=%08x R06=%08x R07=%08x R08=%08x R09=%08x R10=%08x R11=%08x R12=%08x R13=%08x R14=%08x R15=%08x R16=%08x R17=%08x\n", + reg[0].I, reg[1].I, reg[2].I, reg[3].I, reg[4].I, reg[5].I, + reg[6].I, reg[7].I, reg[8].I, reg[9].I, reg[10].I, reg[11].I, + reg[12].I, reg[13].I, reg[14].I, reg[15].I, reg[16].I, + reg[17].I); +#ifdef SDL + log(buffer); +#else + winlog(buffer); +#endif + } else if(!holdState) { + sprintf(buffer, "PC=%08x\n", armNextPC); +#ifdef SDL + log(buffer); +#else + winlog(buffer); +#endif + } + } +#endif + + if(!holdState) { + if(armState) { +#include "arm-new.h" + } else { +#include "thumb.h" + } + } else { + clockTicks = lcdTicks; + + if(soundTicks < clockTicks) + clockTicks = soundTicks; + + if(timer0On && (timer0Ticks < clockTicks)) { + clockTicks = timer0Ticks; + } + if(timer1On && (timer1Ticks < clockTicks)) { + clockTicks = timer1Ticks; + } + if(timer2On && (timer2Ticks < clockTicks)) { + clockTicks = timer2Ticks; + } + if(timer3On && (timer3Ticks < clockTicks)) { + clockTicks = timer3Ticks; + } +#ifdef PROFILING + if(profilingTicksReload != 0) { + if(profilingTicks < clockTicks) { + clockTicks = profilingTicks; + } + } +#endif + } + + cpuLoopTicks -= clockTicks; + if((cpuLoopTicks <= 0)) { + if(cpuSavedTicks) { + clockTicks = cpuSavedTicks;// + cpuLoopTicks; + } + cpuDmaTicksToUpdate = -cpuLoopTicks; + + updateLoop: + lcdTicks -= clockTicks; + + if(lcdTicks <= 0) { + if(DISPSTAT & 1) { // V-BLANK + // if in V-Blank mode, keep computing... + if(DISPSTAT & 2) { + lcdTicks += 960; + VCOUNT++; + UPDATE_REG(0x06, VCOUNT); + DISPSTAT &= 0xFFFD; + UPDATE_REG(0x04, DISPSTAT); + CPUCompareVCOUNT(); + } else { + lcdTicks += 272; + DISPSTAT |= 2; + UPDATE_REG(0x04, DISPSTAT); + if(DISPSTAT & 16) { + IF |= 2; + UPDATE_REG(0x202, IF); + } + } + + if(VCOUNT >= 228) { + DISPSTAT &= 0xFFFC; + UPDATE_REG(0x04, DISPSTAT); + VCOUNT = 0; + UPDATE_REG(0x06, VCOUNT); + CPUCompareVCOUNT(); + } + } else { + bool fastForward = speedup; + int framesToSkip = systemFrameSkip; + #if (defined(WIN32) && !defined(SDL)) + int throttle = theApp.throttle; + if(theApp.frameSearching && throttle < 100) + throttle = 100; + fastForward |= theApp.frameSearchSkipping; + #else + extern int throttle; + #endif + + if(fastForward) + framesToSkip = 9; // try 6 FPS during speedup + else if(throttle != 100) + framesToSkip = (framesToSkip * throttle) / 100; // change frame skip to match up with the throttle's adjusted speed (so 6 frame skip becomes 3 frames at 50% speed) + + if(DISPSTAT & 2) { + // if in H-Blank, leave it and move to drawing mode + VCOUNT++; + UPDATE_REG(0x06, VCOUNT); + + lcdTicks += (960); + DISPSTAT &= 0xFFFD; + if(VCOUNT == 160) { + count++; + systemFrame(60); + + if(count == 60) { + u32 time = systemGetClock(); + if(time != lastTime) { + u32 t = 100000/(time - lastTime); + systemShowSpeed(t); + } else + systemShowSpeed(0); + lastTime = time; + count = 0; + } + u32 joy = 0; + + // update joystick information + if(systemReadJoypads()) + // read default joystick + joy = systemReadJoypad(-1,cpuEEPROMSensorEnabled); + + frameBoundary = true; + + + P1 = 0x03FF ^ (joy & 0x3FF); + + UPDATE_REG(0x130, P1); + u16 P1CNT = READ16LE(((u16 *)&ioMem[0x132])); + // this seems wrong, but there are cases where the game + // can enter the stop state without requesting an IRQ from + // the joypad. + if((P1CNT & 0x4000) || stopState) { + u16 p1 = (0x3FF ^ P1) & 0x3FF; + if(P1CNT & 0x8000) { + if(p1 == (P1CNT & 0x3FF)) { + IF |= 0x1000; + UPDATE_REG(0x202, IF); + } + } else { + if(p1 & P1CNT) { + IF |= 0x1000; + UPDATE_REG(0x202, IF); + } + } + } + + u32 ext = (joy >> 10); + int cheatTicks = 0; + if(cheatsEnabled) + cheatsCheckKeys(P1^0x3FF, ext); + cpuDmaTicksToUpdate += cheatTicks; + speedup = (ext & 1) ? true : false; + capture = (ext & 2) ? true : false; + + if(capture && !capturePrevious) { + captureNumber++; + systemScreenCapture(captureNumber); + } + capturePrevious = capture; + + DISPSTAT |= 1; + DISPSTAT &= 0xFFFD; + UPDATE_REG(0x04, DISPSTAT); + if(DISPSTAT & 0x0008) { + IF |= 1; + UPDATE_REG(0x202, IF); + } + CPUCheckDMA(1, 0x0f); + + pauseAfterFrameAdvance = systemPauseOnFrame(); + + if(frameCount >= framesToSkip || pauseAfterFrameAdvance) { + systemDrawScreen(); + frameCount = 0; + } else + frameCount++; +/// if(systemPauseOnFrame()) +/// ticks = 0; + if(pauseAfterFrameAdvance) + { + #if (defined(WIN32) && !defined(SDL)) + if(theApp.muteFrameAdvance) + theApp.frameAdvanceMuteNow = true; + theApp.paused = true; + if(theApp.sound) + theApp.sound->pause(); // prevents the sound from looping annoyingly after a frame advance in GBA games + #else + extern bool paused; // from SDL.cpp + paused = true; + systemSoundPause(); + #endif + } + else + { + #if (defined(WIN32) && !defined(SDL)) + theApp.frameAdvanceMuteNow = false; + #endif + } + } + + UPDATE_REG(0x04, DISPSTAT); + + CPUCompareVCOUNT(); + } else { + if(frameCount >= framesToSkip || pauseAfterFrameAdvance) { + (*renderLine)(); + + switch(systemColorDepth) { + case 16: + { + u16 *dest = (u16 *)pix + 242 * (VCOUNT+1); + for(int x = 0; x < 240;) { + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + *dest++ = systemColorMap16[lineMix[x++]&0xFFFF]; + } + // for filters that read past the screen + *dest++ = 0; + } + break; + case 24: + { + u8 *dest = (u8 *)pix + 240 * VCOUNT * 3; + for(int x = 0; x < 240;) { + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + *((u32 *)dest) = systemColorMap32[lineMix[x++] & 0xFFFF]; + dest += 3; + } + } + break; + case 32: + { + u32 *dest = (u32 *)pix + 241 * (VCOUNT+1); + for(int x = 0; x < 240; ) { + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + *dest++ = systemColorMap32[lineMix[x++] & 0xFFFF]; + } + } + break; + } + } + // entering H-Blank + DISPSTAT |= 2; + UPDATE_REG(0x04, DISPSTAT); + lcdTicks += 272; + CPUCheckDMA(2, 0x0f); + if(DISPSTAT & 16) { + IF |= 2; + UPDATE_REG(0x202, IF); + } + } + } + } + + if(!stopState) { + if(timer0On) { + if(timer0ClockReload == 1) { + u32 tm0d = TM0D + clockTicks; + if(tm0d > 0xffff) { + tm0d += timer0Reload; + timerOverflow |= 1; + soundTimerOverflow(0); + if(TM0CNT & 0x40) { + IF |= 0x08; + UPDATE_REG(0x202, IF); + } + } + TM0D = tm0d; + timer0Ticks = 0x10000 - TM0D; + UPDATE_REG(0x100, TM0D); + } else { + timer0Ticks -= clockTicks; + if(timer0Ticks <= 0) { + timer0Ticks += timer0ClockReload; + TM0D++; + if(TM0D == 0) { + TM0D = timer0Reload; + timerOverflow |= 1; + soundTimerOverflow(0); + if(TM0CNT & 0x40) { + IF |= 0x08; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x100, TM0D); + } + } + } + + if(timer1On) { + if(TM1CNT & 4) { + if(timerOverflow & 1) { + TM1D++; + if(TM1D == 0) { + TM1D += timer1Reload; + timerOverflow |= 2; + soundTimerOverflow(1); + if(TM1CNT & 0x40) { + IF |= 0x10; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x104, TM1D); + } + } else { + if(timer1ClockReload == 1) { + u32 tm1d = TM1D + clockTicks; + if(tm1d > 0xffff) { + tm1d += timer1Reload; + timerOverflow |= 2; + soundTimerOverflow(1); + if(TM1CNT & 0x40) { + IF |= 0x10; + UPDATE_REG(0x202, IF); + } + } + TM1D = tm1d; + timer1Ticks = 0x10000 - TM1D; + UPDATE_REG(0x104, TM1D); + } else { + timer1Ticks -= clockTicks; + if(timer1Ticks <= 0) { + timer1Ticks += timer1ClockReload; + TM1D++; + + if(TM1D == 0) { + TM1D = timer1Reload; + timerOverflow |= 2; + soundTimerOverflow(1); + if(TM1CNT & 0x40) { + IF |= 0x10; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x104, TM1D); + } + } + } + } + + if(timer2On) { + if(TM2CNT & 4) { + if(timerOverflow & 2) { + TM2D++; + if(TM2D == 0) { + TM2D += timer2Reload; + timerOverflow |= 4; + if(TM2CNT & 0x40) { + IF |= 0x20; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x108, TM2D); + } + } else { + if(timer2ClockReload == 1) { + u32 tm2d = TM2D + clockTicks; + if(tm2d > 0xffff) { + tm2d += timer2Reload; + timerOverflow |= 4; + if(TM2CNT & 0x40) { + IF |= 0x20; + UPDATE_REG(0x202, IF); + } + } + TM2D = tm2d; + timer2Ticks = 0x10000 - TM2D; + UPDATE_REG(0x108, TM2D); + } else { + timer2Ticks -= clockTicks; + if(timer2Ticks <= 0) { + timer2Ticks += timer2ClockReload; + TM2D++; + + if(TM2D == 0) { + TM2D = timer2Reload; + timerOverflow |= 4; + if(TM2CNT & 0x40) { + IF |= 0x20; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x108, TM2D); + } + } + } + } + + if(timer3On) { + if(TM3CNT & 4) { + if(timerOverflow & 4) { + TM3D++; + if(TM3D == 0) { + TM3D += timer3Reload; + if(TM3CNT & 0x40) { + IF |= 0x40; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x10c, TM3D); + } + } else { + if(timer3ClockReload == 1) { + u32 tm3d = TM3D + clockTicks; + if(tm3d > 0xffff) { + tm3d += timer3Reload; + if(TM3CNT & 0x40) { + IF |= 0x40; + UPDATE_REG(0x202, IF); + } + } + TM3D = tm3d; + timer3Ticks = 0x10000 - TM3D; + UPDATE_REG(0x10C, TM3D); + } else { + timer3Ticks -= clockTicks; + if(timer3Ticks <= 0) { + timer3Ticks += timer3ClockReload; + TM3D++; + + if(TM3D == 0) { + TM3D = timer3Reload; + if(TM3CNT & 0x40) { + IF |= 0x40; + UPDATE_REG(0x202, IF); + } + } + UPDATE_REG(0x10C, TM3D); + } + } + } + } + } + // we shouldn't be doing sound in stop state, but we lose synchronization + // if sound is disabled, so in stop state, soundTick will just produce + // mute sound + soundTicks -= clockTicks; + if(soundTicks <= 0) { + soundTick(); + soundTicks += SOUND_CLOCK_TICKS; + } + timerOverflow = 0; + +#ifdef PROFILING + profilingTicks -= clockTicks; + if(profilingTicks <= 0) { + profilingTicks += profilingTicksReload; + if(profilBuffer && profilSize) { + u16 *b = (u16 *)profilBuffer; + int pc = ((reg[15].I - profilLowPC) * profilScale)/0x10000; + if(pc >= 0 && pc < profilSize) { + b[pc]++; + } + } + } +#endif + + ticks -= clockTicks; + + cpuLoopTicks = CPUUpdateTicks(); + + if(cpuDmaTicksToUpdate > 0) { + clockTicks = cpuSavedTicks; + if(clockTicks > cpuDmaTicksToUpdate) + clockTicks = cpuDmaTicksToUpdate; + cpuDmaTicksToUpdate -= clockTicks; + if(cpuDmaTicksToUpdate < 0) + cpuDmaTicksToUpdate = 0; + goto updateLoop; + } + + if(IF && (IME & 1) && armIrqEnable) { + int res = IF & IE; + if(stopState) + res &= 0x3080; + if(res) { + if(intState) { + CPUInterrupt(); + intState = false; + if(holdState) { + holdState = false; + stopState = false; + } + } else { + if(!holdState) { + intState = true; + cpuLoopTicks = 5; + cpuSavedTicks = 5; + } else { + CPUInterrupt(); + if(holdState) { + holdState = false; + stopState = false; + } + } + } + } + } + + #if (defined(WIN32) && !defined(SDL)) + if(theApp.useOldGBTiming) + #else + if(false) /// SDL FIXME + #endif + { + if(ticks <= 0) + break; + } + else + { + if(frameBoundary) + { + frameBoundary = false; + return; + } + } + } + } +} + +struct EmulatedSystem GBASystem = { + // emuMain + CPULoop, + // emuReset + CPUReset, + // emuCleanUp + CPUCleanUp, + // emuReadBattery + CPUReadBatteryFile, + // emuWriteBattery + CPUWriteBatteryFile, + // emuReadBatteryFromStream + CPUReadBatteryFromStream, + // emuWriteBatteryToStream + CPUWriteBatteryToStream, + // emuReadState + CPUReadState, + // emuWriteState + CPUWriteState, + // emuReadStateFromStream + CPUReadStateFromStream, + // emuWriteStateToStream + CPUWriteStateToStream, + // emuReadMemState + CPUReadMemState, + // emuWriteMemState + CPUWriteMemState, + // emuWritePNG + CPUWritePNGFile, + // emuWriteBMP + CPUWriteBMPFile, + // emuUpdateCPSR + CPUUpdateCPSR, + // emuHasDebugger + true, + // emuCount +#ifdef FINAL_VERSION + 250000 +#else + 5000 +#endif +}; diff --git a/src/GBA.h b/src/GBA.h new file mode 100644 index 0000000..43f12d6 --- /dev/null +++ b/src/GBA.h @@ -0,0 +1,175 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_GBA_H +#define VBA_GBA_H + +#include "System.h" + +#if (defined(WIN32) && !defined(SDL)) +#include // for HANDLE +// NOTE: if you get this error: +// #error WINDOWS.H already included. MFC apps must not #include +// it is probably because stdafx.h is getting included at the wrong place +// (i.e. after anything else) in a file, or your precompiled headers are otherwise wrong +#endif + +#define SAVE_GAME_VERSION_1 1 +#define SAVE_GAME_VERSION_2 2 +#define SAVE_GAME_VERSION_3 3 +#define SAVE_GAME_VERSION_4 4 +#define SAVE_GAME_VERSION_5 5 +#define SAVE_GAME_VERSION_6 6 +#define SAVE_GAME_VERSION_7 7 +#define SAVE_GAME_VERSION_8 8 +#define SAVE_GAME_VERSION_9 9 +#define SAVE_GAME_VERSION_10 10 +#define SAVE_GAME_VERSION_11 11 +#define SAVE_GAME_VERSION_12 12 +#define SAVE_GAME_VERSION SAVE_GAME_VERSION_12 + +typedef struct { + u8 *address; + u32 mask; +} memoryMap; + +typedef union { + struct { +#ifdef WORDS_BIGENDIAN + u8 B3; + u8 B2; + u8 B1; + u8 B0; +#else + u8 B0; + u8 B1; + u8 B2; + u8 B3; +#endif + } B; + struct { +#ifdef WORDS_BIGENDIAN + u16 W1; + u16 W0; +#else + u16 W0; + u16 W1; +#endif + } W; +#ifdef WORDS_BIGENDIAN + volatile u32 I; +#else + u32 I; +#endif +} reg_pair; + +#ifndef NO_GBA_MAP +extern memoryMap map[256]; +#endif + +#if (defined(WIN32) && !defined(SDL)) +extern HANDLE mapROM; // shared memory handles +extern HANDLE mapWORKRAM; +extern HANDLE mapBIOS; +extern HANDLE mapIRAM; +extern HANDLE mapPALETTERAM; +extern HANDLE mapVRAM; +extern HANDLE mapOAM; +extern HANDLE mapPIX; +extern HANDLE mapIOMEM; +#endif + +extern reg_pair reg[45]; +extern u8 biosProtected[4]; + +extern bool N_FLAG; +extern bool Z_FLAG; +extern bool C_FLAG; +extern bool V_FLAG; +extern bool armIrqEnable; +extern bool armState; +extern int armMode; +extern void (*cpuSaveGameFunc)(u32,u8); + +extern bool freezeWorkRAM[0x40000]; +extern bool freezeInternalRAM[0x8000]; +extern bool CPUReadGSASnapshot(const char *); +extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *); +extern bool CPUWriteBatteryFile(const char *); +extern bool CPUReadBatteryFile(const char *); +extern bool CPUWriteBatteryToStream(gzFile); +extern bool CPUReadBatteryFromStream(gzFile); +extern bool CPUExportEepromFile(const char *); +extern bool CPUImportEepromFile(const char *); +extern bool CPUWritePNGFile(const char *); +extern bool CPUWriteBMPFile(const char *); +extern void CPUCleanUp(); +extern void CPUUpdateRender(); +extern bool CPUReadMemState(char *, int); +extern bool CPUReadState(const char *); +extern bool CPUWriteMemState(char *, int); +extern bool CPUWriteState(const char *); +extern bool CPUReadStateFromStream(gzFile); +extern bool CPUWriteStateToStream(gzFile); +extern int CPULoadRom(const char *); +extern void CPUUpdateRegister(u32, u16); +extern void CPUWriteHalfWord(u32, u16); +extern void CPUWriteByte(u32, u8); +extern void CPUInit(const char *,bool); +extern void CPUReset(); +extern void CPULoop(int); +extern void CPUCheckDMA(int,int); +extern bool CPUIsGBAImage(const char *); +extern bool CPUIsZipFile(const char *); +#ifdef PROFILING +extern void cpuProfil(char *buffer, int, u32, int); +extern void cpuEnableProfiling(int hz); +#endif + +extern struct EmulatedSystem GBASystem; + +#define R13_IRQ 18 +#define R14_IRQ 19 +#define SPSR_IRQ 20 +#define R13_USR 26 +#define R14_USR 27 +#define R13_SVC 28 +#define R14_SVC 29 +#define SPSR_SVC 30 +#define R13_ABT 31 +#define R14_ABT 32 +#define SPSR_ABT 33 +#define R13_UND 34 +#define R14_UND 35 +#define SPSR_UND 36 +#define R8_FIQ 37 +#define R9_FIQ 38 +#define R10_FIQ 39 +#define R11_FIQ 40 +#define R12_FIQ 41 +#define R13_FIQ 42 +#define R14_FIQ 43 +#define SPSR_FIQ 44 + +#include "Cheats.h" +#include "Globals.h" +#include "EEprom.h" +#include "Flash.h" + +#endif //VBA_GBA_H diff --git a/src/GBAinline.h b/src/GBAinline.h new file mode 100644 index 0000000..d9cf020 --- /dev/null +++ b/src/GBAinline.h @@ -0,0 +1,427 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_GBAinline_H +#define VBA_GBAinline_H + +#include "System.h" +#include "Port.h" +#include "RTC.h" + +extern bool cpuSramEnabled; +extern bool cpuFlashEnabled; +extern bool cpuEEPROMEnabled; +extern bool cpuEEPROMSensorEnabled; + +#define CPUReadByteQuick(addr) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] + +#define CPUReadHalfWordQuick(addr) \ + READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define CPUReadMemoryQuick(addr) \ + READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +//inline u32 CPUReadMemoryQuick(u32 addr) +//{ +// u32 addrShift = (addr)>>24; +// u32 rt = (addr) & map[addrShift].mask; +// return READ32LE(((u32*)&map[addrShift].address[rt])); +//} + +inline u32 CPUReadMemory(u32 address) +{ + +#ifdef DEV_VERSION + if(address & 3) { + if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned word read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } + } +#endif + + u32 value; + switch(address >> 24) { + case 0: + if(reg[15].I >> 24) { + if(address < 0x4000) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal word read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + + value = READ32LE(((u32 *)&biosProtected)); + } + else goto unreadable; + } else + value = READ32LE(((u32 *)&bios[address & 0x3FFC])); + break; + case 2: + value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC])); + break; + case 3: + value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC])); + break; + case 4: + if((address < 0x4000400) && ioReadable[address & 0x3fc]) { + if(ioReadable[(address & 0x3fc) + 2]) + value = READ32LE(((u32 *)&ioMem[address & 0x3fC])); + else + value = READ16LE(((u16 *)&ioMem[address & 0x3fc])); + } else goto unreadable; + break; + case 5: + value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC])); + break; + case 6: + value = READ32LE(((u32 *)&vram[address & 0x1fffc])); + break; + case 7: + value = READ32LE(((u32 *)&oam[address & 0x3FC])); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + value = READ32LE(((u32 *)&rom[address&0x1FFFFFC])); + break; + case 13: + if(cpuEEPROMEnabled) + // no need to swap this + return eepromRead(address); + goto unreadable; + case 14: + if(cpuFlashEnabled | cpuSramEnabled) + // no need to swap this + return flashRead(address); + // default + default: + unreadable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal word read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + + // if(ioMem[0x205] & 0x40) { + if(armState) { + value = CPUReadMemoryQuick(reg[15].I); + } else { + value = CPUReadHalfWordQuick(reg[15].I) | + CPUReadHalfWordQuick(reg[15].I) << 16; + } + // } else { + // value = *((u32 *)&bios[address & 0x3ffc]); + // } + // return 0xFFFFFFFF; + } + + if(address & 3) { +#ifdef C_CORE + int shift = (address & 3) << 3; + value = (value >> shift) | (value << (32 - shift)); +#else +#ifdef __GNUC__ + asm("and $3, %%ecx;" + "shl $3 ,%%ecx;" + "ror %%cl, %0" + : "=r" (value) + : "r" (value), "c" (address)); +#else + __asm { + mov ecx, address; + and ecx, 3; + shl ecx, 3; + ror [dword ptr value], cl; + } +#endif +#endif + } + return value; +} + +extern u32 myROM[]; + +inline u32 CPUReadHalfWord(u32 address) +{ +#ifdef DEV_VERSION + if(address & 1) { + if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned halfword read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } + } +#endif + + u32 value; + + switch(address >> 24) { + case 0: + if (reg[15].I >> 24) { + if(address < 0x4000) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal halfword read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + value = READ16LE(((u16 *)&biosProtected[address&2])); + } else goto unreadable; + } else + value = READ16LE(((u16 *)&bios[address & 0x3FFE])); + break; + case 2: + value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE])); + break; + case 3: + value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe])); + break; + case 4: + if((address < 0x4000400) && ioReadable[address & 0x3fe]) + value = READ16LE(((u16 *)&ioMem[address & 0x3fe])); + else goto unreadable; + break; + case 5: + value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe])); + break; + case 6: + value = READ16LE(((u16 *)&vram[address & 0x1fffe])); + break; + case 7: + value = READ16LE(((u16 *)&oam[address & 0x3fe])); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) + value = rtcRead(address); + else + value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE])); + break; + case 13: + if(cpuEEPROMEnabled) + // no need to swap this + return eepromRead(address); + goto unreadable; + case 14: + if(cpuFlashEnabled | cpuSramEnabled) + // no need to swap this + return flashRead(address); + // default + default: + unreadable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal halfword read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + extern bool cpuDmaHack; + extern u32 cpuDmaLast; + extern int cpuDmaCount; + if(cpuDmaHack && cpuDmaCount) { + value = (u16)cpuDmaLast; + } else { + if(armState) { + value = CPUReadHalfWordQuick(reg[15].I + (address & 2)); + } else { + value = CPUReadHalfWordQuick(reg[15].I); + } + } + // return value; + // if(address & 1) + // value = (value >> 8) | ((value & 0xFF) << 24); + // return 0xFFFF; + break; + } + + if(address & 1) { + value = (value >> 8) | (value << 24); + } + + return value; +} + +inline u16 CPUReadHalfWordSigned(u32 address) +{ + u16 value = CPUReadHalfWord(address); + if((address & 1)) + value = (s8)value; + return value; +} + +inline u8 CPUReadByte(u32 address) +{ + switch(address >> 24) { + case 0: + if (reg[15].I >> 24) { + if(address < 0x4000) { +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal byte read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + return biosProtected[address & 3]; + } else goto unreadable; + } + return bios[address & 0x3FFF]; + case 2: + return workRAM[address & 0x3FFFF]; + case 3: + return internalRAM[address & 0x7fff]; + case 4: + if((address < 0x4000400) && ioReadable[address & 0x3ff]) + return ioMem[address & 0x3ff]; + else goto unreadable; + case 5: + return paletteRAM[address & 0x3ff]; + case 6: + return vram[address & 0x1ffff]; + case 7: + return oam[address & 0x3ff]; + case 8: + case 9: + case 10: + case 11: + case 12: + return rom[address & 0x1FFFFFF]; + case 13: + if(cpuEEPROMEnabled) + return eepromRead(address); + goto unreadable; + case 14: + if(cpuSramEnabled | cpuFlashEnabled) + return flashRead(address); + if(cpuEEPROMSensorEnabled) { + switch(address & 0x00008f00) { + case 0x8200: + return systemGetSensorX() & 255; + case 0x8300: + return (systemGetSensorX() >> 8)|0x80; + case 0x8400: + return systemGetSensorY() & 255; + case 0x8500: + return systemGetSensorY() >> 8; + } + } + // default + default: + unreadable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal byte read: %08x at %08x\n", address, armMode ? + armNextPC - 4 : armNextPC - 2); + } +#endif + + if(armState) { + return CPUReadByteQuick(reg[15].I+(address & 3)); + } else { + return CPUReadByteQuick(reg[15].I+(address & 1)); + } + // return 0xFF; + break; + } +} + +inline void CPUWriteMemory(u32 address, u32 value) +{ +#ifdef DEV_VERSION + if(address & 3) { + if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaliagned word write: %08x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } + } +#endif + + switch(address >> 24) { + case 0x02: +#ifdef SDL + if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC])) + cheatsWriteMemory((u32 *)&workRAM[address & 0x3FFFC], + value, + *((u32 *)&freezeWorkRAM[address & 0x3FFFC])); + else +#endif + WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value); + break; + case 0x03: +#ifdef SDL + if(*((u32 *)&freezeInternalRAM[address & 0x7ffc])) + cheatsWriteMemory((u32 *)&internalRAM[address & 0x7FFC], + value, + *((u32 *)&freezeInternalRAM[address & 0x7ffc])); + else +#endif + WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value); + break; + case 0x04: + CPUUpdateRegister((address & 0x3FC), value & 0xFFFF); + CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16)); + break; + case 0x05: + WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value); + break; + case 0x06: + if(address & 0x10000) + WRITE32LE(((u32 *)&vram[address & 0x17ffc]), value); + else + WRITE32LE(((u32 *)&vram[address & 0x1fffc]), value); + break; + case 0x07: + WRITE32LE(((u32 *)&oam[address & 0x3fc]), value); + break; + case 0x0D: + if(cpuEEPROMEnabled) { + eepromWrite(address, value); + break; + } + goto unwritable; + case 0x0E: + if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) { + (*cpuSaveGameFunc)(address, (u8)value); + break; + } + // default + default: + unwritable: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal word write: %08x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } +#endif + break; + } +} + +#endif //VBA_GBAinline_H diff --git a/src/Gfx.cpp b/src/Gfx.cpp new file mode 100644 index 0000000..aff031b --- /dev/null +++ b/src/Gfx.cpp @@ -0,0 +1,52 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" + +int coeff[32] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; + +// some of the rendering code in gfx.h (such as mode 0 line 1298) +// renders outside the given buffer (past 239) which corrupts other memory, +// so rather than find all places in that code that need to be fixed, +// just give it enough extra scratch space to use +#define LINE_BUFFER_OVERFLOW_LEEWAY (512-240) + +u32 line0[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 line1[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 line2[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 line3[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 lineOBJ[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 lineOBJWin[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +u32 lineMix[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +bool gfxInWin0[240+LINE_BUFFER_OVERFLOW_LEEWAY]; +bool gfxInWin1[240+LINE_BUFFER_OVERFLOW_LEEWAY]; + +int gfxBG2Changed = 0; +int gfxBG3Changed = 0; + +int gfxBG2X = 0; +int gfxBG2Y = 0; +int gfxBG2LastX = 0; +int gfxBG2LastY = 0; +int gfxBG3X = 0; +int gfxBG3Y = 0; +int gfxBG3LastX = 0; +int gfxBG3LastY = 0; +int gfxLastVCOUNT = 0; diff --git a/src/Gfx.h b/src/Gfx.h new file mode 100644 index 0000000..33a4105 --- /dev/null +++ b/src/Gfx.h @@ -0,0 +1,1579 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_GFX_H +#define VBA_GFX_H + +#include "GBA.h" +#include "Gfx.h" +#include "Globals.h" + +#include "Port.h" + +//#define SPRITE_DEBUG + +void gfxDrawTextScreen(u16, u16, u16, u32 *); +void gfxDrawRotScreen(u16, + u16, u16, + u16, u16, + u16, u16, + u16, u16, + int&, int&, + int, + u32*); +void gfxDrawRotScreen16Bit(u16, + u16, u16, + u16, u16, + u16, u16, + u16, u16, + int&, int&, + int, + u32*); +void gfxDrawRotScreen256(u16, + u16, u16, + u16, u16, + u16, u16, + u16, u16, + int&, int&, + int, + u32*); +void gfxDrawRotScreen16Bit160(u16, + u16, u16, + u16, u16, + u16, u16, + u16, u16, + int&, int&, + int, + u32*); +void gfxDrawSprites(u32 *); +void gfxIncreaseBrightness(u32 *line, int coeff); +void gfxDecreaseBrightness(u32 *line, int coeff); +void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb); + +void mode0RenderLine(); +void mode0RenderLineNoWindow(); +void mode0RenderLineAll(); + +void mode1RenderLine(); +void mode1RenderLineNoWindow(); +void mode1RenderLineAll(); + +void mode2RenderLine(); +void mode2RenderLineNoWindow(); +void mode2RenderLineAll(); + +void mode3RenderLine(); +void mode3RenderLineNoWindow(); +void mode3RenderLineAll(); + +void mode4RenderLine(); +void mode4RenderLineNoWindow(); +void mode4RenderLineAll(); + +void mode5RenderLine(); +void mode5RenderLineNoWindow(); +void mode5RenderLineAll(); + +extern int coeff[32]; +extern u32 line0[240]; +extern u32 line1[240]; +extern u32 line2[240]; +extern u32 line3[240]; +extern u32 lineOBJ[240]; +extern u32 lineOBJWin[240]; +extern u32 lineMix[240]; +extern bool gfxInWin0[240]; +extern bool gfxInWin1[240]; + +extern int gfxBG2Changed; +extern int gfxBG3Changed; + +extern int gfxBG2X; +extern int gfxBG2Y; +extern int gfxBG2LastX; +extern int gfxBG2LastY; +extern int gfxBG3X; +extern int gfxBG3Y; +extern int gfxBG3LastX; +extern int gfxBG3LastY; +extern int gfxLastVCOUNT; + +inline void gfxClearArray(u32 *array) +{ + for(int i = 0; i < 240; i++) { + *array++ = 0x80000000; + } +} + +inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, + u32 *line) +{ + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800]; + u32 prio = ((control & 3)<<25) + 0x1000000; + int sizeX = 256; + int sizeY = 256; + switch((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = 512; + break; + case 2: + sizeY = 512; + break; + case 3: + sizeX = 512; + sizeY = 512; + break; + } + + int maskX = sizeX-1; + int maskY = sizeY-1; + + bool mosaicOn = (control & 0x40) ? true : false; + + int xxx = hofs & maskX; + int yyy = (vofs + VCOUNT) & maskY; + int mosaicX = (MOSAIC & 0x000F)+1; + int mosaicY = ((MOSAIC & 0x00F0)>>4)+1; + + if(mosaicOn) { + if((VCOUNT % mosaicY) != 0) { + mosaicY = (VCOUNT / mosaicY) * mosaicY; + yyy = (vofs + mosaicY) & maskY; + } + } + + if(yyy > 255 && sizeY > 256) { + yyy &= 255; + screenBase += 0x400; + if(sizeX > 256) + screenBase += 0x400; + } + + int yshift = ((yyy>>3)<<5); + if((control) & 0x80) { + u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift; + for(int x = 0; x < 240; x++) { + u16 data = READ16LE(screenSource); + + int tile = data & 0x3FF; + int tileX = (xxx & 7); + int tileY = yyy & 7; + + if(data & 0x0400) + tileX = 7 - tileX; + if(data & 0x0800) + tileY = 7 - tileY; + + u8 color = charBase[tile * 64 + tileY * 8 + tileX]; + + line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000; + + if(data & 0x0400) { + if(tileX == 0) + screenSource++; + } else if(tileX == 7) + screenSource++; + xxx++; + if(xxx == 256) { + if(sizeX > 256) + screenSource = screenBase + 0x400 + yshift; + else { + screenSource = screenBase + yshift; + xxx = 0; + } + } else if(xxx >= sizeX) { + xxx = 0; + screenSource = screenBase + yshift; + } + } + } else { + u16 *screenSource = screenBase + 0x400*(xxx>>8)+((xxx&255)>>3) + + yshift; + for(int x = 0; x < 240; x++) { + u16 data = READ16LE(screenSource); + + int tile = data & 0x3FF; + int tileX = (xxx & 7); + int tileY = yyy & 7; + + if(data & 0x0400) + tileX = 7 - tileX; + if(data & 0x0800) + tileY = 7 - tileY; + + u8 color = charBase[(tile<<5) + (tileY<<2) + (tileX>>1)]; + + if(tileX & 1) { + color = (color >> 4); + } else { + color &= 0x0F; + } + + int pal = (READ16LE(screenSource)>>8) & 0xF0; + line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000; + + if(data & 0x0400) { + if(tileX == 0) + screenSource++; + } else if(tileX == 7) + screenSource++; + xxx++; + if(xxx == 256) { + if(sizeX > 256) + screenSource = screenBase + 0x400 + yshift; + else { + screenSource = screenBase + yshift; + xxx = 0; + } + } else if(xxx >= sizeX) { + xxx = 0; + screenSource = screenBase + yshift; + } + } + } + if(mosaicOn) { + if(mosaicX > 1) { + int m = 1; + for(int i = 0; i < 239; i++) { + line[i+1] = line[i]; + m++; + if(m == mosaicX) { + m = 1; + i++; + } + } + } + } +} + +inline void gfxDrawRotScreen(u16 control, + u16 x_l, u16 x_h, + u16 y_l, u16 y_h, + u16 pa, u16 pb, + u16 pc, u16 pd, + int& currentX, int& currentY, + int changed, + u32 *line) +{ + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800]; + int prio = ((control & 3) << 25) + 0x1000000; + + int sizeX = 128; + int sizeY = 128; + switch((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = sizeY = 256; + break; + case 2: + sizeX = sizeY = 512; + break; + case 3: + sizeX = sizeY = 1024; + break; + } + + int dx = pa & 0x7FFF; + if(pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if(pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if(pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFFF; + if(pd & 0x8000) + dmy |= 0xFFFF8000; + + if(VCOUNT == 0) + changed = 3; + + if(changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if(changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if(control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; + int y = (VCOUNT % mosaicY); + realX -= y*dmx; + realY -= y*dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + if(control & 0x2000) { + xxx %= sizeX; + yyy %= sizeY; + if(xxx < 0) + xxx += sizeX; + if(yyy < 0) + yyy += sizeY; + } + + if(control & 0x80) { + for(int x = 0; x < 240; x++) { + if(xxx < 0 || + yyy < 0 || + xxx >= sizeX || + yyy >= sizeY) { + line[x] = 0x80000000; + } else { + int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; + + int tileX = (xxx & 7); + int tileY = yyy & 7; + + u8 color = charBase[(tile<<6) + (tileY<<3) + tileX]; + + line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + + if(control & 0x2000) { + xxx %= sizeX; + yyy %= sizeY; + if(xxx < 0) + xxx += sizeX; + if(yyy < 0) + yyy += sizeY; + } + } + } else { + for(int x = 0; x < 240; x++) { + if(xxx < 0 || + yyy < 0 || + xxx >= sizeX || + yyy >= sizeY) { + line[x] = 0x80000000; + } else { + int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; + + int tileX = (xxx & 7); + int tileY = yyy & 7; + + u8 color = charBase[(tile<<6) + (tileY<<3) + tileX]; + + line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + + if(control & 0x2000) { + xxx %= sizeX; + yyy %= sizeY; + if(xxx < 0) + xxx += sizeX; + if(yyy < 0) + yyy += sizeY; + } + } + } + + if(control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if(mosaicX > 1) { + int m = 1; + for(int i = 0; i < 239; i++) { + line[i+1] = line[i]; + m++; + if(m == mosaicX) { + m = 1; + i++; + } + } + } + } +} + +inline void gfxDrawRotScreen16Bit(u16 control, + u16 x_l, u16 x_h, + u16 y_l, u16 y_h, + u16 pa, u16 pb, + u16 pc, u16 pd, + int& currentX, int& currentY, + int changed, + u32 *line) +{ + u16 *screenBase = (u16 *)&vram[0]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 240; + int sizeY = 160; + + int startX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + startY |= 0xF8000000; + + int dx = pa & 0x7FFF; + if(pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if(pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if(pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFFF; + if(pd & 0x8000) + dmy |= 0xFFFF8000; + + if(VCOUNT == 0) + changed = 3; + + if(changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + currentX |= 0xF8000000; + } else + currentX += dmx; + + if(changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if(control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; + int y = (VCOUNT % mosaicY); + realX -= y*dmx; + realY -= y*dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for(int x = 0; x < 240; x++) { + if(xxx < 0 || + yyy < 0 || + xxx >= sizeX || + yyy >= sizeY) { + line[x] = 0x80000000; + } else { + line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if(control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if(mosaicX > 1) { + int m = 1; + for(int i = 0; i < 239; i++) { + line[i+1] = line[i]; + m++; + if(m == mosaicX) { + m = 1; + i++; + } + } + } + } +} + +inline void gfxDrawRotScreen256(u16 control, + u16 x_l, u16 x_h, + u16 y_l, u16 y_h, + u16 pa, u16 pb, + u16 pc, u16 pd, + int ¤tX, int& currentY, + int changed, + u32 *line) +{ + u16 *palette = (u16 *)paletteRAM; + u8 *screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 240; + int sizeY = 160; + + int startX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + startY |= 0xF8000000; + + int dx = pa & 0x7FFF; + if(pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if(pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if(pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFFF; + if(pd & 0x8000) + dmy |= 0xFFFF8000; + + if(VCOUNT == 0) + changed = 3; + + if(changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if(changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if(control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; + int y = (VCOUNT / mosaicY) * mosaicY; + realX = startX + y*dmx; + realY = startY + y*dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for(int x = 0; x < 240; x++) { + if(xxx < 0 || + yyy < 0 || + xxx >= sizeX || + yyy >= sizeY) { + line[x] = 0x80000000; + } else { + u8 color = screenBase[yyy * 240 + xxx]; + + line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if(control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if(mosaicX > 1) { + int m = 1; + for(int i = 0; i < 239; i++) { + line[i+1] = line[i]; + m++; + if(m == mosaicX) { + m = 1; + i++; + } + } + } + } +} + +inline void gfxDrawRotScreen16Bit160(u16 control, + u16 x_l, u16 x_h, + u16 y_l, u16 y_h, + u16 pa, u16 pb, + u16 pc, u16 pd, + int& currentX, int& currentY, + int changed, + u32 *line) +{ + u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] : + (u16 *)&vram[0]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 160; + int sizeY = 128; + + int startX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + startY |= 0xF8000000; + + int dx = pa & 0x7FFF; + if(pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if(pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if(pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFFF; + if(pd & 0x8000) + dmy |= 0xFFFF8000; + + if(VCOUNT == 0) + changed = 3; + + if(changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF)<<16); + if(x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if(changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF)<<16); + if(y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if(control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; + int y = (VCOUNT / mosaicY) * mosaicY; + realX = startX + y*dmx; + realY = startY + y*dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for(int x = 0; x < 240; x++) { + if(xxx < 0 || + yyy < 0 || + xxx >= sizeX || + yyy >= sizeY) { + line[x] = 0x80000000; + } else { + line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if(control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if(mosaicX > 1) { + int m = 1; + for(int i = 0; i < 239; i++) { + line[i+1] = line[i]; + m++; + if(m == mosaicX) { + m = 1; + i++; + } + } + } + } +} + +inline void gfxDrawSprites(u32 *lineOBJ) +{ + int m=0; + gfxClearArray(lineOBJ); + if(layerEnable & 0x1000) { + u16 *sprites = (u16 *)oam; + u16 *spritePalette = &((u16 *)paletteRAM)[256]; + int mosaicY = ((MOSAIC & 0xF000)>>12) + 1; + int mosaicX = ((MOSAIC & 0xF00)>>8) + 1; + for(int x = 0; x < 128 ; x++) { + u16 a0 = READ16LE(sprites++); + u16 a1 = READ16LE(sprites++); + u16 a2 = READ16LE(sprites++); + sprites++; + + // ignore OBJ-WIN + if((a0 & 0x0c00) == 0x0800) + continue; + + int sizeY = 8; + int sizeX = 8; + + switch(((a0 >>12) & 0x0c)|(a1>>14)) { + case 0: + break; + case 1: + sizeX = sizeY = 16; + break; + case 2: + sizeX = sizeY = 32; + break; + case 3: + sizeX = sizeY = 64; + break; + case 4: + sizeX = 16; + break; + case 5: + sizeX = 32; + break; + case 6: + sizeX = 32; + sizeY = 16; + break; + case 7: + sizeX = 64; + sizeY = 32; + break; + case 8: + sizeY = 16; + break; + case 9: + sizeY = 32; + break; + case 10: + sizeX = 16; + sizeY = 32; + break; + case 11: + sizeX = 32; + sizeY = 64; + break; + default: + continue; + } + +#ifdef SPRITE_DEBUG + int maskX = sizeX-1; + int maskY = sizeY-1; +#endif + + int sy = (a0 & 255); + + if(sy > 160) + sy -= 256; + + if(a0 & 0x0100) { + int fieldX = sizeX; + int fieldY = sizeY; + if(a0 & 0x0200) { + fieldX <<= 1; + fieldY <<= 1; + } + + int t = VCOUNT - sy; + if((t >= 0) && (t < fieldY)) { + int sx = (a1 & 0x1FF); + if((sx < 240) || (((sx + fieldX) & 511) < 240)) { + // int t2 = t - (fieldY >> 1); + int rot = (a1 >> 9) & 0x1F; + u16 *OAM = (u16 *)oam; + int dx = READ16LE(&OAM[3 + (rot << 4)]); + if(dx & 0x8000) + dx |= 0xFFFF8000; + int dmx = READ16LE(&OAM[7 + (rot << 4)]); + if(dmx & 0x8000) + dmx |= 0xFFFF8000; + int dy = READ16LE(&OAM[11 + (rot << 4)]); + if(dy & 0x8000) + dy |= 0xFFFF8000; + int dmy = READ16LE(&OAM[15 + (rot << 4)]); + if(dmy & 0x8000) + dmy |= 0xFFFF8000; + + if(a0 & 0x1000) { + t -= (t % mosaicY); + } + + int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx + + t * dmx; + int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy + + t * dmy; + + u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + + if(a0 & 0x2000) { + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 2; + else + c &= 0x3FE; + for(int x = 0; x < fieldX; x++) { + int xxx = realX >> 8; + int yyy = realY >> 8; + + if(xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY || + sx >= 240); + else { + u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) + + ((yyy & 7)<<3) + ((xxx >> 3)<<6) + + (xxx & 7))&0x7FFF)]; + if ((color==0) && (((prio >> 25)&3) < + ((lineOBJ[sx]>>25)&3))) { + lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { + lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } + + if (a0 & 0x1000) { + m++; + if (m==mosaicX) + m=0; + } +#ifdef SPRITE_DEBUG + if(t == 0 || t == maskY || x == 0 || x == maskX) + lineOBJ[sx] = 0x001F; +#endif + } + sx = (sx+1)&511;; + realX += dx; + realY += dy; + } + } else { + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 3; + int palette = (a2 >> 8) & 0xF0; + for(int x = 0; x < fieldX; x++) { + int xxx = realX >> 8; + int yyy = realY >> 8; + if(xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY || + sx >= 240); + else { + u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) + + ((yyy & 7)<<2) + ((xxx >> 3)<<5) + + ((xxx & 7)>>1))&0x7FFF)]; + if(xxx & 1) + color >>= 4; + else + color &= 0x0F; + + if ((color==0) && (((prio >> 25)&3) < + ((lineOBJ[sx]>>25)&3))) { + lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { + lineOBJ[sx] = READ16LE(&spritePalette[palette+color]) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } + } + if((a0 & 0x1000) && m) { + m++; + if (m==mosaicX) + m=0; + } + +#ifdef SPRITE_DEBUG + if(t == 0 || t == maskY || x == 0 || x == maskX) + lineOBJ[sx] = 0x001F; +#endif + sx = (sx+1)&511;; + realX += dx; + realY += dy; + + } + } + } + } + } else { + int t = VCOUNT - sy; + if((t >= 0) && (t < sizeY)) { + int sx = (a1 & 0x1FF); + if(((sx < 240)||(((sx+sizeX)&511)<240)) && !(a0 & 0x0200)) { + if(a0 & 0x2000) { + if(a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) { + inc = sizeX >> 2; + } else { + c &= 0x3FE; + } + int xxx = 0; + if(a1 & 0x1000) + xxx = sizeX-1; + + if(a0 & 0x1000) { + t -= (t % mosaicY); + } + + int address = 0x10000 + ((((c+ (t>>3) * inc) << 5) + + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF); + + if(a1 & 0x1000) + xxx = 7; + u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + + for(int xx = 0; xx < sizeX; xx++) { + if(sx < 240) { + u8 color = vram[address]; + if ((color==0) && (((prio >> 25)&3) < + ((lineOBJ[sx]>>25)&3))) { + lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { + lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } + + if (a0 & 0x1000) { + m++; + if (m==mosaicX) + m=0; + } + +#ifdef SPRITE_DEBUG + if(t == 0 || t == maskY || xx == 0 || xx == maskX) + lineOBJ[sx] = 0x001F; +#endif + } + + sx = (sx+1) & 511; + if(a1 & 0x1000) { + xxx--; + address--; + if(xxx == -1) { + address -= 56; + xxx = 7; + } + if(address < 0x10000) + address += 0x8000; + } else { + xxx++; + address++; + if(xxx == 8) { + address += 56; + xxx = 0; + } + if(address > 0x17fff) + address -= 0x8000; + } + } + } else { + if(a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) { + inc = sizeX >> 3; + } + int xxx = 0; + if(a1 & 0x1000) + xxx = sizeX - 1; + + if(a0 & 0x1000) { + t -= (t % mosaicY); + } + + int address = 0x10000 + ((((c + (t>>3) * inc)<<5) + + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF); + u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + int palette = (a2 >> 8) & 0xF0; + if(a1 & 0x1000) { + xxx = 7; + for(int xx = sizeX - 1; xx >= 0; xx--) { + if(sx < 240) { + u8 color = vram[address]; + if(xx & 1) { + color = (color >> 4); + } else + color &= 0x0F; + + if ((color==0) && (((prio >> 25)&3) < + ((lineOBJ[sx]>>25)&3))) { + lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { + lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } + } + if (a0 & 0x1000) { + m++; + if (m==mosaicX) + m=0; + } +#ifdef SPRITE_DEBUG + if(t == 0 || t == maskY || xx == 0 || xx == maskX) + lineOBJ[sx] = 0x001F; +#endif + sx = (sx+1) & 511; + xxx--; + if(!(xx & 1)) + address--; + if(xxx == -1) { + xxx = 7; + address -= 28; + } + if(address < 0x10000) + address += 0x8000; + } + } else { + for(int xx = 0; xx < sizeX; xx++) { + if(sx < 240) { + u8 color = vram[address]; + if(xx & 1) { + color = (color >> 4); + } else + color &= 0x0F; + + if ((color==0) && (((prio >> 25)&3) < + ((lineOBJ[sx]>>25)&3))) { + lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { + lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio; + if((a0 & 0x1000) && m) + lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; + + } + } + if (a0 & 0x1000) { + m++; + if (m==mosaicX) + m=0; + } +#ifdef SPRITE_DEBUG + if(t == 0 || t == maskY || xx == 0 || xx == maskX) + lineOBJ[sx] = 0x001F; +#endif + sx = (sx+1) & 511; + xxx++; + if(xx & 1) + address++; + if(xxx == 8) { + address += 28; + xxx = 0; + } + if(address > 0x17fff) + address -= 0x8000; + } + } + } + } + } + } + } + } +} + +inline void gfxDrawOBJWin(u32 *lineOBJWin) +{ + gfxClearArray(lineOBJWin); + if(layerEnable & 0x8000) { + u16 *sprites = (u16 *)oam; + // u16 *spritePalette = &((u16 *)paletteRAM)[256]; + for(int x = 0; x < 128 ; x++) { + u16 a0 = READ16LE(sprites++); + u16 a1 = READ16LE(sprites++); + u16 a2 = READ16LE(sprites++); + sprites++; + + // ignore non OBJ-WIN + if((a0 & 0x0c00) != 0x0800) + continue; + + int sizeY = 8; + int sizeX = 8; + + switch(((a0 >>12) & 0x0c)|(a1>>14)) { + case 0: + break; + case 1: + sizeX = sizeY = 16; + break; + case 2: + sizeX = sizeY = 32; + break; + case 3: + sizeX = sizeY = 64; + break; + case 4: + sizeX = 16; + break; + case 5: + sizeX = 32; + break; + case 6: + sizeX = 32; + sizeY = 16; + break; + case 7: + sizeX = 64; + sizeY = 32; + break; + case 8: + sizeY = 16; + break; + case 9: + sizeY = 32; + break; + case 10: + sizeX = 16; + sizeY = 32; + break; + case 11: + sizeX = 32; + sizeY = 64; + break; + default: + continue; + } + + int sy = (a0 & 255); + + if(sy > 160) + sy -= 256; + + if(a0 & 0x0100) { + int fieldX = sizeX; + int fieldY = sizeY; + if(a0 & 0x0200) { + fieldX <<= 1; + fieldY <<= 1; + } + + int t = VCOUNT - sy; + if((t >= 0) && (t < fieldY)) { + int sx = (a1 & 0x1FF); + if((sx < 240) || (((sx + fieldX) & 511) < 240)) { + // int t2 = t - (fieldY >> 1); + int rot = (a1 >> 9) & 0x1F; + u16 *OAM = (u16 *)oam; + int dx = READ16LE(&OAM[3 + (rot << 4)]); + if(dx & 0x8000) + dx |= 0xFFFF8000; + int dmx = READ16LE(&OAM[7 + (rot << 4)]); + if(dmx & 0x8000) + dmx |= 0xFFFF8000; + int dy = READ16LE(&OAM[11 + (rot << 4)]); + if(dy & 0x8000) + dy |= 0xFFFF8000; + int dmy = READ16LE(&OAM[15 + (rot << 4)]); + if(dmy & 0x8000) + dmy |= 0xFFFF8000; + + int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx + + t * dmx; + int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy + + t * dmy; + + // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + + if(a0 & 0x2000) { + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 2; + else + c &= 0x3FE; + for(int x = 0; x < fieldX; x++) { + int xxx = realX >> 8; + int yyy = realY >> 8; + + if(xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY) { + } else { + u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) + + ((yyy & 7)<<3) + ((xxx >> 3)<<6) + + (xxx & 7))&0x7fff)]; + if(color) { + lineOBJWin[sx] = 1; + } + } + sx = (sx+1)&511;; + realX += dx; + realY += dy; + } + } else { + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 3; + // int palette = (a2 >> 8) & 0xF0; + for(int x = 0; x < fieldX; x++) { + int xxx = realX >> 8; + int yyy = realY >> 8; + + // if(x == 0 || x == (sizeX-1) || + // t == 0 || t == (sizeY-1)) { + // lineOBJ[sx] = 0x001F | prio; + // } else { + if(xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY){ + } else { + u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) + + ((yyy & 7)<<2) + ((xxx >> 3)<<5) + + ((xxx & 7)>>1))&0x7fff)]; + if(xxx & 1) + color >>= 4; + else + color &= 0x0F; + + if(color) { + lineOBJWin[sx] = 1; + } + } + // } + sx = (sx+1)&511;; + realX += dx; + realY += dy; + } + } + } + } + } else { + int t = VCOUNT - sy; + if((t >= 0) && (t < sizeY)) { + int sx = (a1 & 0x1FF); + if(((sx < 240)||(((sx+sizeX)&511)<240)) && !(a0 & 0x0200)) { + if(a0 & 0x2000) { + if(a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) { + inc = sizeX >> 2; + } else { + c &= 0x3FE; + } + int xxx = 0; + if(a1 & 0x1000) + xxx = sizeX-1; + int address = 0x10000 + ((((c+ (t>>3) * inc) << 5) + + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7))&0x7fff); + if(a1 & 0x1000) + xxx = 7; + // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + for(int xx = 0; xx < sizeX; xx++) { + if(sx < 240) { + u8 color = vram[address]; + if(color) { + lineOBJWin[sx] = 1; + } + } + + sx = (sx+1) & 511; + if(a1 & 0x1000) { + xxx--; + address--; + if(xxx == -1) { + address -= 56; + xxx = 7; + } + if(address < 0x10000) + address += 0x8000; + } else { + xxx++; + address++; + if(xxx == 8) { + address += 56; + xxx = 0; + } + if(address > 0x17fff) + address -= 0x8000; + } + } + } else { + if(a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if(DISPCNT & 0x40) { + inc = sizeX >> 3; + } + int xxx = 0; + if(a1 & 0x1000) + xxx = sizeX - 1; + int address = 0x10000 + ((((c + (t>>3) * inc)<<5) + + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff); + // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + // int palette = (a2 >> 8) & 0xF0; + if(a1 & 0x1000) { + xxx = 7; + for(int xx = sizeX - 1; xx >= 0; xx--) { + if(sx < 240) { + u8 color = vram[address]; + if(xx & 1) { + color = (color >> 4); + } else + color &= 0x0F; + + if(color) { + lineOBJWin[sx] = 1; + } + } + sx = (sx+1) & 511; + xxx--; + if(!(xx & 1)) + address--; + if(xxx == -1) { + xxx = 7; + address -= 28; + } + if(address < 0x10000) + address += 0x8000; + } + } else { + for(int xx = 0; xx < sizeX; xx++) { + if(sx < 240) { + u8 color = vram[address]; + if(xx & 1) { + color = (color >> 4); + } else + color &= 0x0F; + + if(color) { + lineOBJWin[sx] = 1; + } + } + sx = (sx+1) & 511; + xxx++; + if(xx & 1) + address++; + if(xxx == 8) { + address += 28; + xxx = 0; + } + if(address > 0x17fff) + address -= 0x8000; + } + } + } + } + } + } + } + } +} + +inline u32 gfxIncreaseBrightness(u32 color, int coeff) +{ + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + + r = r + (((31 - r) * coeff) >> 4); + g = g + (((31 - g) * coeff) >> 4); + b = b + (((31 - b) * coeff) >> 4); + if(r > 31) + r = 31; + if(g > 31) + g = 31; + if(b > 31) + b = 31; + color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + return color; +} + +inline void gfxIncreaseBrightness(u32 *line, int coeff) +{ + for(int x = 0; x < 240; x++) { + u32 color = *line; + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + + r = r + (((31 - r) * coeff) >> 4); + g = g + (((31 - g) * coeff) >> 4); + b = b + (((31 - b) * coeff) >> 4); + if(r > 31) + r = 31; + if(g > 31) + g = 31; + if(b > 31) + b = 31; + *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } +} + +inline u32 gfxDecreaseBrightness(u32 color, int coeff) +{ + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + + r = r - ((r * coeff) >> 4); + g = g - ((g * coeff) >> 4); + b = b - ((b * coeff) >> 4); + if(r < 0) + r = 0; + if(g < 0) + g = 0; + if(b < 0) + b = 0; + color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + + return color; +} + +inline void gfxDecreaseBrightness(u32 *line, int coeff) +{ + for(int x = 0; x < 240; x++) { + u32 color = *line; + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + + r = r - ((r * coeff) >> 4); + g = g - ((g * coeff) >> 4); + b = b - ((b * coeff) >> 4); + if(r < 0) + r = 0; + if(g < 0) + g = 0; + if(b < 0) + b = 0; + *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } +} + +inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb) +{ + if(color < 0x80000000) { + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + int r0 = (color2 & 0x1F); + int g0 = ((color2 >> 5) & 0x1F); + int b0 = ((color2 >> 10) & 0x1F); + + r = ((r * ca) >> 4) + ((r0 * cb) >> 4); + g = ((g * ca) >> 4) + ((g0 * cb) >> 4); + b = ((b * ca) >> 4) + ((b0 * cb) >> 4); + + if(r > 31) + r = 31; + if(g > 31) + g = 31; + if(b > 31) + b = 31; + + return (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } + return color; +} + +inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb) +{ + for(int x = 0; x < 240; x++) { + u32 color = *ta; + if(color < 0x80000000) { + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + u32 color2 = (*tb++); + int r0 = (color2 & 0x1F); + int g0 = ((color2 >> 5) & 0x1F); + int b0 = ((color2 >> 10) & 0x1F); + + r = ((r * ca) >> 4) + ((r0 * cb) >> 4); + g = ((g * ca) >> 4) + ((g0 * cb) >> 4); + b = ((b * ca) >> 4) + ((b0 * cb) >> 4); + + if(r > 31) + r = 31; + if(g > 31) + g = 31; + if(b > 31) + b = 31; + + *ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } else { + ta++; + tb++; + } + } +} + +#endif // VBA_GFX_H diff --git a/src/Globals.cpp b/src/Globals.cpp new file mode 100644 index 0000000..35bd734 --- /dev/null +++ b/src/Globals.cpp @@ -0,0 +1,136 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" + +reg_pair reg[45]; +memoryMap map[256]; +bool ioReadable[0x400]; +bool N_FLAG = 0; +bool C_FLAG = 0; +bool Z_FLAG = 0; +bool V_FLAG = 0; +bool armState = true; +bool armIrqEnable = true; +u32 armNextPC = 0x00000000; +int armMode = 0x1f; +u32 stop = 0x08000568; +int saveType = 0; +bool useBios = false; +bool skipBios = false; +int frameSkip = 1; +bool speedup = false; +bool synchronize = true; +bool cpuDisableSfx = false; +bool cpuIsMultiBoot = false; +bool parseDebug = true; +int layerSettings = 0xff00; +int layerEnable = 0xff00; +bool speedHack = false; +bool memLagEnabled = false, memLagTempEnabled = false; +int cpuSaveType = 0; +bool cpuEnhancedDetection = true; +bool cheatsEnabled = true; + +u8 *bios = NULL; +u8 *rom = NULL; +u8 *internalRAM = NULL; +u8 *workRAM = NULL; +u8 *paletteRAM = NULL; +u8 *vram = NULL; +u8 *pix = NULL; +u8 *oam = NULL; +u8 *ioMem = NULL; + +u16 DISPCNT = 0x0080; +u16 DISPSTAT = 0x0000; +u16 VCOUNT = 0x0000; +u16 BG0CNT = 0x0000; +u16 BG1CNT = 0x0000; +u16 BG2CNT = 0x0000; +u16 BG3CNT = 0x0000; +u16 BG0HOFS = 0x0000; +u16 BG0VOFS = 0x0000; +u16 BG1HOFS = 0x0000; +u16 BG1VOFS = 0x0000; +u16 BG2HOFS = 0x0000; +u16 BG2VOFS = 0x0000; +u16 BG3HOFS = 0x0000; +u16 BG3VOFS = 0x0000; +u16 BG2PA = 0x0100; +u16 BG2PB = 0x0000; +u16 BG2PC = 0x0000; +u16 BG2PD = 0x0100; +u16 BG2X_L = 0x0000; +u16 BG2X_H = 0x0000; +u16 BG2Y_L = 0x0000; +u16 BG2Y_H = 0x0000; +u16 BG3PA = 0x0100; +u16 BG3PB = 0x0000; +u16 BG3PC = 0x0000; +u16 BG3PD = 0x0100; +u16 BG3X_L = 0x0000; +u16 BG3X_H = 0x0000; +u16 BG3Y_L = 0x0000; +u16 BG3Y_H = 0x0000; +u16 WIN0H = 0x0000; +u16 WIN1H = 0x0000; +u16 WIN0V = 0x0000; +u16 WIN1V = 0x0000; +u16 WININ = 0x0000; +u16 WINOUT = 0x0000; +u16 MOSAIC = 0x0000; +u16 BLDMOD = 0x0000; +u16 COLEV = 0x0000; +u16 COLY = 0x0000; +u16 DM0SAD_L = 0x0000; +u16 DM0SAD_H = 0x0000; +u16 DM0DAD_L = 0x0000; +u16 DM0DAD_H = 0x0000; +u16 DM0CNT_L = 0x0000; +u16 DM0CNT_H = 0x0000; +u16 DM1SAD_L = 0x0000; +u16 DM1SAD_H = 0x0000; +u16 DM1DAD_L = 0x0000; +u16 DM1DAD_H = 0x0000; +u16 DM1CNT_L = 0x0000; +u16 DM1CNT_H = 0x0000; +u16 DM2SAD_L = 0x0000; +u16 DM2SAD_H = 0x0000; +u16 DM2DAD_L = 0x0000; +u16 DM2DAD_H = 0x0000; +u16 DM2CNT_L = 0x0000; +u16 DM2CNT_H = 0x0000; +u16 DM3SAD_L = 0x0000; +u16 DM3SAD_H = 0x0000; +u16 DM3DAD_L = 0x0000; +u16 DM3DAD_H = 0x0000; +u16 DM3CNT_L = 0x0000; +u16 DM3CNT_H = 0x0000; +u16 TM0D = 0x0000; +u16 TM0CNT = 0x0000; +u16 TM1D = 0x0000; +u16 TM1CNT = 0x0000; +u16 TM2D = 0x0000; +u16 TM2CNT = 0x0000; +u16 TM3D = 0x0000; +u16 TM3CNT = 0x0000; +u16 P1 = 0xFFFF; +u16 IE = 0x0000; +u16 IF = 0x0000; +u16 IME = 0x0000; diff --git a/src/Globals.h b/src/Globals.h new file mode 100644 index 0000000..c35afaf --- /dev/null +++ b/src/Globals.h @@ -0,0 +1,150 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_GLOBALS_H +#define VBA_GLOBALS_H + +#define VERBOSE_SWI 1 +#define VERBOSE_UNALIGNED_MEMORY 2 +#define VERBOSE_ILLEGAL_WRITE 4 +#define VERBOSE_ILLEGAL_READ 8 +#define VERBOSE_DMA0 16 +#define VERBOSE_DMA1 32 +#define VERBOSE_DMA2 64 +#define VERBOSE_DMA3 128 +#define VERBOSE_UNDEFINED 256 +#define VERBOSE_AGBPRINT 512 + +extern reg_pair reg[45]; +extern bool ioReadable[0x400]; +extern bool N_FLAG; +extern bool C_FLAG; +extern bool Z_FLAG; +extern bool V_FLAG; +extern bool armState; +extern bool armIrqEnable; +extern u32 armNextPC; +extern int armMode; +extern u32 stop; +extern int saveType; +extern bool useBios; +extern bool skipBios; +extern int frameSkip; +extern bool speedup; +extern bool synchronize; +extern bool cpuDisableSfx; +extern bool cpuIsMultiBoot; +extern bool parseDebug; +extern int layerSettings; +extern int layerEnable; +extern bool speedHack; +extern bool memLagEnabled, memLagTempEnabled; +extern int cpuSaveType; +extern bool cpuEnhancedDetection; +extern bool cheatsEnabled; + +extern u8 *bios; +extern u8 *rom; +extern u8 *internalRAM; +extern u8 *workRAM; +extern u8 *paletteRAM; +extern u8 *vram; +extern u8 *pix; +extern u8 *oam; +extern u8 *ioMem; + +extern u16 DISPCNT; +extern u16 DISPSTAT; +extern u16 VCOUNT; +extern u16 BG0CNT; +extern u16 BG1CNT; +extern u16 BG2CNT; +extern u16 BG3CNT; +extern u16 BG0HOFS; +extern u16 BG0VOFS; +extern u16 BG1HOFS; +extern u16 BG1VOFS; +extern u16 BG2HOFS; +extern u16 BG2VOFS; +extern u16 BG3HOFS; +extern u16 BG3VOFS; +extern u16 BG2PA; +extern u16 BG2PB; +extern u16 BG2PC; +extern u16 BG2PD; +extern u16 BG2X_L; +extern u16 BG2X_H; +extern u16 BG2Y_L; +extern u16 BG2Y_H; +extern u16 BG3PA; +extern u16 BG3PB; +extern u16 BG3PC; +extern u16 BG3PD; +extern u16 BG3X_L; +extern u16 BG3X_H; +extern u16 BG3Y_L; +extern u16 BG3Y_H; +extern u16 WIN0H; +extern u16 WIN1H; +extern u16 WIN0V; +extern u16 WIN1V; +extern u16 WININ; +extern u16 WINOUT; +extern u16 MOSAIC; +extern u16 BLDMOD; +extern u16 COLEV; +extern u16 COLY; +extern u16 DM0SAD_L; +extern u16 DM0SAD_H; +extern u16 DM0DAD_L; +extern u16 DM0DAD_H; +extern u16 DM0CNT_L; +extern u16 DM0CNT_H; +extern u16 DM1SAD_L; +extern u16 DM1SAD_H; +extern u16 DM1DAD_L; +extern u16 DM1DAD_H; +extern u16 DM1CNT_L; +extern u16 DM1CNT_H; +extern u16 DM2SAD_L; +extern u16 DM2SAD_H; +extern u16 DM2DAD_L; +extern u16 DM2DAD_H; +extern u16 DM2CNT_L; +extern u16 DM2CNT_H; +extern u16 DM3SAD_L; +extern u16 DM3SAD_H; +extern u16 DM3DAD_L; +extern u16 DM3DAD_H; +extern u16 DM3CNT_L; +extern u16 DM3CNT_H; +extern u16 TM0D; +extern u16 TM0CNT; +extern u16 TM1D; +extern u16 TM1CNT; +extern u16 TM2D; +extern u16 TM2CNT; +extern u16 TM3D; +extern u16 TM3CNT; +extern u16 P1; +extern u16 IE; +extern u16 IF; +extern u16 IME; + +#endif // VBA_GLOBALS_H diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..f3a4bea --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,19 @@ +CORE_SUBDIRS = gb + +EXTRA_SUBDIRS = i386 prof sdl gtk + +SUBDIRS = $(CORE_SUBDIRS) @VBA_SRC_EXTRA@ + +DIST_SUBDIRS = $(CORE_SUBDIRS) $(EXTRA_SUBDIRS) + +dist_sysconf_DATA = VisualBoyAdvance.cfg + +EXTRA_DIST = \ + win32 \ + expr.l \ + expr.y \ + CheatSearch.cpp \ + CheatSearch.h + +dist-hook: + rm -rf `find $(distdir)/win32 -name CVS` diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..adf50e7 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,483 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +CORE_SUBDIRS = gb + +EXTRA_SUBDIRS = i386 prof sdl gtk + +SUBDIRS = $(CORE_SUBDIRS) @VBA_SRC_EXTRA@ + +DIST_SUBDIRS = $(CORE_SUBDIRS) $(EXTRA_SUBDIRS) + +dist_sysconf_DATA = VisualBoyAdvance.cfg + +EXTRA_DIST = \ + win32 \ + expr.l \ + expr.y \ + CheatSearch.cpp \ + CheatSearch.h + +subdir = src +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DATA = $(dist_sysconf_DATA) + + +RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ + ps-recursive install-info-recursive uninstall-info-recursive \ + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ + check-recursive installcheck-recursive +DIST_COMMON = $(dist_sysconf_DATA) $(srcdir)/Makefile.in Makefile.am +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: +dist_sysconfDATA_INSTALL = $(INSTALL_DATA) +install-dist_sysconfDATA: $(dist_sysconf_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(sysconfdir) + @list='$(dist_sysconf_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(dist_sysconfDATA_INSTALL) $$d$$p $(DESTDIR)$(sysconfdir)/$$f"; \ + $(dist_sysconfDATA_INSTALL) $$d$$p $(DESTDIR)$(sysconfdir)/$$f; \ + done + +uninstall-dist_sysconfDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_sysconf_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(sysconfdir)/$$f"; \ + rm -f $(DESTDIR)$(sysconfdir)/$$f; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if (etags --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + else \ + include_option=--include; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(sysconfdir) + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: install-dist_sysconfDATA + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-dist_sysconfDATA uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-generic clean-recursive ctags ctags-recursive distclean \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am dvi-recursive info info-am info-recursive install \ + install-am install-data install-data-am install-data-recursive \ + install-dist_sysconfDATA install-exec install-exec-am \ + install-exec-recursive install-info install-info-am \ + install-info-recursive install-man install-recursive \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am installdirs-recursive maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive mostlyclean \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am \ + pdf-recursive ps ps-am ps-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-dist_sysconfDATA \ + uninstall-info-am uninstall-info-recursive uninstall-recursive + + +dist-hook: + rm -rf `find $(distdir)/win32 -name CVS` +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/Mode0.cpp b/src/Mode0.cpp new file mode 100644 index 0000000..5d30d7f --- /dev/null +++ b/src/Mode0.cpp @@ -0,0 +1,552 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Globals.h" +#include "Gfx.h" + +void mode0RenderLine() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + return; + } + + if(layerEnable & 0x0100) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + if(layerEnable & 0x0200) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if(layerEnable & 0x0400) { + gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); + } + + if(layerEnable & 0x0800) { + gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line0[x] < color) { + color = line0[x]; + top = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(color >> 24)) { + color = line1[x]; + top = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(color >> 24)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(color >> 24)) { + color = line3[x]; + top = 0x08; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line0[x]>>24) < (u8)(back >> 24)) { + back = line0[x]; + top2 = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(back >> 24)) { + back = line1[x]; + top2 = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(back >> 24)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } +} + +void mode0RenderLineNoWindow() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + return; + } + + if(layerEnable & 0x0100) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + if(layerEnable & 0x0200) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if(layerEnable & 0x0400) { + gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); + } + + if(layerEnable & 0x0800) { + gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + int effect = (BLDMOD >> 6) & 3; + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line0[x] < color) { + color = line0[x]; + top = 0x01; + } + + if(line1[x] < (color & 0xFF000000)) { + color = line1[x]; + top = 0x02; + } + + if(line2[x] < (color & 0xFF000000)) { + color = line2[x]; + top = 0x04; + } + + if(line3[x] < (color & 0xFF000000)) { + color = line3[x]; + top = 0x08; + } + + if(lineOBJ[x] < (color & 0xFF000000)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch(effect) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + if(line0[x] < back) { + if(top != 0x01) { + back = line0[x]; + top2 = 0x01; + } + } + + if(line1[x] < (back & 0xFF000000)) { + if(top != 0x02) { + back = line1[x]; + top2 = 0x02; + } + } + + if(line2[x] < (back & 0xFF000000)) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if(line3[x] < (back & 0xFF000000)) { + if(top != 0x08) { + back = line3[x]; + top2 = 0x08; + } + } + + if(lineOBJ[x] < (back & 0xFF000000)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if(line0[x] < back) { + back = line0[x]; + top2 = 0x01; + } + + if(line1[x] < (back & 0xFF000000)) { + back = line1[x]; + top2 = 0x02; + } + + if(line2[x] < (back & 0xFF000000)) { + back = line2[x]; + top2 = 0x04; + } + + if(line3[x] < (back & 0xFF000000)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } +} + +void mode0RenderLineAll() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + return; + } + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + if((layerEnable & 0x0100)) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + if((layerEnable & 0x0200)) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if((layerEnable & 0x0400)) { + gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); + } + + if((layerEnable & 0x0800)) { + gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if((mask & 1) && (line0[x] < color)) { + color = line0[x]; + top = 0x01; + } + + if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24))) { + color = line1[x]; + top = 0x02; + } + + if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24))) { + color = line2[x]; + top = 0x04; + } + + if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24))) { + color = line3[x]; + top = 0x08; + } + + if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))) { + color = lineOBJ[x]; + top = 0x10; + } + + // special FX on in the window + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { + if(top != 0x01) { + back = line0[x]; + top2 = 0x01; + } + } + + if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { + if(top != 0x02) { + back = line1[x]; + top2 = 0x02; + } + } + + if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { + if(top != 0x08) { + back = line3[x]; + top2 = 0x08; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) { + back = line0[x]; + top2 = 0x01; + } + + if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) { + back = line1[x]; + top2 = 0x02; + } + + if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) { + back = line2[x]; + top2 = 0x04; + } + + if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) { + back = line0[x]; + top2 = 0x01; + } + + if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) { + back = line1[x]; + top2 = 0x02; + } + + if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) { + back = line2[x]; + top2 = 0x04; + } + + if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } +} diff --git a/src/Mode1.cpp b/src/Mode1.cpp new file mode 100644 index 0000000..0349158 --- /dev/null +++ b/src/Mode1.cpp @@ -0,0 +1,513 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Globals.h" +#include "Gfx.h" + +void mode1RenderLine() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0100) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + if(layerEnable & 0x0200) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, line2); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line0[x] < color) { + color = line0[x]; + top = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(color >> 24)) { + color = line1[x]; + top = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(color >> 24)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line0[x]>>24) < (u8)(back >> 24)) { + back = line0[x]; + top2 = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(back >> 24)) { + back = line1[x]; + top2 = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode1RenderLineNoWindow() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0100) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + + if(layerEnable & 0x0200) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, line2); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line0[x] < color) { + color = line0[x]; + top = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(color >> 24)) { + color = line1[x]; + top = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(color >> 24)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + if((u8)(line0[x]>>24) < (u8)(back >> 24)) { + if(top != 0x01) { + back = line0[x]; + top2 = 0x01; + } + } + + if((u8)(line1[x]>>24) < (u8)(back >> 24)) { + if(top != 0x02) { + back = line1[x]; + top2 = 0x02; + } + } + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line0[x]>>24) < (u8)(back >> 24)) { + back = line0[x]; + top2 = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(back >> 24)) { + back = line1[x]; + top2 = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode1RenderLineAll() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + if(layerEnable & 0x0100) { + gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); + } + + if(layerEnable & 0x0200) { + gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, line2); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if(line0[x] < color && (mask & 1)) { + color = line0[x]; + top = 0x01; + } + + if((u8)(line1[x]>>24) < (u8)(color >> 24) && (mask & 2)) { + color = line1[x]; + top = 0x02; + } + + if((u8)(line2[x]>>24) < (u8)(color >> 24) && (mask & 4)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) { + color = lineOBJ[x]; + top = 0x10; + } + + // special FX on the window + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { + if(top != 0x01) { + back = line0[x]; + top2 = 0x01; + } + } + + if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { + if(top != 0x02) { + back = line1[x]; + top2 = 0x02; + } + } + + if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { + back = line0[x]; + top2 = 0x01; + } + + if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { + back = line1[x]; + top2 = 0x02; + } + + if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { + back = line0[x]; + top2 = 0x01; + } + + if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { + back = line1[x]; + top2 = 0x02; + } + + if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} diff --git a/src/Mode2.cpp b/src/Mode2.cpp new file mode 100644 index 0000000..462f2b0 --- /dev/null +++ b/src/Mode2.cpp @@ -0,0 +1,478 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Globals.h" +#include "Gfx.h" + +void mode2RenderLine() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, + changed, line2); + } + + if(layerEnable & 0x0800) { + int changed = gfxBG3Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, + BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, + changed, line3); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + + if((u8)(line2[x]>>24) < (u8)(color >> 24)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(color >> 24)) { + color = line3[x]; + top = 0x08; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(back >> 24)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxBG3Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode2RenderLineNoWindow() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, + changed, line2); + } + + if(layerEnable & 0x0800) { + int changed = gfxBG3Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, + BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, + changed, line3); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + + if((u8)(line2[x]>>24) < (u8)(color >> 24)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(color >> 24)) { + color = line3[x]; + top = 0x08; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((u8)(line3[x]>>24) < (u8)(back >> 24)) { + if(top != 0x08) { + back = line3[x]; + top2 = 0x08; + } + } + + if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((u8)(line2[x]>>24) < (u8)(back >> 24)) { + back = line2[x]; + top2 = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(back >> 24)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxBG3Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode2RenderLineAll() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, + changed, line2); + } + + if(layerEnable & 0x0800) { + int changed = gfxBG3Changed; + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, + BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, + changed, line3); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if(line2[x] < color && (mask & 4)) { + color = line2[x]; + top = 0x04; + } + + if((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8)) { + color = line3[x]; + top = 0x08; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { + if(top != 0x08) { + back = line3[x]; + top2 = 0x08; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { + back = line3[x]; + top2 = 0x08; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxBG3Changed = 0; + gfxLastVCOUNT = VCOUNT; +} diff --git a/src/Mode3.cpp b/src/Mode3.cpp new file mode 100644 index 0000000..8a87308 --- /dev/null +++ b/src/Mode3.cpp @@ -0,0 +1,405 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Globals.h" +#include "Gfx.h" + +void mode3RenderLine() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 background = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode3RenderLineNoWindow() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 background = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode3RenderLineAll() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x80) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + u32 background = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if((mask & 4) && (line2[x] < color)) { + color = line2[x]; + top = 0x04; + } + + if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) { + color = lineOBJ[x]; + top = 0x10; + } + + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} diff --git a/src/Mode4.cpp b/src/Mode4.cpp new file mode 100644 index 0000000..8e81523 --- /dev/null +++ b/src/Mode4.cpp @@ -0,0 +1,402 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Gfx.h" +#include "Globals.h" + +void mode4RenderLine() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode4RenderLineNoWindow() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + if(layerEnable & 0x400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + + if(line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode4RenderLineAll() +{ + u16 *palette = (u16 *)paletteRAM; + + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + if(layerEnable & 0x400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, + BG2PA, BG2PB, BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + for(int x = 0; x < 240; x++) { + u32 color = backdrop; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if((mask & 4) && (line2[x] < color)) { + color = line2[x]; + top = 0x04; + } + + if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) { + color = lineOBJ[x]; + top = 0x10; + } + + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = backdrop; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} diff --git a/src/Mode5.cpp b/src/Mode5.cpp new file mode 100644 index 0000000..d3e9710 --- /dev/null +++ b/src/Mode5.cpp @@ -0,0 +1,405 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Globals.h" +#include "Gfx.h" + +void mode5RenderLine() +{ + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + u16 *palette = (u16 *)paletteRAM; + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 background = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if((top & 0x10) && (color & 0x00010000)) { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode5RenderLineNoWindow() +{ + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + u16 *palette = (u16 *)paletteRAM; + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + + u32 background = ( READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + + if(line2[x] < color) { + color = line2[x]; + top = 0x04; + } + + if((u8)(lineOBJ[x]>>24) < (u8)(color >>24)) { + color = lineOBJ[x]; + top = 0x10; + } + + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if(line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} + +void mode5RenderLineAll() +{ + if(DISPCNT & 0x0080) { + for(int x = 0; x < 240; x++) { + lineMix[x] = 0x7fff; + } + gfxLastVCOUNT = VCOUNT; + return; + } + + u16 *palette = (u16 *)paletteRAM; + + if(layerEnable & 0x0400) { + int changed = gfxBG2Changed; + + if(gfxLastVCOUNT > VCOUNT) + changed = 3; + + gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, + BG2Y_L, BG2Y_H, BG2PA, BG2PB, + BG2PC, BG2PD, + gfxBG2X, gfxBG2Y, changed, + line2); + } + + gfxDrawSprites(lineOBJ); + gfxDrawOBJWin(lineOBJWin); + + bool inWindow0 = false; + bool inWindow1 = false; + + if(layerEnable & 0x2000) { + u8 v0 = WIN0V >> 8; + u8 v1 = WIN0V & 255; + inWindow0 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1); + } + if(layerEnable & 0x4000) { + u8 v0 = WIN1V >> 8; + u8 v1 = WIN1V & 255; + inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); + if(v1 >= v0) + inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); + else + inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); + } + + u8 inWin0Mask = WININ & 0xFF; + u8 inWin1Mask = WININ >> 8; + u8 outMask = WINOUT & 0xFF; + + u32 background = (READ16LE(&palette[0]) | 0x30000000); + + for(int x = 0; x < 240; x++) { + u32 color = background; + u8 top = 0x20; + u8 mask = outMask; + + if(!(lineOBJWin[x] & 0x80000000)) { + mask = WINOUT >> 8; + } + + if(inWindow1) { + if(gfxInWin1[x]) + mask = inWin1Mask; + } + + if(inWindow0) { + if(gfxInWin0[x]) { + mask = inWin0Mask; + } + } + + if((mask & 4) && (line2[x] < color)) { + color = line2[x]; + top = 0x04; + } + + if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >>24))) { + color = lineOBJ[x]; + top = 0x10; + } + + if(mask & 32) { + if(!(color & 0x00010000)) { + switch((BLDMOD >> 6) & 3) { + case 0: + break; + case 1: + { + if(top & BLDMOD) { + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + if(top != 0x04) { + back = line2[x]; + top2 = 0x04; + } + } + + if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { + if(top != 0x10) { + back = lineOBJ[x]; + top2 = 0x10; + } + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + + } + } + break; + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } else { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + } else if(color & 0x00010000) { + // semi-transparent OBJ + u32 back = background; + u8 top2 = 0x20; + + if((mask & 4) && line2[x] < back) { + back = line2[x]; + top2 = 0x04; + } + + if(top2 & (BLDMOD>>8)) + color = gfxAlphaBlend(color, back, + coeff[COLEV & 0x1F], + coeff[(COLEV >> 8) & 0x1F]); + else { + switch((BLDMOD >> 6) & 3) { + case 2: + if(BLDMOD & top) + color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]); + break; + case 3: + if(BLDMOD & top) + color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); + break; + } + } + } + + lineMix[x] = color; + } + gfxBG2Changed = 0; + gfxLastVCOUNT = VCOUNT; +} diff --git a/src/NLS.h b/src/NLS.h new file mode 100644 index 0000000..ca024de --- /dev/null +++ b/src/NLS.h @@ -0,0 +1,62 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#define N_(String) (String) + +#define MSG_UNSUPPORTED_VBA_SGM 1 +#define MSG_CANNOT_LOAD_SGM 2 +#define MSG_SAVE_GAME_NOT_USING_BIOS 3 +#define MSG_SAVE_GAME_USING_BIOS 4 +#define MSG_UNSUPPORTED_SAVE_TYPE 5 +#define MSG_CANNOT_OPEN_FILE 6 +#define MSG_BAD_ZIP_FILE 7 +#define MSG_NO_IMAGE_ON_ZIP 8 +#define MSG_ERROR_OPENING_IMAGE 9 +#define MSG_ERROR_READING_IMAGE 10 +#define MSG_UNSUPPORTED_BIOS_FUNCTION 11 +#define MSG_INVALID_BIOS_FILE_SIZE 12 +#define MSG_INVALID_CHEAT_CODE 13 +#define MSG_UNKNOWN_ARM_OPCODE 14 +#define MSG_UNKNOWN_THUMB_OPCODE 15 +#define MSG_ERROR_CREATING_FILE 16 +#define MSG_FAILED_TO_READ_SGM 17 +#define MSG_FAILED_TO_READ_RTC 18 +#define MSG_UNSUPPORTED_VB_SGM 19 +#define MSG_CANNOT_LOAD_SGM_FOR 20 +#define MSG_ERROR_OPENING_IMAGE_FROM 21 +#define MSG_ERROR_READING_IMAGE_FROM 22 +#define MSG_UNSUPPORTED_ROM_SIZE 23 +#define MSG_UNSUPPORTED_RAM_SIZE 24 +#define MSG_UNKNOWN_CARTRIDGE_TYPE 25 +#define MSG_MAXIMUM_NUMBER_OF_CHEATS 26 +#define MSG_INVALID_GAMESHARK_CODE 27 +#define MSG_INVALID_GAMEGENIE_CODE 28 +#define MSG_INVALID_CHEAT_TO_REMOVE 29 +#define MSG_INVALID_CHEAT_CODE_ADDRESS 30 +#define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31 +#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32 +#define MSG_INVALID_GSA_CODE 33 +#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34 +#define MSG_UNSUPPORTED_SNAPSHOT_FILE 35 +#define MSG_UNSUPPORTED_ARM_MODE 36 +#define MSG_UNSUPPORTED_CODE_FILE 37 +#define MSG_GBA_CODE_WARNING 38 +#define MSG_INVALID_CBA_CODE 39 +#define MSG_CBA_CODE_WARNING 40 +#define MSG_OUT_OF_MEMORY 41 diff --git a/src/Port.h b/src/Port.h new file mode 100644 index 0000000..3716bf9 --- /dev/null +++ b/src/Port.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_PORT_H +#define VBA_PORT_H + +// swaps a 16-bit value +static inline u16 swap16(u16 v) +{ + return (v<<8)|(v>>8); +} + +// swaps a 32-bit value +static inline u32 swap32(u32 v) +{ + return (v<<24)|((v<<8)&0xff0000)|((v>>8)&0xff00)|(v>>24); +} + +#ifdef WORDS_BIGENDIAN +#if defined(__GNUC__) && defined(__ppc__) + +#define READ16LE(base) \ + ({ unsigned short lhbrxResult; \ + __asm__ ("lhbrx %0, 0, %1" : "=r" (lhbrxResult) : "r" (base) : "memory"); \ + lhbrxResult; }) + +#define READ32LE(base) \ + ({ unsigned long lwbrxResult; \ + __asm__ ("lwbrx %0, 0, %1" : "=r" (lwbrxResult) : "r" (base) : "memory"); \ + lwbrxResult; }) + +#define WRITE16LE(base, value) \ + __asm__ ("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") + +#define WRITE32LE(base, value) \ + __asm__ ("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") + +#else +#define READ16LE(x) \ + swap16(*((u16 *)(x))) +#define READ32LE(x) \ + swap32(*((u32 *)(x))) +#define WRITE16LE(x,v) \ + *((u16 *)x) = swap16((v)) +#define WRITE32LE(x,v) \ + *((u32 *)x) = swap32((v)) +#endif +#else +#define READ16LE(x) \ + *((u16 *)x) +#define READ32LE(x) \ + *((u32 *)x) +#define WRITE16LE(x,v) \ + *((u16 *)x) = (v) +#define WRITE32LE(x,v) \ + *((u32 *)x) = (v) +#endif + +#endif diff --git a/src/RTC.cpp b/src/RTC.cpp new file mode 100644 index 0000000..72b57d8 --- /dev/null +++ b/src/RTC.cpp @@ -0,0 +1,237 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" +#include "GBA.h" +#include "Globals.h" +#include "Port.h" +#include "Util.h" +#include "NLS.h" +#include "movie.h" + +#include +#include + +enum RTCSTATE { IDLE, COMMAND, DATA, READDATA }; + +typedef struct { + u8 byte0; + u8 byte1; + u8 byte2; + u8 command; + int dataLen; + int bits; + RTCSTATE state; + u8 data[12]; + // reserved variables for future + u8 reserved[12]; + bool reserved2; + u32 reserved3; +} RTCCLOCKDATA; + +static RTCCLOCKDATA rtcClockData; +static bool rtcEnabled = false; + +void rtcEnable(bool e) +{ + rtcEnabled = e; +} + +bool rtcIsEnabled() +{ + return rtcEnabled; +} + +u16 rtcRead(u32 address) +{ + if(rtcEnabled) { + if(address == 0x80000c8) + return rtcClockData.byte2; + else if(address == 0x80000c6) + return rtcClockData.byte1; + else if(address == 0x80000c4) { + return rtcClockData.byte0; + } + } + + return READ16LE((&rom[address & 0x1FFFFFE])); +} + +static u8 toBCD(u8 value) +{ + value = value % 100; + int l = value % 10; + int h = value / 10; + return h * 16 + l; +} + +bool rtcWrite(u32 address, u16 value) +{ + if(!rtcEnabled) + return false; + + if(address == 0x80000c8) { + rtcClockData.byte2 = (u8)value; // enable ? + } else if(address == 0x80000c6) { + rtcClockData.byte1 = (u8)value; // read/write + } else if(address == 0x80000c4) { + if(rtcClockData.byte2 & 1) { + if(rtcClockData.state == IDLE && rtcClockData.byte0 == 1 && value == 5) { + rtcClockData.state = COMMAND; + rtcClockData.bits = 0; + rtcClockData.command = 0; + } else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer + rtcClockData.byte0 = (u8)value; + switch(rtcClockData.state) { + case COMMAND: + rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits); + rtcClockData.bits++; + if(rtcClockData.bits == 8) { + rtcClockData.bits = 0; + switch(rtcClockData.command) { + case 0x60: + // not sure what this command does but it doesn't take parameters + // maybe it is a reset or stop + rtcClockData.state = IDLE; + rtcClockData.bits = 0; + break; + case 0x62: + // this sets the control state but not sure what those values are + rtcClockData.state = READDATA; + rtcClockData.dataLen = 1; + break; + case 0x63: + rtcClockData.dataLen = 1; + rtcClockData.data[0] = 0x40; + rtcClockData.state = DATA; + break; + case 0x65: + { + struct tm *newtime; + time_t long_time; + + if(VBAMovieActive() || VBAMovieLoading()) + { + long_time = VBAMovieGetId() + VBAMovieGetFrameCounter()/60; + newtime = gmtime( &long_time ); + } + else + { + time( &long_time ); /* Get time as long integer. */ + newtime = localtime( &long_time ); /* Convert to local time. */ + } + + rtcClockData.dataLen = 7; + rtcClockData.data[0] = toBCD(newtime->tm_year); + rtcClockData.data[1] = toBCD(newtime->tm_mon+1); + rtcClockData.data[2] = toBCD(newtime->tm_mday); + rtcClockData.data[3] = 0; + rtcClockData.data[4] = toBCD(newtime->tm_hour); + rtcClockData.data[5] = toBCD(newtime->tm_min); + rtcClockData.data[6] = toBCD(newtime->tm_sec); + rtcClockData.state = DATA; + } + break; + case 0x67: + { + struct tm *newtime; + time_t long_time; + + if(VBAMovieActive() || VBAMovieLoading()) + { + long_time = VBAMovieGetId() + VBAMovieGetFrameCounter()/60; + newtime = gmtime( &long_time ); + } + else + { + time( &long_time ); /* Get time as long integer. */ + newtime = localtime( &long_time ); /* Convert to local time. */ + } + + rtcClockData.dataLen = 3; + rtcClockData.data[0] = toBCD(newtime->tm_hour); + rtcClockData.data[1] = toBCD(newtime->tm_min); + rtcClockData.data[2] = toBCD(newtime->tm_sec); + rtcClockData.state = DATA; + } + break; + default: + systemMessage(0, N_("Unknown RTC command %02x"), rtcClockData.command); + rtcClockData.state = IDLE; + break; + } + } + break; + case DATA: + if(rtcClockData.byte1 & 2) { + } else { + rtcClockData.byte0 = (rtcClockData.byte0 & ~2) | + ((rtcClockData.data[rtcClockData.bits >> 3] >> + (rtcClockData.bits & 7)) & 1)*2; + rtcClockData.bits++; + if(rtcClockData.bits == 8*rtcClockData.dataLen) { + rtcClockData.bits = 0; + rtcClockData.state = IDLE; + } + } + break; + case READDATA: + if(!(rtcClockData.byte1 & 2)) { + } else { + rtcClockData.data[rtcClockData.bits >> 3] = + (rtcClockData.data[rtcClockData.bits >> 3] >> 1) | + ((value << 6) & 128); + rtcClockData.bits++; + if(rtcClockData.bits == 8*rtcClockData.dataLen) { + rtcClockData.bits = 0; + rtcClockData.state = IDLE; + } + } + break; + default: + break; + } + } else + rtcClockData.byte0 = (u8)value; + } + } + return true; +} + +void rtcReset() +{ + memset(&rtcClockData, 0, sizeof(rtcClockData)); + + rtcClockData.byte0 = 0; + rtcClockData.byte1 = 0; + rtcClockData.byte2 = 0; + rtcClockData.command = 0; + rtcClockData.dataLen = 0; + rtcClockData.bits = 0; + rtcClockData.state = IDLE; +} + +void rtcSaveGame(gzFile gzFile) +{ + utilGzWrite(gzFile, &rtcClockData, sizeof(rtcClockData)); +} + +void rtcReadGame(gzFile gzFile) +{ + utilGzRead(gzFile, &rtcClockData, sizeof(rtcClockData)); +} diff --git a/src/RTC.h b/src/RTC.h new file mode 100644 index 0000000..acbd3f6 --- /dev/null +++ b/src/RTC.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_RTC_H +#define VBA_RTC_H +extern u16 rtcRead(u32 address); +extern bool rtcWrite(u32 address, u16 value); +extern void rtcEnable(bool); +extern bool rtcIsEnabled(); +extern void rtcReset(); + +extern void rtcReadGame(gzFile gzFile); +extern void rtcSaveGame(gzFile gzFile); + +#endif diff --git a/src/Sound.cpp b/src/Sound.cpp new file mode 100644 index 0000000..5368575 --- /dev/null +++ b/src/Sound.cpp @@ -0,0 +1,1348 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if (defined(WIN32) && !defined(SDL)) +# include "win32/stdafx.h" +# include "win32/VBA.h" +#endif + +#include + +#include "GBA.h" +#include "Globals.h" +#include "Sound.h" +#include "Util.h" + +#define USE_TICKS_AS 380 +#define SOUND_MAGIC 0x60000000 +#define SOUND_MAGIC_2 0x30000000 +#define NOISE_MAGIC 5 + +extern bool stopState; + +u8 soundWavePattern[4][32] = { + {0x01,0x01,0x01,0x01, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff}, + {0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff}, + {0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff}, + {0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff} +}; + +int soundFreqRatio[8] = { + 1048576, // 0 + 524288, // 1 + 262144, // 2 + 174763, // 3 + 131072, // 4 + 104858, // 5 + 87381, // 6 + 74898 // 7 +}; + +int soundShiftClock[16]= { + 2, // 0 + 4, // 1 + 8, // 2 + 16, // 3 + 32, // 4 + 64, // 5 + 128, // 6 + 256, // 7 + 512, // 8 + 1024, // 9 + 2048, // 10 + 4096, // 11 + 8192, // 12 + 16384, // 13 + 1, // 14 + 1 // 15 +}; + +int soundVolume = 0; + +u8 soundBuffer[6][735]; +u16 soundFinalWave[1470]; + +int soundBufferLen = 1470; +int soundBufferTotalLen = 14700; +int soundQuality = 2; +int soundPaused = 1; +int soundPlay = 0; +int soundTicks = soundQuality * USE_TICKS_AS; +int SOUND_CLOCK_TICKS = soundQuality * USE_TICKS_AS; +u32 soundNextPosition = 0; + +int soundLevel1 = 0; +int soundLevel2 = 0; +int soundBalance = 0; +int soundMasterOn = 0; +int soundIndex = 0; +int soundBufferIndex = 0; +int soundDebug = 0; +bool soundOffFlag = false; + +int sound1On = 0; +int sound1ATL = 0; +int sound1Skip = 0; +int sound1Index = 0; +int sound1Continue = 0; +int sound1EnvelopeVolume = 0; +int sound1EnvelopeATL = 0; +int sound1EnvelopeUpDown = 0; +int sound1EnvelopeATLReload = 0; +int sound1SweepATL = 0; +int sound1SweepATLReload = 0; +int sound1SweepSteps = 0; +int sound1SweepUpDown = 0; +int sound1SweepStep = 0; +u8 *sound1Wave = soundWavePattern[2]; + +int sound2On = 0; +int sound2ATL = 0; +int sound2Skip = 0; +int sound2Index = 0; +int sound2Continue = 0; +int sound2EnvelopeVolume = 0; +int sound2EnvelopeATL = 0; +int sound2EnvelopeUpDown = 0; +int sound2EnvelopeATLReload = 0; +u8 *sound2Wave = soundWavePattern[2]; + +int sound3On = 0; +int sound3ATL = 0; +int sound3Skip = 0; +int sound3Index = 0; +int sound3Continue = 0; +int sound3OutputLevel = 0; +int sound3Last = 0; +u8 sound3WaveRam[0x20]; +int sound3Bank = 0; +int sound3DataSize = 0; +int sound3ForcedOutput = 0; + +int sound4On = 0; +int sound4Clock = 0; +int sound4ATL = 0; +int sound4Skip = 0; +int sound4Index = 0; +int sound4ShiftRight = 0x7f; +int sound4ShiftSkip = 0; +int sound4ShiftIndex = 0; +int sound4NSteps = 0; +int sound4CountDown = 0; +int sound4Continue = 0; +int sound4EnvelopeVolume = 0; +int sound4EnvelopeATL = 0; +int sound4EnvelopeUpDown = 0; +int sound4EnvelopeATLReload = 0; + +int soundControl = 0; + +int soundDSFifoAIndex = 0; +int soundDSFifoACount = 0; +int soundDSFifoAWriteIndex = 0; +bool soundDSAEnabled = false; +int soundDSATimer = 0; +u8 soundDSFifoA[32]; +u8 soundDSAValue = 0; + +int soundDSFifoBIndex = 0; +int soundDSFifoBCount = 0; +int soundDSFifoBWriteIndex = 0; +bool soundDSBEnabled = false; +int soundDSBTimer = 0; +u8 soundDSFifoB[32]; +u8 soundDSBValue = 0; + +int soundEnableFlag = 0x3ff; + +s16 soundFilter[4000]; +s16 soundRight[5] = { 0, 0, 0, 0, 0 }; +s16 soundLeft[5] = { 0, 0, 0, 0, 0 }; +int soundEchoIndex = 0; +bool soundEcho = false; +bool soundLowPass = false; +bool soundReverse = false; + +variable_desc soundSaveStruct[] = { + { &soundPaused, sizeof(int) }, + { &soundPlay, sizeof(int) }, + { &soundTicks, sizeof(int) }, + { &SOUND_CLOCK_TICKS, sizeof(int) }, + { &soundLevel1, sizeof(int) }, + { &soundLevel2, sizeof(int) }, + { &soundBalance, sizeof(int) }, + { &soundMasterOn, sizeof(int) }, + { &soundIndex, sizeof(int) }, + { &sound1On, sizeof(int) }, + { &sound1ATL, sizeof(int) }, + { &sound1Skip, sizeof(int) }, + { &sound1Index, sizeof(int) }, + { &sound1Continue, sizeof(int) }, + { &sound1EnvelopeVolume, sizeof(int) }, + { &sound1EnvelopeATL, sizeof(int) }, + { &sound1EnvelopeATLReload, sizeof(int) }, + { &sound1EnvelopeUpDown, sizeof(int) }, + { &sound1SweepATL, sizeof(int) }, + { &sound1SweepATLReload, sizeof(int) }, + { &sound1SweepSteps, sizeof(int) }, + { &sound1SweepUpDown, sizeof(int) }, + { &sound1SweepStep, sizeof(int) }, + { &sound2On, sizeof(int) }, + { &sound2ATL, sizeof(int) }, + { &sound2Skip, sizeof(int) }, + { &sound2Index, sizeof(int) }, + { &sound2Continue, sizeof(int) }, + { &sound2EnvelopeVolume, sizeof(int) }, + { &sound2EnvelopeATL, sizeof(int) }, + { &sound2EnvelopeATLReload, sizeof(int) }, + { &sound2EnvelopeUpDown, sizeof(int) }, + { &sound3On, sizeof(int) }, + { &sound3ATL, sizeof(int) }, + { &sound3Skip, sizeof(int) }, + { &sound3Index, sizeof(int) }, + { &sound3Continue, sizeof(int) }, + { &sound3OutputLevel, sizeof(int) }, + { &sound4On, sizeof(int) }, + { &sound4ATL, sizeof(int) }, + { &sound4Skip, sizeof(int) }, + { &sound4Index, sizeof(int) }, + { &sound4Clock, sizeof(int) }, + { &sound4ShiftRight, sizeof(int) }, + { &sound4ShiftSkip, sizeof(int) }, + { &sound4ShiftIndex, sizeof(int) }, + { &sound4NSteps, sizeof(int) }, + { &sound4CountDown, sizeof(int) }, + { &sound4Continue, sizeof(int) }, + { &sound4EnvelopeVolume, sizeof(int) }, + { &sound4EnvelopeATL, sizeof(int) }, + { &sound4EnvelopeATLReload, sizeof(int) }, + { &sound4EnvelopeUpDown, sizeof(int) }, + { &soundEnableFlag, sizeof(int) }, + { &soundControl, sizeof(int) }, + { &soundDSFifoAIndex, sizeof(int) }, + { &soundDSFifoACount, sizeof(int) }, + { &soundDSFifoAWriteIndex, sizeof(int) }, + { &soundDSAEnabled, sizeof(bool) }, + { &soundDSATimer, sizeof(int) }, + { &soundDSFifoA[0], 32 }, + { &soundDSAValue, sizeof(u8) }, + { &soundDSFifoBIndex, sizeof(int) }, + { &soundDSFifoBCount, sizeof(int) }, + { &soundDSFifoBWriteIndex, sizeof(int) }, + { &soundDSBEnabled, sizeof(int) }, + { &soundDSBTimer, sizeof(int) }, + { &soundDSFifoB[0], 32 }, + { &soundDSBValue, sizeof(int) }, + { &soundBuffer[0][0], 6*735 }, + { &soundFinalWave[0], 2*735 }, + { NULL, 0 } +}; + +variable_desc soundSaveStructV2[] = { + { &sound3WaveRam[0], 0x20 }, + { &sound3Bank, sizeof(int) }, + { &sound3DataSize, sizeof(int) }, + { &sound3ForcedOutput, sizeof(int) }, + { NULL, 0 } +}; + +void soundEvent(u32 address, u8 data) +{ + int freq = 0; + + switch(address) { + case NR10: + data &= 0x7f; + sound1SweepATL = sound1SweepATLReload = 344 * ((data >> 4) & 7); + sound1SweepSteps = data & 7; + sound1SweepUpDown = data & 0x08; + sound1SweepStep = 0; + ioMem[address] = data; + break; + case NR11: + sound1Wave = soundWavePattern[data >> 6]; + sound1ATL = 172 * (64 - (data & 0x3f)); + ioMem[address] = data; + break; + case NR12: + sound1EnvelopeUpDown = data & 0x08; + sound1EnvelopeATLReload = 689 * (data & 7); + if((data & 0xF8) == 0) + sound1EnvelopeVolume = 0; + ioMem[address] = data; + break; + case NR13: + freq = (((int)(ioMem[NR14] & 7)) << 8) | data; + sound1ATL = 172 * (64 - (ioMem[NR11] & 0x3f)); + freq = 2048 - freq; + if(freq) { + sound1Skip = SOUND_MAGIC / freq; + } else + sound1Skip = 0; + ioMem[address] = data; + break; + case NR14: + data &= 0xC7; + freq = (((int)(data&7) << 8) | ioMem[NR13]); + freq = 2048 - freq; + sound1ATL = 172 * (64 - (ioMem[NR11] & 0x3f)); + sound1Continue = data & 0x40; + if(freq) { + sound1Skip = SOUND_MAGIC / freq; + } else + sound1Skip = 0; + if(data & 0x80) { + ioMem[NR52] |= 1; + sound1EnvelopeVolume = ioMem[NR12] >> 4; + sound1EnvelopeUpDown = ioMem[NR12] & 0x08; + sound1ATL = 172 * (64 - (ioMem[NR11] & 0x3f)); + sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (ioMem[NR12] & 7); + sound1SweepATL = sound1SweepATLReload = 344 * ((ioMem[NR10] >> 4) & 7); + sound1SweepSteps = ioMem[NR10] & 7; + sound1SweepUpDown = ioMem[NR10] & 0x08; + sound1SweepStep = 0; + + sound1Index = 0; + sound1On = 1; + } + ioMem[address] = data; + break; + case NR21: + sound2Wave = soundWavePattern[data >> 6]; + sound2ATL = 172 * (64 - (data & 0x3f)); + ioMem[address] = data; + break; + case NR22: + sound2EnvelopeUpDown = data & 0x08; + sound2EnvelopeATLReload = 689 * (data & 7); + if((data & 0xF8) == 0) + sound2EnvelopeVolume = 0; + ioMem[address] = data; + break; + case NR23: + freq = (((int)(ioMem[NR24] & 7)) << 8) | data; + sound2ATL = 172 * (64 - (ioMem[NR21] & 0x3f)); + freq = 2048 - freq; + if(freq) { + sound2Skip = SOUND_MAGIC / freq; + } else + sound2Skip = 0; + ioMem[address] = data; + break; + case NR24: + data &= 0xC7; + freq = (((int)(data&7) << 8) | ioMem[NR23]); + freq = 2048 - freq; + sound2ATL = 172 * (64 - (ioMem[NR21] & 0x3f)); + sound2Continue = data & 0x40; + if(freq) { + sound2Skip = SOUND_MAGIC / freq; + } else + sound2Skip = 0; + if(data & 0x80) { + ioMem[NR52] |= 2; + sound2EnvelopeVolume = ioMem[NR22] >> 4; + sound2EnvelopeUpDown = ioMem[NR22] & 0x08; + sound2ATL = 172 * (64 - (ioMem[NR21] & 0x3f)); + sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (ioMem[NR22] & 7); + + sound2Index = 0; + sound2On = 1; + } + break; + ioMem[address] = data; + case NR30: + data &= 0xe0; + if(!(data & 0x80)) { + ioMem[NR52] &= 0xfb; + sound3On = 0; + } + if(((data >> 6) & 1) != sound3Bank) + memcpy(&ioMem[0x90], &sound3WaveRam[(((data >> 6) & 1) * 0x10)^0x10], + 0x10); + sound3Bank = (data >> 6) & 1; + sound3DataSize = (data >> 5) & 1; + ioMem[address] = data; + break; + case NR31: + sound3ATL = 172 * (256-data); + ioMem[address] = data; + break; + case NR32: + data &= 0xe0; + sound3OutputLevel = (data >> 5) & 3; + sound3ForcedOutput = (data >> 7) & 1; + ioMem[address] = data; + break; + case NR33: + freq = 2048 - (((int)(ioMem[NR34]&7) << 8) | data); + if(freq) { + sound3Skip = SOUND_MAGIC_2 / freq; + } else + sound3Skip = 0; + ioMem[address] = data; + break; + case NR34: + data &= 0xc7; + freq = 2048 - (((data &7) << 8) | (int)ioMem[NR33]); + if(freq) { + sound3Skip = SOUND_MAGIC_2 / freq; + } else { + sound3Skip = 0; + } + sound3Continue = data & 0x40; + if((data & 0x80) && (ioMem[NR30] & 0x80)) { + ioMem[NR52] |= 4; + sound3ATL = 172 * (256 - ioMem[NR31]); + sound3Index = 0; + sound3On = 1; + } + ioMem[address] = data; + break; + case NR41: + data &= 0x3f; + sound4ATL = 172 * (64 - (data & 0x3f)); + ioMem[address] = data; + break; + case NR42: + sound4EnvelopeUpDown = data & 0x08; + sound4EnvelopeATLReload = 689 * (data & 7); + if((data & 0xF8) == 0) + sound4EnvelopeVolume = 0; + ioMem[address] = data; + break; + case NR43: + freq = soundFreqRatio[data & 7]; + sound4NSteps = data & 0x08; + + sound4Skip = (freq << 8) / NOISE_MAGIC; + + sound4Clock = data >> 4; + + freq = freq / soundShiftClock[sound4Clock]; + + sound4ShiftSkip = (freq << 8) / NOISE_MAGIC; + ioMem[address] = data; + break; + case NR44: + data &= 0xc0; + sound4Continue = data & 0x40; + if(data & 0x80) { + ioMem[NR52] |= 8; + sound4EnvelopeVolume = ioMem[NR42] >> 4; + sound4EnvelopeUpDown = ioMem[NR42] & 0x08; + sound4ATL = 172 * (64 - (ioMem[NR41] & 0x3f)); + sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (ioMem[NR42] & 7); + + sound4On = 1; + + sound4Index = 0; + sound4ShiftIndex = 0; + + freq = soundFreqRatio[ioMem[NR43] & 7]; + + sound4Skip = (freq << 8) / NOISE_MAGIC; + + sound4NSteps = ioMem[NR43] & 0x08; + + freq = freq / soundShiftClock[ioMem[NR43] >> 4]; + + sound4ShiftSkip = (freq << 8) / NOISE_MAGIC; + if(sound4NSteps) + sound4ShiftRight = 0x7fff; + else + sound4ShiftRight = 0x7f; + } + ioMem[address] = data; + break; + case NR50: + data &= 0x77; + soundLevel1 = data & 7; + soundLevel2 = (data >> 4) & 7; + ioMem[address] = data; + break; + case NR51: + soundBalance = (data & soundEnableFlag); + ioMem[address] = data; + break; + case NR52: + data &= 0x80; + data |= ioMem[NR52] & 15; + soundMasterOn = data & 0x80; + if(!(data & 0x80)) { + sound1On = 0; + sound2On = 0; + sound3On = 0; + sound4On = 0; + } + ioMem[address] = data; + break; + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9a: + case 0x9b: + case 0x9c: + case 0x9d: + case 0x9e: + case 0x9f: + sound3WaveRam[(sound3Bank*0x10)^0x10+(address&15)] = data; + break; + } +} + +void soundEvent(u32 address, u16 data) +{ + switch(address) { + case SGCNT0_H: + data &= 0xFF0F; + soundControl = data & 0x770F;; + if(data & 0x0800) { + soundDSFifoAWriteIndex = 0; + soundDSFifoAIndex = 0; + soundDSFifoACount = 0; + soundDSAValue = 0; + memset(soundDSFifoA, 0, 32); + } + soundDSAEnabled = (data & 0x0300) ? true : false; + soundDSATimer = (data & 0x0400) ? 1 : 0; + if(data & 0x8000) { + soundDSFifoBWriteIndex = 0; + soundDSFifoBIndex = 0; + soundDSFifoBCount = 0; + soundDSBValue = 0; + memset(soundDSFifoB, 0, 32); + } + soundDSBEnabled = (data & 0x3000) ? true : false; + soundDSBTimer = (data & 0x4000) ? 1 : 0; + *((u16 *)&ioMem[address]) = data; + break; + case FIFOA_L: + case FIFOA_H: + soundDSFifoA[soundDSFifoAWriteIndex++] = data & 0xFF; + soundDSFifoA[soundDSFifoAWriteIndex++] = data >> 8; + soundDSFifoACount += 2; + soundDSFifoAWriteIndex &= 31; + *((u16 *)&ioMem[address]) = data; + break; + case FIFOB_L: + case FIFOB_H: + soundDSFifoB[soundDSFifoBWriteIndex++] = data & 0xFF; + soundDSFifoB[soundDSFifoBWriteIndex++] = data >> 8; + soundDSFifoBCount += 2; + soundDSFifoBWriteIndex &= 31; + *((u16 *)&ioMem[address]) = data; + break; + case 0x88: + data &= 0xC3FF; + *((u16 *)&ioMem[address]) = data; + break; + case 0x90: + case 0x92: + case 0x94: + case 0x96: + case 0x98: + case 0x9a: + case 0x9c: + case 0x9e: + *((u16 *)&sound3WaveRam[(sound3Bank*0x10)^0x10+(address&14)]) = data; + *((u16 *)&ioMem[address]) = data; + break; + } +} + +void soundChannel1() +{ + int vol = sound1EnvelopeVolume; + + int freq = 0; + int value = 0; + + if(sound1On && (sound1ATL || !sound1Continue)) { + sound1Index += soundQuality*sound1Skip; + sound1Index &= 0x1fffffff; + + value = ((s8)sound1Wave[sound1Index>>24]) * vol; + } + + soundBuffer[0][soundIndex] = value; + + + if(sound1On) { + if(sound1ATL) { + sound1ATL-=soundQuality; + + if(sound1ATL <=0 && sound1Continue) { + ioMem[NR52] &= 0xfe; + sound1On = 0; + } + } + + if(sound1EnvelopeATL) { + sound1EnvelopeATL-=soundQuality; + + if(sound1EnvelopeATL<=0) { + if(sound1EnvelopeUpDown) { + if(sound1EnvelopeVolume < 15) + sound1EnvelopeVolume++; + } else { + if(sound1EnvelopeVolume) + sound1EnvelopeVolume--; + } + + sound1EnvelopeATL += sound1EnvelopeATLReload; + } + } + + if(sound1SweepATL) { + sound1SweepATL-=soundQuality; + + if(sound1SweepATL<=0) { + freq = (((int)(ioMem[NR14]&7) << 8) | ioMem[NR13]); + + int updown = 1; + + if(sound1SweepUpDown) + updown = -1; + + int newfreq = 0; + if(sound1SweepSteps) { + newfreq = freq + updown * freq / (1 << sound1SweepSteps); + if(newfreq == freq) + newfreq = 0; + } else + newfreq = freq; + + if(newfreq < 0) { + sound1SweepATL += sound1SweepATLReload; + } else if(newfreq > 2047) { + sound1SweepATL = 0; + sound1On = 0; + ioMem[NR52] &= 0xfe; + } else { + sound1SweepATL += sound1SweepATLReload; + sound1Skip = SOUND_MAGIC/(2048 - newfreq); + + ioMem[NR13] = newfreq & 0xff; + ioMem[NR14] = (ioMem[NR14] & 0xf8) |((newfreq >> 8) & 7); + } + } + } + } +} + +void soundChannel2() +{ + // int freq = 0; + int vol = sound2EnvelopeVolume; + + int value = 0; + + if(sound2On && (sound2ATL || !sound2Continue)) { + sound2Index += soundQuality*sound2Skip; + sound2Index &= 0x1fffffff; + + value = ((s8)sound2Wave[sound2Index>>24]) * vol; + } + + soundBuffer[1][soundIndex] = value; + + if(sound2On) { + if(sound2ATL) { + sound2ATL-=soundQuality; + + if(sound2ATL <= 0 && sound2Continue) { + ioMem[NR52] &= 0xfd; + sound2On = 0; + } + } + + if(sound2EnvelopeATL) { + sound2EnvelopeATL-=soundQuality; + + if(sound2EnvelopeATL <= 0) { + if(sound2EnvelopeUpDown) { + if(sound2EnvelopeVolume < 15) + sound2EnvelopeVolume++; + } else { + if(sound2EnvelopeVolume) + sound2EnvelopeVolume--; + } + sound2EnvelopeATL += sound2EnvelopeATLReload; + } + } + } +} + +void soundChannel3() +{ + int value = sound3Last; + + if(sound3On && (sound3ATL || !sound3Continue)) { + sound3Index += soundQuality*sound3Skip; + if(sound3DataSize) { + sound3Index &= 0x3fffffff; + value = sound3WaveRam[sound3Index>>25]; + } else { + sound3Index &= 0x1fffffff; + value = sound3WaveRam[sound3Bank*0x10 + (sound3Index>>25)]; + } + + if( (sound3Index & 0x01000000)) { + value &= 0x0f; + } else { + value >>= 4; + } + + value -= 8; + value *= 2; + + if(sound3ForcedOutput) { + value = ((value >> 1) + value) >> 1; + } else { + switch(sound3OutputLevel) { + case 0: + value = 0; + break; + case 1: + break; + case 2: + value = (value >> 1); + break; + case 3: + value = (value >> 2); + break; + } + } + sound3Last = value; + } + + soundBuffer[2][soundIndex] = value; + + if(sound3On) { + if(sound3ATL) { + sound3ATL-=soundQuality; + + if(sound3ATL <= 0 && sound3Continue) { + ioMem[NR52] &= 0xfb; + sound3On = 0; + } + } + } +} + +void soundChannel4() +{ + int vol = sound4EnvelopeVolume; + + int value = 0; + + if(sound4Clock <= 0x0c) { + if(sound4On && (sound4ATL || !sound4Continue)) { + sound4Index += soundQuality*sound4Skip; + sound4ShiftIndex += soundQuality*sound4ShiftSkip; + + if(sound4NSteps) { + while(sound4ShiftIndex > 0x1fffff) { + sound4ShiftRight = (((sound4ShiftRight << 6) ^ + (sound4ShiftRight << 5)) & 0x40) | + (sound4ShiftRight >> 1); + sound4ShiftIndex -= 0x200000; + } + } else { + while(sound4ShiftIndex > 0x1fffff) { + sound4ShiftRight = (((sound4ShiftRight << 14) ^ + (sound4ShiftRight << 13)) & 0x4000) | + (sound4ShiftRight >> 1); + + sound4ShiftIndex -= 0x200000; + } + } + + sound4Index &= 0x1fffff; + sound4ShiftIndex &= 0x1fffff; + + value = ((sound4ShiftRight & 1)*2-1) * vol; + } else { + value = 0; + } + } + + soundBuffer[3][soundIndex] = value; + + if(sound4On) { + if(sound4ATL) { + sound4ATL-=soundQuality; + + if(sound4ATL <= 0 && sound4Continue) { + ioMem[NR52] &= 0xfd; + sound4On = 0; + } + } + + if(sound4EnvelopeATL) { + sound4EnvelopeATL-=soundQuality; + + if(sound4EnvelopeATL <= 0) { + if(sound4EnvelopeUpDown) { + if(sound4EnvelopeVolume < 15) + sound4EnvelopeVolume++; + } else { + if(sound4EnvelopeVolume) + sound4EnvelopeVolume--; + } + sound4EnvelopeATL += sound4EnvelopeATLReload; + } + } + } +} + +void soundDirectSoundA() +{ + soundBuffer[4][soundIndex] = soundDSAValue; +} + +void soundDirectSoundATimer() +{ + if(soundDSAEnabled) { + if(soundDSFifoACount <= 16) { + CPUCheckDMA(3, 2); + if(soundDSFifoACount <= 16) { + soundEvent(FIFOA_L, (u16)0); + soundEvent(FIFOA_H, (u16)0); + soundEvent(FIFOA_L, (u16)0); + soundEvent(FIFOA_H, (u16)0); + soundEvent(FIFOA_L, (u16)0); + soundEvent(FIFOA_H, (u16)0); + soundEvent(FIFOA_L, (u16)0); + soundEvent(FIFOA_H, (u16)0); + } + } + + soundDSAValue = (soundDSFifoA[soundDSFifoAIndex]); + soundDSFifoAIndex = (++soundDSFifoAIndex) & 31; + soundDSFifoACount--; + } else + soundDSAValue = 0; +} + +void soundDirectSoundB() +{ + soundBuffer[5][soundIndex] = soundDSBValue; +} + +void soundDirectSoundBTimer() +{ + if(soundDSBEnabled) { + if(soundDSFifoBCount <= 16) { + CPUCheckDMA(3, 4); + if(soundDSFifoBCount <= 16) { + soundEvent(FIFOB_L, (u16)0); + soundEvent(FIFOB_H, (u16)0); + soundEvent(FIFOB_L, (u16)0); + soundEvent(FIFOB_H, (u16)0); + soundEvent(FIFOB_L, (u16)0); + soundEvent(FIFOB_H, (u16)0); + soundEvent(FIFOB_L, (u16)0); + soundEvent(FIFOB_H, (u16)0); + } + } + + soundDSBValue = (soundDSFifoB[soundDSFifoBIndex]); + soundDSFifoBIndex = (++soundDSFifoBIndex) & 31; + soundDSFifoBCount--; + } else { + soundDSBValue = 0; + } +} + +void soundTimerOverflow(int timer) +{ + if(soundDSAEnabled && (soundDSATimer == timer)) { + soundDirectSoundATimer(); + } + if(soundDSBEnabled && (soundDSBTimer == timer)) { + soundDirectSoundBTimer(); + } +} + +#ifndef max +#define max(a,b) (a)<(b)?(b):(a) +#endif + +void soundMix() +{ + int res = 0; + int cgbRes = 0; + int ratio = ioMem[0x82] & 3; + int dsaRatio = ioMem[0x82] & 4; + int dsbRatio = ioMem[0x82] & 8; + + if(soundBalance & 16) { + cgbRes = ((s8)soundBuffer[0][soundIndex]); + } + if(soundBalance & 32) { + cgbRes += ((s8)soundBuffer[1][soundIndex]); + } + if(soundBalance & 64) { + cgbRes += ((s8)soundBuffer[2][soundIndex]); + } + if(soundBalance & 128) { + cgbRes += ((s8)soundBuffer[3][soundIndex]); + } + + if((soundControl & 0x0200) && (soundEnableFlag & 0x100)){ + if(!dsaRatio) + res = ((s8)soundBuffer[4][soundIndex])>>1; + else + res = ((s8)soundBuffer[4][soundIndex]); + } + + if((soundControl & 0x2000) && (soundEnableFlag & 0x200)){ + if(!dsbRatio) + res += ((s8)soundBuffer[5][soundIndex])>>1; + else + res += ((s8)soundBuffer[5][soundIndex]); + } + + res = (res * 170); + cgbRes = (cgbRes * 52 * soundLevel1); + + switch(ratio) { + case 0: + case 3: // prohibited, but 25% + cgbRes >>= 2; + break; + case 1: + cgbRes >>= 1; + break; + case 2: + break; + } + + res += cgbRes; + + if(soundEcho) { + res *= 2; + res += soundFilter[soundEchoIndex]; + res /= 2; + soundFilter[soundEchoIndex++] = res; + } + + if(soundLowPass) { + soundLeft[4] = soundLeft[3]; + soundLeft[3] = soundLeft[2]; + soundLeft[2] = soundLeft[1]; + soundLeft[1] = soundLeft[0]; + soundLeft[0] = res; + res = (soundLeft[4] + 2*soundLeft[3] + 8*soundLeft[2] + 2*soundLeft[1] + + soundLeft[0])/14; + } + + switch(soundVolume) { + case 0: + case 1: + case 2: + case 3: + res *= (soundVolume+1); + break; + case 4: + res >>= 2; + break; + case 5: + res >>= 1; + break; + } + + if(res > 32767) + res = 32767; + if(res < -32768) + res = -32768; + + if(soundReverse) + soundFinalWave[++soundBufferIndex] = res; + else + soundFinalWave[soundBufferIndex++] = res; + + res = 0; + cgbRes = 0; + + if(soundBalance & 1) { + cgbRes = ((s8)soundBuffer[0][soundIndex]); + } + if(soundBalance & 2) { + cgbRes += ((s8)soundBuffer[1][soundIndex]); + } + if(soundBalance & 4) { + cgbRes += ((s8)soundBuffer[2][soundIndex]); + } + if(soundBalance & 8) { + cgbRes += ((s8)soundBuffer[3][soundIndex]); + } + + if((soundControl & 0x0100) && (soundEnableFlag & 0x100)){ + if(!dsaRatio) + res = ((s8)soundBuffer[4][soundIndex])>>1; + else + res = ((s8)soundBuffer[4][soundIndex]); + } + + if((soundControl & 0x1000) && (soundEnableFlag & 0x200)){ + if(!dsbRatio) + res += ((s8)soundBuffer[5][soundIndex])>>1; + else + res += ((s8)soundBuffer[5][soundIndex]); + } + + res = (res * 170); + cgbRes = (cgbRes * 52 * soundLevel1); + + switch(ratio) { + case 0: + case 3: // prohibited, but 25% + cgbRes >>= 2; + break; + case 1: + cgbRes >>= 1; + break; + case 2: + break; + } + + res += cgbRes; + + if(soundEcho) { + res *= 2; + res += soundFilter[soundEchoIndex]; + res /= 2; + soundFilter[soundEchoIndex++] = res; + + if(soundEchoIndex >= 4000) + soundEchoIndex = 0; + } + + if(soundLowPass) { + soundRight[4] = soundRight[3]; + soundRight[3] = soundRight[2]; + soundRight[2] = soundRight[1]; + soundRight[1] = soundRight[0]; + soundRight[0] = res; + res = (soundRight[4] + 2*soundRight[3] + 8*soundRight[2] + 2*soundRight[1] + + soundRight[0])/14; + } + + switch(soundVolume) { + case 0: + case 1: + case 2: + case 3: + res *= (soundVolume+1); + break; + case 4: + res >>= 2; + break; + case 5: + res >>= 1; + break; + } + + if(res > 32767) + res = 32767; + if(res < -32768) + res = -32768; + + if(soundReverse) + soundFinalWave[-1+soundBufferIndex++] = res; + else + soundFinalWave[soundBufferIndex++] = res; +} + +void soundTick() +{ + if(systemSoundOn) { + if(soundMasterOn && !stopState +#if (defined(WIN32) && !defined(SDL)) + && !theApp.frameAdvanceMuteNow +#endif + ) { + soundChannel1(); + soundChannel2(); + soundChannel3(); + soundChannel4(); + soundDirectSoundA(); + soundDirectSoundB(); + soundMix(); + } else { + soundFinalWave[soundBufferIndex++] = 0; + soundFinalWave[soundBufferIndex++] = 0; + } + + soundIndex++; + + if(2*soundBufferIndex >= soundBufferLen) { + if(systemSoundOn) { + if(soundPaused) { + soundResume(); + } + + systemWriteDataToSoundBuffer(); + } + soundIndex = 0; + soundBufferIndex = 0; + } + } +} + +void soundShutdown() +{ + systemSoundShutdown(); +} + +void soundPause() +{ + systemSoundPause(); + soundPaused = 1; +} + +void soundResume() +{ + systemSoundResume(); + soundPaused = 0; +} + +void soundEnable(int channels) +{ + int c = channels & 0x0f; + + soundEnableFlag |= ((channels & 0x30f) |c | (c << 4)); + extern u8 *gbMemory; + if(ioMem) + soundBalance = (ioMem[NR51] & soundEnableFlag); + else if(gbMemory) + soundBalance = (gbMemory[0xff25] & soundEnableFlag); +} + +void soundDisable(int channels) +{ + int c = channels & 0x0f; + + soundEnableFlag &= (~((channels & 0x30f)|c|(c<<4))); + extern u8 *gbMemory; + if(ioMem) + soundBalance = (ioMem[NR51] & soundEnableFlag); + else if(gbMemory) + soundBalance = (gbMemory[0xff25] & soundEnableFlag); +} + +int soundGetEnable() +{ + return (soundEnableFlag & 0x30f); +} + +void soundReset() +{ + systemSoundReset(); + + soundPaused = 1; + soundPlay = 0; + SOUND_CLOCK_TICKS = soundQuality * USE_TICKS_AS; + soundTicks = SOUND_CLOCK_TICKS; + soundNextPosition = 0; + soundMasterOn = 1; + soundIndex = 0; + soundBufferIndex = 0; + soundLevel1 = 7; + soundLevel2 = 7; + + sound1On = 0; + sound1ATL = 0; + sound1Skip = 0; + sound1Index = 0; + sound1Continue = 0; + sound1EnvelopeVolume = 0; + sound1EnvelopeATL = 0; + sound1EnvelopeUpDown = 0; + sound1EnvelopeATLReload = 0; + sound1SweepATL = 0; + sound1SweepATLReload = 0; + sound1SweepSteps = 0; + sound1SweepUpDown = 0; + sound1SweepStep = 0; + sound1Wave = soundWavePattern[2]; + + sound2On = 0; + sound2ATL = 0; + sound2Skip = 0; + sound2Index = 0; + sound2Continue = 0; + sound2EnvelopeVolume = 0; + sound2EnvelopeATL = 0; + sound2EnvelopeUpDown = 0; + sound2EnvelopeATLReload = 0; + sound2Wave = soundWavePattern[2]; + + sound3On = 0; + sound3ATL = 0; + sound3Skip = 0; + sound3Index = 0; + sound3Continue = 0; + sound3OutputLevel = 0; + sound3Last = 0; + sound3Bank = 0; + sound3DataSize = 0; + sound3ForcedOutput = 0; + + sound4On = 0; + sound4Clock = 0; + sound4ATL = 0; + sound4Skip = 0; + sound4Index = 0; + sound4ShiftRight = 0x7f; + sound4NSteps = 0; + sound4CountDown = 0; + sound4Continue = 0; + sound4EnvelopeVolume = 0; + sound4EnvelopeATL = 0; + sound4EnvelopeUpDown = 0; + sound4EnvelopeATLReload = 0; + + sound1On = 0; + sound2On = 0; + sound3On = 0; + sound4On = 0; + + int addr = 0x90; + + while(addr < 0xA0) { + ioMem[addr++] = 0x00; + ioMem[addr++] = 0xff; + } + + addr = 0; + while(addr < 0x20) { + sound3WaveRam[addr++] = 0x00; + sound3WaveRam[addr++] = 0xff; + } + + memset(soundFinalWave, 0, soundBufferLen); + + memset(soundFilter, 0, sizeof(soundFilter)); + soundEchoIndex = 0; +} + +bool soundInit() +{ + if(systemSoundInit()) { + memset(soundBuffer[0], 0, 735*2); + memset(soundBuffer[1], 0, 735*2); + memset(soundBuffer[2], 0, 735*2); + memset(soundBuffer[3], 0, 735*2); + + memset(soundFinalWave, 0, soundBufferLen); + + soundPaused = true; + return true; + } + return false; +} + +void soundSetQuality(int quality) +{ + if(soundQuality != quality && systemCanChangeSoundQuality()) { + if(!soundOffFlag) + soundShutdown(); + soundQuality = quality; + soundNextPosition = 0; + if(!soundOffFlag) + soundInit(); + SOUND_CLOCK_TICKS = USE_TICKS_AS * soundQuality; + soundIndex = 0; + soundBufferIndex = 0; + } else if(soundQuality != quality) { + soundNextPosition = 0; + SOUND_CLOCK_TICKS = USE_TICKS_AS * soundQuality; + soundIndex = 0; + soundBufferIndex = 0; + } +} + +void soundSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, soundSaveStruct); + utilWriteData(gzFile, soundSaveStructV2); + + utilGzWrite(gzFile, &soundQuality, sizeof(int)); +} + +void soundReadGame(gzFile gzFile, int version) +{ + utilReadData(gzFile, soundSaveStruct); + if(version >= SAVE_GAME_VERSION_3) { + utilReadData(gzFile, soundSaveStructV2); + } else { + sound3Bank = (ioMem[NR30] >> 6) & 1; + sound3DataSize = (ioMem[NR30] >> 5) & 1; + sound3ForcedOutput = (ioMem[NR32] >> 7) & 1; + // nothing better to do here... + memcpy(&sound3WaveRam[0x00], &ioMem[0x90], 0x10); + memcpy(&sound3WaveRam[0x10], &ioMem[0x90], 0x10); + } + soundBufferIndex = soundIndex * 2; + + int quality = 1; + utilGzRead(gzFile, &quality, sizeof(int)); + soundSetQuality(quality); + + sound1Wave = soundWavePattern[ioMem[NR11] >> 6]; + sound2Wave = soundWavePattern[ioMem[NR21] >> 6]; +} diff --git a/src/Sound.h b/src/Sound.h new file mode 100644 index 0000000..4e1dac7 --- /dev/null +++ b/src/Sound.h @@ -0,0 +1,82 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_SOUND_H +#define VBA_SOUND_H + +#define NR10 0x60 +#define NR11 0x62 +#define NR12 0x63 +#define NR13 0x64 +#define NR14 0x65 +#define NR21 0x68 +#define NR22 0x69 +#define NR23 0x6c +#define NR24 0x6d +#define NR30 0x70 +#define NR31 0x72 +#define NR32 0x73 +#define NR33 0x74 +#define NR34 0x75 +#define NR41 0x78 +#define NR42 0x79 +#define NR43 0x7c +#define NR44 0x7d +#define NR50 0x80 +#define NR51 0x81 +#define NR52 0x84 +#define SGCNT0_H 0x82 +#define FIFOA_L 0xa0 +#define FIFOA_H 0xa2 +#define FIFOB_L 0xa4 +#define FIFOB_H 0xa6 + +extern void soundTick(); +extern void soundShutdown(); +extern bool soundInit(); +extern void soundPause(); +extern void soundResume(); +extern void soundEnable(int); +extern void soundDisable(int); +extern int soundGetEnable(); +extern void soundReset(); +extern void soundSaveGame(gzFile); +extern void soundReadGame(gzFile, int); +extern void soundEvent(u32, u8); +extern void soundEvent(u32, u16); +extern void soundTimerOverflow(int); +extern void soundSetQuality(int); + +//extern int SOUND_TICKS; +extern int SOUND_CLOCK_TICKS; +extern int soundTicks; +extern int soundPaused; +extern bool soundOffFlag; +extern int soundQuality; +extern int soundBufferLen; +extern int soundBufferTotalLen; +extern u32 soundNextPosition; +extern u16 soundFinalWave[1470]; +extern int soundVolume; + +extern bool soundEcho; +extern bool soundLowPass; +extern bool soundReverse; + +#endif // VBA_SOUND_H diff --git a/src/Sram.cpp b/src/Sram.cpp new file mode 100644 index 0000000..1a46097 --- /dev/null +++ b/src/Sram.cpp @@ -0,0 +1,32 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "GBA.h" +#include "Flash.h" +#include "Sram.h" + +u8 sramRead(u32 address) +{ + return flashSaveMemory[address & 0xFFFF]; +} + +void sramWrite(u32 address, u8 byte) +{ + flashSaveMemory[address & 0xFFFF] = byte; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; +} diff --git a/src/Sram.h b/src/Sram.h new file mode 100644 index 0000000..f33f4c8 --- /dev/null +++ b/src/Sram.h @@ -0,0 +1,26 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_SRAM_H +#define VBA_SRAM_H + +extern u8 sramRead(u32 address); +extern void sramWrite(u32 address, u8 byte); + +#endif // VBA_SRAM_H diff --git a/src/System.h b/src/System.h new file mode 100644 index 0000000..bcae330 --- /dev/null +++ b/src/System.h @@ -0,0 +1,131 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_SYSTEM_H +#define VBA_SYSTEM_H + +#include "unzip.h" + +#ifndef NULL +#define NULL 0 +#endif + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; + +#ifdef _MSC_VER +typedef unsigned __int64 u64; +#else +typedef unsigned long long u64; +#endif + +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; + +#ifdef _MSC_VER +typedef signed __int64 s64; +#else +typedef signed long long s64; +#endif + +struct EmulatedSystem { + // main emulation function + void (*emuMain)(int); + // reset emulator + void (*emuReset)(); + // clean up memory + void (*emuCleanUp)(); + // load battery file + bool (*emuReadBattery)(const char *); + // write battery file + bool (*emuWriteBattery)(const char *); + // load battery file from stream + bool (*emuReadBatteryFromStream)(gzFile); + // write battery file to stream + bool (*emuWriteBatteryToStream)(gzFile); + // load state + bool (*emuReadState)(const char *); + // save state + bool (*emuWriteState)(const char *); + // load state from stream + bool (*emuReadStateFromStream)(gzFile); + // save state to stream + bool (*emuWriteStateToStream)(gzFile); + // load memory state (rewind) + bool (*emuReadMemState)(char *, int); + // write memory state (rewind) + bool (*emuWriteMemState)(char *, int); + // write PNG file + bool (*emuWritePNG)(const char *); + // write BMP file + bool (*emuWriteBMP)(const char *); + // emulator update CPSR (ARM only) + void (*emuUpdateCPSR)(); + // emulator has debugger + bool emuHasDebugger; + // clock ticks to emulate + int emuCount; +}; + +extern void log(const char *,...); + +extern bool systemPauseOnFrame(); +extern void systemGbPrint(u8 *,int,int,int,int); +extern void systemScreenCapture(int); +extern void systemDrawScreen(); +// updates the joystick data +extern bool systemReadJoypads(); +// return information about the given joystick, -1 for default joystick... the bool is for if motion sensor should be handled too +extern u32 systemReadJoypad(int,bool); +extern u32 systemGetClock(); +extern void systemMessage(int, const char *, ...); +extern void systemSetTitle(const char *); +extern void systemWriteDataToSoundBuffer(); +extern void systemSoundShutdown(); +extern void systemSoundPause(); +extern void systemSoundResume(); +extern void systemSoundReset(); +extern bool systemSoundInit(); +extern void systemScreenMessage(const char *msg, int slot=0, int duration=3000, const char *colorList=NULL); +extern int systemGetSensorX(); +extern int systemGetSensorY(); +extern bool systemCanChangeSoundQuality(); +extern void systemShowSpeed(int); +extern void systemFrame(int rate); +extern void systemGbBorderOn(); + +extern bool systemSoundOn; +extern u16 systemColorMap16[0x10000]; +extern u32 systemColorMap32[0x10000]; +extern u16 systemGbPalette[24]; +extern int systemRedShift; +extern int systemGreenShift; +extern int systemBlueShift; +extern int systemColorDepth; +extern int systemDebug; +extern int systemVerbose; +extern int systemFrameSkip; +extern int systemSaveUpdateCounter; + +#define SYSTEM_SAVE_UPDATED 30 +#define SYSTEM_SAVE_NOT_UPDATED 0 + +#endif //VBA_SYSTEM_H diff --git a/src/Text.cpp b/src/Text.cpp new file mode 100644 index 0000000..2896422 --- /dev/null +++ b/src/Text.cpp @@ -0,0 +1,273 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2002 Ben Parnell + * + * 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 + */ + +/* Code originally from fceu/drawing.h file, adapted by Forgotten + */ +#include "System.h" + +bool outlinedText=true, transparentText=false; +int textColor=0, textMethod=1; + +extern int RGB_LOW_BITS_MASK; + +static const u8 fontdata2[2048] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x1c,0x3e,0x1c,0x7f,0x7f,0x3e,0x1c,0x3e,0x08,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x3e,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xf0,0xe0,0xf0,0xbe,0x33,0x33,0x33,0x1e,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0xfc,0xcc,0xfc,0x0c,0x0c,0x0e,0x0f,0x07,0xfe,0xc6,0xfe,0xc6,0xc6,0xe6,0x67,0x03,0x99,0x5a,0x3c,0xe7,0xe7,0x3c,0x5a,0x99,0x01,0x07,0x1f,0x7f,0x1f,0x07,0x01,0x00,0x40,0x70,0x7c,0x7f,0x7c,0x70,0x40,0x00,0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0xfe,0xdb,0xdb,0xde,0xd8,0xd8,0xd8,0x00,0x7c,0xc6,0x1c,0x36,0x36,0x1c,0x33,0x1e,0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00,0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x1e,0x1e,0x0c,0x0c,0x00,0x0c,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x7f,0x36,0x36,0x00,0x0c,0x3e,0x03,0x1e,0x30,0x1f,0x0c,0x00,0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00,0x1c,0x36,0x1c,0x6e,0x3b,0x33,0x6e,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x0c,0x18,0x00,0x06,0x0c,0x18,0x18,0x18,0x0c,0x06,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x06,0x00,0x00,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00,0x3e,0x63,0x73,0x7b,0x6f,0x67,0x3e,0x00,0x0c,0x0e,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x06,0x33,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x30,0x33,0x1e,0x00,0x38,0x3c,0x36,0x33,0x7f,0x30,0x78,0x00,0x3f,0x03,0x1f,0x30,0x30,0x33,0x1e,0x00,0x1c,0x06,0x03,0x1f,0x33,0x33,0x1e,0x00,0x3f,0x33,0x30,0x18,0x0c,0x0c,0x0c,0x00,0x1e,0x33,0x33,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x33,0x3e,0x30,0x18,0x0e,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x06,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x00,0x00,0x00,0x3f,0x00,0x00,0x3f,0x00,0x00,0x06,0x0c,0x18,0x30,0x18,0x0c,0x06,0x00,0x1e,0x33,0x30,0x18,0x0c,0x00,0x0c,0x00, + 0x3e,0x63,0x7b,0x7b,0x7b,0x03,0x1e,0x00,0x0c,0x1e,0x33,0x33,0x3f,0x33,0x33,0x00,0x3f,0x66,0x66,0x3e,0x66,0x66,0x3f,0x00,0x3c,0x66,0x03,0x03,0x03,0x66,0x3c,0x00,0x1f,0x36,0x66,0x66,0x66,0x36,0x1f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x46,0x7f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x06,0x0f,0x00,0x3c,0x66,0x03,0x03,0x73,0x66,0x7c,0x00,0x33,0x33,0x33,0x3f,0x33,0x33,0x33,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x78,0x30,0x30,0x30,0x33,0x33,0x1e,0x00,0x67,0x66,0x36,0x1e,0x36,0x66,0x67,0x00,0x0f,0x06,0x06,0x06,0x46,0x66,0x7f,0x00,0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x00,0x1c,0x36,0x63,0x63,0x63,0x36,0x1c,0x00,0x3f,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00,0x1e,0x33,0x33,0x33,0x3b,0x1e,0x38,0x00,0x3f,0x66,0x66,0x3e,0x36,0x66,0x67,0x00,0x1e,0x33,0x07,0x0e,0x38,0x33,0x1e,0x00,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x00,0x33,0x33,0x33,0x33,0x33,0x1e,0x0c,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x1e,0x00,0x7f,0x63,0x31,0x18,0x4c,0x66,0x7f,0x00,0x1e,0x06,0x06,0x06,0x06,0x06,0x1e,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0x1e,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff, + 0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x30,0x3e,0x33,0x6e,0x00,0x07,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x1e,0x33,0x03,0x33,0x1e,0x00,0x38,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00,0x00,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x1c,0x36,0x06,0x0f,0x06,0x06,0x0f,0x00,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x1f,0x07,0x06,0x36,0x6e,0x66,0x66,0x67,0x00,0x0c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x30,0x00,0x30,0x30,0x30,0x33,0x33,0x1e,0x07,0x06,0x66,0x36,0x1e,0x36,0x67,0x00,0x0e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x33,0x7f,0x7f,0x6b,0x63,0x00,0x00,0x00,0x1f,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x1e,0x33,0x33,0x33,0x1e,0x00,0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78,0x00,0x00,0x3b,0x6e,0x66,0x06,0x0f,0x00,0x00,0x00,0x3e,0x03,0x1e,0x30,0x1f,0x00,0x08,0x0c,0x3e,0x0c,0x0c,0x2c,0x18,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x6e,0x00,0x00,0x00,0x33,0x33,0x33,0x1e,0x0c,0x00,0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00,0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00,0x00,0x00,0x33,0x33,0x33,0x3e,0x30,0x1f,0x00,0x00,0x3f,0x19,0x0c,0x26,0x3f,0x00,0x38,0x0c,0x0c,0x07,0x0c,0x0c,0x38,0x00,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x07,0x0c,0x0c,0x38,0x0c,0x0c,0x07,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00, + 0x1e,0x33,0x03,0x33,0x1e,0x18,0x30,0x1e,0x00,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x38,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x7e,0xc3,0x3c,0x60,0x7c,0x66,0xfc,0x00,0x33,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x07,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x0c,0x0c,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x00,0x00,0x1e,0x03,0x03,0x1e,0x30,0x1c,0x7e,0xc3,0x3c,0x66,0x7e,0x06,0x3c,0x00,0x33,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x07,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x33,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x3e,0x63,0x1c,0x18,0x18,0x18,0x3c,0x00,0x07,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00,0x0c,0x0c,0x00,0x1e,0x33,0x3f,0x33,0x00,0x38,0x00,0x3f,0x06,0x1e,0x06,0x3f,0x00,0x00,0x00,0xfe,0x30,0xfe,0x33,0xfe,0x00,0x7c,0x36,0x33,0x7f,0x33,0x33,0x73,0x00,0x1e,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x07,0x00,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x07,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x33,0x00,0x33,0x33,0x3e,0x30,0x1f,0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00,0x33,0x00,0x33,0x33,0x33,0x33,0x1e,0x00,0x18,0x18,0x7e,0x03,0x03,0x7e,0x18,0x18,0x1c,0x36,0x26,0x0f,0x06,0x67,0x3f,0x00,0x33,0x33,0x1e,0x3f,0x0c,0x3f,0x0c,0x0c,0x1f,0x33,0x33,0x5f,0x63,0xf3,0x63,0xe3,0x70,0xd8,0x18,0x3c,0x18,0x18,0x1b,0x0e, + 0x38,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x1c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x38,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x38,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x1f,0x00,0x1f,0x33,0x33,0x33,0x00,0x3f,0x00,0x33,0x37,0x3f,0x3b,0x33,0x00,0x3c,0x36,0x36,0x7c,0x00,0x7e,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00,0x0c,0x00,0x0c,0x06,0x03,0x33,0x1e,0x00,0x00,0x00,0x00,0x3f,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x30,0x00,0x00,0xc3,0x63,0x33,0x7b,0xcc,0x66,0x33,0xf0,0xc3,0x63,0x33,0xdb,0xec,0xf6,0xf3,0xc0,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00,0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xdb,0xee,0xdb,0x77,0xdb,0xee,0xdb,0x77,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0x6f,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x7f,0x6c,0x6c,0x6c,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x7f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x60,0x7f,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0x7f,0x00,0x00,0x00,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0x0c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xef,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xec,0x6c,0x6c,0x6c,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0xef,0x00,0xef,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xfc,0x00,0x00,0x00,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xfc,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xff,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +static void calcColors(const int colorNum, int & lo, int & hi, int & out) +{ + int redLo, redHi, greenLo, greenHi, blueLo, blueHi; + + if(colorNum == 0 || colorNum == 1 || colorNum == 2 || colorNum == 6) // white, red, yellow, or magenta + redLo = (0xf) << systemRedShift, redHi = (0x1f) << systemRedShift; + else redLo = redHi = 0; + + if(colorNum == 0 || colorNum == 2 || colorNum == 3 || colorNum == 4) // white, yellow, green, or cyan + greenLo = (0xf) << systemGreenShift, greenHi = (0x1f) << systemGreenShift; + else greenLo = greenHi = 0; + + if(colorNum == 0 || colorNum == 4 || colorNum == 5 || colorNum == 6) // white, cyan, blue, or magenta + blueLo = (0xf) << systemBlueShift, blueHi = (0x1f) << systemBlueShift; + else blueLo = blueHi = 0; + + lo = redLo + greenLo + blueLo; + hi = redHi + greenHi + blueHi; + + if(colorNum == 7) // black + out = 0xffffffff; // white border + else out = 0; // black border +} + +int lastColID = 0; +static void progressColorList(const char*& colorList, int & lo, int & hi, int & out) +{ + if(*colorList) + { + if(*colorList != lastColID) + { + calcColors((int)(*colorList)-1, lo, hi, out); + lastColID = *colorList; + } + colorList++; + } + else + { + colorList = NULL; + } +} + + +static void drawTextInternal(u8 *screen, int pitch, int x, int y, + const char *string, bool trans, const char *colorList=NULL) +{ + if(colorList && !*colorList) + colorList = NULL; + + int loCol, hiCol, outCol; + calcColors(textColor, loCol, hiCol, outCol); + + lastColID = 0; + + const static int xd [8] = {-1,0,1,1,1,0,-1,-1}; + const static int yd [8] = {-1,-1,-1,0,1,1,1,0}; + + screen += y*pitch; + int inc = 2; + switch(systemColorDepth) { + case 24: + inc = 3; + break; + case 32: + inc = 4; + break; + } + screen += x*inc; + + int xpos = x; + switch(systemColorDepth) { + case 16: + { + while(*string) { + char c = *string++; + u8 *scr = screen; + + if(colorList) progressColorList(colorList, loCol, hiCol, outCol); + + u16 mask = ~RGB_LOW_BITS_MASK; + int h, w; + u16 *s = (u16 *)scr; + for (h = 0-1; h < 8+1; h++) { + for (w = 0-1; w < 8+1; w++, s++) { + int on = (h<0||w<0||h>=8||w>=8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1; + + int border = 0; + if(outlinedText) + for(int i = 0 ; i < 8 ; i++) + { + int h2 = h+yd[i], w2 = w+xd[i]; + border = (h2<0||w2<0||h2>=8||w2>=8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1; + if(border) break; + } + + if(trans) { + if(on) + *s = loCol + + ((*s & mask) >>1); + else if(border) + *s = outCol; + } else { + if(on) + *s = hiCol; + else if(border) + *s = outCol; + } + } + scr += pitch; + s = (u16 *)scr; + } + screen += inc*8; + + xpos += 8; + if(xpos+8 > pitch>>1) // cut off text at right boundary + break; + } + } + break; + case 24: // TODO: verify this code's correctness + { + while(*string) { + char c = *string++; + u8 *scr = screen; + + if(colorList) progressColorList(colorList, loCol, hiCol, outCol); + + int h, w; + u8 *s = (u8 *)scr; + for (h = 0-1; h < 8+1; h++) { + for (w = 0-1; w < 8+1; w++, s++) { + int on = (h<0||w<0||h>=8||w>=8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1; + + int border = 0; + if(outlinedText) + for(int i = 0 ; i < 8 ; i++) + { + int h2 = h+yd[i], w2 = w+xd[i]; + border = (h2<0||w2<0||h2>=8||w2>=8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1; + if(border) break; + } + + if(trans) { + if(on) { + u32 color = hiCol; + *s = ((color & 255)>>1)+(*s>>1); + *(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1); + *(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1); + } + else if(border) + *s = outCol; + } else { + if(on) { + u32 color = hiCol; + *s = (color & 255); + *(s+1) = (color >> 8) & 255; + *(s+2) = (color >> 16) & 255; + } + else if(border) + *s = outCol; + } + } + scr += pitch; + s = (u8 *)scr; + } + screen += inc*8; + + xpos += 8; + if(xpos+8 > pitch/3) // cut off text at right boundary + break; + } + } + break; + case 32: + { + while(*string) { + char c = *string++; + u8 *scr = screen; + + if(colorList) progressColorList(colorList, loCol, hiCol, outCol); + + int h, w; + u32 mask = 0xfefefe; + u32 *s = (u32 *)scr; + for (h = 0-1; h < 8+1; h++) { + for (w = 0-1; w < 8+1; w++, s++) { + int on = (h<0||w<0||h>=8||w>=8) ? 0 : (fontdata2[(c<<3)+h]>>w)&1; + + int border = 0; + if(outlinedText) + for(int i = 0 ; i < 8 ; i++) + { + int h2 = h+yd[i], w2 = w+xd[i]; + border = (h2<0||w2<0||h2>=8||w2>=8) ? 0 : (fontdata2[(c<<3)+h2]>>w2)&1; + if(border) break; + } + + if(trans) { + if(on) + *s = loCol + + ((*s & mask)>>1); + else if(border) + *s = outCol; + } else { + if(on) + *s = hiCol; + else if(border) + *s = outCol; + } + } + scr += pitch; + s = (u32 *)scr; + } + screen += inc*8; + + xpos += 8; + if(xpos+8 > pitch>>2) // cut off text at right boundary + break; + } + } + break; + } +} + +void drawText(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList) +{ + drawTextInternal(screen, pitch, x, y, string, transparentText, colorList); +} + +void drawTextTransp(u8 *screen, int pitch, int x, int y, const char *string, const char *colorList) +{ + drawTextInternal(screen, pitch, x, y, string, true, colorList); +} diff --git a/src/Text.h b/src/Text.h new file mode 100644 index 0000000..0b5bfff --- /dev/null +++ b/src/Text.h @@ -0,0 +1,24 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +extern void drawText(u8 *, int, int, int, const char *, const char*cl=NULL); +extern void drawTextTransp(u8 *, int, int, int, const char *, const char*cl=NULL); + +extern bool outlinedText, transparentText; +extern int textColor, textMethod; diff --git a/src/Util.cpp b/src/Util.cpp new file mode 100644 index 0000000..362603d --- /dev/null +++ b/src/Util.cpp @@ -0,0 +1,1111 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include + +extern "C" { +#include +} + +#if 0 +#include "unrarlib.h" +#endif + +#include "System.h" +#include "NLS.h" +#include "Util.h" +#include "Flash.h" +#include "GBA.h" +#include "Globals.h" +#include "RTC.h" +#include "Port.h" + + +extern "C" { +#include "memgzio.h" +} + +#ifndef _MSC_VER +#define _stricmp strcasecmp +#endif // ! _MSC_VER + +extern int systemColorDepth; +extern int systemRedShift; +extern int systemGreenShift; +extern int systemBlueShift; + +extern u16 systemColorMap16[0x10000]; +extern u32 systemColorMap32[0x10000]; + +static int (ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL; +static int (ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL; +static int (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL; + +bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix) +{ + u8 writeBuffer[512 * 3]; + + FILE *fp = fopen(fileName,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); + return false; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return false; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return false; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return false; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + switch(systemColorDepth) { + case 16: + { + u16 *p = (u16 *)(pix+(w+2)*2); // skip first black line + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u16 v = *p++; + + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + } + break; + case 24: + { + u8 *pixU8 = (u8 *)pix; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + if(systemRedShift < systemBlueShift) { + *b++ = *pixU8++; // R + *b++ = *pixU8++; // G + *b++ = *pixU8++; // B + } else { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + } + break; + case 32: + { + u32 *pixU32 = (u32 *)(pix+4*(w+1)); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + } + pixU32++; + + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + } + break; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); + + return true; +} + +void utilPutDword(u8 *p, u32 value) +{ + *p++ = value & 255; + *p++ = (value >> 8) & 255; + *p++ = (value >> 16) & 255; + *p = (value >> 24) & 255; +} + +void utilPutWord(u8 *p, u16 value) +{ + *p++ = value & 255; + *p = (value >> 8) & 255; +} + +void utilWriteBMP(char *buf, int w, int h, int dstDepth, u8 *pix) +{ + u8 *b = (u8 *)buf; + + int sizeX = w; + int sizeY = h; + + switch(dstDepth>0 ? dstDepth : systemColorDepth) { + case 16: + { + u16 *p = (u16 *)(pix+(w+2)*(h)*2); // skip first black line + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u16 v = *p++; + + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + p -= 2*(w+2); + } + } + break; + case 24: + { + u8 *pixU8 = (u8 *)pix+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + if(systemRedShift > systemBlueShift) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } else { + int red = *pixU8++; + int green = *pixU8++; + int blue = *pixU8++; + + *b++ = blue; + *b++ = green; + *b++ = red; + } + } + pixU8 -= 2*3*w; + } + } + break; + case 32: + { + u32 *pixU32 = (u32 *)(pix+4*(w+1)*(h)); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + pixU32++; + pixU32 -= 2*(w+1); + } + } + break; + } +} + +bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix) +{ + u8 writeBuffer[512 * 3]; + + FILE *fp = fopen(fileName,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); + return false; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + // u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x36); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + switch(systemColorDepth) { + case 16: + { + u16 *p = (u16 *)(pix+(w+2)*(h)*2); // skip first black line + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u16 v = *p++; + + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + p -= 2*(w+2); + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + } + break; + case 24: + { + u8 *pixU8 = (u8 *)pix+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + if(systemRedShift > systemBlueShift) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } else { + int red = *pixU8++; + int green = *pixU8++; + int blue = *pixU8++; + + *b++ = blue; + *b++ = green; + *b++ = red; + } + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + } + break; + case 32: + { + u32 *pixU32 = (u32 *)(pix+4*(w+1)*(h)); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + pixU32++; + pixU32 -= 2*(w+1); + + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + } + break; + } + + fclose(fp); + + return true; +} + +static int utilReadInt2(FILE *f) +{ + int res = 0; + int c = fgetc(f); + if(c == EOF) + return -1; + res = c; + c = fgetc(f); + if(c == EOF) + return -1; + return c + (res<<8); +} + +static int utilReadInt3(FILE *f) +{ + int res = 0; + int c = fgetc(f); + if(c == EOF) + return -1; + res = c; + c = fgetc(f); + if(c == EOF) + return -1; + res = c + (res<<8); + c = fgetc(f); + if(c == EOF) + return -1; + return c + (res<<8); +} + +void utilApplyIPS(const char *ips, u8 **r, int *s) +{ + // from the IPS spec at http://zerosoft.zophar.net/ips.htm + FILE *f = fopen(ips, "rb"); + if(!f) + return; + u8 *rom = *r; + int size = *s; + if(fgetc(f) == 'P' && + fgetc(f) == 'A' && + fgetc(f) == 'T' && + fgetc(f) == 'C' && + fgetc(f) == 'H') { + int b; + int offset; + int len; + for(;;) { + // read offset + offset = utilReadInt3(f); + // if offset == EOF, end of patch + if(offset == 0x454f46) + break; + // read length + len = utilReadInt2(f); + if(!len) { + // len == 0, RLE block + len = utilReadInt2(f); + // byte to fill + int c = fgetc(f); + if(c == -1) + break; + b = (u8)c; + } else + b= -1; + // check if we need to reallocate our ROM + if((offset + len) >= size) { + size *= 2; + rom = (u8 *)realloc(rom, size); + *r = rom; + *s = size; + } + if(b == -1) { + // normal block, just read the data + if(fread(&rom[offset], 1, len, f) != (size_t)len) + break; + } else { + // fill the region with the given byte + while(len--) { + rom[offset++] = b; + } + } + } + } + // close the file + fclose(f); +} + +extern bool cpuIsMultiBoot; + +bool utilIsGBAImage(const char * file) +{ + cpuIsMultiBoot = false; + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".gba") == 0) + return true; + if(_stricmp(p, ".agb") == 0) + return true; + if(_stricmp(p, ".bin") == 0) + return true; + if(_stricmp(p, ".elf") == 0) + return true; + if(_stricmp(p, ".mb") == 0) { + cpuIsMultiBoot = true; + return true; + } + } + } + + return false; +} + +bool utilIsGBImage(const char * file) +{ + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".gb") == 0) + return true; + if(_stricmp(p, ".gbc") == 0) + return true; + if(_stricmp(p, ".cgb") == 0) + return true; + if(_stricmp(p, ".sgb") == 0) + return true; + } + } + + return false; +} + +bool utilIsZipFile(const char *file) +{ + if(strlen(file) > 4) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".zip") == 0) + return true; + } + } + + return false; +} + +#if 0 +bool utilIsRarFile(const char *file) +{ + if(strlen(file) > 4) { + char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".rar") == 0) + return true; + } + } + + return false; +} +#endif + +bool utilIsGzipFile(const char *file) +{ + if(strlen(file) > 3) { + const char * p = strrchr(file,'.'); + + if(p != NULL) { + if(_stricmp(p, ".gz") == 0) + return true; + if(_stricmp(p, ".z") == 0) + return true; + } + } + + return false; +} + +void utilGetBaseName(const char *file, char *buffer) +{ + strcpy(buffer, file); + + if(utilIsGzipFile(file)) { + char *p = strrchr(buffer, '.'); + + if(p) + *p = 0; + } +} + +IMAGE_TYPE utilFindType(const char *file) +{ + char buffer[2048]; + + if(utilIsZipFile(file)) { + unzFile unz = unzOpen(file); + + if(unz == NULL) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), file); + return IMAGE_UNKNOWN; + } + + int r = unzGoToFirstFile(unz); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file); + return IMAGE_UNKNOWN; + } + + IMAGE_TYPE found = IMAGE_UNKNOWN; + + unz_file_info info; + + while(true) { + r = unzGetCurrentFileInfo(unz, + &info, + buffer, + sizeof(buffer), + NULL, + 0, + NULL, + 0); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file); + return IMAGE_UNKNOWN; + } + + if(utilIsGBAImage(buffer)) { + found = IMAGE_GBA; + break; + } + + if(utilIsGBImage(buffer)) { + found = IMAGE_GB; + break; + } + + r = unzGoToNextFile(unz); + + if(r != UNZ_OK) + break; + } + unzClose(unz); + + if(found == IMAGE_UNKNOWN) { + systemMessage(MSG_NO_IMAGE_ON_ZIP, + N_("No image found on ZIP file %s"), file); + return found; + } + return found; +#if 0 + } else if(utilIsRarFile(file)) { + IMAGE_TYPE found = IMAGE_UNKNOWN; + + ArchiveList_struct *rarList = NULL; + if(urarlib_list((void *)file, (ArchiveList_struct *)&rarList)) { + ArchiveList_struct *p = rarList; + + while(p) { + if(utilIsGBAImage(p->item.Name)) { + found = IMAGE_GBA; + break; + } + + if(utilIsGBImage(p->item.Name)) { + found = IMAGE_GB; + break; + } + p = p->next; + } + + urarlib_freelist(rarList); + } + return found; +#endif + } else { + if(utilIsGzipFile(file)) + utilGetBaseName(file, buffer); + else + strcpy(buffer, file); + + if(utilIsGBAImage(buffer)) + return IMAGE_GBA; + if(utilIsGBImage(buffer)) + return IMAGE_GB; + } + return IMAGE_UNKNOWN; +} + +static int utilGetSize(int size) +{ + int res = 1; + while(res < size) + res <<= 1; + return res; +} + +static u8 *utilLoadFromZip(const char *file, + bool (*accept)(const char *), + u8 *data, + int &size) +{ + char buffer[2048]; + + unzFile unz = unzOpen(file); + + if(unz == NULL) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), file); + return NULL; + } + int r = unzGoToFirstFile(unz); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file); + return NULL; + } + + bool found = false; + + unz_file_info info; + + while(true) { + r = unzGetCurrentFileInfo(unz, + &info, + buffer, + sizeof(buffer), + NULL, + 0, + NULL, + 0); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(MSG_BAD_ZIP_FILE, N_("Bad ZIP file %s"), file); + return NULL; + } + + if(accept(buffer)) { + found = true; + break; + } + + r = unzGoToNextFile(unz); + + if(r != UNZ_OK) + break; + } + + if(!found) { + unzClose(unz); + systemMessage(MSG_NO_IMAGE_ON_ZIP, + N_("No image found on ZIP file %s"), file); + return NULL; + } + + int fileSize = info.uncompressed_size; + if(size == 0) + size = fileSize; + r = unzOpenCurrentFile(unz); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), buffer); + return NULL; + } + + u8 *image = data; + + if(image == NULL) { + image = (u8 *)malloc(utilGetSize(size)); + if(image == NULL) { + unzCloseCurrentFile(unz); + unzClose(unz); + systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), + "data"); + return NULL; + } + size = fileSize; + } + int read = fileSize <= size ? fileSize : size; + r = unzReadCurrentFile(unz, + image, + read); + + unzCloseCurrentFile(unz); + unzClose(unz); + + if(r != (int)read) { + systemMessage(MSG_ERROR_READING_IMAGE, + N_("Error reading image %s"), buffer); + if(data == NULL) + free(image); + return NULL; + } + + size = fileSize; + + return image; +} + +static u8 *utilLoadGzipFile(const char *file, + bool (*accept)(const char *), + u8 *data, + int &size) +{ + FILE *f = fopen(file, "rb"); + + if(f == NULL) { + systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file); + return NULL; + } + + fseek(f, -4, SEEK_END); + int fileSize = fgetc(f) | (fgetc(f) << 8) | (fgetc(f) << 16) | (fgetc(f) << 24); + fclose(f); + if(size == 0) + size = fileSize; + + gzFile gz = gzopen(file, "rb"); + + if(gz == NULL) { + // should not happen, but who knows? + systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file); + return NULL; + } + + u8 *image = data; + + if(image == NULL) { + image = (u8 *)malloc(utilGetSize(size)); + if(image == NULL) { + systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), + "data"); + fclose(f); + return NULL; + } + size = fileSize; + } + int read = fileSize <= size ? fileSize : size; + int r = gzread(gz, image, read); + gzclose(gz); + + if(r != (int)read) { + systemMessage(MSG_ERROR_READING_IMAGE, + N_("Error reading image %s"), file); + if(data == NULL) + free(image); + return NULL; + } + + size = fileSize; + + return image; +} + +#if 0 +static u8 *utilLoadRarFile(const char *file, + bool (*accept)(const char *), + u8 *data, + int &size) +{ + char buffer[2048]; + + ArchiveList_struct *rarList = NULL; + if(urarlib_list((void *)file, (ArchiveList_struct *)&rarList)) { + ArchiveList_struct *p = rarList; + + bool found = false; + while(p) { + if(accept(p->item.Name)) { + strcpy(buffer, p->item.Name); + found = true; + break; + } + p = p->next; + } + if(found) { + void *memory = NULL; + unsigned long lsize = 0; + size = p->item.UnpSize; + int r = urarlib_get((void *)&memory, &lsize, buffer, (void *)file, ""); + if(!r) { + systemMessage(MSG_ERROR_READING_IMAGE, + N_("Error reading image %s"), buffer); + urarlib_freelist(rarList); + return NULL; + } + u8 *image = (u8 *)memory; + if(data != NULL) { + memcpy(image, data, size); + } + urarlib_freelist(rarList); + return image; + } + systemMessage(MSG_NO_IMAGE_ON_ZIP, + N_("No image found on RAR file %s"), file); + urarlib_freelist(rarList); + return NULL; + } + // nothing found + return NULL; +} +#endif + +u8 *utilLoad(const char *file, + bool (*accept)(const char *), + u8 *data, + int &size) +{ + if(utilIsZipFile(file)) { + return utilLoadFromZip(file, accept, data, size); + } + if(utilIsGzipFile(file)) { + return utilLoadGzipFile(file, accept, data, size); + } +#if 0 + if(utilIsRarFile(file)) { + return utilLoadRarFile(file, accept, data, size); + } +#endif + + u8 *image = data; + + FILE *f = fopen(file, "rb"); + + if(!f) { + systemMessage(MSG_ERROR_OPENING_IMAGE, N_("Error opening image %s"), file); + return NULL; + } + + fseek(f,0,SEEK_END); + int fileSize = ftell(f); + fseek(f,0,SEEK_SET); + if(size == 0) + size = fileSize; + + if(image == NULL) { + image = (u8 *)malloc(utilGetSize(size)); + if(image == NULL) { + systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), + "data"); + fclose(f); + return NULL; + } + size = fileSize; + } + int read = fileSize <= size ? fileSize : size; + int r = fread(image, 1, read, f); + fclose(f); + + if(r != (int)read) { + systemMessage(MSG_ERROR_READING_IMAGE, + N_("Error reading image %s"), file); + if(data == NULL) + free(image); + return NULL; + } + + size = fileSize; + + return image; +} + +void utilWriteInt(gzFile gzFile, int i) +{ + utilGzWrite(gzFile, &i, sizeof(int)); +} + +int utilReadInt(gzFile gzFile) +{ + int i = 0; + utilGzRead(gzFile, &i, sizeof(int)); + return i; +} + +void utilReadData(gzFile gzFile, variable_desc* data) +{ + while(data->address) { + utilGzRead(gzFile, data->address, data->size); + data++; + } +} + +void utilWriteData(gzFile gzFile, variable_desc *data) +{ + while(data->address) { + utilGzWrite(gzFile, data->address, data->size); + data++; + } +} + +gzFile utilGzOpen(const char *file, const char *mode) +{ + utilGzWriteFunc = (int (ZEXPORT *)(void *,void * const, unsigned int))gzwrite; + utilGzReadFunc = gzread; + utilGzCloseFunc = gzclose; + + return gzopen(file, mode); +} + +gzFile utilGzReopen(int id, const char *mode) +{ + utilGzWriteFunc = (int (*)(void *,void * const, unsigned int))gzwrite; + utilGzReadFunc = gzread; + utilGzCloseFunc = gzclose; + + return gzdopen(id, mode); +} + +gzFile utilMemGzOpen(char *memory, int available, char *mode) +{ + utilGzWriteFunc = memgzwrite; + utilGzReadFunc = memgzread; + utilGzCloseFunc = memgzclose; + + return memgzopen(memory, available, mode); +} + +int utilGzWrite(gzFile file, const voidp buffer, unsigned int len) +{ + return utilGzWriteFunc(file, buffer, len); +} + +int utilGzRead(gzFile file, voidp buffer, unsigned int len) +{ + return utilGzReadFunc(file, buffer, len); +} + +int utilGzClose(gzFile file) +{ + return utilGzCloseFunc(file); +} + +long utilGzMemTell(gzFile file) +{ + return memtell(file); +} + +void utilGBAFindSave(const u8 *data, const int size) +{ + u32 *p = (u32 *)data; + u32 *end = (u32 *)(data + size); + int saveType = 0; + int flashSize = 0x10000; + bool rtcFound = false; + + while(p < end) { + u32 d = READ32LE(p); + + if(d == 0x52504545) { + if(memcmp(p, "EEPROM_", 7) == 0) { + if(saveType == 0) + saveType = 1; + } + } else if (d == 0x4D415253) { + if(memcmp(p, "SRAM_", 5) == 0) { + if(saveType == 0) + saveType = 2; + } + } else if (d == 0x53414C46) { + if(memcmp(p, "FLASH1M_", 8) == 0) { + if(saveType == 0) { + saveType = 3; + flashSize = 0x20000; + } + } else if(memcmp(p, "FLASH", 5) == 0) { + if(saveType == 0) { + saveType = 3; + flashSize = 0x10000; + } + } + } else if (d == 0x52494953) { + if(memcmp(p, "SIIRTC_V", 8) == 0) + rtcFound = true; + } + p++; + } + // if no matches found, then set it to NONE + if(saveType == 0) { + saveType = 5; + } + rtcEnable(rtcFound); + cpuSaveType = saveType; + flashSetSize(flashSize); +} + +void utilUpdateSystemColorMaps() +{ + switch(systemColorDepth) { + case 16: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + case 24: + case 32: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + } +} diff --git a/src/Util.h b/src/Util.h new file mode 100644 index 0000000..a64aca3 --- /dev/null +++ b/src/Util.h @@ -0,0 +1,66 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_UTIL_H +#define VBA_UTIL_H +enum IMAGE_TYPE { + IMAGE_UNKNOWN = -1, + IMAGE_GBA = 0, + IMAGE_GB = 1 +}; + +// save game + +typedef struct { + void *address; + int size; +} variable_desc; + +extern bool utilWritePNGFile(const char *, int, int, u8 *); +extern bool utilWriteBMPFile(const char *, int, int, u8 *); +extern void utilApplyIPS(const char *ips, u8 **rom, int *size); +extern void utilWriteBMP(char * out, int w, int h, int dstDepth, u8 * in); +extern bool utilIsGBAImage(const char *); +extern bool utilIsGBImage(const char *); +extern bool utilIsZipFile(const char *); +extern bool utilIsGzipFile(const char *); +extern bool utilIsRarFile(const char *); +extern void utilGetBaseName(const char *, char *); +extern IMAGE_TYPE utilFindType(const char *); +extern u8 *utilLoad(const char *, + bool (*)(const char*), + u8 *, + int &); + +extern void utilPutDword(u8 *, u32); +extern void utilPutWord(u8 *, u16); +extern void utilWriteData(gzFile, variable_desc *); +extern void utilReadData(gzFile, variable_desc *); +extern int utilReadInt(gzFile); +extern void utilWriteInt(gzFile, int); +extern gzFile utilGzOpen(const char *file, const char *mode); +extern gzFile utilGzReopen(int id, const char *mode); +extern gzFile utilMemGzOpen(char *memory, int available, char *mode); +extern int utilGzWrite(gzFile file, const voidp buffer, unsigned int len); +extern int utilGzRead(gzFile file, voidp buffer, unsigned int len); +extern int utilGzClose(gzFile file); +extern long utilGzMemTell(gzFile file); +extern void utilGBAFindSave(const u8 *, const int); +extern void utilUpdateSystemColorMaps(); +#endif diff --git a/src/VisualBoyAdvance.cfg b/src/VisualBoyAdvance.cfg new file mode 100644 index 0000000..e6cf0c1 --- /dev/null +++ b/src/VisualBoyAdvance.cfg @@ -0,0 +1,213 @@ +# All numeric values are in hexadecimal +# Use TAB or EQUAL sign to separate name from value + +# +# Key configuration (all numbers are in hexadecimal!) +# +# Keys values are in the format YXXX where Y is the device number. 0 means +# keyborad and XXX is the SDL define for the desired key (read SDL_keysym.h). +# +# If Y is greater than 0, it means joystick number Y-1 and it uses the +# following format for XXX: +# +# - if XXX < 20, XXX is the axis number multiplied by 2. An even number means +# movement to the negative side (on the X axis, it means left). An odd +# number means movement to the positive side (on the X axis, it mean +# right). For the Y axis, negative means up and positive means down. +# X axis is usally axis number 0 and Y is axis number 1. +# - if 20 >= XXX > 30, then XXX is the HAT number multiplied by 4 plus the +# direction: 0 for up, 1 for down, 2 for right and 3 for left. Example: +# 0021 is HAT 0 down, 0026 is HAT 1 right. +# - if 80 >= XXX > 100, XXX is the joystick button number (XXX-080). +# +# Default key configuration is (value in parenthesis): +# +# Left Left Arrow (0114) +# Right Right Arrow (0113) +# Up Up Arrow (0111) +# Down Down Arrow (0112) +# A Z (007a) +# B X (0078) +# L A (0061) +# R S (0073) +# Start ENTER (000d) +# Select BACKSPACE (0008) +# Speed up SPACE (0020) +# Capture F12 (0125) +# +Joy0_Left=0114 +Joy0_Right=0113 +Joy0_Up=0111 +Joy0_Down=0112 +Joy0_A=007a +Joy0_B=0078 +Joy0_L=0061 +Joy0_R=0073 +Joy0_Start=000d +Joy0_Select=0008 +Joy0_Speed=0020 +Joy0_Capture=0125 + +# Motion support keys. Same format as above +# +# Default keys are (value in parenthesis): +# +# Left Numeric Pad 4 (0104) +# Right Numeric Pad 6 (0106) +# Up Numeric Pad 8 (0108) +# Down Numeric Pad 2 (0102) +# +Motion_Left=0104 +Motion_Right=0106 +Motion_Up=0108 +Motion_Down=0102 + +# Frame skip setting. Allowed values are from 0 to 5 only. +frameSkip=2 + +# Gameboy Frame skip setting. Allowed values are from 0 to 5 only. +gbFrameSkip=0 + +# Video setting. 0=1x, 1=2x, 2=3x, 3=4x. +video=1 + +# Use fullscreen mode. 0=false, any other value means true +fullScreen=0 + +# Disables MMX support +disableMMX=1 + +# Use bios file. 0=false, any other value means true +useBios=0 + +# Bios file full path and name (ZIP not supported) +biosFile=none + +# Filter to use. 0=no filter, 1=TV Mode, 2=2xSaI, 3=Super 2xSaI, 4=Super Eagle +# 5=Pixelate, 6=Motion Blur, 7=AdvanceMAME Scale2x, 8=Simple 2x, +# 9=Bilinear, A=Bilinear Plus, B=hq2x, C=lq2x +filter=0 + +# Disable status messages. 0=false, any other value means true +disableStatus=0 + +# Enable Gameboy border. 0=false, any other value means true +borderOn=0 + +# Gameboy emulator type. 0=automatic, 1=CGB/GBC, 2=SGB, 3=GB, 4=GBA, 5=SGB2 +emulatorType=1 + +# Enable washed colors. 0=false, any other value means true +colorOption=1 + +# Directories. Not setting one them makes the file go the rom directory. + +# Save state directory +#saveDir= + +# Screen shot Capture directory +#captureDir= + +# Battery directory +#batteryDir= + +# Screen capture format +# 0=PNG, anything else for BMP +captureFormat=0 + +# Sound quality +# 1=44 Khz, 2=22Khz, 4=11Khz +soundQuality=2 + +# Sound Echo +# 0=false, anything else for true +soundEcho=0 + +# Sound Low pass filter +# 0=false, anything else for true +soundLowPass=0 + +# Sound reverse stereo +# 0=false, anything else for true +soundReverse=0 + +# Remove GBA intros (not supported anymore) +# 0=false, anything else for true +# removeIntros=0 + +# Save Type +# 0=automatic, 1=EEPROM, 2=SRAM, 3=Flash, 4=EEPROM+Sensor, 5=NONE +saveType=0 + +# Flash size +# 0=64K Flash, 1=128K Flash + +flashSize=0 + +# Sound volume +# 0=1x, 1=2x, 2=3x, 3=4x +soundVolume=0 + +# Interframe blending +# 0=none, 1=motion blur, 2=smart +ifbType=0 + +# Show emulation speed +# 0=none, 1=percentage, 2=detailed +showSpeed=1 + +# Show speed in transparent mode +# 0=normal, anything else for transparent +showSpeedTransparent=1 + +# Enable/Disable auto frameskip +# 0=disable, anything else to enable +autoFrameSkip=0 + +# Sets the desired throttle +# 0=disable, 5...1000 valid throttle speeds +throttle=0 + +# Pauses the emulator when the window is inactive +# 0=disable, anything else to enable +pauseWhenInactive=0 + +# Enables AGBPrint support +# 0=disable, anything else to enable +agbPrint=0 + +# Enables GBA RTC support +# 0=disable, anything else to enable +rtcEnabled=0 + +# Sound OFF flag +# 0=sound on, anything else turns off sound +soundOff=0 + +# Sound Enable +# Controls which channels are enabled: (add values) +# 1 - Channel 1 +# 2 - Channel 2 +# 4 - Channel 3 +# 8 - Channel 4 +# 100 - DirectSound A +# 200 - DirectSound B +# 30f=all enabled, 0=mute all +soundEnable=30f + +# Controls automatic SGB border +# 0=disable, anything else enables automatic SGB border display +borderAutomatic=0 + +# Skip bios code +# 0=disable, anything else skips BIOS code +skipBios=0 + +# The interval between the rewind saves +# Minimum of 0 seconds to disable rewind support, +# Maximum of 60 minutes. Value in seconds (hexadecimal numbers) +rewindTimer=0 + +# Enable enhanced save type detection +# 0=disable, anything else to enable (no longer used) +#enhancedDetection=1 diff --git a/src/admame.cpp b/src/admame.cpp new file mode 100644 index 0000000..bdde667 --- /dev/null +++ b/src/admame.cpp @@ -0,0 +1,1010 @@ +/* + * This file is part of the Advance project. + * + * Copyright (C) 1999-2002 Andrea Mazzoleni + * + * 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. + * + * In addition, as a special exception, Andrea Mazzoleni + * gives permission to link the code of this program with + * the MAME library (or with modified versions of MAME that use the + * same license as MAME), and distribute linked combinations including + * the two. You must obey the GNU General Public License in all + * respects for all of the code used other than MAME. If you modify + * this file, you may extend this exception to your version of the + * file, but you are not obligated to do so. If you do not wish to + * do so, delete this exception statement from your version. + */ + +/* + * Alternatively at the previous license terms, you are allowed to use this + * code in your program with these conditions: + * - the program is not used in commercial activities. + * - the whole source code of the program is released with the binary. + */ + +#include "System.h" + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif + +static void internal_scale2x_16_def(u16 *dst, const u16* src0, const u16* src1, const u16* src2, unsigned count) { + /* first pixel */ + dst[0] = src1[0]; + if (src1[1] == src0[0] && src2[0] != src0[0]) + dst[1] = src0[0]; + else + dst[1] = src1[0]; + ++src0; + ++src1; + ++src2; + dst += 2; + + /* central pixels */ + count -= 2; + while (count) { + if (src0[0] != src2[0] && src1[-1] != src1[1]) { + dst[0] = src1[-1] == src0[0] ? src0[0] : src1[0]; + dst[1] = src1[1] == src0[0] ? src0[0] : src1[0]; + } else { + dst[0] = src1[0]; + dst[1] = src1[0]; + } + + ++src0; + ++src1; + ++src2; + dst += 2; + --count; + } + + /* last pixel */ + if (src1[-1] == src0[0] && src2[0] != src0[0]) + dst[0] = src0[0]; + else + dst[0] = src1[0]; + dst[1] = src1[0]; +} + +static void internal_scale2x_32_def(u32* dst, + const u32* src0, + const u32* src1, + const u32* src2, + unsigned count) +{ + /* first pixel */ + dst[0] = src1[0]; + if (src1[1] == src0[0] && src2[0] != src0[0]) + dst[1] = src0[0]; + else + dst[1] = src1[0]; + ++src0; + ++src1; + ++src2; + dst += 2; + + /* central pixels */ + count -= 2; + while (count) { + if (src0[0] != src2[0] && src1[-1] != src1[1]) { + dst[0] = src1[-1] == src0[0] ? src0[0] : src1[0]; + dst[1] = src1[1] == src0[0] ? src0[0] : src1[0]; + } else { + dst[0] = src1[0]; + dst[1] = src1[0]; + } + + ++src0; + ++src1; + ++src2; + dst += 2; + --count; + } + + /* last pixel */ + if (src1[-1] == src0[0] && src2[0] != src0[0]) + dst[0] = src0[0]; + else + dst[0] = src1[0]; + dst[1] = src1[0]; +} + +#ifdef MMX +static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16* src1, const u16* src2, unsigned count) { + /* always do the first and last run */ + count -= 2*4; + +#ifdef __GNUC__ + __asm__ __volatile__( + /* first run */ + /* set the current, current_pre, current_next registers */ + "movq 0(%1), %%mm0\n" + "movq 0(%1),%%mm7\n" + "movq 8(%1),%%mm1\n" + "psllq $48,%%mm0\n" + "psllq $48,%%mm1\n" + "psrlq $48, %%mm0\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $16,%%mm2\n" + "psrlq $16,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqw %%mm6,%%mm2\n" + "pcmpeqw %%mm6,%%mm4\n" + "pcmpeqw (%2),%%mm3\n" + "pcmpeqw (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqw %%mm1,%%mm2\n" + "pcmpeqw %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpcklwd %%mm4,%%mm2\n" + "punpckhwd %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3,8(%3)\n" + + /* next */ + "addl $8,%0\n" + "addl $8,%1\n" + "addl $8,%2\n" + "addl $16,%3\n" + + /* central runs */ + "shrl $2,%4\n" + "jz 1f\n" + + "0:\n" + + /* set the current, current_pre, current_next registers */ + "movq -8(%1),%%mm0\n" + "movq (%1),%%mm7\n" + "movq 8(%1),%%mm1\n" + "psrlq $48,%%mm0\n" + "psllq $48,%%mm1\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $16,%%mm2\n" + "psrlq $16,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqw %%mm6,%%mm2\n" + "pcmpeqw %%mm6,%%mm4\n" + "pcmpeqw (%2),%%mm3\n" + "pcmpeqw (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqw %%mm1,%%mm2\n" + "pcmpeqw %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpcklwd %%mm4,%%mm2\n" + "punpckhwd %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3,8(%3)\n" + + /* next */ + "addl $8,%0\n" + "addl $8,%1\n" + "addl $8,%2\n" + "addl $16,%3\n" + + "decl %4\n" + "jnz 0b\n" + "1:\n" + + /* final run */ + /* set the current, current_pre, current_next registers */ + "movq (%1),%%mm1\n" + "movq (%1),%%mm7\n" + "movq -8(%1),%%mm0\n" + "psrlq $48,%%mm1\n" + "psrlq $48,%%mm0\n" + "psllq $48,%%mm1\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $16,%%mm2\n" + "psrlq $16,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqw %%mm6,%%mm2\n" + "pcmpeqw %%mm6,%%mm4\n" + "pcmpeqw (%2),%%mm3\n" + "pcmpeqw (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqw %%mm1,%%mm2\n" + "pcmpeqw %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpcklwd %%mm4,%%mm2\n" + "punpckhwd %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3,8(%3)\n" + "emms\n" + + : "+r" (src0), "+r" (src1), "+r" (src2), "+r" (dst), "+r" (count) + : + : "cc" + ); +#else + __asm { + mov eax, src0; + mov ebx, src1; + mov ecx, src2; + mov edx, dst; + mov esi, count; + + /* first run */ + /* set the current, current_pre, current_next registers */ + movq mm0, qword ptr [ebx]; + movq mm7, qword ptr [ebx]; + movq mm1, qword ptr [ebx + 8]; + psllq mm0, 48; + psllq mm1, 48; + psrlq mm0, 48; + movq mm2, mm7; + movq mm3, mm7; + psllq mm2, 16; + psrlq mm3, 16; + por mm0, mm2; + por mm1, mm3; + + /* current_upper */ + movq mm6, qword ptr [eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2, mm0; + movq mm4, mm1; + movq mm3, mm0; + movq mm5, mm1; + pcmpeqw mm2, mm6; + pcmpeqw mm4, mm6; + pcmpeqw mm3, qword ptr [ecx]; + pcmpeqw mm5, qword ptr [ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqw mm2,mm1; + pcmpeqw mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst0 */ + movq mm3,mm2; + punpcklwd mm2,mm4; + punpckhwd mm3,mm4; + movq qword ptr [edx], mm2; + movq qword ptr [edx + 8], mm3; + + /* next */ + add eax, 8; + add ebx, 8; + add ecx, 8; + add edx, 16; + + /* central runs */ + shr esi, 2; + jz label1; + align 4; + label0: + + /* set the current, current_pre, current_next registers */ + movq mm0, qword ptr [ebx-8]; + movq mm7, qword ptr [ebx]; + movq mm1, qword ptr [ebx+8]; + psrlq mm0,48; + psllq mm1,48; + movq mm2,mm7; + movq mm3,mm7; + psllq mm2,16; + psrlq mm3,16; + por mm0,mm2; + por mm1,mm3; + + /* current_upper */ + movq mm6, qword ptr [eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2,mm0; + movq mm4,mm1; + movq mm3,mm0; + movq mm5,mm1; + pcmpeqw mm2,mm6; + pcmpeqw mm4,mm6; + pcmpeqw mm3, qword ptr [ecx]; + pcmpeqw mm5, qword ptr [ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqw mm2,mm1; + pcmpeqw mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst */ + movq mm3,mm2; + punpcklwd mm2,mm4; + punpckhwd mm3,mm4; + movq qword ptr [edx], mm2; + movq qword ptr [edx+8], mm3; + + /* next */ + add eax,8; + add ebx,8; + add ecx,8; + add edx,16; + + dec esi; + jnz label0; + label1: + + /* final run */ + /* set the current, current_pre, current_next registers */ + movq mm1, qword ptr [ebx]; + movq mm7, qword ptr [ebx]; + movq mm0, qword ptr [ebx-8]; + psrlq mm1,48; + psrlq mm0,48; + psllq mm1,48; + movq mm2,mm7; + movq mm3,mm7; + psllq mm2,16; + psrlq mm3,16; + por mm0,mm2; + por mm1,mm3; + + /* current_upper */ + movq mm6, qword ptr [eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2,mm0; + movq mm4,mm1; + movq mm3,mm0; + movq mm5,mm1; + pcmpeqw mm2,mm6; + pcmpeqw mm4,mm6; + pcmpeqw mm3, qword ptr [ecx]; + pcmpeqw mm5, qword ptr [ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqw mm2,mm1; + pcmpeqw mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst */ + movq mm3,mm2; + punpcklwd mm2,mm4; + punpckhwd mm3,mm4; + movq qword ptr [edx], mm2; + movq qword ptr [edx+8], mm3; + + mov src0, eax; + mov src1, ebx; + mov src2, ecx; + mov dst, edx; + mov count, esi; + + emms; + } +#endif +} + +static void internal_scale2x_32_mmx_single(u32* dst, const u32* src0, const u32* src1, const u32* src2, unsigned count) { + /* always do the first and last run */ + count -= 2*2; + +#ifdef __GNUC__ + __asm__ __volatile__( + /* first run */ + /* set the current, current_pre, current_next registers */ + "movq 0(%1),%%mm0\n" + "movq 0(%1),%%mm7\n" + "movq 8(%1),%%mm1\n" + "psllq $32,%%mm0\n" + "psllq $32,%%mm1\n" + "psrlq $32,%%mm0\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $32,%%mm2\n" + "psrlq $32,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqd %%mm6,%%mm2\n" + "pcmpeqd %%mm6,%%mm4\n" + "pcmpeqd (%2),%%mm3\n" + "pcmpeqd (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqd %%mm1,%%mm2\n" + "pcmpeqd %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpckldq %%mm4,%%mm2\n" + "punpckhdq %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3, 8(%3)\n" + + /* next */ + "addl $8,%0\n" + "addl $8,%1\n" + "addl $8,%2\n" + "addl $16,%3\n" + + /* central runs */ + "shrl $1,%4\n" + "jz 1f\n" + + "0:\n" + + /* set the current, current_pre, current_next registers */ + "movq -8(%1),%%mm0\n" + "movq (%1),%%mm7\n" + "movq 8(%1),%%mm1\n" + "psrlq $32,%%mm0\n" + "psllq $32,%%mm1\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $32,%%mm2\n" + "psrlq $32,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqd %%mm6,%%mm2\n" + "pcmpeqd %%mm6,%%mm4\n" + "pcmpeqd (%2),%%mm3\n" + "pcmpeqd (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqd %%mm1,%%mm2\n" + "pcmpeqd %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpckldq %%mm4,%%mm2\n" + "punpckhdq %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3,8(%3)\n" + + /* next */ + "addl $8,%0\n" + "addl $8,%1\n" + "addl $8,%2\n" + "addl $16,%3\n" + + "decl %4\n" + "jnz 0b\n" + "1:\n" + + /* final run */ + /* set the current, current_pre, current_next registers */ + "movq (%1),%%mm1\n" + "movq (%1),%%mm7\n" + "movq -8(%1), %%mm0\n" + "psrlq $32,%%mm1\n" + "psrlq $32,%%mm0\n" + "psllq $32,%%mm1\n" + "movq %%mm7,%%mm2\n" + "movq %%mm7,%%mm3\n" + "psllq $32,%%mm2\n" + "psrlq $32,%%mm3\n" + "por %%mm2,%%mm0\n" + "por %%mm3,%%mm1\n" + + /* current_upper */ + "movq (%0),%%mm6\n" + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "movq %%mm0,%%mm3\n" + "movq %%mm1,%%mm5\n" + "pcmpeqd %%mm6,%%mm2\n" + "pcmpeqd %%mm6,%%mm4\n" + "pcmpeqd (%2),%%mm3\n" + "pcmpeqd (%2),%%mm5\n" + "pandn %%mm2,%%mm3\n" + "pandn %%mm4,%%mm5\n" + "movq %%mm0,%%mm2\n" + "movq %%mm1,%%mm4\n" + "pcmpeqd %%mm1,%%mm2\n" + "pcmpeqd %%mm0,%%mm4\n" + "pandn %%mm3,%%mm2\n" + "pandn %%mm5,%%mm4\n" + "movq %%mm2,%%mm3\n" + "movq %%mm4,%%mm5\n" + "pand %%mm6,%%mm2\n" + "pand %%mm6,%%mm4\n" + "pandn %%mm7,%%mm3\n" + "pandn %%mm7,%%mm5\n" + "por %%mm3,%%mm2\n" + "por %%mm5,%%mm4\n" + + /* set *dst */ + "movq %%mm2,%%mm3\n" + "punpckldq %%mm4,%%mm2\n" + "punpckhdq %%mm4,%%mm3\n" + "movq %%mm2,(%3)\n" + "movq %%mm3,8(%3)\n" + "emms\n" + + : "+r" (src0), "+r" (src1), "+r" (src2), "+r" (dst), "+r" (count) + : + : "cc" + ); +#else + __asm { + mov eax, src0; + mov ebx, src1; + mov ecx, src2; + mov edx, dst; + mov esi, count; + + /* first run */ + /* set the current, current_pre, current_next registers */ + movq mm0,qword ptr [ebx]; + movq mm7,qword ptr [ebx]; + movq mm1,qword ptr [ebx + 8]; + psllq mm0,32; + psllq mm1,32; + psrlq mm0,32; + movq mm2,mm7; + movq mm3,mm7; + psllq mm2,32; + psrlq mm3,32; + por mm0,mm2; + por mm1,mm3; + + /* current_upper */ + movq mm6,qword ptr [eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2,mm0; + movq mm4,mm1; + movq mm3,mm0; + movq mm5,mm1; + pcmpeqd mm2,mm6; + pcmpeqd mm4,mm6; + pcmpeqd mm3,qword ptr [ecx]; + pcmpeqd mm5,qword ptr [ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqd mm2,mm1; + pcmpeqd mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst */ + movq mm3,mm2; + punpckldq mm2,mm4; + punpckhdq mm3,mm4; + movq qword ptr [edx],mm2; + movq qword ptr [edx+8],mm3; + + /* next */ + add eax,8; + add ebx,8; + add ecx,8; + add edx,16; + + /* central runs */ + shr esi,1; + jz label1; +label0: + + /* set the current, current_pre, current_next registers */ + movq mm0,qword ptr [ebx-8]; + movq mm7,qword ptr [ebx]; + movq mm1,qword ptr [ebx+8]; + psrlq mm0,32; + psllq mm1,32; + movq mm2,mm7; + movq mm3,mm7; + psllq mm2,32; + psrlq mm3,32; + por mm0,mm2; + por mm1,mm3; + + /* current_upper */ + movq mm6,qword ptr[eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2,mm0; + movq mm4,mm1; + movq mm3,mm0; + movq mm5,mm1; + pcmpeqd mm2,mm6; + pcmpeqd mm4,mm6; + pcmpeqd mm3,qword ptr[ecx]; + pcmpeqd mm5,qword ptr[ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqd mm2,mm1; + pcmpeqd mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst */ + movq mm3,mm2; + punpckldq mm2,mm4; + punpckhdq mm3,mm4; + movq qword ptr [edx],mm2; + movq qword ptr [edx+8],mm3; + + /* next */ + add eax,8; + add ebx,8; + add ecx,8; + add edx,16; + + dec esi; + jnz label0; +label1: + + /* final run */ + /* set the current, current_pre, current_next registers */ + movq mm1,qword ptr [ebx]; + movq mm7,qword ptr [ebx]; + movq mm0,qword ptr [ebx-8]; + psrlq mm1,32; + psrlq mm0,32; + psllq mm1,32; + movq mm2,mm7; + movq mm3,mm7; + psllq mm2,32; + psrlq mm3,32; + por mm0,mm2; + por mm1,mm3; + + /* current_upper */ + movq mm6,qword ptr [eax]; + + /* compute the upper-left pixel for dst on %%mm2 */ + /* compute the upper-right pixel for dst on %%mm4 */ + movq mm2,mm0; + movq mm4,mm1; + movq mm3,mm0; + movq mm5,mm1; + pcmpeqd mm2,mm6; + pcmpeqd mm4,mm6; + pcmpeqd mm3,qword ptr [ecx]; + pcmpeqd mm5,qword ptr [ecx]; + pandn mm3,mm2; + pandn mm5,mm4; + movq mm2,mm0; + movq mm4,mm1; + pcmpeqd mm2,mm1; + pcmpeqd mm4,mm0; + pandn mm2,mm3; + pandn mm4,mm5; + movq mm3,mm2; + movq mm5,mm4; + pand mm2,mm6; + pand mm4,mm6; + pandn mm3,mm7; + pandn mm5,mm7; + por mm2,mm3; + por mm4,mm5; + + /* set *dst */ + movq mm3,mm2; + punpckldq mm2,mm4; + punpckhdq mm3,mm4; + movq qword ptr [edx],mm2; + movq qword ptr [edx+8],mm3; + + mov src0, eax; + mov src1, ebx; + mov src2, ecx; + mov dst, edx; + mov count, esi; + + emms; + } +#endif +} + +static void internal_scale2x_16_mmx(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count) { + // assert( count >= 2*4 ); + internal_scale2x_16_mmx_single(dst0, src0, src1, src2, count); + internal_scale2x_16_mmx_single(dst1, src2, src1, src0, count); +} + +static void internal_scale2x_32_mmx(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count) { + // assert( count >= 2*2 ); + internal_scale2x_32_mmx_single(dst0, src0, src1, src2, count); + internal_scale2x_32_mmx_single(dst1, src2, src1, src0, count); +} +#endif + +void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u16 *dst0 = (u16 *)dstPtr; + u16 *dst1 = dst0 + (dstPitch >> 1); + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = src0 + (srcPitch >> 1); + u16 *src2 = src1 + (srcPitch >> 1); +#ifdef MMX + if(cpu_mmx) { + internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch; + dst1 += dstPitch; + internal_scale2x_16_mmx(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch; + dst1 += dstPitch; + internal_scale2x_16_mmx(dst0, dst1, src0, src1, src1, width); + } else { +#endif + internal_scale2x_16_def(dst0, src0, src0, src1, width); + internal_scale2x_16_def(dst1, src1, src0, src0, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch; + dst1 += dstPitch; + internal_scale2x_16_def(dst0, src0, src1, src2, width); + internal_scale2x_16_def(dst1, src2, src1, src0, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch; + dst1 += dstPitch; + internal_scale2x_16_def(dst0, src0, src1, src1, width); + internal_scale2x_16_def(dst1, src1, src1, src0, width); +#ifdef MMX + } +#endif +} + +void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dst0 = (u32 *)dstPtr; + u32 *dst1 = dst0 + (dstPitch >> 2); + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = src0 + (srcPitch >> 2); + u32 *src2 = src1 + (srcPitch >> 2); +#ifdef MMX + if(cpu_mmx) { + internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + internal_scale2x_32_mmx(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + internal_scale2x_32_mmx(dst0, dst1, src0, src1, src1, width); + } else { +#endif + internal_scale2x_32_def(dst0, src0, src0, src1, width); + internal_scale2x_32_def(dst1, src1, src0, src0, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + internal_scale2x_32_def(dst0, src0, src1, src2, width); + internal_scale2x_32_def(dst1, src2, src1, src0, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + internal_scale2x_32_def(dst0, src0, src1, src1, width); + internal_scale2x_32_def(dst1, src1, src1, src0, width); +#ifdef MMX + } +#endif +} diff --git a/src/agbprint.cpp b/src/agbprint.cpp new file mode 100644 index 0000000..301c671 --- /dev/null +++ b/src/agbprint.cpp @@ -0,0 +1,99 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include + +#include "GBA.h" +#include "Globals.h" +#include "Port.h" + +#define debuggerWriteHalfWord(addr, value) \ + WRITE16LE((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], (value)) + +#define debuggerReadHalfWord(addr) \ + READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +static bool agbPrintEnabled = false; +static bool agbPrintProtect = false; + +bool agbPrintWrite(u32 address, u16 value) +{ + if(agbPrintEnabled) { + if(address == 0x9fe2ffe) { // protect + agbPrintProtect = (value != 0); + debuggerWriteHalfWord(address, value); + return true; + } else { + if(agbPrintProtect && + ((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure + || (address >= 0x8fd0000 && address <= 0x8fdffff) + || (address >= 0x9fd0000 && address <= 0x9fdffff))) { + debuggerWriteHalfWord(address, value); + return true; + } + } + } + return false; +} + +void agbPrintReset() +{ + agbPrintProtect = false; +} + +void agbPrintEnable(bool enable) +{ + agbPrintEnabled = enable; +} + +bool agbPrintIsEnabled() +{ + return agbPrintEnabled; +} + +extern void (*dbgOutput)(char *, u32); + +void agbPrintFlush() +{ + u16 get = debuggerReadHalfWord(0x9fe20fc); + u16 put = debuggerReadHalfWord(0x9fe20fe); + + u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16); + if(address != 0xfd0000 && address != 0x1fd0000) { + dbgOutput("Did you forget to call AGBPrintInit?\n", 0); + // get rid of the text otherwise we will continue to be called + debuggerWriteHalfWord(0x9fe20fc, put); + return; + } + + u8 *data = &rom[address]; + + while(get != put) { + char c = data[get++]; + char s[2]; + s[0] = c; + s[1] = 0; + + if(systemVerbose & VERBOSE_AGBPRINT) + dbgOutput(s, 0); + if(c == '\n') + break; + } + debuggerWriteHalfWord(0x9fe20fc, get); +} diff --git a/src/agbprint.h b/src/agbprint.h new file mode 100644 index 0000000..d7742de --- /dev/null +++ b/src/agbprint.h @@ -0,0 +1,27 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_AGBPRINT_H +#define VBA_AGBPRINT_H +extern void agbPrintEnable(bool); +extern bool agbPrintIsEnabled(); +extern void agbPrintReset(); +extern bool agbPrintWrite(u32, u16); +extern void agbPrintFlush(); +#endif diff --git a/src/arm-new.h b/src/arm-new.h new file mode 100644 index 0000000..8dee998 --- /dev/null +++ b/src/arm-new.h @@ -0,0 +1,7164 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifdef BKPT_SUPPORT +#define CONSOLE_OUTPUT(a,b) \ + extern void (*dbgOutput)(char *, u32);\ + if((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) {\ + dbgOutput((a), (b));\ + } +#else +#define CONSOLE_OUTPUT(a,b) +#endif + +#define OP_AND \ + reg[dest].I = reg[(opcode>>16)&15].I & value;\ + CONSOLE_OUTPUT(NULL,reg[2].I); + +#define OP_ANDS \ + reg[dest].I = reg[(opcode>>16)&15].I & value;\ + \ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_EOR \ + reg[dest].I = reg[(opcode>>16)&15].I ^ value; + +#define OP_EORS \ + reg[dest].I = reg[(opcode>>16)&15].I ^ value;\ + \ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; +#ifdef C_CORE +#define NEG(i) ((i) >> 31) +#define POS(i) ((~(i)) >> 31) +#define ADDCARRY(a, b, c) \ + C_FLAG = ((NEG(a) & NEG(b)) |\ + (NEG(a) & POS(c)) |\ + (NEG(b) & POS(c))) ? true : false; +#define ADDOVERFLOW(a, b, c) \ + V_FLAG = ((NEG(a) & NEG(b) & POS(c)) |\ + (POS(a) & POS(b) & NEG(c))) ? true : false; +#define SUBCARRY(a, b, c) \ + C_FLAG = ((NEG(a) & POS(b)) |\ + (NEG(a) & POS(c)) |\ + (POS(b) & POS(c))) ? true : false; +#define SUBOVERFLOW(a, b, c)\ + V_FLAG = ((NEG(a) & POS(b) & POS(c)) |\ + (POS(a) & NEG(b) & NEG(c))) ? true : false; +#define OP_SUB \ + {\ + reg[dest].I = reg[base].I - value;\ + } +#define OP_SUBS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define OP_RSB \ + {\ + reg[dest].I = value - reg[base].I;\ + } +#define OP_RSBS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = rhs - lhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(rhs, lhs, res);\ + SUBOVERFLOW(rhs, lhs, res);\ + } +#define OP_ADD \ + {\ + reg[dest].I = reg[base].I + value;\ + } +#define OP_ADDS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define OP_ADC \ + {\ + reg[dest].I = reg[base].I + value + (u32)C_FLAG;\ + } +#define OP_ADCS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs + (u32)C_FLAG;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define OP_SBC \ + {\ + reg[dest].I = reg[base].I - value - !((u32)C_FLAG);\ + } +#define OP_SBCS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs - !((u32)C_FLAG);\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define OP_RSC \ + {\ + reg[dest].I = value - reg[base].I - !((u32)C_FLAG);\ + } +#define OP_RSCS \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = rhs - lhs - !((u32)C_FLAG);\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(rhs, lhs, res);\ + SUBOVERFLOW(rhs, lhs, res);\ + } +#define OP_CMP \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define OP_CMN \ + {\ + u32 lhs = reg[base].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } + +#define LOGICAL_LSL_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (32 - shift)) & 1 ? true : false;\ + value = v << shift;\ + } +#define LOGICAL_LSR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = v >> shift;\ + } +#define LOGICAL_ASR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false;\ + value = (s32)v >> (int)shift;\ + } +#define LOGICAL_ROR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } +#define LOGICAL_RRX_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + shift = (int)C_FLAG;\ + C_OUT = (v & 1) ? true : false;\ + value = ((v >> 1) |\ + (shift << 31));\ + } +#define LOGICAL_ROR_IMM \ + {\ + u32 v = opcode & 0xff;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } +#define ARITHMETIC_LSL_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = v << shift;\ + } +#define ARITHMETIC_LSR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = v >> shift;\ + } +#define ARITHMETIC_ASR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = (s32)v >> (int)shift;\ + } +#define ARITHMETIC_ROR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } +#define ARITHMETIC_RRX_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + shift = (int)C_FLAG;\ + value = ((v >> 1) |\ + (shift << 31));\ + } +#define ARITHMETIC_ROR_IMM \ + {\ + u32 v = opcode & 0xff;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } +#define ROR_IMM_MSR \ + {\ + u32 v = opcode & 0xff;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } +#define ROR_VALUE \ + {\ + value = ((value << (32 - shift)) |\ + (value >> shift));\ + } +#define RCR_VALUE \ + {\ + shift = (int)C_FLAG;\ + value = ((value >> 1) |\ + (shift << 31));\ + } +#else +#ifdef __GNUC__ + #ifdef __POWERPC__ + #define OP_SUB \ + {\ + reg[dest].I = reg[base].I - value;\ + } + #define OP_SUBS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_RSB \ + {\ + reg[dest].I = value - reg[base].I;\ + } + #define OP_RSBS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subfco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_ADD \ + {\ + reg[dest].I = reg[base].I + value;\ + } + + #define OP_ADDS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("addco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_ADC \ + {\ + reg[dest].I = reg[base].I + value + (u32)C_FLAG;\ + } + #define OP_ADCS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("mtspr xer, %4\n" \ + "addeo. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value), \ + "r" (C_FLAG << 29) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_SBC \ + {\ + reg[dest].I = reg[base].I - value - (C_FLAG^1);\ + } + #define OP_SBCS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("mtspr xer, %4\n" \ + "subfeo. %0, %3, %2\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value), \ + "r" (C_FLAG << 29) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_RSC \ + {\ + reg[dest].I = value - reg[base].I - (C_FLAG^1);\ + } + #define OP_RSCS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("mtspr xer, %4\n" \ + "subfeo. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value), \ + "r" (C_FLAG << 29) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_CMP \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value) \ + ); \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define OP_CMN \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("addco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[base].I), \ + "r" (value) \ + ); \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + + #define LOGICAL_LSL_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (32 - shift)) & 1 ? true : false;\ + value = v << shift;\ + } + #define LOGICAL_LSR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = v >> shift;\ + } + #define LOGICAL_ASR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false;\ + value = (s32)v >> (int)shift;\ + } + #define LOGICAL_ROR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } + #define LOGICAL_RRX_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + shift = (int)C_FLAG;\ + C_OUT = (v & 1) ? true : false;\ + value = ((v >> 1) |\ + (shift << 31));\ + } + #define LOGICAL_ROR_IMM \ + {\ + u32 v = opcode & 0xff;\ + C_OUT = (v >> (shift - 1)) & 1 ? true : false;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } + #define ARITHMETIC_LSL_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = v << shift;\ + } + #define ARITHMETIC_LSR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = v >> shift;\ + } + #define ARITHMETIC_ASR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = (s32)v >> (int)shift;\ + } + #define ARITHMETIC_ROR_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } + #define ARITHMETIC_RRX_REG \ + {\ + u32 v = reg[opcode & 0x0f].I;\ + shift = (int)C_FLAG;\ + value = ((v >> 1) |\ + (shift << 31));\ + } + #define ARITHMETIC_ROR_IMM \ + {\ + u32 v = opcode & 0xff;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } + #define ROR_IMM_MSR \ + {\ + u32 v = opcode & 0xff;\ + value = ((v << (32 - shift)) |\ + (v >> shift));\ + } + #define ROR_VALUE \ + {\ + value = ((value << (32 - shift)) |\ + (value >> shift));\ + } + #define RCR_VALUE \ + {\ + shift = (int)C_FLAG;\ + value = ((value >> 1) |\ + (shift << 31));\ + } +#else +#define OP_SUB \ + asm ("sub %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_SUBS \ + asm ("sub %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_RSB \ + asm ("sub %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (reg[base].I), "b" (value)); + +#define OP_RSBS \ + asm ("sub %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (reg[base].I), "b" (value)); + +#define OP_ADD \ + asm ("add %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_ADDS \ + asm ("add %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_ADC \ + asm ("bt $0, C_FLAG;"\ + "adc %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_ADCS \ + asm ("bt $0, C_FLAG;"\ + "adc %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_SBC \ + asm ("bt $0, C_FLAG;"\ + "cmc;"\ + "sbb %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); + +#define OP_SBCS \ + asm ("bt $0, C_FLAG;"\ + "cmc;"\ + "sbb %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[base].I)); +#define OP_RSC \ + asm ("bt $0, C_FLAG;"\ + "cmc;"\ + "sbb %1, %%ebx;"\ + : "=b" (reg[dest].I)\ + : "r" (reg[base].I), "b" (value)); + +#define OP_RSCS \ + asm ("bt $0, C_FLAG;"\ + "cmc;"\ + "sbb %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (reg[base].I), "b" (value)); +#define OP_CMP \ + asm ("sub %0, %1;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + :\ + : "r" (value), "r" (reg[base].I)); + +#define OP_CMN \ + asm ("add %0, %1;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : \ + : "r" (value), "r" (reg[base].I)); +#define LOGICAL_LSL_REG \ + asm("shl %%cl, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define LOGICAL_LSR_REG \ + asm("shr %%cl, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define LOGICAL_ASR_REG \ + asm("sar %%cl, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define LOGICAL_ROR_REG \ + asm("ror %%cl, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define LOGICAL_RRX_REG \ + asm("bt $0, C_FLAG;"\ + "rcr $1, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (reg[opcode & 0x0f].I)); + +#define LOGICAL_ROR_IMM \ + asm("ror %%cl, %%eax;"\ + "setcb %%cl;"\ + : "=a" (value), "=c" (C_OUT)\ + : "a" (opcode & 0xff), "c" (shift)); +#define ARITHMETIC_LSL_REG \ + asm("\ + shl %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define ARITHMETIC_LSR_REG \ + asm("\ + shr %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define ARITHMETIC_ASR_REG \ + asm("\ + sar %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define ARITHMETIC_ROR_REG \ + asm("\ + ror %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (reg[opcode & 0x0f].I), "c" (shift)); + +#define ARITHMETIC_RRX_REG \ + asm("\ + bt $0, C_FLAG;\ + rcr $1, %%eax;"\ + : "=a" (value)\ + : "a" (reg[opcode & 0x0f].I)); + +#define ARITHMETIC_ROR_IMM \ + asm("\ + ror %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (opcode & 0xff), "c" (shift)); +#define ROR_IMM_MSR \ + asm ("ror %%cl, %%eax;"\ + : "=a" (value)\ + : "a" (opcode & 0xFF), "c" (shift)); +#define ROR_VALUE \ + asm("ror %%cl, %0"\ + : "=r" (value)\ + : "r" (value), "c" (shift)); +#define RCR_VALUE \ + asm("bt $0, C_FLAG;"\ + "rcr $1, %0"\ + : "=r" (value)\ + : "r" (value)); +#endif +#else +#define OP_SUB \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm sub ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + } + +#define OP_SUBS \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm sub ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } + +#define OP_RSB \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm mov eax, value\ + __asm sub eax, ebx\ + __asm mov ebx, dest\ + __asm mov dword ptr [OFFSET reg+4*ebx], eax\ + } + +#define OP_RSBS \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm mov eax, value\ + __asm sub eax, ebx\ + __asm mov ebx, dest\ + __asm mov dword ptr [OFFSET reg+4*ebx], eax\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } + +#define OP_ADD \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm add ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + } + +#define OP_ADDS \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm add ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } + +#define OP_ADC \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm bt word ptr C_FLAG, 0\ + __asm adc ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + } + +#define OP_ADCS \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm bt word ptr C_FLAG, 0\ + __asm adc ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } + +#define OP_SBC \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\ + __asm mov eax, value\ + __asm bt word ptr C_FLAG, 0\ + __asm cmc\ + __asm sbb ebx, eax\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg + 4*eax], ebx\ + } + +#define OP_SBCS \ + {\ + __asm mov ebx, base\ + __asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\ + __asm mov eax, value\ + __asm bt word ptr C_FLAG, 0\ + __asm cmc\ + __asm sbb ebx, eax\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg + 4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define OP_RSC \ + {\ + __asm mov ebx, value\ + __asm mov eax, base\ + __asm mov eax, dword ptr[OFFSET reg + 4*eax]\ + __asm bt word ptr C_FLAG, 0\ + __asm cmc\ + __asm sbb ebx, eax\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg + 4*eax], ebx\ + } + +#define OP_RSCS \ + {\ + __asm mov ebx, value\ + __asm mov eax, base\ + __asm mov eax, dword ptr[OFFSET reg + 4*eax]\ + __asm bt word ptr C_FLAG, 0\ + __asm cmc\ + __asm sbb ebx, eax\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg + 4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define OP_CMP \ + {\ + __asm mov eax, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm sub ebx, value\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } + +#define OP_CMN \ + {\ + __asm mov eax, base\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm add ebx, value\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define LOGICAL_LSL_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shl eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT + +#define LOGICAL_LSR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shr eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT + +#define LOGICAL_ASR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm sar eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT + +#define LOGICAL_ROR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0F\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm mov cl, byte ptr shift\ + __asm ror eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT + +#define LOGICAL_RRX_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0F\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm bt word ptr C_OUT, 0\ + __asm rcr eax, 1\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT + +#define LOGICAL_ROR_IMM \ + __asm mov eax, opcode\ + __asm and eax, 0xff\ + __asm mov cl, byte ptr shift\ + __asm ror eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_OUT +#define ARITHMETIC_LSL_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shl eax, cl\ + __asm mov value, eax + +#define ARITHMETIC_LSR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shr eax, cl\ + __asm mov value, eax + +#define ARITHMETIC_ASR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0f\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm sar eax, cl\ + __asm mov value, eax + +#define ARITHMETIC_ROR_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0F\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm mov cl, byte ptr shift\ + __asm ror eax, cl\ + __asm mov value, eax + +#define ARITHMETIC_RRX_REG \ + __asm mov eax, opcode\ + __asm and eax, 0x0F\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm bt word ptr C_FLAG, 0\ + __asm rcr eax, 1\ + __asm mov value, eax + +#define ARITHMETIC_ROR_IMM \ + __asm mov eax, opcode\ + __asm and eax, 0xff\ + __asm mov cl, byte ptr shift\ + __asm ror eax, cl\ + __asm mov value, eax +#define ROR_IMM_MSR \ + {\ + __asm mov eax, opcode\ + __asm and eax, 0xff\ + __asm mov cl, byte ptr shift\ + __asm ror eax, CL\ + __asm mov value, eax\ + } +#define ROR_VALUE \ + {\ + __asm mov cl, byte ptr shift\ + __asm ror dword ptr value, cl\ + } +#define RCR_VALUE \ + {\ + __asm mov cl, byte ptr shift\ + __asm bt word ptr C_FLAG, 0\ + __asm rcr dword ptr value, 1\ + } +#endif +#endif + +#define OP_TST \ + u32 res = reg[base].I & value;\ + N_FLAG = (res & 0x80000000) ? true : false;\ + Z_FLAG = (res) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_TEQ \ + u32 res = reg[base].I ^ value;\ + N_FLAG = (res & 0x80000000) ? true : false;\ + Z_FLAG = (res) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_ORR \ + reg[dest].I = reg[base].I | value; + +#define OP_ORRS \ + reg[dest].I = reg[base].I | value;\ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_MOV \ + reg[dest].I = value; + +#define OP_MOVS \ + reg[dest].I = value;\ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_BIC \ + reg[dest].I = reg[base].I & (~value); + +#define OP_BICS \ + reg[dest].I = reg[base].I & (~value);\ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; + +#define OP_MVN \ + reg[dest].I = ~value; + +#define OP_MVNS \ + reg[dest].I = ~value; \ + N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\ + Z_FLAG = (reg[dest].I) ? false : true;\ + C_FLAG = C_OUT; + +#define CASE_16(BASE) \ + case BASE:\ + case BASE+1:\ + case BASE+2:\ + case BASE+3:\ + case BASE+4:\ + case BASE+5:\ + case BASE+6:\ + case BASE+7:\ + case BASE+8:\ + case BASE+9:\ + case BASE+10:\ + case BASE+11:\ + case BASE+12:\ + case BASE+13:\ + case BASE+14:\ + case BASE+15: + +#define CASE_256(BASE) \ + CASE_16(BASE)\ + CASE_16(BASE+0x10)\ + CASE_16(BASE+0x20)\ + CASE_16(BASE+0x30)\ + CASE_16(BASE+0x40)\ + CASE_16(BASE+0x50)\ + CASE_16(BASE+0x60)\ + CASE_16(BASE+0x70)\ + CASE_16(BASE+0x80)\ + CASE_16(BASE+0x90)\ + CASE_16(BASE+0xa0)\ + CASE_16(BASE+0xb0)\ + CASE_16(BASE+0xc0)\ + CASE_16(BASE+0xd0)\ + CASE_16(BASE+0xe0)\ + CASE_16(BASE+0xf0) + +#define LOGICAL_DATA_OPCODE(OPCODE, OPCODE2, BASE) \ + case BASE: \ + case BASE+8:\ + {\ + /* OP Rd,Rb,Rm LSL # */ \ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + \ + if(shift) {\ + LOGICAL_LSL_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+2:\ + case BASE+10:\ + {\ + /* OP Rd,Rb,Rm LSR # */ \ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_LSR_REG\ + } else {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false;\ + }\ + \ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+4:\ + case BASE+12:\ + {\ + /* OP Rd,Rb,Rm ASR # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ASR_REG\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + C_OUT = true;\ + } else {\ + value = 0;\ + C_OUT = false;\ + } \ + }\ + \ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+6:\ + case BASE+14:\ + {\ + /* OP Rd,Rb,Rm ROR # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ROR_REG\ + } else {\ + LOGICAL_RRX_REG\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+1:\ + {\ + /* OP Rd,Rb,Rm LSL Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false);\ + } else if(shift < 32) {\ + LOGICAL_LSL_REG\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+3:\ + {\ + /* OP Rd,Rb,Rm LSR Rs */ \ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false);\ + } else if(shift < 32) {\ + LOGICAL_LSR_REG\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+5:\ + {\ + /* OP Rd,Rb,Rm ASR Rs */ \ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift < 32) {\ + if(shift) {\ + LOGICAL_ASR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + C_OUT = true;\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+7:\ + {\ + /* OP Rd,Rb,Rm ROR Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + shift &= 0x1f;\ + if(shift) {\ + LOGICAL_ROR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + C_OUT = (value & 0x80000000 ? true : false);\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + C_OUT = (value & 0x80000000 ? true : false);\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+0x200:\ + case BASE+0x201:\ + case BASE+0x202:\ + case BASE+0x203:\ + case BASE+0x204:\ + case BASE+0x205:\ + case BASE+0x206:\ + case BASE+0x207:\ + case BASE+0x208:\ + case BASE+0x209:\ + case BASE+0x20a:\ + case BASE+0x20b:\ + case BASE+0x20c:\ + case BASE+0x20d:\ + case BASE+0x20e:\ + case BASE+0x20f:\ + {\ + int shift = (opcode & 0xF00) >> 7;\ + int base = (opcode >> 16) & 0x0F;\ + int dest = (opcode >> 12) & 0x0F;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ROR_IMM\ + } else {\ + value = opcode & 0xff;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break; + +#define LOGICAL_DATA_OPCODE_WITHOUT_base(OPCODE, OPCODE2, BASE) \ + case BASE: \ + case BASE+8:\ + {\ + /* OP Rd,Rb,Rm LSL # */ \ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + \ + if(shift) {\ + LOGICAL_LSL_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+2:\ + case BASE+10:\ + {\ + /* OP Rd,Rb,Rm LSR # */ \ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_LSR_REG\ + } else {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false;\ + }\ + \ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+4:\ + case BASE+12:\ + {\ + /* OP Rd,Rb,Rm ASR # */\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ASR_REG\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + C_OUT = true;\ + } else {\ + value = 0;\ + C_OUT = false;\ + } \ + }\ + \ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+6:\ + case BASE+14:\ + {\ + /* OP Rd,Rb,Rm ROR # */\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ROR_REG\ + } else {\ + LOGICAL_RRX_REG\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+1:\ + {\ + /* OP Rd,Rb,Rm LSL Rs */\ + clockTicks++;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false);\ + } else if(shift < 32) {\ + LOGICAL_LSL_REG\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+3:\ + {\ + /* OP Rd,Rb,Rm LSR Rs */ \ + clockTicks++;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false);\ + } else if(shift < 32) {\ + LOGICAL_LSR_REG\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+5:\ + {\ + /* OP Rd,Rb,Rm ASR Rs */ \ + clockTicks++;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift < 32) {\ + if(shift) {\ + LOGICAL_ASR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + C_OUT = true;\ + } else {\ + value = 0;\ + C_OUT = false;\ + }\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+7:\ + {\ + /* OP Rd,Rb,Rm ROR Rs */\ + clockTicks++;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + shift &= 0x1f;\ + if(shift) {\ + LOGICAL_ROR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + C_OUT = (value & 0x80000000 ? true : false);\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + C_OUT = (value & 0x80000000 ? true : false);\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+0x200:\ + case BASE+0x201:\ + case BASE+0x202:\ + case BASE+0x203:\ + case BASE+0x204:\ + case BASE+0x205:\ + case BASE+0x206:\ + case BASE+0x207:\ + case BASE+0x208:\ + case BASE+0x209:\ + case BASE+0x20a:\ + case BASE+0x20b:\ + case BASE+0x20c:\ + case BASE+0x20d:\ + case BASE+0x20e:\ + case BASE+0x20f:\ + {\ + int shift = (opcode & 0xF00) >> 7;\ + int dest = (opcode >> 12) & 0x0F;\ + bool C_OUT = C_FLAG;\ + u32 value;\ + if(shift) {\ + LOGICAL_ROR_IMM\ + } else {\ + value = opcode & 0xff;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break; + +#define ARITHMETIC_DATA_OPCODE(OPCODE, OPCODE2, BASE) \ + case BASE:\ + case BASE+8:\ + {\ + /* OP Rd,Rb,Rm LSL # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + ARITHMETIC_LSL_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+2:\ + case BASE+10:\ + {\ + /* OP Rd,Rb,Rm LSR # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + ARITHMETIC_LSR_REG\ + } else {\ + value = 0;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+4:\ + case BASE+12:\ + {\ + /* OP Rd,Rb,Rm ASR # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + ARITHMETIC_ASR_REG\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + } else value = 0;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+6:\ + case BASE+14:\ + {\ + /* OP Rd,Rb,Rm ROR # */\ + int base = (opcode >> 16) & 0x0F;\ + int shift = (opcode >> 7) & 0x1F;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + ARITHMETIC_ROR_REG\ + } else {\ + ARITHMETIC_RRX_REG\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+1:\ + {\ + /* OP Rd,Rb,Rm LSL Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + } else if(shift < 32) {\ + ARITHMETIC_LSL_REG\ + } else value = 0;\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+3:\ + {\ + /* OP Rd,Rb,Rm LSR Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + if(shift == 32) {\ + value = 0;\ + } else if(shift < 32) {\ + ARITHMETIC_LSR_REG\ + } else value = 0;\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+5:\ + {\ + /* OP Rd,Rb,Rm ASR Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift < 32) {\ + if(shift) {\ + ARITHMETIC_ASR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + } else {\ + if(reg[opcode & 0x0F].I & 0x80000000){\ + value = 0xFFFFFFFF;\ + } else value = 0;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+7:\ + {\ + /* OP Rd,Rb,Rm ROR Rs */\ + clockTicks++;\ + int base = (opcode >> 16) & 0x0F;\ + int shift = reg[(opcode >> 8)&15].B.B0;\ + int dest = (opcode>>12) & 15;\ + u32 value;\ + if(shift) {\ + shift &= 0x1f;\ + if(shift) {\ + ARITHMETIC_ROR_REG\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + } else {\ + value = reg[opcode & 0x0F].I;\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break;\ + case BASE+0x200:\ + case BASE+0x201:\ + case BASE+0x202:\ + case BASE+0x203:\ + case BASE+0x204:\ + case BASE+0x205:\ + case BASE+0x206:\ + case BASE+0x207:\ + case BASE+0x208:\ + case BASE+0x209:\ + case BASE+0x20a:\ + case BASE+0x20b:\ + case BASE+0x20c:\ + case BASE+0x20d:\ + case BASE+0x20e:\ + case BASE+0x20f:\ + {\ + int shift = (opcode & 0xF00) >> 7;\ + int base = (opcode >> 16) & 0x0F;\ + int dest = (opcode >> 12) & 0x0F;\ + u32 value;\ + {\ + ARITHMETIC_ROR_IMM\ + }\ + if(dest == 15) {\ + OPCODE2\ + /* todo */\ + if(opcode & 0x00100000) {\ + clockTicks++;\ + CPUSwitchMode(reg[17].I & 0x1f, false);\ + }\ + if(armState) {\ + reg[15].I &= 0xFFFFFFFC;\ + armNextPC = reg[15].I;\ + reg[15].I += 4;\ + } else {\ + reg[15].I &= 0xFFFFFFFE;\ + armNextPC = reg[15].I;\ + reg[15].I += 2;\ + }\ + } else {\ + OPCODE \ + }\ + }\ + break; + + u32 opcode = CPUReadMemoryQuick(armNextPC); + + clockTicks = memoryWaitFetch32[(armNextPC >> 24) & 15]; + +#ifndef FINAL_VERSION + if(armNextPC == stop) { + armNextPC++; + } +#endif + + armNextPC = reg[15].I; + reg[15].I += 4; + int cond = opcode >> 28; + // suggested optimization for frequent cases + bool cond_res; + if(cond == 0x0e) { + cond_res = true; + } else { + switch(cond) { + case 0x00: // EQ + cond_res = Z_FLAG; + break; + case 0x01: // NE + cond_res = !Z_FLAG; + break; + case 0x02: // CS + cond_res = C_FLAG; + break; + case 0x03: // CC + cond_res = !C_FLAG; + break; + case 0x04: // MI + cond_res = N_FLAG; + break; + case 0x05: // PL + cond_res = !N_FLAG; + break; + case 0x06: // VS + cond_res = V_FLAG; + break; + case 0x07: // VC + cond_res = !V_FLAG; + break; + case 0x08: // HI + cond_res = C_FLAG && !Z_FLAG; + break; + case 0x09: // LS + cond_res = !C_FLAG || Z_FLAG; + break; + case 0x0A: // GE + cond_res = N_FLAG == V_FLAG; + break; + case 0x0B: // LT + cond_res = N_FLAG != V_FLAG; + break; + case 0x0C: // GT + cond_res = !Z_FLAG &&(N_FLAG == V_FLAG); + break; + case 0x0D: // LE + cond_res = Z_FLAG || (N_FLAG != V_FLAG); + break; + case 0x0E: + cond_res = true; + break; + case 0x0F: + default: + // ??? + cond_res = false; + break; + } + } + +if(cond_res) { + switch(((opcode>>16)&0xFF0) | ((opcode>>4)&0x0F)) { + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND, OP_AND, 0x000); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_ANDS, OP_AND, 0x010); + case 0x009: + { + // MUL Rd, Rm, Rs + int dest = (opcode >> 16) & 0x0F; + int mult = (opcode & 0x0F); + u32 rs = reg[(opcode >> 8) & 0x0F].I; + reg[dest].I = reg[mult].I * rs; + if(((s32)rs)<0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 2; + else if ((rs & 0xFFFF0000) == 0) + clockTicks += 3; + else if ((rs & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + case 0x019: + { + // MULS Rd, Rm, Rs + int dest = (opcode >> 16) & 0x0F; + int mult = (opcode & 0x0F); + u32 rs = reg[(opcode >> 8) & 0x0F].I; + reg[dest].I = reg[mult].I * rs; + N_FLAG = (reg[dest].I & 0x80000000) ? true : false; + Z_FLAG = (reg[dest].I) ? false : true; + if(((s32)rs)<0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 2; + else if ((rs & 0xFFFF0000) == 0) + clockTicks += 3; + else if ((rs & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + case 0x00b: + case 0x02b: + { + // STRH Rd, [Rn], -Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + address -= offset; + reg[base].I = address; + } + break; + case 0x04b: + case 0x06b: + { + // STRH Rd, [Rn], #-offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + address -= offset; + reg[base].I = address; + } + break; + case 0x08b: + case 0x0ab: + { + // STRH Rd, [Rn], Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + address += offset; + reg[base].I = address; + } + break; + case 0x0cb: + case 0x0eb: + { + // STRH Rd, [Rn], #offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + address += offset; + reg[base].I = address; + } + break; + case 0x10b: + { + // STRH Rd, [Rn, -Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + } + break; + case 0x12b: + { + // STRH Rd, [Rn, -Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + reg[base].I = address; + } + break; + case 0x14b: + { + // STRH Rd, [Rn, -#offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + } + break; + case 0x16b: + { + // STRH Rd, [Rn, -#offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + reg[base].I = address; + } + break; + case 0x18b: + { + // STRH Rd, [Rn, Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + } + break; + case 0x1ab: + { + // STRH Rd, [Rn, Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + reg[base].I = address; + } + break; + case 0x1cb: + { + // STRH Rd, [Rn, #offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + } + break; + case 0x1eb: + { + // STRH Rd, [Rn, #offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 4 + CPUUpdateTicksAccess16(address); + CPUWriteHalfWord(address, reg[dest].W.W0); + reg[base].I = address; + } + break; + case 0x01b: + case 0x03b: + { + // LDRH Rd, [Rn], -Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x05b: + case 0x07b: + { + // LDRH Rd, [Rn], #-offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x09b: + case 0x0bb: + { + // LDRH Rd, [Rn], Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x0db: + case 0x0fb: + { + // LDRH Rd, [Rn], #offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x11b: + { + // LDRH Rd, [Rn, -Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + } + break; + case 0x13b: + { + // LDRH Rd, [Rn, -Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x15b: + { + // LDRH Rd, [Rn, -#offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + } + break; + case 0x17b: + { + // LDRH Rd, [Rn, -#offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x19b: + { + // LDRH Rd, [Rn, Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + } + break; + case 0x1bb: + { + // LDRH Rd, [Rn, Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x1db: + { + // LDRH Rd, [Rn, #offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + } + break; + case 0x1fb: + { + // LDRH Rd, [Rn, #offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = CPUReadHalfWord(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x01d: + case 0x03d: + { + // LDRSB Rd, [Rn], -Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x05d: + case 0x07d: + { + // LDRSB Rd, [Rn], #-offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x09d: + case 0x0bd: + { + // LDRSB Rd, [Rn], Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x0dd: + case 0x0fd: + { + // LDRSB Rd, [Rn], #offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x11d: + { + // LDRSB Rd, [Rn, -Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + } + break; + case 0x13d: + { + // LDRSB Rd, [Rn, -Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x15d: + { + // LDRSB Rd, [Rn, -#offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + } + break; + case 0x17d: + { + // LDRSB Rd, [Rn, -#offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x19d: + { + // LDRSB Rd, [Rn, Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + } + break; + case 0x1bd: + { + // LDRSB Rd, [Rn, Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x1dd: + { + // LDRSB Rd, [Rn, #offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + } + break; + case 0x1fd: + { + // LDRSB Rd, [Rn, #offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s8)CPUReadByte(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x01f: + case 0x03f: + { + // LDRSH Rd, [Rn], -Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x05f: + case 0x07f: + { + // LDRSH Rd, [Rn], #-offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) { + address -= offset; + reg[base].I = address; + } + } + break; + case 0x09f: + case 0x0bf: + { + // LDRSH Rd, [Rn], Rm + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x0df: + case 0x0ff: + { + // LDRSH Rd, [Rn], #offset + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I; + int offset = (opcode & 0x0F) | ((opcode >> 4) & 0xF0); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) { + address += offset; + reg[base].I = address; + } + } + break; + case 0x11f: + { + // LDRSH Rd, [Rn, -Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + } + break; + case 0x13f: + { + // LDRSH Rd, [Rn, -Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x15f: + { + // LDRSH Rd, [Rn, -#offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + } + break; + case 0x17f: + { + // LDRSH Rd, [Rn, -#offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I - ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x19f: + { + // LDRSH Rd, [Rn, Rm] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + } + break; + case 0x1bf: + { + // LDRSH Rd, [Rn, Rm]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + reg[opcode & 0x0F].I; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) + reg[base].I = address; + } + break; + case 0x1df: + { + // LDRSH Rd, [Rn, #offset] + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + } + break; + case 0x1ff: + { + // LDRSH Rd, [Rn, #offset]! + int base = (opcode >> 16) & 0x0F; + int dest = (opcode >> 12) & 0x0F; + u32 address = reg[base].I + ((opcode & 0x0F)|((opcode>>4)&0xF0)); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + reg[dest].I = (s16)CPUReadHalfWordSigned(address); + if(dest != base) + reg[base].I = address; + } + break; + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EOR, OP_EOR, 0x020); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EORS, OP_EOR, 0x030); + case 0x029: + { + // MLA Rd, Rm, Rs, Rn + int dest = (opcode >> 16) & 0x0F; + int mult = (opcode & 0x0F); + u32 rs = reg[(opcode >> 8) & 0x0F].I; + reg[dest].I = reg[mult].I * rs + reg[(opcode>>12)&0x0f].I; + if(((s32)rs)<0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 3; + else if ((rs & 0xFFFF0000) == 0) + clockTicks += 4; + else if ((rs & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + case 0x039: + { + // MLAS Rd, Rm, Rs, Rn + int dest = (opcode >> 16) & 0x0F; + int mult = (opcode & 0x0F); + u32 rs = reg[(opcode >> 8) & 0x0F].I; + reg[dest].I = reg[mult].I * rs + reg[(opcode>>12)&0x0f].I; + N_FLAG = (reg[dest].I & 0x80000000) ? true : false; + Z_FLAG = (reg[dest].I) ? false : true; + if(((s32)rs)<0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 3; + else if ((rs & 0xFFFF0000) == 0) + clockTicks += 4; + else if ((rs & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + ARITHMETIC_DATA_OPCODE(OP_SUB, OP_SUB, 0x040); + ARITHMETIC_DATA_OPCODE(OP_SUBS, OP_SUB, 0x050); + ARITHMETIC_DATA_OPCODE(OP_RSB, OP_RSB, 0x060); + ARITHMETIC_DATA_OPCODE(OP_RSBS, OP_RSB, 0x070); + ARITHMETIC_DATA_OPCODE(OP_ADD, OP_ADD, 0x080); + ARITHMETIC_DATA_OPCODE(OP_ADDS, OP_ADD, 0x090); + case 0x089: + { + // UMULL RdLo, RdHi, Rn, Rs + u32 umult = reg[(opcode & 0x0F)].I; + u32 usource = reg[(opcode >> 8) & 0x0F].I; + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u64 uTemp = ((u64)umult)*((u64)usource); + reg[destLo].I = (u32)uTemp; + reg[destHi].I = (u32)(uTemp >> 32); + if ((usource & 0xFFFFFF00) == 0) + clockTicks += 2; + else if ((usource & 0xFFFF0000) == 0) + clockTicks += 3; + else if ((usource & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + case 0x099: + { + // UMULLS RdLo, RdHi, Rn, Rs + u32 umult = reg[(opcode & 0x0F)].I; + u32 usource = reg[(opcode >> 8) & 0x0F].I; + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u64 uTemp = ((u64)umult)*((u64)usource); + reg[destLo].I = (u32)uTemp; + reg[destHi].I = (u32)(uTemp >> 32); + Z_FLAG = (uTemp) ? false : true; + N_FLAG = (reg[destHi].I & 0x80000000) ? true : false; + if ((usource & 0xFFFFFF00) == 0) + clockTicks += 2; + else if ((usource & 0xFFFF0000) == 0) + clockTicks += 3; + else if ((usource & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + ARITHMETIC_DATA_OPCODE(OP_ADC, OP_ADC, 0x0a0); + ARITHMETIC_DATA_OPCODE(OP_ADCS, OP_ADC, 0x0b0); + case 0x0a9: + { + // UMLAL RdLo, RdHi, Rn, Rs + u32 umult = reg[(opcode & 0x0F)].I; + u32 usource = reg[(opcode >> 8) & 0x0F].I; + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u64 uTemp = (u64)reg[destHi].I; + uTemp <<= 32; + uTemp |= (u64)reg[destLo].I; + uTemp += ((u64)umult)*((u64)usource); + reg[destLo].I = (u32)uTemp; + reg[destHi].I = (u32)(uTemp >> 32); + if ((usource & 0xFFFFFF00) == 0) + clockTicks += 3; + else if ((usource & 0xFFFF0000) == 0) + clockTicks += 4; + else if ((usource & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + case 0x0b9: + { + // UMLALS RdLo, RdHi, Rn, Rs + u32 umult = reg[(opcode & 0x0F)].I; + u32 usource = reg[(opcode >> 8) & 0x0F].I; + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u64 uTemp = (u64)reg[destHi].I; + uTemp <<= 32; + uTemp |= (u64)reg[destLo].I; + uTemp += ((u64)umult)*((u64)usource); + reg[destLo].I = (u32)uTemp; + reg[destHi].I = (u32)(uTemp >> 32); + Z_FLAG = (uTemp) ? false : true; + N_FLAG = (reg[destHi].I & 0x80000000) ? true : false; + if ((usource & 0xFFFFFF00) == 0) + clockTicks += 3; + else if ((usource & 0xFFFF0000) == 0) + clockTicks += 4; + else if ((usource & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + ARITHMETIC_DATA_OPCODE(OP_SBC, OP_SBC, 0x0c0); + ARITHMETIC_DATA_OPCODE(OP_SBCS, OP_SBC, 0x0d0); + case 0x0c9: + { + // SMULL RdLo, RdHi, Rm, Rs + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u32 rs = reg[(opcode >> 8) & 0x0F].I; + s64 m = (s32)reg[(opcode & 0x0F)].I; + s64 s = (s32)rs; + s64 sTemp = m*s; + reg[destLo].I = (u32)sTemp; + reg[destHi].I = (u32)(sTemp >> 32); + if(((s32)rs) < 0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 2; + else if((rs & 0xFFFF0000) == 0) + clockTicks += 3; + else if((rs & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + case 0x0d9: + { + // SMULLS RdLo, RdHi, Rm, Rs + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u32 rs = reg[(opcode >> 8) & 0x0F].I; + s64 m = (s32)reg[(opcode & 0x0F)].I; + s64 s = (s32)rs; + s64 sTemp = m*s; + reg[destLo].I = (u32)sTemp; + reg[destHi].I = (u32)(sTemp >> 32); + Z_FLAG = (sTemp) ? false : true; + N_FLAG = (sTemp < 0) ? true : false; + if(((s32)rs) < 0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 2; + else if((rs & 0xFFFF0000) == 0) + clockTicks += 3; + else if((rs & 0xFF000000) == 0) + clockTicks += 4; + else + clockTicks += 5; + } + break; + ARITHMETIC_DATA_OPCODE(OP_RSC, OP_RSC, 0x0e0); + ARITHMETIC_DATA_OPCODE(OP_RSCS, OP_RSC, 0x0f0); + case 0x0e9: + { + // SMLAL RdLo, RdHi, Rm, Rs + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u32 rs = reg[(opcode >> 8) & 0x0F].I; + s64 m = (s32)reg[(opcode & 0x0F)].I; + s64 s = (s32)rs; + s64 sTemp = (u64)reg[destHi].I; + sTemp <<= 32; + sTemp |= (u64)reg[destLo].I; + sTemp += m*s; + reg[destLo].I = (u32)sTemp; + reg[destHi].I = (u32)(sTemp >> 32); + if(((s32)rs) < 0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 3; + else if((rs & 0xFFFF0000) == 0) + clockTicks += 4; + else if((rs & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + case 0x0f9: + { + // SMLALS RdLo, RdHi, Rm, Rs + int destLo = (opcode >> 12) & 0x0F; + int destHi = (opcode >> 16) & 0x0F; + u32 rs = reg[(opcode >> 8) & 0x0F].I; + s64 m = (s32)reg[(opcode & 0x0F)].I; + s64 s = (s32)rs; + s64 sTemp = (u64)reg[destHi].I; + sTemp <<= 32; + sTemp |= (u64)reg[destLo].I; + sTemp += m*s; + reg[destLo].I = (u32)sTemp; + reg[destHi].I = (u32)(sTemp >> 32); + Z_FLAG = (sTemp) ? false : true; + N_FLAG = (sTemp < 0) ? true : false; + if(((s32)rs) < 0) + rs = ~rs; + if((rs & 0xFFFFFF00) == 0) + clockTicks += 3; + else if((rs & 0xFFFF0000) == 0) + clockTicks += 4; + else if((rs & 0xFF000000) == 0) + clockTicks += 5; + else + clockTicks += 6; + } + break; + LOGICAL_DATA_OPCODE(OP_TST, OP_TST, 0x110); + case 0x100: + // MRS Rd, CPSR + // TODO: check if right instruction.... + CPUUpdateCPSR(); + reg[(opcode >> 12) & 0x0F].I = reg[16].I; + break; + case 0x109: + { + // SWP Rd, Rm, [Rn] + u32 address = reg[(opcode >> 16) & 15].I; + u32 temp = CPUReadMemory(address); + CPUWriteMemory(address, reg[opcode&15].I); + reg[(opcode >> 12) & 15].I = temp; + } + break; + LOGICAL_DATA_OPCODE(OP_TEQ, OP_TEQ, 0x130); + case 0x120: + { + // MSR CPSR_fields, Rm + CPUUpdateCPSR(); + u32 value = reg[opcode & 15].I; + u32 newValue = reg[16].I; + if(armMode > 0x10) { + if(opcode & 0x00010000) + newValue = (newValue & 0xFFFFFF00) | (value & 0x000000FF); + if(opcode & 0x00020000) + newValue = (newValue & 0xFFFF00FF) | (value & 0x0000FF00); + if(opcode & 0x00040000) + newValue = (newValue & 0xFF00FFFF) | (value & 0x00FF0000); + } + if(opcode & 0x00080000) + newValue = (newValue & 0x00FFFFFF) | (value & 0xFF000000); + newValue |= 0x10; + CPUSwitchMode(newValue & 0x1f, false); + reg[16].I = newValue; + CPUUpdateFlags(); + } + break; + case 0x121: + { + // BX Rm + // TODO: check if right instruction... + clockTicks += 3; + int base = opcode & 0x0F; + armState = reg[base].I & 1 ? false : true; + if(armState) { + reg[15].I = reg[base].I & 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } else { + reg[15].I = reg[base].I & 0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + } + } + break; + ARITHMETIC_DATA_OPCODE(OP_CMP, OP_CMP, 0x150); + case 0x140: + // MRS Rd, SPSR + // TODO: check if right instruction... + reg[(opcode >> 12) & 0x0F].I = reg[17].I; + break; + case 0x149: + { + // SWPB Rd, Rm, [Rn] + u32 address = reg[(opcode >> 16) & 15].I; + u32 temp = CPUReadByte(address); + CPUWriteByte(address, reg[opcode&15].B.B0); + reg[(opcode>>12)&15].I = temp; + } + break; + ARITHMETIC_DATA_OPCODE(OP_CMN, OP_CMN, 0x170); + case 0x160: + { + // MSR SPSR_fields, Rm + u32 value = reg[opcode & 15].I; + if(armMode > 0x10 && armMode < 0x1f) { + if(opcode & 0x00010000) + reg[17].I = (reg[17].I & 0xFFFFFF00) | (value & 0x000000FF); + if(opcode & 0x00020000) + reg[17].I = (reg[17].I & 0xFFFF00FF) | (value & 0x0000FF00); + if(opcode & 0x00040000) + reg[17].I = (reg[17].I & 0xFF00FFFF) | (value & 0x00FF0000); + if(opcode & 0x00080000) + reg[17].I = (reg[17].I & 0x00FFFFFF) | (value & 0xFF000000); + } + } + break; + LOGICAL_DATA_OPCODE (OP_ORR, OP_ORR, 0x180); + LOGICAL_DATA_OPCODE (OP_ORRS, OP_ORR, 0x190); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOV, OP_MOV, 0x1a0); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOVS, OP_MOV, 0x1b0); + LOGICAL_DATA_OPCODE (OP_BIC, OP_BIC, 0x1c0); + LOGICAL_DATA_OPCODE (OP_BICS, OP_BIC, 0x1d0); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVN, OP_MVN, 0x1e0); + LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVNS, OP_MVN, 0x1f0); +#ifdef BKPT_SUPPORT + case 0x127: + case 0x7ff: // for GDB support + extern void (*dbgSignal)(int,int); + reg[15].I -= 4; + armNextPC -= 4; + dbgSignal(5, (opcode & 0x0f)|((opcode>>4) & 0xfff0)); + return; +#endif + case 0x320: + case 0x321: + case 0x322: + case 0x323: + case 0x324: + case 0x325: + case 0x326: + case 0x327: + case 0x328: + case 0x329: + case 0x32a: + case 0x32b: + case 0x32c: + case 0x32d: + case 0x32e: + case 0x32f: + { + // MSR CPSR_fields, # + CPUUpdateCPSR(); + u32 value = opcode & 0xFF; + int shift = (opcode & 0xF00) >> 7; + if(shift) { + ROR_IMM_MSR; + } + u32 newValue = reg[16].I; + if(armMode > 0x10) { + if(opcode & 0x00010000) + newValue = (newValue & 0xFFFFFF00) | (value & 0x000000FF); + if(opcode & 0x00020000) + newValue = (newValue & 0xFFFF00FF) | (value & 0x0000FF00); + if(opcode & 0x00040000) + newValue = (newValue & 0xFF00FFFF) | (value & 0x00FF0000); + } + if(opcode & 0x00080000) + newValue = (newValue & 0x00FFFFFF) | (value & 0xFF000000); + + newValue |= 0x10; + + CPUSwitchMode(newValue & 0x1f, false); + reg[16].I = newValue; + CPUUpdateFlags(); + } + break; + case 0x360: + case 0x361: + case 0x362: + case 0x363: + case 0x364: + case 0x365: + case 0x366: + case 0x367: + case 0x368: + case 0x369: + case 0x36a: + case 0x36b: + case 0x36c: + case 0x36d: + case 0x36e: + case 0x36f: + { + // MSR SPSR_fields, # + if(armMode > 0x10 && armMode < 0x1f) { + u32 value = opcode & 0xFF; + int shift = (opcode & 0xF00) >> 7; + if(shift) { + ROR_IMM_MSR; + } + if(opcode & 0x00010000) + reg[17].I = (reg[17].I & 0xFFFFFF00) | (value & 0x000000FF); + if(opcode & 0x00020000) + reg[17].I = (reg[17].I & 0xFFFF00FF) | (value & 0x0000FF00); + if(opcode & 0x00040000) + reg[17].I = (reg[17].I & 0xFF00FFFF) | (value & 0x00FF0000); + if(opcode & 0x00080000) + reg[17].I = (reg[17].I & 0x00FFFFFF) | (value & 0xFF000000); + } + } + break; + CASE_16(0x400) + // T versions shouldn't be different on GBA + CASE_16(0x420) + { + // STR Rd, [Rn], -# + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x480) + // T versions shouldn't be different on GBA + CASE_16(0x4a0) + { + // STR Rd, [Rn], # + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x500) + { + // STR Rd, [Rn, -#] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x520) + { + // STR Rd, [Rn, -#]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x580) + { + // STR Rd, [Rn, #] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x5a0) + { + // STR Rd, [Rn, #]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x410) + { + // LDR Rd, [Rn], -# + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I -= offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x430) + { + // LDRT Rd, [Rn], -# + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I -= offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x490) + { + // LDR Rd, [Rn], # + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I += offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x4b0) + { + // LDRT Rd, [Rn], # + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I += offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + } + break; + CASE_16(0x510) + { + // LDR Rd, [Rn, -#] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x530) + { + // LDR Rd, [Rn, -#]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x590) + { + // LDR Rd, [Rn, #] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x5b0) + { + // LDR Rd, [Rn, #]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x440) + // T versions shouldn't be different on GBA + CASE_16(0x460) + { + // STRB Rd, [Rn], -# + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x4c0) + // T versions shouldn't be different on GBA + CASE_16(0x4e0) + // STRB Rd, [Rn], # + { + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x540) + { + // STRB Rd, [Rn, -#] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x560) + { + // STRB Rd, [Rn, -#]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x5c0) + { + // STRB Rd, [Rn, #] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x5e0) + { + // STRB Rd, [Rn, #]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x450) + // T versions shouldn't be different + CASE_16(0x470) + { + // LDRB Rd, [Rn], -# + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I -= offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x4d0) + CASE_16(0x4f0) // T versions should not be different + { + // LDRB Rd, [Rn], # + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I += offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x550) + { + // LDRB Rd, [Rn, -#] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x570) + { + // LDRB Rd, [Rn, -#]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x5d0) + { + // LDRB Rd, [Rn, #] + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + CASE_16(0x5f0) + { + // LDRB Rd, [Rn, #]! + int offset = opcode & 0xFFF; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x600: + case 0x608: + // T versions are the same + case 0x620: + case 0x628: + { + // STR Rd, [Rn], -Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x602: + case 0x60a: + // T versions are the same + case 0x622: + case 0x62a: + { + // STR Rd, [Rn], -Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x604: + case 0x60c: + // T versions are the same + case 0x624: + case 0x62c: + { + // STR Rd, [Rn], -Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x606: + case 0x60e: + // T versions are the same + case 0x626: + case 0x62e: + { + // STR Rd, [Rn], -Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address - value; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x680: + case 0x688: + // T versions are the same + case 0x6a0: + case 0x6a8: + { + // STR Rd, [Rn], Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x682: + case 0x68a: + // T versions are the same + case 0x6a2: + case 0x6aa: + { + // STR Rd, [Rn], Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x684: + case 0x68c: + // T versions are the same + case 0x6a4: + case 0x6ac: + { + // STR Rd, [Rn], Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x686: + case 0x68e: + // T versions are the same + case 0x6a6: + case 0x6ae: + { + // STR Rd, [Rn], Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteMemory(address, reg[dest].I); + reg[base].I = address + value; + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x700: + case 0x708: + { + // STR Rd, [Rn, -Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x702: + case 0x70a: + { + // STR Rd, [Rn, -Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x704: + case 0x70c: + { + // STR Rd, [Rn, -Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x706: + case 0x70e: + { + // STR Rd, [Rn, -Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x720: + case 0x728: + { + // STR Rd, [Rn, -Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x722: + case 0x72a: + { + // STR Rd, [Rn, -Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x724: + case 0x72c: + { + // STR Rd, [Rn, -Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x726: + case 0x72e: + { + // STR Rd, [Rn, -Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x780: + case 0x788: + { + // STR Rd, [Rn, Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x782: + case 0x78a: + { + // STR Rd, [Rn, Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x784: + case 0x78c: + { + // STR Rd, [Rn, Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x786: + case 0x78e: + { + // STR Rd, [Rn, Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x7a0: + case 0x7a8: + { + // STR Rd, [Rn, Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x7a2: + case 0x7aa: + { + // STR Rd, [Rn, Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x7a4: + case 0x7ac: + { + // STR Rd, [Rn, Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x7a6: + case 0x7ae: + { + // STR Rd, [Rn, Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[base].I = address; + CPUWriteMemory(address, reg[dest].I); + clockTicks += 2 + CPUUpdateTicksAccess32(address); + } + break; + case 0x610: + case 0x618: + // T versions are the same + case 0x630: + case 0x638: + { + // LDR Rd, [Rn], -Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x612: + case 0x61a: + // T versions are the same + case 0x632: + case 0x63a: + { + // LDR Rd, [Rn], -Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x614: + case 0x61c: + // T versions are the same + case 0x634: + case 0x63c: + { + // LDR Rd, [Rn], -Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x616: + case 0x61e: + // T versions are the same + case 0x636: + case 0x63e: + { + // LDR Rd, [Rn], -Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address - value; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x690: + case 0x698: + // T versions are the same + case 0x6b0: + case 0x6b8: + { + // LDR Rd, [Rn], Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x692: + case 0x69a: + // T versions are the same + case 0x6b2: + case 0x6ba: + { + // LDR Rd, [Rn], Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x694: + case 0x69c: + // T versions are the same + case 0x6b4: + case 0x6bc: + { + // LDR Rd, [Rn], Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x696: + case 0x69e: + // T versions are the same + case 0x6b6: + case 0x6be: + { + // LDR Rd, [Rn], Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address + value; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x710: + case 0x718: + { + // LDR Rd, [Rn, -Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x712: + case 0x71a: + { + // LDR Rd, [Rn, -Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x714: + case 0x71c: + { + // LDR Rd, [Rn, -Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x716: + case 0x71e: + { + // LDR Rd, [Rn, -Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x730: + case 0x738: + { + // LDR Rd, [Rn, -Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x732: + case 0x73a: + { + // LDR Rd, [Rn, -Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x734: + case 0x73c: + { + // LDR Rd, [Rn, -Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x736: + case 0x73e: + { + // LDR Rd, [Rn, -Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x790: + case 0x798: + { + // LDR Rd, [Rn, Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x792: + case 0x79a: + { + // LDR Rd, [Rn, Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x794: + case 0x79c: + { + // LDR Rd, [Rn, Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x796: + case 0x79e: + { + // LDR Rd, [Rn, Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[dest].I = CPUReadMemory(address); + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x7b0: + case 0x7b8: + { + // LDR Rd, [Rn, Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x7b2: + case 0x7ba: + { + // LDR Rd, [Rn, Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x7b4: + case 0x7bc: + { + // LDR Rd, [Rn, Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x7b6: + case 0x7be: + { + // LDR Rd, [Rn, Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[dest].I = CPUReadMemory(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess32(address); + if(dest == 15) { + clockTicks += 2; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + case 0x640: + case 0x648: + // T versions are the same + case 0x660: + case 0x668: + { + // STRB Rd, [Rn], -Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x642: + case 0x64a: + // T versions are the same + case 0x662: + case 0x66a: + { + // STRB Rd, [Rn], -Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x644: + case 0x64c: + // T versions are the same + case 0x664: + case 0x66c: + { + // STRB Rd, [Rn], -Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address - offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x646: + case 0x64e: + // T versions are the same + case 0x666: + case 0x66e: + { + // STRB Rd, [Rn], -Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address - value; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6c0: + case 0x6c8: + // T versions are the same + case 0x6e0: + case 0x6e8: + { + // STRB Rd, [Rn], Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6c2: + case 0x6ca: + // T versions are the same + case 0x6e2: + case 0x6ea: + { + // STRB Rd, [Rn], Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6c4: + case 0x6cc: + // T versions are the same + case 0x6e4: + case 0x6ec: + { + // STR Rd, [Rn], Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address + offset; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6c6: + case 0x6ce: + // T versions are the same + case 0x6e6: + case 0x6ee: + { + // STRB Rd, [Rn], Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + CPUWriteByte(address, reg[dest].B.B0); + reg[base].I = address + value; + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x740: + case 0x748: + { + // STRB Rd, [Rn, -Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x742: + case 0x74a: + { + // STRB Rd, [Rn, -Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x744: + case 0x74c: + { + // STRB Rd, [Rn, -Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x746: + case 0x74e: + { + // STRB Rd, [Rn, -Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x760: + case 0x768: + { + // STRB Rd, [Rn, -Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x762: + case 0x76a: + { + // STRB Rd, [Rn, -Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x764: + case 0x76c: + { + // STRB Rd, [Rn, -Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x766: + case 0x76e: + { + // STRB Rd, [Rn, -Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7c0: + case 0x7c8: + { + // STRB Rd, [Rn, Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7c2: + case 0x7ca: + { + // STRB Rd, [Rn, Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7c4: + case 0x7cc: + { + // STRB Rd, [Rn, Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7c6: + case 0x7ce: + { + // STRB Rd, [Rn, Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7e0: + case 0x7e8: + { + // STRB Rd, [Rn, Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7e2: + case 0x7ea: + { + // STRB Rd, [Rn, Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7e4: + case 0x7ec: + { + // STRB Rd, [Rn, Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7e6: + case 0x7ee: + { + // STRB Rd, [Rn, Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[base].I = address; + CPUWriteByte(address, reg[dest].B.B0); + clockTicks += 2 + CPUUpdateTicksAccess16(address); + } + break; + case 0x650: + case 0x658: + // T versions are the same + case 0x670: + case 0x678: + { + // LDRB Rd, [Rn], -Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x652: + case 0x65a: + // T versions are the same + case 0x672: + case 0x67a: + { + // LDRB Rd, [Rn], -Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x654: + case 0x65c: + // T versions are the same + case 0x674: + case 0x67c: + { + // LDRB Rd, [Rn], -Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address - offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x656: + case 0x65e: + // T versions are the same + case 0x676: + case 0x67e: + { + // LDRB Rd, [Rn], -Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address - value; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6d0: + case 0x6d8: + // T versions are the same + case 0x6f0: + case 0x6f8: + { + // LDRB Rd, [Rn], Rm, LSL # + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6d2: + case 0x6da: + // T versions are the same + case 0x6f2: + case 0x6fa: + { + // LDRB Rd, [Rn], Rm, LSR # + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6d4: + case 0x6dc: + // T versions are the same + case 0x6f4: + case 0x6fc: + { + // LDRB Rd, [Rn], Rm, ASR # + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address + offset; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x6d6: + case 0x6de: + // T versions are the same + case 0x6f6: + case 0x6fe: + { + // LDRB Rd, [Rn], Rm, ROR # + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address + value; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x750: + case 0x758: + { + // LDRB Rd, [Rn, -Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x752: + case 0x75a: + { + // LDRB Rd, [Rn, -Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x754: + case 0x75c: + { + // LDRB Rd, [Rn, -Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x756: + case 0x75e: + { + // LDRB Rd, [Rn, -Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x770: + case 0x778: + { + // LDRB Rd, [Rn, -Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x772: + case 0x77a: + { + // LDRB Rd, [Rn, -Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x774: + case 0x77c: + { + // LDRB Rd, [Rn, -Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x776: + case 0x77e: + { + // LDRB Rd, [Rn, -Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I - value; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7d0: + case 0x7d8: + { + // LDRB Rd, [Rn, Rm, LSL #] + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7d2: + case 0x7da: + { + // LDRB Rd, [Rn, Rm, LSR #] + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7d4: + case 0x7dc: + { + // LDRB Rd, [Rn, Rm, ASR #] + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7d6: + case 0x7de: + { + // LDRB Rd, [Rn, Rm, ROR #] + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[dest].I = CPUReadByte(address); + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7f0: + case 0x7f8: + { + // LDRB Rd, [Rn, Rm, LSL #]! + int offset = reg[opcode & 15].I << ((opcode>>7)& 31); + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7f2: + case 0x7fa: + { + // LDRB Rd, [Rn, Rm, LSR #]! + int shift = (opcode >> 7) & 31; + int offset = shift ? reg[opcode & 15].I >> shift : 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7f4: + case 0x7fc: + { + // LDRB Rd, [Rn, Rm, ASR #]! + int shift = (opcode >> 7) & 31; + int offset; + if(shift) + offset = (int)((s32)reg[opcode & 15].I >> shift); + else if(reg[opcode & 15].I & 0x80000000) + offset = 0xFFFFFFFF; + else + offset = 0; + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + offset; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; + case 0x7f6: + case 0x7fe: + { + // LDRB Rd, [Rn, Rm, ROR #]! + int shift = (opcode >> 7) & 31; + u32 value = reg[opcode & 15].I; + if(shift) { + ROR_VALUE; + } else { + RCR_VALUE; + } + int dest = (opcode >> 12) & 15; + int base = (opcode >> 16) & 15; + u32 address = reg[base].I + value; + reg[dest].I = CPUReadByte(address); + if(dest != base) + reg[base].I = address; + clockTicks += 3 + CPUUpdateTicksAccess16(address); + } + break; +#define STMW_REG(val,num) \ + if(opcode & (val)) {\ + CPUWriteMemory(address, reg[(num)].I);\ + if(!offset) {\ + reg[base].I = temp;\ + clockTicks += 1 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + } else {\ + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);\ + }\ + address += 4;\ + } +#define STM_REG(val,num) \ + if(opcode & (val)) {\ + CPUWriteMemory(address, reg[(num)].I);\ + if(!offset) {\ + clockTicks += 1 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + } else {\ + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);\ + }\ + address += 4;\ + } + + CASE_16(0x800) + // STMDA Rn, {Rlist} + { + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp + 4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + STM_REG(8192, 13); + STM_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x820) + { + // STMDA Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + STMW_REG(8192, 13); + STMW_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + reg[base].I = temp; + } + } + break; + CASE_16(0x840) + { + // STMDA Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + + if(armMode == 0x11) { + STM_REG(256, R8_FIQ); + STM_REG(512, R9_FIQ); + STM_REG(1024, R10_FIQ); + STM_REG(2048, R11_FIQ); + STM_REG(4096, R12_FIQ); + } else { + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + STM_REG(8192, R13_USR); + STM_REG(16384, R14_USR); + } else { + STM_REG(8192, 13); + STM_REG(16384, 14); + } + + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x860) + { + // STMDA Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + + if(armMode == 0x11) { + STMW_REG(256, R8_FIQ); + STMW_REG(512, R9_FIQ); + STMW_REG(1024, R10_FIQ); + STMW_REG(2048, R11_FIQ); + STMW_REG(4096, R12_FIQ); + } else { + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + STMW_REG(8192, R13_USR); + STMW_REG(16384, R14_USR); + } else { + STMW_REG(8192, 13); + STMW_REG(16384, 14); + } + + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + reg[base].I = temp; + } + } + break; + + CASE_16(0x880) + { + // STMIA Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + STM_REG(8192, 13); + STM_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x8a0) + { + // STMIA Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + + cpuBitsSet[(opcode >> 8) & 255]); + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + STMW_REG(8192, 13); + STMW_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) { + reg[base].I = temp; + clockTicks += 1 + CPUUpdateTicksAccess32(address); + } else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x8c0) + { + // STMIA Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + if(armMode == 0x11) { + STM_REG(256, R8_FIQ); + STM_REG(512, R9_FIQ); + STM_REG(1024, R10_FIQ); + STM_REG(2048, R11_FIQ); + STM_REG(4096, R12_FIQ); + } else { + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + } + if(armMode != 0x10 && armMode != 0x1f) { + STM_REG(8192, R13_USR); + STM_REG(16384, R14_USR); + } else { + STM_REG(8192, 13); + STM_REG(16384, 14); + } + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x8e0) + { + // STMIA Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + + cpuBitsSet[(opcode >> 8) & 255]); + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + if(armMode == 0x11) { + STMW_REG(256, R8_FIQ); + STMW_REG(512, R9_FIQ); + STMW_REG(1024, R10_FIQ); + STMW_REG(2048, R11_FIQ); + STMW_REG(4096, R12_FIQ); + } else { + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + } + if(armMode != 0x10 && armMode != 0x1f) { + STMW_REG(8192, R13_USR); + STMW_REG(16384, R14_USR); + } else { + STMW_REG(8192, 13); + STMW_REG(16384, 14); + } + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) { + reg[base].I = temp; + clockTicks += 1 + CPUUpdateTicksAccess32(address); + } else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + + CASE_16(0x900) + { + // STMDB Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + STM_REG(8192, 13); + STM_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x920) + { + // STMDB Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + STMW_REG(8192, 13); + STMW_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + reg[base].I = temp; + } + } + break; + CASE_16(0x940) + { + // STMDB Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + + if(armMode == 0x11) { + STM_REG(256, R8_FIQ); + STM_REG(512, R9_FIQ); + STM_REG(1024, R10_FIQ); + STM_REG(2048, R11_FIQ); + STM_REG(4096, R12_FIQ); + } else { + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + STM_REG(8192, R13_USR); + STM_REG(16384, R14_USR); + } else { + STM_REG(8192, 13); + STM_REG(16384, 14); + } + + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x960) + { + // STMDB Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + + if(armMode == 0x11) { + STMW_REG(256, R8_FIQ); + STMW_REG(512, R9_FIQ); + STMW_REG(1024, R10_FIQ); + STMW_REG(2048, R11_FIQ); + STMW_REG(4096, R12_FIQ); + } else { + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + STMW_REG(8192, R13_USR); + STMW_REG(16384, R14_USR); + } else { + STMW_REG(8192, 13); + STMW_REG(16384, 14); + } + + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + reg[base].I = temp; + } + } + break; + + CASE_16(0x980) + // STMIB Rn, {Rlist} + { + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + STM_REG(8192, 13); + STM_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x9a0) + { + // STMIB Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + + cpuBitsSet[(opcode >> 8) & 255]); + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + STMW_REG(8192, 13); + STMW_REG(16384, 14); + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) { + reg[base].I = temp; + clockTicks += 1 + CPUUpdateTicksAccess32(address); + } else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x9c0) + { + // STMIB Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + STM_REG(1, 0); + STM_REG(2, 1); + STM_REG(4, 2); + STM_REG(8, 3); + STM_REG(16, 4); + STM_REG(32, 5); + STM_REG(64, 6); + STM_REG(128, 7); + if(armMode == 0x11) { + STM_REG(256, R8_FIQ); + STM_REG(512, R9_FIQ); + STM_REG(1024, R10_FIQ); + STM_REG(2048, R11_FIQ); + STM_REG(4096, R12_FIQ); + } else { + STM_REG(256, 8); + STM_REG(512, 9); + STM_REG(1024, 10); + STM_REG(2048, 11); + STM_REG(4096, 12); + } + if(armMode != 0x10 && armMode != 0x1f) { + STM_REG(8192, R13_USR); + STM_REG(16384, R14_USR); + } else { + STM_REG(8192, 13); + STM_REG(16384, 14); + } + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) + clockTicks += 1 + CPUUpdateTicksAccess32(address); + else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + CASE_16(0x9e0) + { + // STMIB Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + + cpuBitsSet[(opcode >> 8) & 255]); + STMW_REG(1, 0); + STMW_REG(2, 1); + STMW_REG(4, 2); + STMW_REG(8, 3); + STMW_REG(16, 4); + STMW_REG(32, 5); + STMW_REG(64, 6); + STMW_REG(128, 7); + if(armMode == 0x11) { + STMW_REG(256, R8_FIQ); + STMW_REG(512, R9_FIQ); + STMW_REG(1024, R10_FIQ); + STMW_REG(2048, R11_FIQ); + STMW_REG(4096, R12_FIQ); + } else { + STMW_REG(256, 8); + STMW_REG(512, 9); + STMW_REG(1024, 10); + STMW_REG(2048, 11); + STMW_REG(4096, 12); + } + if(armMode != 0x10 && armMode != 0x1f) { + STMW_REG(8192, R13_USR); + STMW_REG(16384, R14_USR); + } else { + STMW_REG(8192, 13); + STMW_REG(16384, 14); + } + if(opcode & 32768) { + CPUWriteMemory(address, reg[15].I+4); + if(!offset) { + reg[base].I = temp; + clockTicks += 1 + CPUUpdateTicksAccess32(address); + } else + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address); + } + } + break; + +#define LDM_REG(val,num) \ + if(opcode & (val)) {\ + reg[(num)].I = CPUReadMemory(address);\ + if(offset)\ + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);\ + else {\ + clockTicks += 1 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + }\ + address += 4;\ + } + + CASE_16(0x810) + { + // LDMDA Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp + 4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x830) + { + // LDMDA Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp + 4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + break; + CASE_16(0x850) + { + // LDMDA Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp + 4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + } + } + break; + CASE_16(0x870) + { + // LDMDA Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (temp + 4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if(!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + if(!(opcode & (1 << base))) + reg[base].I = temp; + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + } + break; + + CASE_16(0x890) + { + // LDMIA Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x8b0) + { + // LDMIA Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I + + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + break; + CASE_16(0x8d0) + { + // LDMIA Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + } + } + break; + CASE_16(0x8f0) + { + // LDMIA Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I + + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = reg[base].I & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if(!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + if(!(opcode & (1 << base))) + reg[base].I = temp; + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + } + break; + + CASE_16(0x910) + { + // LDMDB Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x930) + { + // LDMDB Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + break; + CASE_16(0x950) + { + // LDMDB Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + } + } + break; + CASE_16(0x970) + { + // LDMDB Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I - + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = temp & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if(!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + if(!(opcode & (1 << base))) + reg[base].I = temp; + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + } + break; + + CASE_16(0x990) + { + // LDMIB Rn, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + } + break; + CASE_16(0x9b0) + { + // LDMIB Rn!, {Rlist} + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I + + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + if(opcode & 32768) { + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + armNextPC = reg[15].I; + reg[15].I += 4; + } + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + break; + CASE_16(0x9d0) + { + // LDMIB Rn, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if (!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + } + } + break; + CASE_16(0x9f0) + { + // LDMIB Rn!, {Rlist}^ + int base = (opcode & 0x000F0000) >> 16; + u32 temp = reg[base].I + + 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); + u32 address = (reg[base].I+4) & 0xFFFFFFFC; + clockTicks += 2; + int offset = 0; + if(opcode & 0x8000) { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + LDM_REG(8192, 13); + LDM_REG(16384, 14); + + reg[15].I = CPUReadMemory(address); + if(!offset) + clockTicks += 2 + CPUUpdateTicksAccess32(address); + else + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address); + + if(!(opcode & (1 << base))) + reg[base].I = temp; + + CPUSwitchMode(reg[17].I & 0x1f, false); + if(armState) { + armNextPC = reg[15].I & 0xFFFFFFFC; + reg[15].I = armNextPC + 4; + } else { + armNextPC = reg[15].I & 0xFFFFFFFE; + reg[15].I = armNextPC + 2; + } + } else { + LDM_REG(1, 0); + LDM_REG(2, 1); + LDM_REG(4, 2); + LDM_REG(8, 3); + LDM_REG(16, 4); + LDM_REG(32, 5); + LDM_REG(64, 6); + LDM_REG(128, 7); + + if(armMode == 0x11) { + LDM_REG(256, R8_FIQ); + LDM_REG(512, R9_FIQ); + LDM_REG(1024, R10_FIQ); + LDM_REG(2048, R11_FIQ); + LDM_REG(4096, R12_FIQ); + } else { + LDM_REG(256, 8); + LDM_REG(512, 9); + LDM_REG(1024, 10); + LDM_REG(2048, 11); + LDM_REG(4096, 12); + } + + if(armMode != 0x10 && armMode != 0x1f) { + LDM_REG(8192, R13_USR); + LDM_REG(16384, R14_USR); + } else { + LDM_REG(8192, 13); + LDM_REG(16384, 14); + } + + if(!(opcode & (1 << base))) + reg[base].I = temp; + } + } + break; + CASE_256(0xa00) + { + // B + clockTicks += 3; + int offset = opcode & 0x00FFFFFF; + if(offset & 0x00800000) { + offset |= 0xFF000000; + } + offset <<= 2; + reg[15].I += offset; + armNextPC = reg[15].I; + reg[15].I += 4; + } + break; + CASE_256(0xb00) + { + // BL + clockTicks += 3; + int offset = opcode & 0x00FFFFFF; + if(offset & 0x00800000) { + offset |= 0xFF000000; + } + offset <<= 2; + reg[14].I = reg[15].I - 4; + reg[15].I += offset; + armNextPC = reg[15].I; + reg[15].I += 4; + } + break; + CASE_256(0xf00) + // SWI + clockTicks += 3; + CPUSoftwareInterrupt(opcode & 0x00FFFFFF); + break; +#ifdef GP_SUPPORT + case 0xe11: + case 0xe13: + case 0xe15: + case 0xe17: + case 0xe19: + case 0xe1b: + case 0xe1d: + case 0xe1f: + // MRC + break; + case 0xe01: + case 0xe03: + case 0xe05: + case 0xe07: + case 0xe09: + case 0xe0b: + case 0xe0d: + case 0xe0f: + // MRC + break; +#endif + default: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_UNDEFINED) + log("Undefined ARM instruction %08x at %08x\n", opcode, + armNextPC-4); +#endif + CPUUndefinedException(); + break; + // END + } +} diff --git a/src/armdis.cpp b/src/armdis.cpp new file mode 100644 index 0000000..5162952 --- /dev/null +++ b/src/armdis.cpp @@ -0,0 +1,742 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/************************************************************************/ +/* Arm/Thumb command set disassembler */ +/************************************************************************/ +#include + +#include "System.h" +#include "Port.h" +#include "GBA.h" +#include "armdis.h" +#include "elf.h" + +struct Opcodes { + u32 mask; + u32 cval; + char *mnemonic; +}; + +#define debuggerReadMemory(addr) \ + READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define debuggerReadHalfWord(addr) \ + READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define debuggerReadByte(addr) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] + +const char hdig[] = "0123456789abcdef"; + +const char *decVals[16] = { + "0","1","2","3","4","5","6","7","8", + "9","10","11","12","13","14","15" +}; + +const char *regs[16] = { + "r0","r1","r2","r3","r4","r5","r6","r7", + "r8","r9","r10","r11","r12","sp","lr","pc" +}; + +const char *conditions[16] = { + "eq","ne","cs","cc","mi","pl","vs","vc", + "hi","ls","ge","lt","gt","le","","nv" +}; + +const char *shifts[5] = { + "lsl","lsr","asr","ror","rrx" +}; + +const char *armMultLoadStore[12] = { + // non-stack + "da","ia","db","ib", + // stack store + "ed","ea","fd","fa", + // stack load + "fa","fd","ea","ed" +}; + +const Opcodes thumbOpcodes[] = { + // Format 1 + {0xf800, 0x0000, "lsl %r0, %r3, %o"}, + {0xf800, 0x0800, "lsr %r0, %r3, %o"}, + {0xf800, 0x1000, "asr %r0, %r3, %o"}, + // Format 2 + {0xfe00, 0x1800, "add %r0, %r3, %r6"}, + {0xfe00, 0x1a00, "sub %r0, %r3, %r6"}, + {0xfe00, 0x1c00, "add %r0, %r3, %i"}, + {0xfe00, 0x1e00, "sub %r0, %r3, %i"}, + // Format 3 + {0xf800, 0x2000, "mov %r8, %O"}, + {0xf800, 0x2800, "cmp %r8, %O"}, + {0xf800, 0x3000, "add %r8, %O"}, + {0xf800, 0x3800, "sub %r8, %O"}, + // Format 4 + {0xffc0, 0x4000, "and %r0, %r3"}, + {0xffc0, 0x4040, "eor %r0, %r3"}, + {0xffc0, 0x4080, "lsl %r0, %r3"}, + {0xffc0, 0x40c0, "lsr %r0, %r3"}, + {0xffc0, 0x4100, "asr %r0, %r3"}, + {0xffc0, 0x4140, "adc %r0, %r3"}, + {0xffc0, 0x4180, "sbc %r0, %r3"}, + {0xffc0, 0x41c0, "ror %r0, %r3"}, + {0xffc0, 0x4200, "tst %r0, %r3"}, + {0xffc0, 0x4240, "neg %r0, %r3"}, + {0xffc0, 0x4280, "cmp %r0, %r3"}, + {0xffc0, 0x42c0, "cmn %r0, %r3"}, + {0xffc0, 0x4300, "orr %r0, %r3"}, + {0xffc0, 0x4340, "mul %r0, %r3"}, + {0xffc0, 0x4380, "bic %r0, %r3"}, + {0xffc0, 0x43c0, "mvn %r0, %r3"}, + // Format 5 + {0xff80, 0x4700, "bx %h36"}, + {0xfcc0, 0x4400, "[ ??? ]"}, + {0xff00, 0x4400, "add %h07, %h36"}, + {0xff00, 0x4500, "cmp %h07, %h36"}, + {0xff00, 0x4600, "mov %h07, %h36"}, + // Format 6 + {0xf800, 0x4800, "ldr %r8, [%I] (=%J)"}, + // Format 7 + {0xfa00, 0x5000, "str%b %r0, [%r3, %r6]"}, + {0xfa00, 0x5800, "ldr%b %r0, [%r3, %r6]"}, + // Format 8 + {0xfe00, 0x5200, "strh %r0, [%r3, %r6]"}, + {0xfe00, 0x5600, "ldrh %r0, [%r3, %r6]"}, + {0xfe00, 0x5a00, "ldsb %r0, [%r3, %r6]"}, + {0xfe00, 0x5e00, "ldsh %r0, [%r3, %r6]"}, + // Format 9 + {0xe800, 0x6000, "str%B %r0, [%r3, %p]"}, + {0xe800, 0x6800, "ldr%B %r0, [%r3, %p]"}, + // Format 10 + {0xf800, 0x8000, "strh %r0, [%r3, %e]"}, + {0xf800, 0x8800, "ldrh %r0, [%r3, %e]"}, + // Format 11 + {0xf800, 0x9000, "str %r8, [sp, %w]"}, + {0xf800, 0x9800, "ldr %r8, [sp, %w]"}, + // Format 12 + {0xf800, 0xa000, "add %r8, pc, %w (=%K)"}, + {0xf800, 0xa800, "add %r8, sp, %w"}, + // Format 13 + {0xff00, 0xb000, "add sp, %s"}, + // Format 14 + {0xffff, 0xb500, "push {lr}"}, + {0xff00, 0xb400, "push {%l}"}, + {0xff00, 0xb500, "push {%l,lr}"}, + {0xffff, 0xbd00, "pop {pc}"}, + {0xff00, 0xbd00, "pop {%l,pc}"}, + {0xff00, 0xbc00, "pop {%l}"}, + // Format 15 + {0xf800, 0xc000, "stmia %r8!, {%l}"}, + {0xf800, 0xc800, "ldmia %r8!, {%l}"}, + // Format 17 + {0xff00, 0xdf00, "swi %m"}, + // Format 16 + {0xf000, 0xd000, "b%c %W"}, + // Format 18 + {0xf800, 0xe000, "b %a"}, + // Format 19 + {0xf800, 0xf000, "bl %A"}, + {0xf800, 0xf800, "blh %Z"}, + {0xff00, 0xbe00, "bkpt %O"}, + // Unknown + {0x0000, 0x0000, "[ ??? ]"} +}; + +const Opcodes armOpcodes[] = { + // Undefined + {0x0e000010, 0x06000010, "[ undefined ]"}, + // Branch instructions + {0x0ff000f0, 0x01200010, "bx%c %r0"}, + {0x0f000000, 0x0a000000, "b%c %o"}, + {0x0f000000, 0x0b000000, "bl%c %o"}, + {0x0f000000, 0x0f000000, "swi%c %q"}, + // PSR transfer + {0x0fbf0fff, 0x010f0000, "mrs%c %r3, %p"}, + {0x0db0f000, 0x0120f000, "msr%c %p, %i"}, + // Multiply instructions + {0x0fe000f0, 0x00000090, "mul%c%s %r4, %r0, %r2"}, + {0x0fe000f0, 0x00200090, "mla%c%s %r4, %r0, %r2, %r3"}, + {0x0fa000f0, 0x00800090, "%umull%c%s %r3, %r4, %r0, %r2"}, + {0x0fa000f0, 0x00a00090, "%umlal%c%s %r3, %r4, %r0, %r2"}, + // Load/Store instructions + {0x0fb00ff0, 0x01000090, "swp%c%b %r3, %r0, [%r4]"}, + {0x0fb000f0, 0x01000090, "[ ??? ]"}, + {0x0c100000, 0x04000000, "str%c%b%t %r3, %a"}, + {0x0c100000, 0x04100000, "ldr%c%b%t %r3, %a"}, + {0x0e100090, 0x00000090, "str%c%h %r3, %a"}, + {0x0e100090, 0x00100090, "ldr%c%h %r3, %a"}, + {0x0e100000, 0x08000000, "stm%c%m %r4%l"}, + {0x0e100000, 0x08100000, "ldm%c%m %r4%l"}, + // Data processing + {0x0de00000, 0x00000000, "and%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00200000, "eor%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00400000, "sub%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00600000, "rsb%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00800000, "add%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00a00000, "adc%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00c00000, "sbc%c%s %r3, %r4, %i"}, + {0x0de00000, 0x00e00000, "rsc%c%s %r3, %r4, %i"}, + {0x0de00000, 0x01000000, "tst%c%s %r4, %i"}, + {0x0de00000, 0x01200000, "teq%c%s %r4, %i"}, + {0x0de00000, 0x01400000, "cmp%c%s %r4, %i"}, + {0x0de00000, 0x01600000, "cmn%c%s %r4, %i"}, + {0x0de00000, 0x01800000, "orr%c%s %r3, %r4, %i"}, + {0x0de00000, 0x01a00000, "mov%c%s %r3, %i"}, + {0x0de00000, 0x01c00000, "bic%c%s %r3, %r4, %i"}, + {0x0de00000, 0x01e00000, "mvn%c%s %r3, %i"}, + // Coprocessor operations + {0x0f000010, 0x0e000000, "cdp%c %P, %N, %r3, %R4, %R0%V"}, + {0x0e100000, 0x0c000000, "stc%c%L %P, %r3, %A"}, + {0x0f100010, 0x0e000010, "mcr%c %P, %N, %r3, %R4, %R0%V"}, + {0x0f100010, 0x0e100010, "mrc%c %P, %N, %r3, %R4, %R0%V"}, + // Unknown + {0x00000000, 0x00000000, "[ ??? ]"} +}; + +char* addStr(char *dest, const char *src){ + while (*src){ + *dest++ = *src++; + } + return dest; +} + +char* addHex(char *dest, int siz, u32 val){ + if (siz==0){ + siz = 28; + while ( (((val>>siz)&15)==0) && (siz>=4) ) + siz -= 4; + siz += 4; + } + while (siz>0){ + siz -= 4; + *dest++ = hdig[(val>>siz)&15]; + } + return dest; +} + +int disArm(u32 offset, char *dest, int flags){ + u32 opcode = debuggerReadMemory(offset); + + const Opcodes *sp = armOpcodes; + while( sp->cval != (opcode & sp->mask) ) + sp++; + + if (flags&DIS_VIEW_ADDRESS){ + dest = addHex(dest, 32, offset); + *dest++ = ' '; + } + if (flags&DIS_VIEW_CODE){ + dest = addHex(dest, 32, opcode); + *dest++ = ' '; + } + + char *src = sp->mnemonic; + while (*src){ + if (*src!='%') + *dest++ = *src++; + else{ + src++; + switch (*src){ + case 'c': + dest = addStr(dest, conditions[opcode>>28]); + break; + case 'r': + dest = addStr(dest, regs[(opcode>>((*(++src)-'0')*4))&15]); + break; + case 'o': + { + *dest++ = '$'; + int off = opcode&0xffffff; + if (off&0x800000) + off |= 0xff000000; + off <<= 2; + dest = addHex(dest, 32, offset+8+off); + } + break; + case 'i': + if (opcode&(1<<25)){ + dest = addStr(dest, "#0x"); + int imm = opcode&0xff; + int rot = (opcode&0xf00)>>7; + int val = (imm<<(32-rot))|(imm>>rot); + dest = addHex(dest, 0, val); + } else{ + dest = addStr(dest, regs[opcode&0x0f]); + int shi = (opcode>>5)&3; + int sdw = (opcode>>7)&0x1f; + if ((sdw==0)&&(shi==3)) + shi = 4; + if ( (sdw) || (opcode&0x10) || (shi)) { + dest = addStr(dest, ", "); + dest = addStr(dest, shifts[shi]); + if (opcode&0x10){ + *dest++ = ' '; + dest = addStr(dest, regs[(opcode>>8)&15]); + } else { + if (sdw==0 && ( (shi==1) || (shi==2) )) + sdw = 32; + if(shi != 4) { + dest = addStr(dest, " #0x"); + dest = addHex(dest, 8, sdw); + } + } + } + } + break; + case 'p': + if (opcode&(1<<22)) + dest = addStr(dest, "spsr"); + else + dest = addStr(dest, "cpsr"); + if(opcode & 0x00F00000) { + *dest++ = '_'; + if(opcode & 0x00080000) + *dest++ = 'f'; + if(opcode & 0x00040000) + *dest++ = 's'; + if(opcode & 0x00020000) + *dest++ = 'x'; + if(opcode & 0x00010000) + *dest++ = 'c'; + } + break; + case 's': + if (opcode&(1<<20)) + *dest++ = 's'; + break; + case 'S': + if (opcode&(1<<22)) + *dest++ = 's'; + break; + case 'u': + if (opcode&(1<<22)) + *dest++ = 's'; + else + *dest++ = 'u'; + break; + case 'b': + if (opcode&(1<<22)) + *dest++ = 'b'; + break; + case 'a': + if ((opcode&0x076f0000)==0x004f0000){ + *dest++ = '['; + *dest++ = '$'; + int adr = offset+8; + int add = (opcode&15)|((opcode>>8)&0xf0); + if (opcode&(1<<23)) + adr += add; + else + adr -= add; + dest = addHex(dest, 32, adr); + *dest++ = ']'; + dest = addStr(dest, " (="); + *dest++ = '$'; + dest = addHex(dest ,32, debuggerReadMemory(adr)); + *dest++=')'; + } + if ((opcode&0x072f0000)==0x050f0000){ + *dest++ = '['; + *dest++ = '$'; + int adr = offset+8; + if (opcode&(1<<23)) + adr += opcode&0xfff; + else + adr -= opcode&0xfff; + dest = addHex(dest, 32, adr); + *dest++ = ']'; + dest = addStr(dest, " (="); + *dest++ = '$'; + dest = addHex(dest ,32, debuggerReadMemory(adr)); + *dest++=')'; + } else { + int reg = (opcode>>16)&15; + *dest++ = '['; + dest = addStr(dest, regs[reg]); + if (!(opcode&(1<<24))) + *dest++ = ']'; + if ( ((opcode&(1<<25))&&(opcode&(1<<26))) || (!(opcode&(1<<22))&&!(opcode&(1<<26))) ){ + dest = addStr(dest, ", "); + if (!(opcode&(1<<23))) + *dest++ = '-'; + dest = addStr(dest, regs[opcode&0x0f]); + int shi = (opcode>>5)&3; + if (opcode&(1<<26)){ + if ( ((opcode>>7)&0x1f) || (opcode&0x10) || (shi==1) || (shi==2)){ + dest = addStr(dest, ", "); + dest = addStr(dest, shifts[shi]); + if (opcode&0x10){ + *dest++ = ' '; + dest = addStr(dest, regs[(opcode>>8)&15]); + } else { + int sdw = (opcode>>7)&0x1f; + if (sdw==0 && ( (shi==1) || (shi==2) )) + sdw = 32; + dest = addStr(dest, " #0x"); + dest = addHex(dest, 8, sdw); + } + } + } + } else { + int off; + if (opcode&(1<<26)) + off = opcode&0xfff; + else + off = (opcode&15)|((opcode>>4)&0xf0); + if (off){ + dest = addStr(dest, ", "); + if (!(opcode&(1<<23))) + *dest++ = '-'; + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, off); + } + } + if (opcode&(1<<24)){ + *dest++ = ']'; + if (opcode&(1<<21)) + *dest++ = '!'; + } + } + break; + case 't': + if ((opcode&0x01200000)==0x01200000) + *dest++ = 't'; + break; + case 'h': + if (opcode&(1<<6)) + *dest++ = 's'; + if (opcode&(1<<5)) + *dest++ = 'h'; + else + *dest++ = 'b'; + break; + case 'm': + if (((opcode>>16)&15)==13) { + if(opcode & 0x00100000) + dest = addStr(dest, armMultLoadStore[8+((opcode>>23)&3)]); + else + dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]); + } else + dest = addStr(dest, armMultLoadStore[(opcode>>23)&3]); + break; + case 'l': + if (opcode&(1<<21)) + *dest++ = '!'; + dest = addStr(dest, ", {"); + { + int rlst = opcode&0xffff; + int msk = 0; + int not_first = 0; + while (msk<16){ + if (rlst&(1<>8)&15]); + break; + case 'N': + if (opcode&0x10) + dest = addStr(dest, decVals[(opcode>>21)&7]); + else + dest = addStr(dest, decVals[(opcode>>20)&15]); + break; + case 'R': + { + src++; + int reg = 4*(*src-'0'); + *dest++ = 'c'; + dest = addStr(dest, decVals[(opcode>>reg)&15]); + } + break; + case 'V': + { + int val = (opcode>>5)&7; + if (val){ + dest = addStr(dest, ", "); + dest = addStr(dest, decVals[val]); + } + } + break; + case 'L': + if (opcode&(1<<22)) + *dest++ = 'l'; + break; + case 'A': + if ((opcode&0x012f0000)==0x010f0000){ + int adr = offset+8; + int add = (opcode&0xff)<<2; + if (opcode&(1<<23)) + adr += add; + else + adr -= add; + *dest++ = '$'; + addHex(dest, 32, adr); + } else { + *dest++ = '['; + dest = addStr(dest, regs[(opcode>>16)&15]); + if (!(opcode&(1<<24))) + *dest++ = ']'; + int off = (opcode&0xff)<<2; + if (off){ + dest = addStr(dest, ", "); + if (!(opcode&(1<<23))) + *dest++ = '-'; + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, off); + } + if (opcode&(1<<24)){ + *dest++ = ']'; + if (opcode&(1<<21)) + *dest++ = '!'; + } + } + break; + } + src++; + } + } + *dest++ = 0; + + return 4; +} + +int disThumb(u32 offset, char *dest, int flags){ + u32 opcode = debuggerReadHalfWord(offset); + + const Opcodes *sp = thumbOpcodes; + int ret = 2; + while( sp->cval != (opcode & sp->mask) ) + sp++; + + if (flags&DIS_VIEW_ADDRESS){ + dest = addHex(dest, 32, offset); + *dest++ = ' '; + } + if (flags&DIS_VIEW_CODE){ + dest = addHex(dest, 16, opcode); + *dest++ = ' '; + } + + char *src = sp->mnemonic; + while (*src){ + if (*src!='%') + *dest++ = *src++; + else { + src++; + switch (*src){ + case 'r': + src++; + dest = addStr(dest, regs[(opcode>>(*src-'0'))&7]); + break; + case 'o': + dest = addStr(dest, "#0x"); + { + int val = (opcode>>6)&0x1f; + dest = addHex(dest, 8, val); + } + break; + case 'p': + dest = addStr(dest, "#0x"); + { + int val = (opcode>>6)&0x1f; + if (!(opcode&(1<<12))) + val <<= 2; + dest = addHex(dest, 0, val); + } + break; + case 'e': + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, ((opcode>>6)&0x1f)<<1); + break; + case 'i': + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, (opcode>>6)&7); + break; + case 'h': + { + src++; + int reg = (opcode>>(*src-'0'))&7; + src++; + if (opcode&(1<<(*src-'0'))) + reg += 8; + dest = addStr(dest, regs[reg]); + } + break; + case 'O': + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, (opcode&0xff)); + break; + case 'I': + *dest++ = '$'; + dest = addHex(dest, 32, (offset&0xfffffffc)+4+((opcode&0xff)<<2)); + break; + case 'J': + { + u32 value = debuggerReadMemory((offset&0xfffffffc)+4+ + ((opcode & 0xff)<<2)); + *dest++ = '$'; + dest = addHex(dest, 32, value); + char *s = elfGetAddressSymbol(value); + if(*s) { + *dest++ = ' '; + dest = addStr(dest, s); + } + } + break; + case 'K': + { + u32 value = (offset&0xfffffffc)+4+((opcode & 0xff)<<2); + *dest++ = '$'; + dest = addHex(dest, 32, value); + char *s = elfGetAddressSymbol(value); + if(*s) { + *dest++ = ' '; + dest = addStr(dest, s); + } + } + break; + case 'b': + if (opcode&(1<<10)) + *dest++ = 'b'; + break; + case 'B': + if (opcode&(1<<12)) + *dest++ = 'b'; + break; + case 'w': + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, (opcode&0xff)<<2); + break; + case 'W': + *dest++ = '$'; + { + int add = opcode&0xff; + if (add&0x80) + add |= 0xffffff00; + dest = addHex(dest, 32, (offset&0xfffffffe)+4+(add<<1)); + } + break; + case 'c': + dest = addStr(dest, conditions[(opcode>>8)&15]); + break; + case 's': + if (opcode&(1<<7)) + *dest++ = '-'; + dest = addStr(dest, "#0x"); + dest = addHex(dest, 0, (opcode&0x7f)<<2); + break; + case 'l': + { + int rlst = opcode&0xff; + int msk = 0; + int not_first = 0; + while (msk<8){ + if (rlst&(1<>3) << systemRedShift |\ + ((g) >> 3) << systemGreenShift |\ + ((b) >> 3) << systemBlueShift\ + +static void fill_rgb_row_16(u16 *from, int src_width, u8 *row, int width) +{ + u8 *copy_start = row + src_width*3; + u8 *all_stop = row + width*3; + while (row < copy_start) { + u16 color = *from++; + *row++ = ((color >> systemRedShift) & 0x1f) << 3; + *row++ = ((color >> systemGreenShift) & 0x1f) << 3; + *row++ = ((color >> systemBlueShift) & 0x1f) << 3; + } + // any remaining elements to be written to 'row' are a replica of the + // preceding pixel + u8 *p = row-3; + while (row < all_stop) { + // we're guaranteed three elements per pixel; could unroll the loop + // further, especially with a Duff's Device, but the gains would be + // probably limited (judging by profiler output) + *row++ = *p++; + *row++ = *p++; + *row++ = *p++; + } +} + +static void fill_rgb_row_32(u32 *from, int src_width, u8 *row, int width) +{ + u8 *copy_start = row + src_width*3; + u8 *all_stop = row + width*3; + while (row < copy_start) { + u32 color = *from++; + *row++ = ((color >> systemRedShift) & 0x1f) << 3; + *row++ = ((color >> systemGreenShift) & 0x1f) << 3; + *row++ = ((color >> systemBlueShift) & 0x1f) << 3; + } + // any remaining elements to be written to 'row' are a replica of the + // preceding pixel + u8 *p = row-3; + while (row < all_stop) { + // we're guaranteed three elements per pixel; could unroll the loop + // further, especially with a Duff's Device, but the gains would be + // probably limited (judging by profiler output) + *row++ = *p++; + *row++ = *p++; + *row++ = *p++; + } +} + +void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u16 *to = (u16 *)dstPtr; + u16 *to_odd = (u16 *)(dstPtr + dstPitch); + + int from_width = width; + u16 *from = (u16 *)srcPtr; + fill_rgb_row_16(from, from_width, rgb_row_cur, width+1); + + for(int y = 0; y < height; y++) { + u16 *from_orig = from; + u16 *to_orig = to; + + if (y+1 < height) + fill_rgb_row_16(from+width+2, from_width, rgb_row_next, + width+1); + else + fill_rgb_row_16(from, from_width, rgb_row_next, width+1); + + // every pixel in the src region, is extended to 4 pixels in the + // destination, arranged in a square 'quad'; if the current src + // pixel is 'a', then in what follows 'b' is the src pixel to the + // right, 'c' is the src pixel below, and 'd' is the src pixel to + // the right and down + u8 *cur_row = rgb_row_cur; + u8 *next_row = rgb_row_next; + u8 *ar = cur_row++; + u8 *ag = cur_row++; + u8 *ab = cur_row++; + u8 *cr = next_row++; + u8 *cg = next_row++; + u8 *cb = next_row++; + for(int x=0; x < width; x++) { + u8 *br = cur_row++; + u8 *bg = cur_row++; + u8 *bb = cur_row++; + u8 *dr = next_row++; + u8 *dg = next_row++; + u8 *db = next_row++; + + // upper left pixel in quad: just copy it in + *to++ = RGB(*ar, *ag, *ab); + + // upper right + *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); + + // lower left + *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); + + // lower right + *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, + (*ag+*bg+*cg+*dg)>>2, + (*ab+*bb+*cb+*db)>>2); + + // 'b' becomes 'a', 'd' becomes 'c' + ar = br; + ag = bg; + ab = bb; + cr = dr; + cg = dg; + cb = db; + } + + // the "next" rgb row becomes the current; the old current rgb row is + // recycled and serves as the new "next" row + u8 *temp; + temp = rgb_row_cur; + rgb_row_cur = rgb_row_next; + rgb_row_next = temp; + + // update the pointers for start of next pair of lines + from = (u16 *)((u8 *)from_orig + srcPitch); + to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); + to_odd = (u16 *)((u8 *)to + dstPitch); + } +} + +void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u16 *to = (u16 *)dstPtr; + u16 *to_odd = (u16 *)(dstPtr + dstPitch); + + int from_width = width; + u16 *from = (u16 *)srcPtr; + fill_rgb_row_16(from, from_width, rgb_row_cur, width+1); + + for(int y = 0; y < height; y++) { + u16 *from_orig = from; + u16 *to_orig = to; + + if (y+1 < height) + fill_rgb_row_16(from+width+2, from_width, rgb_row_next, + width+1); + else + fill_rgb_row_16(from, from_width, rgb_row_next, width+1); + + // every pixel in the src region, is extended to 4 pixels in the + // destination, arranged in a square 'quad'; if the current src + // pixel is 'a', then in what follows 'b' is the src pixel to the + // right, 'c' is the src pixel below, and 'd' is the src pixel to + // the right and down + u8 *cur_row = rgb_row_cur; + u8 *next_row = rgb_row_next; + u8 *ar = cur_row++; + u8 *ag = cur_row++; + u8 *ab = cur_row++; + u8 *cr = next_row++; + u8 *cg = next_row++; + u8 *cb = next_row++; + for(int x=0; x < width; x++) { + u8 *br = cur_row++; + u8 *bg = cur_row++; + u8 *bb = cur_row++; + u8 *dr = next_row++; + u8 *dg = next_row++; + u8 *db = next_row++; + + // upper left pixel in quad: just copy it in + //*to++ = manip.rgb(*ar, *ag, *ab); +#ifdef USE_ORIGINAL_BILINEAR_PLUS + *to++ = RGB( + (((*ar)<<2) +((*ar)) + (*cr+*br+*br) )>> 3, + (((*ag)<<2) +((*ag)) + (*cg+*bg+*bg) )>> 3, + (((*ab)<<2) +((*ab)) + (*cb+*bb+*bb) )>> 3); +#else + *to++ = RGB( + (((*ar)<<3) +((*ar)<<1) + (*cr+*br+*br+*cr) )>> 4, + (((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4, + (((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4); +#endif + + // upper right + *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); + + // lower left + *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); + + // lower right + *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, + (*ag+*bg+*cg+*dg)>>2, + (*ab+*bb+*cb+*db)>>2); + + // 'b' becomes 'a', 'd' becomes 'c' + ar = br; + ag = bg; + ab = bb; + cr = dr; + cg = dg; + cb = db; + } + + // the "next" rgb row becomes the current; the old current rgb row is + // recycled and serves as the new "next" row + u8 *temp; + temp = rgb_row_cur; + rgb_row_cur = rgb_row_next; + rgb_row_next = temp; + + // update the pointers for start of next pair of lines + from = (u16 *)((u8 *)from_orig + srcPitch); + to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); + to_odd = (u16 *)((u8 *)to + dstPitch); + } +} + +void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *to = (u32 *)dstPtr; + u32 *to_odd = (u32 *)(dstPtr + dstPitch); + + int from_width = width; + if(width+1 < from_width) + from_width = width+1; + u32 *from = (u32 *)srcPtr; + fill_rgb_row_32(from, from_width, rgb_row_cur, width+1); + + for(int y = 0; y < height; y++) { + u32 *from_orig = from; + u32 *to_orig = to; + + if (y+1 < height) + fill_rgb_row_32(from+width+1, from_width, rgb_row_next, + width+1); + else + fill_rgb_row_32(from, from_width, rgb_row_next, width+1); + + // every pixel in the src region, is extended to 4 pixels in the + // destination, arranged in a square 'quad'; if the current src + // pixel is 'a', then in what follows 'b' is the src pixel to the + // right, 'c' is the src pixel below, and 'd' is the src pixel to + // the right and down + u8 *cur_row = rgb_row_cur; + u8 *next_row = rgb_row_next; + u8 *ar = cur_row++; + u8 *ag = cur_row++; + u8 *ab = cur_row++; + u8 *cr = next_row++; + u8 *cg = next_row++; + u8 *cb = next_row++; + for(int x=0; x < width; x++) { + u8 *br = cur_row++; + u8 *bg = cur_row++; + u8 *bb = cur_row++; + u8 *dr = next_row++; + u8 *dg = next_row++; + u8 *db = next_row++; + + // upper left pixel in quad: just copy it in + *to++ = RGB(*ar, *ag, *ab); + + // upper right + *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); + + // lower left + *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); + + // lower right + *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, + (*ag+*bg+*cg+*dg)>>2, + (*ab+*bb+*cb+*db)>>2); + + // 'b' becomes 'a', 'd' becomes 'c' + ar = br; + ag = bg; + ab = bb; + cr = dr; + cg = dg; + cb = db; + } + + // the "next" rgb row becomes the current; the old current rgb row is + // recycled and serves as the new "next" row + u8 *temp; + temp = rgb_row_cur; + rgb_row_cur = rgb_row_next; + rgb_row_next = temp; + + // update the pointers for start of next pair of lines + from = (u32 *)((u8 *)from_orig + srcPitch); + to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); + to_odd = (u32 *)((u8 *)to + dstPitch); + } +} + +void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *to = (u32 *)dstPtr; + u32 *to_odd = (u32 *)(dstPtr + dstPitch); + + int from_width = width; + if(width+1 < from_width) + from_width = width+1; + u32 *from = (u32 *)srcPtr; + fill_rgb_row_32(from, from_width, rgb_row_cur, width+1); + + for(int y = 0; y < height; y++) { + u32 *from_orig = from; + u32 *to_orig = to; + + if (y+1 < height) + fill_rgb_row_32(from+width+1, from_width, rgb_row_next, + width+1); + else + fill_rgb_row_32(from, from_width, rgb_row_next, width+1); + + // every pixel in the src region, is extended to 4 pixels in the + // destination, arranged in a square 'quad'; if the current src + // pixel is 'a', then in what follows 'b' is the src pixel to the + // right, 'c' is the src pixel below, and 'd' is the src pixel to + // the right and down + u8 *cur_row = rgb_row_cur; + u8 *next_row = rgb_row_next; + u8 *ar = cur_row++; + u8 *ag = cur_row++; + u8 *ab = cur_row++; + u8 *cr = next_row++; + u8 *cg = next_row++; + u8 *cb = next_row++; + for(int x=0; x < width; x++) { + u8 *br = cur_row++; + u8 *bg = cur_row++; + u8 *bb = cur_row++; + u8 *dr = next_row++; + u8 *dg = next_row++; + u8 *db = next_row++; + + // upper left pixel in quad: just copy it in + //*to++ = manip.rgb(*ar, *ag, *ab); +#ifdef USE_ORIGINAL_BILINEAR_PLUS + *to++ = RGB( + (((*ar)<<2) +((*ar)) + (*cr+*br+*br) )>> 3, + (((*ag)<<2) +((*ag)) + (*cg+*bg+*bg) )>> 3, + (((*ab)<<2) +((*ab)) + (*cb+*bb+*bb) )>> 3); +#else + *to++ = RGB( + (((*ar)<<3) +((*ar)<<1) + (*cr+*br+*br+*cr) )>> 4, + (((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4, + (((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4); +#endif + + // upper right + *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); + + // lower left + *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); + + // lower right + *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, + (*ag+*bg+*cg+*dg)>>2, + (*ab+*bb+*cb+*db)>>2); + + // 'b' becomes 'a', 'd' becomes 'c' + ar = br; + ag = bg; + ab = bb; + cr = dr; + cg = dg; + cb = db; + } + + // the "next" rgb row becomes the current; the old current rgb row is + // recycled and serves as the new "next" row + u8 *temp; + temp = rgb_row_cur; + rgb_row_cur = rgb_row_next; + rgb_row_next = temp; + + // update the pointers for start of next pair of lines + from = (u32 *)((u8 *)from_orig + srcPitch); + to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); + to_odd = (u32 *)((u8 *)to + dstPitch); + } +} + diff --git a/src/bios.cpp b/src/bios.cpp new file mode 100644 index 0000000..aa17dc2 --- /dev/null +++ b/src/bios.cpp @@ -0,0 +1,1158 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#include "GBA.h" +#include "bios.h" +#include "GBAinline.h" +#include "Globals.h" + +s16 sineTable[256] = { + (s16)0x0000, (s16)0x0192, (s16)0x0323, (s16)0x04B5, (s16)0x0645, (s16)0x07D5, (s16)0x0964, (s16)0x0AF1, + (s16)0x0C7C, (s16)0x0E05, (s16)0x0F8C, (s16)0x1111, (s16)0x1294, (s16)0x1413, (s16)0x158F, (s16)0x1708, + (s16)0x187D, (s16)0x19EF, (s16)0x1B5D, (s16)0x1CC6, (s16)0x1E2B, (s16)0x1F8B, (s16)0x20E7, (s16)0x223D, + (s16)0x238E, (s16)0x24DA, (s16)0x261F, (s16)0x275F, (s16)0x2899, (s16)0x29CD, (s16)0x2AFA, (s16)0x2C21, + (s16)0x2D41, (s16)0x2E5A, (s16)0x2F6B, (s16)0x3076, (s16)0x3179, (s16)0x3274, (s16)0x3367, (s16)0x3453, + (s16)0x3536, (s16)0x3612, (s16)0x36E5, (s16)0x37AF, (s16)0x3871, (s16)0x392A, (s16)0x39DA, (s16)0x3A82, + (s16)0x3B20, (s16)0x3BB6, (s16)0x3C42, (s16)0x3CC5, (s16)0x3D3E, (s16)0x3DAE, (s16)0x3E14, (s16)0x3E71, + (s16)0x3EC5, (s16)0x3F0E, (s16)0x3F4E, (s16)0x3F84, (s16)0x3FB1, (s16)0x3FD3, (s16)0x3FEC, (s16)0x3FFB, + (s16)0x4000, (s16)0x3FFB, (s16)0x3FEC, (s16)0x3FD3, (s16)0x3FB1, (s16)0x3F84, (s16)0x3F4E, (s16)0x3F0E, + (s16)0x3EC5, (s16)0x3E71, (s16)0x3E14, (s16)0x3DAE, (s16)0x3D3E, (s16)0x3CC5, (s16)0x3C42, (s16)0x3BB6, + (s16)0x3B20, (s16)0x3A82, (s16)0x39DA, (s16)0x392A, (s16)0x3871, (s16)0x37AF, (s16)0x36E5, (s16)0x3612, + (s16)0x3536, (s16)0x3453, (s16)0x3367, (s16)0x3274, (s16)0x3179, (s16)0x3076, (s16)0x2F6B, (s16)0x2E5A, + (s16)0x2D41, (s16)0x2C21, (s16)0x2AFA, (s16)0x29CD, (s16)0x2899, (s16)0x275F, (s16)0x261F, (s16)0x24DA, + (s16)0x238E, (s16)0x223D, (s16)0x20E7, (s16)0x1F8B, (s16)0x1E2B, (s16)0x1CC6, (s16)0x1B5D, (s16)0x19EF, + (s16)0x187D, (s16)0x1708, (s16)0x158F, (s16)0x1413, (s16)0x1294, (s16)0x1111, (s16)0x0F8C, (s16)0x0E05, + (s16)0x0C7C, (s16)0x0AF1, (s16)0x0964, (s16)0x07D5, (s16)0x0645, (s16)0x04B5, (s16)0x0323, (s16)0x0192, + (s16)0x0000, (s16)0xFE6E, (s16)0xFCDD, (s16)0xFB4B, (s16)0xF9BB, (s16)0xF82B, (s16)0xF69C, (s16)0xF50F, + (s16)0xF384, (s16)0xF1FB, (s16)0xF074, (s16)0xEEEF, (s16)0xED6C, (s16)0xEBED, (s16)0xEA71, (s16)0xE8F8, + (s16)0xE783, (s16)0xE611, (s16)0xE4A3, (s16)0xE33A, (s16)0xE1D5, (s16)0xE075, (s16)0xDF19, (s16)0xDDC3, + (s16)0xDC72, (s16)0xDB26, (s16)0xD9E1, (s16)0xD8A1, (s16)0xD767, (s16)0xD633, (s16)0xD506, (s16)0xD3DF, + (s16)0xD2BF, (s16)0xD1A6, (s16)0xD095, (s16)0xCF8A, (s16)0xCE87, (s16)0xCD8C, (s16)0xCC99, (s16)0xCBAD, + (s16)0xCACA, (s16)0xC9EE, (s16)0xC91B, (s16)0xC851, (s16)0xC78F, (s16)0xC6D6, (s16)0xC626, (s16)0xC57E, + (s16)0xC4E0, (s16)0xC44A, (s16)0xC3BE, (s16)0xC33B, (s16)0xC2C2, (s16)0xC252, (s16)0xC1EC, (s16)0xC18F, + (s16)0xC13B, (s16)0xC0F2, (s16)0xC0B2, (s16)0xC07C, (s16)0xC04F, (s16)0xC02D, (s16)0xC014, (s16)0xC005, + (s16)0xC000, (s16)0xC005, (s16)0xC014, (s16)0xC02D, (s16)0xC04F, (s16)0xC07C, (s16)0xC0B2, (s16)0xC0F2, + (s16)0xC13B, (s16)0xC18F, (s16)0xC1EC, (s16)0xC252, (s16)0xC2C2, (s16)0xC33B, (s16)0xC3BE, (s16)0xC44A, + (s16)0xC4E0, (s16)0xC57E, (s16)0xC626, (s16)0xC6D6, (s16)0xC78F, (s16)0xC851, (s16)0xC91B, (s16)0xC9EE, + (s16)0xCACA, (s16)0xCBAD, (s16)0xCC99, (s16)0xCD8C, (s16)0xCE87, (s16)0xCF8A, (s16)0xD095, (s16)0xD1A6, + (s16)0xD2BF, (s16)0xD3DF, (s16)0xD506, (s16)0xD633, (s16)0xD767, (s16)0xD8A1, (s16)0xD9E1, (s16)0xDB26, + (s16)0xDC72, (s16)0xDDC3, (s16)0xDF19, (s16)0xE075, (s16)0xE1D5, (s16)0xE33A, (s16)0xE4A3, (s16)0xE611, + (s16)0xE783, (s16)0xE8F8, (s16)0xEA71, (s16)0xEBED, (s16)0xED6C, (s16)0xEEEF, (s16)0xF074, (s16)0xF1FB, + (s16)0xF384, (s16)0xF50F, (s16)0xF69C, (s16)0xF82B, (s16)0xF9BB, (s16)0xFB4B, (s16)0xFCDD, (s16)0xFE6E +}; + +void BIOS_ArcTan() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("ArcTan: %08x (VCOUNT=%2d)\n", + reg[0].I, + VCOUNT); + } +#endif + + s32 a = -((s32)(reg[0].I * reg[0].I)) >> 14; + s32 b = ((0xA9 * a) >> 14) + 0x390; + b = ((b * a) >> 14) + 0x91C; + b = ((b * a) >> 14) + 0xFB6; + b = ((b * a) >> 14) + 0x16AA; + b = ((b * a) >> 14) + 0x2081; + b = ((b * a) >> 14) + 0x3651; + b = ((b * a) >> 14) + 0xA2F9; + reg[0].I = (reg[0].I * b) >> 16; + +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("ArcTan: return=%08x\n", + reg[0].I); + } +#endif +} + +void BIOS_ArcTan2() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("ArcTan2: %08x,%08x (VCOUNT=%2d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + s16 x = reg[0].I; + s16 y = reg[1].I; + + if (y == 0) { + reg[0].I = 0x8000 & x; + reg[3].I = 0x170; + } else { + if (x == 0) { + reg[0].I = (0x8000 & y) + 0x4000; + reg[3].I = 0x170; + } else { + if (abs(x) > abs(y)) { + reg[1].I = x; + reg[0].I = y << 14; + BIOS_Div(); + BIOS_ArcTan(); + if (x < 0) + reg[0].I = 0x8000 + reg[0].I; + else + reg[0].I = ((y & 0x8000) << 1 ) + reg[0].I; + reg[3].I = 0x170; + } else { + reg[0].I = x << 14; + BIOS_Div(); + BIOS_ArcTan(); + reg[0].I = (0x4000 + (y & 0x8000)) - reg[0].I; + reg[3].I = 0x170; + } + } + } + +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("ArcTan2: return=%08x\n", + reg[0].I); + } +#endif +} + +void BIOS_BitUnPack() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("BitUnPack: %08x,%08x,%08x (VCOUNT=%2d)\n", + reg[0].I, + reg[1].I, + reg[2].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + u32 header = reg[2].I; + + int len = CPUReadHalfWord(header); + // check address + int bits = CPUReadByte(header+2); + int revbits = 8 - bits; + // u32 value = 0; + u32 base = CPUReadMemory(header+4); + bool addBase = (base & 0x80000000) ? true : false; + base &= 0x7fffffff; + int dataSize = CPUReadByte(header+3); + + int data = 0; + int bitwritecount = 0; + while(1) { + len -= 1; + if(len < 0) + break; + int mask = 0xff >> revbits; + u8 b = CPUReadByte(source); + source++; + int bitcount = 0; + while(1) { + if(bitcount >= 8) + break; + u32 d = b & mask; + u32 temp = d >> bitcount; + if(!temp && addBase) { + temp += base; + } + data |= temp << bitwritecount; + bitwritecount += dataSize; + if(bitwritecount >= 32) { + CPUWriteMemory(dest, data); + dest += 4; + data = 0; + bitwritecount = 0; + } + mask <<= bits; + bitcount += bits; + } + } +} + +void BIOS_BgAffineSet() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("BgAffineSet: %08x,%08x,%08x (VCOUNT=%2d)\n", + reg[0].I, + reg[1].I, + reg[2].I, + VCOUNT); + } +#endif + + u32 src = reg[0].I; + u32 dest = reg[1].I; + int num = reg[2].I; + + for(int i = 0; i < num; i++) { + s32 cx = CPUReadMemory(src); + src+=4; + s32 cy = CPUReadMemory(src); + src+=4; + s16 dispx = CPUReadHalfWord(src); + src+=2; + s16 dispy = CPUReadHalfWord(src); + src+=2; + s16 rx = CPUReadHalfWord(src); + src+=2; + s16 ry = CPUReadHalfWord(src); + src+=2; + u16 theta = CPUReadHalfWord(src)>>8; + src+=4; // keep structure alignment + s32 a = sineTable[(theta+0x40)&255]; + s32 b = sineTable[theta]; + + s16 dx = (rx * a)>>14; + s16 dmx = (rx * b)>>14; + s16 dy = (ry * b)>>14; + s16 dmy = (ry * a)>>14; + + CPUWriteHalfWord(dest, dx); + dest += 2; + CPUWriteHalfWord(dest, -dmx); + dest += 2; + CPUWriteHalfWord(dest, dy); + dest += 2; + CPUWriteHalfWord(dest, dmy); + dest += 2; + + s32 startx = cx - dx * dispx + dmx * dispy; + s32 starty = cy - dy * dispx - dmy * dispy; + + CPUWriteMemory(dest, startx); + dest += 4; + CPUWriteMemory(dest, starty); + dest += 4; + } +} + +void BIOS_CpuSet() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("CpuSet: 0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I, + reg[2].I, VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + u32 cnt = reg[2].I; + + if(((source & 0xe000000) == 0) || + ((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0) + return; + + int count = cnt & 0x1FFFFF; + + // 32-bit ? + if((cnt >> 26) & 1) { + // needed for 32-bit mode! + source &= 0xFFFFFFFC; + dest &= 0xFFFFFFFC; + // fill ? + if((cnt >> 24) & 1) { + u32 value = CPUReadMemory(source); + while(count) { + CPUWriteMemory(dest, value); + dest += 4; + count--; + } + } else { + // copy + while(count) { + CPUWriteMemory(dest, CPUReadMemory(source)); + source += 4; + dest += 4; + count--; + } + } + } else { + // 16-bit fill? + if((cnt >> 24) & 1) { + u16 value = CPUReadHalfWord(source); + while(count) { + CPUWriteHalfWord(dest, value); + dest += 2; + count--; + } + } else { + // copy + while(count) { + CPUWriteHalfWord(dest, CPUReadHalfWord(source)); + source += 2; + dest += 2; + count--; + } + } + } +} + +void BIOS_CpuFastSet() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("CpuFastSet: 0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I, + reg[2].I, VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + u32 cnt = reg[2].I; + + if(((source & 0xe000000) == 0) || + ((source + (((cnt << 11)>>9) & 0x1fffff)) & 0xe000000) == 0) + return; + + // needed for 32-bit mode! + source &= 0xFFFFFFFC; + dest &= 0xFFFFFFFC; + + int count = cnt & 0x1FFFFF; + + // fill? + if((cnt >> 24) & 1) { + while(count > 0) { + // BIOS always transfers 32 bytes at a time + u32 value = CPUReadMemory(source); + for(int i = 0; i < 8; i++) { + CPUWriteMemory(dest, value); + dest += 4; + } + count -= 8; + } + } else { + // copy + while(count > 0) { + // BIOS always transfers 32 bytes at a time + for(int i = 0; i < 8; i++) { + CPUWriteMemory(dest, CPUReadMemory(source)); + source += 4; + dest += 4; + } + count -= 8; + } + } +} + +void BIOS_Diff8bitUnFilterWram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Diff8bitUnFilterWram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, + reg[1].I, VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0)) + return; + + int len = header >> 8; + + u8 data = CPUReadByte(source++); + CPUWriteByte(dest++, data); + len--; + + while(len > 0) { + u8 diff = CPUReadByte(source++); + data += diff; + CPUWriteByte(dest++, data); + len--; + } +} + +void BIOS_Diff8bitUnFilterVram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Diff8bitUnFilterVram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, + reg[1].I, VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int len = header >> 8; + + u8 data = CPUReadByte(source++); + u16 writeData = data; + int shift = 8; + int bytes = 1; + + while(len >= 2) { + u8 diff = CPUReadByte(source++); + data += diff; + writeData |= (data << shift); + bytes++; + shift += 8; + if(bytes == 2) { + CPUWriteHalfWord(dest, writeData); + dest += 2; + len -= 2; + bytes = 0; + writeData = 0; + shift = 0; + } + } +} + +void BIOS_Diff16bitUnFilter() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Diff16bitUnFilter: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, + reg[1].I, VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int len = header >> 8; + + u16 data = CPUReadHalfWord(source); + source += 2; + CPUWriteHalfWord(dest, data); + dest += 2; + len -= 2; + + while(len >= 2) { + u16 diff = CPUReadHalfWord(source); + source += 2; + data += diff; + CPUWriteHalfWord(dest, data); + dest += 2; + len -= 2; + } +} + +void BIOS_Div() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Div: 0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + int number = reg[0].I; + int denom = reg[1].I; + + if(denom != 0) { + reg[0].I = number / denom; + reg[1].I = number % denom; + s32 temp = (s32)reg[0].I; + reg[3].I = temp < 0 ? (u32)-temp : (u32)temp; + } +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Div: return=0x%08x,0x%08x,0x%08x\n", + reg[0].I, + reg[1].I, + reg[3].I); + } +#endif +} + +void BIOS_DivARM() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("DivARM: 0x%08x, (VCOUNT=%d)\n", + reg[0].I, + VCOUNT); + } +#endif + + u32 temp = reg[0].I; + reg[0].I = reg[1].I; + reg[1].I = temp; + BIOS_Div(); +} + +void BIOS_HuffUnComp() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("HuffUnComp: 0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + u8 treeSize = CPUReadByte(source++); + + u32 treeStart = source; + + source += (treeSize<<1) + 1; + + int len = header >> 8; + + u32 mask = 0x80000000; + u32 data = CPUReadMemory(source); + source += 4; + + int pos = 0; + u8 rootNode = CPUReadByte(treeStart); + u8 currentNode = rootNode; + bool writeData = false; + int byteShift = 0; + int byteCount = 0; + u32 writeValue = 0; + + if((header & 0x0F) == 8) { + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if(data & mask) { + // right + if(currentNode & 0x40) + writeData = true; + currentNode = CPUReadByte(treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = true; + currentNode = CPUReadByte(treeStart+pos); + } + + if(writeData) { + writeValue |= (currentNode << byteShift); + byteCount++; + byteShift += 8; + + pos = 0; + currentNode = rootNode; + writeData = false; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + CPUWriteMemory(dest, writeValue); + writeValue = 0; + dest += 4; + len -= 4; + } + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = CPUReadMemory(source); + source += 4; + } + } + } else { + int halfLen = 0; + int value = 0; + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if((data & mask)) { + // right + if(currentNode & 0x40) + writeData = true; + currentNode = CPUReadByte(treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = true; + currentNode = CPUReadByte(treeStart+pos); + } + + if(writeData) { + if(halfLen == 0) + value |= currentNode; + else + value |= (currentNode<<4); + + halfLen += 4; + if(halfLen == 8) { + writeValue |= (value << byteShift); + byteCount++; + byteShift += 8; + + halfLen = 0; + value = 0; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + CPUWriteMemory(dest, writeValue); + dest += 4; + writeValue = 0; + len -= 4; + } + } + pos = 0; + currentNode = rootNode; + writeData = false; + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = CPUReadMemory(source); + source += 4; + } + } + } +} + +void BIOS_LZ77UnCompVram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("LZ77UnCompVram: 0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int byteCount = 0; + int byteShift = 0; + u32 writeValue = 0; + + int len = header >> 8; + + while(len > 0) { + u8 d = CPUReadByte(source++); + + if(d) { + for(int i = 0; i < 8; i++) { + if(d & 0x80) { + u16 data = CPUReadByte(source++) << 8; + data |= CPUReadByte(source++); + int length = (data >> 12) + 3; + int offset = (data & 0x0FFF); + u32 windowOffset = dest + byteCount - offset - 1; + for(int i = 0; i < length; i++) { + writeValue |= (CPUReadByte(windowOffset++) << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + CPUWriteHalfWord(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return; + } + } else { + writeValue |= (CPUReadByte(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + CPUWriteHalfWord(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return; + } + d <<= 1; + } + } else { + for(int i = 0; i < 8; i++) { + writeValue |= (CPUReadByte(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + CPUWriteHalfWord(dest, writeValue); + dest += 2; + byteShift = 0; + byteCount = 0; + writeValue = 0; + } + len--; + if(len == 0) + return; + } + } + } +} + +void BIOS_LZ77UnCompWram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("LZ77UnCompWram: 0x%08x,0x%08x (VCOUNT=%d)\n", reg[0].I, reg[1].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int len = header >> 8; + + while(len > 0) { + u8 d = CPUReadByte(source++); + + if(d) { + for(int i = 0; i < 8; i++) { + if(d & 0x80) { + u16 data = CPUReadByte(source++) << 8; + data |= CPUReadByte(source++); + int length = (data >> 12) + 3; + int offset = (data & 0x0FFF); + u32 windowOffset = dest - offset - 1; + for(int i = 0; i < length; i++) { + CPUWriteByte(dest++, CPUReadByte(windowOffset++)); + len--; + if(len == 0) + return; + } + } else { + CPUWriteByte(dest++, CPUReadByte(source++)); + len--; + if(len == 0) + return; + } + d <<= 1; + } + } else { + for(int i = 0; i < 8; i++) { + CPUWriteByte(dest++, CPUReadByte(source++)); + len--; + if(len == 0) + return; + } + } + } +} + +void BIOS_ObjAffineSet() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("ObjAffineSet: 0x%08x,0x%08x,0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + reg[2].I, + reg[3].I, + VCOUNT); + } +#endif + + u32 src = reg[0].I; + u32 dest = reg[1].I; + int num = reg[2].I; + int offset = reg[3].I; + + for(int i = 0; i < num; i++) { + s16 rx = CPUReadHalfWord(src); + src+=2; + s16 ry = CPUReadHalfWord(src); + src+=2; + u16 theta = CPUReadHalfWord(src)>>8; + src+=4; // keep structure alignment + + s32 a = (s32)sineTable[(theta+0x40)&255]; + s32 b = (s32)sineTable[theta]; + + s16 dx = ((s32)rx * a)>>14; + s16 dmx = ((s32)rx * b)>>14; + s16 dy = ((s32)ry * b)>>14; + s16 dmy = ((s32)ry * a)>>14; + + CPUWriteHalfWord(dest, dx); + dest += offset; + CPUWriteHalfWord(dest, -dmx); + dest += offset; + CPUWriteHalfWord(dest, dy); + dest += offset; + CPUWriteHalfWord(dest, dmy); + dest += offset; + } +} + +void BIOS_RegisterRamReset(u32 flags) +{ + // no need to trace here. this is only called directly from GBA.cpp + // to emulate bios initialization + + if(flags) { + if(flags & 0x01) { + // clear work RAM + memset(workRAM, 0, 0x40000); + } + if(flags & 0x02) { + // clear internal RAM + memset(internalRAM, 0, 0x7e00); // don't clear 0x7e00-0x7fff + } + if(flags & 0x04) { + // clear palette RAM + memset(paletteRAM, 0, 0x400); + } + if(flags & 0x08) { + // clear VRAM + memset(vram, 0, 0x18000); + } + if(flags & 0x10) { + // clean OAM + memset(oam, 0, 0x400); + } + + if(flags & 0x80) { + int i; + for(i = 0; i < 8; i++) + CPUUpdateRegister(0x200+i*2, 0); + + CPUUpdateRegister(0x202, 0xFFFF); + + for(i = 0; i < 8; i++) + CPUUpdateRegister(0x4+i*2, 0); + + for(i = 0; i < 16; i++) + CPUUpdateRegister(0x20+i*2, 0); + + for(i = 0; i < 24; i++) + CPUUpdateRegister(0xb0+i*2, 0); + + CPUUpdateRegister(0x130, 0); + CPUUpdateRegister(0x20, 0x100); + CPUUpdateRegister(0x30, 0x100); + CPUUpdateRegister(0x26, 0x100); + CPUUpdateRegister(0x36, 0x100); + } + + if(flags & 0x20) { + int i; + for(i = 0; i < 8; i++) + CPUUpdateRegister(0x110+i*2, 0); + CPUUpdateRegister(0x134, 0x8000); + for(i = 0; i < 7; i++) + CPUUpdateRegister(0x140+i*2, 0); + } + + if(flags & 0x40) { + int i; + CPUWriteByte(0x4000084, 0); + CPUWriteByte(0x4000084, 0x80); + CPUWriteMemory(0x4000080, 0x880e0000); + CPUUpdateRegister(0x88, CPUReadHalfWord(0x4000088)&0x3ff); + CPUWriteByte(0x4000070, 0x70); + for(i = 0; i < 8; i++) + CPUUpdateRegister(0x90+i*2, 0); + CPUWriteByte(0x4000070, 0); + for(i = 0; i < 8; i++) + CPUUpdateRegister(0x90+i*2, 0); + CPUWriteByte(0x4000084, 0); + } + } +} + +void BIOS_RegisterRamReset() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("RegisterRamReset: 0x%08x (VCOUNT=%d)\n", + reg[0].I, + VCOUNT); + } +#endif + + BIOS_RegisterRamReset(reg[0].I); +} + +void BIOS_RLUnCompVram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("RLUnCompVram: 0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int len = header >> 8; + int byteCount = 0; + int byteShift = 0; + u32 writeValue = 0; + + while(len > 0) { + u8 d = CPUReadByte(source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = CPUReadByte(source++); + l += 3; + for(int i = 0;i < l; i++) { + writeValue |= (data << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + CPUWriteHalfWord(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return; + } + } else { + l++; + for(int i = 0; i < l; i++) { + writeValue |= (CPUReadByte(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + CPUWriteHalfWord(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return; + } + } + } +} + +void BIOS_RLUnCompWram() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("RLUnCompWram: 0x%08x,0x%08x (VCOUNT=%d)\n", + reg[0].I, + reg[1].I, + VCOUNT); + } +#endif + + u32 source = reg[0].I; + u32 dest = reg[1].I; + + u32 header = CPUReadMemory(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return; + + int len = header >> 8; + + while(len > 0) { + u8 d = CPUReadByte(source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = CPUReadByte(source++); + l += 3; + for(int i = 0;i < l; i++) { + CPUWriteByte(dest++, data); + len--; + if(len == 0) + return; + } + } else { + l++; + for(int i = 0; i < l; i++) { + CPUWriteByte(dest++, CPUReadByte(source++)); + len--; + if(len == 0) + return; + } + } + } +} + +void BIOS_SoftReset() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("SoftReset: (VCOUNT=%d)\n", VCOUNT); + } +#endif + + armState = true; + armMode = 0x1F; + armIrqEnable = false; + C_FLAG = V_FLAG = N_FLAG = Z_FLAG = false; + reg[13].I = 0x03007F00; + reg[14].I = 0x00000000; + reg[16].I = 0x00000000; + reg[R13_IRQ].I = 0x03007FA0; + reg[R14_IRQ].I = 0x00000000; + reg[SPSR_IRQ].I = 0x00000000; + reg[R13_SVC].I = 0x03007FE0; + reg[R14_SVC].I = 0x00000000; + reg[SPSR_SVC].I = 0x00000000; + u8 b = internalRAM[0x7ffa]; + + memset(&internalRAM[0x7e00], 0, 0x200); + + if(b) { + armNextPC = 0x02000000; + reg[15].I = 0x02000004; + } else { + armNextPC = 0x08000000; + reg[15].I = 0x08000004; + } +} + +void BIOS_Sqrt() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Sqrt: %08x (VCOUNT=%2d)\n", + reg[0].I, + VCOUNT); + } +#endif + reg[0].I = (u32)sqrt((double)reg[0].I); +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("Sqrt: return=%08x\n", + reg[0].I); + } +#endif +} + +void BIOS_MidiKey2Freq() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("MidiKey2Freq: WaveData=%08x mk=%08x fp=%08x\n", + reg[0].I, + reg[1].I, + reg[2].I); + } +#endif + int freq = CPUReadMemory(reg[0].I+4); + double tmp; + tmp = ((double)(180 - reg[1].I)) - ((double)reg[2].I / 256.f); + tmp = pow((double)2.f, tmp / 12.f); + reg[0].I = (int)((double)freq / tmp); + +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("MidiKey2Freq: return %08x\n", + reg[0].I); + } +#endif +} + +void BIOS_SndDriverJmpTableCopy() +{ +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_SWI) { + log("SndDriverJmpTableCopy: dest=%08x\n", + reg[0].I); + } +#endif + for(int i = 0; i < 0x24; i++) { + CPUWriteMemory(reg[0].I, 0x9c); + reg[0].I += 4; + } +} diff --git a/src/bios.h b/src/bios.h new file mode 100644 index 0000000..58b3417 --- /dev/null +++ b/src/bios.h @@ -0,0 +1,46 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_BIOS_H +#define VBA_BIOS_H + +extern void BIOS_ArcTan(); +extern void BIOS_ArcTan2(); +extern void BIOS_BitUnPack(); +extern void BIOS_BgAffineSet(); +extern void BIOS_CpuSet(); +extern void BIOS_CpuFastSet(); +extern void BIOS_Diff8bitUnFilterWram(); +extern void BIOS_Diff8bitUnFilterVram(); +extern void BIOS_Diff16bitUnFilter(); +extern void BIOS_Div(); +extern void BIOS_DivARM(); +extern void BIOS_HuffUnComp(); +extern void BIOS_LZ77UnCompVram(); +extern void BIOS_LZ77UnCompWram(); +extern void BIOS_ObjAffineSet(); +extern void BIOS_RegisterRamReset(); +extern void BIOS_RegisterRamReset(u32); +extern void BIOS_RLUnCompVram(); +extern void BIOS_RLUnCompWram(); +extern void BIOS_SoftReset(); +extern void BIOS_Sqrt(); +extern void BIOS_MidiKey2Freq(); +extern void BIOS_SndDriverJmpTableCopy(); +#endif // VBA_BIOS_H diff --git a/src/elf.cpp b/src/elf.cpp new file mode 100644 index 0000000..90be846 --- /dev/null +++ b/src/elf.cpp @@ -0,0 +1,2997 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#include "GBA.h" +#include "Port.h" +#include "elf.h" +#include "NLS.h" + +#define elfReadMemory(addr) \ + READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define DW_TAG_array_type 0x01 +#define DW_TAG_enumeration_type 0x04 +#define DW_TAG_formal_parameter 0x05 +#define DW_TAG_label 0x0a +#define DW_TAG_lexical_block 0x0b +#define DW_TAG_member 0x0d +#define DW_TAG_pointer_type 0x0f +#define DW_TAG_reference_type 0x10 +#define DW_TAG_compile_unit 0x11 +#define DW_TAG_structure_type 0x13 +#define DW_TAG_subroutine_type 0x15 +#define DW_TAG_typedef 0x16 +#define DW_TAG_union_type 0x17 +#define DW_TAG_unspecified_parameters 0x18 +#define DW_TAG_inheritance 0x1c +#define DW_TAG_inlined_subroutine 0x1d +#define DW_TAG_subrange_type 0x21 +#define DW_TAG_base_type 0x24 +#define DW_TAG_const_type 0x26 +#define DW_TAG_enumerator 0x28 +#define DW_TAG_subprogram 0x2e +#define DW_TAG_variable 0x34 +#define DW_TAG_volatile_type 0x35 + +#define DW_AT_sibling 0x01 +#define DW_AT_location 0x02 +#define DW_AT_name 0x03 +#define DW_AT_byte_size 0x0b +#define DW_AT_bit_offset 0x0c +#define DW_AT_bit_size 0x0d +#define DW_AT_stmt_list 0x10 +#define DW_AT_low_pc 0x11 +#define DW_AT_high_pc 0x12 +#define DW_AT_language 0x13 +#define DW_AT_compdir 0x1b +#define DW_AT_const_value 0x1c +#define DW_AT_containing_type 0x1d +#define DW_AT_inline 0x20 +#define DW_AT_producer 0x25 +#define DW_AT_prototyped 0x27 +#define DW_AT_upper_bound 0x2f +#define DW_AT_abstract_origin 0x31 +#define DW_AT_accessibility 0x32 +#define DW_AT_artificial 0x34 +#define DW_AT_data_member_location 0x38 +#define DW_AT_decl_file 0x3a +#define DW_AT_decl_line 0x3b +#define DW_AT_declaration 0x3c +#define DW_AT_encoding 0x3e +#define DW_AT_external 0x3f +#define DW_AT_frame_base 0x40 +#define DW_AT_macro_info 0x43 +#define DW_AT_specification 0x47 +#define DW_AT_type 0x49 +#define DW_AT_virtuality 0x4c +#define DW_AT_vtable_elem_location 0x4d +// DWARF 2.1/3.0 extensions +#define DW_AT_entry_pc 0x52 +#define DW_AT_ranges 0x55 +// ARM Compiler extensions +#define DW_AT_proc_body 0x2000 +#define DW_AT_save_offset 0x2001 +#define DW_AT_user_2002 0x2002 +// MIPS extensions +#define DW_AT_MIPS_linkage_name 0x2007 + +#define DW_FORM_addr 0x01 +#define DW_FORM_data2 0x05 +#define DW_FORM_data4 0x06 +#define DW_FORM_string 0x08 +#define DW_FORM_block 0x09 +#define DW_FORM_block1 0x0a +#define DW_FORM_data1 0x0b +#define DW_FORM_flag 0x0c +#define DW_FORM_sdata 0x0d +#define DW_FORM_strp 0x0e +#define DW_FORM_udata 0x0f +#define DW_FORM_ref_addr 0x10 +#define DW_FORM_ref4 0x13 +#define DW_FORM_ref_udata 0x15 +#define DW_FORM_indirect 0x16 + +#define DW_OP_addr 0x03 +#define DW_OP_plus_uconst 0x23 +#define DW_OP_reg0 0x50 +#define DW_OP_reg1 0x51 +#define DW_OP_reg2 0x52 +#define DW_OP_reg3 0x53 +#define DW_OP_reg4 0x54 +#define DW_OP_reg5 0x55 +#define DW_OP_reg6 0x56 +#define DW_OP_reg7 0x57 +#define DW_OP_reg8 0x58 +#define DW_OP_reg9 0x59 +#define DW_OP_reg10 0x5a +#define DW_OP_reg11 0x5b +#define DW_OP_reg12 0x5c +#define DW_OP_reg13 0x5d +#define DW_OP_reg14 0x5e +#define DW_OP_reg15 0x5f +#define DW_OP_fbreg 0x91 + +#define DW_LNS_extended_op 0x00 +#define DW_LNS_copy 0x01 +#define DW_LNS_advance_pc 0x02 +#define DW_LNS_advance_line 0x03 +#define DW_LNS_set_file 0x04 +#define DW_LNS_set_column 0x05 +#define DW_LNS_negate_stmt 0x06 +#define DW_LNS_set_basic_block 0x07 +#define DW_LNS_const_add_pc 0x08 +#define DW_LNS_fixed_advance_pc 0x09 + +#define DW_LNE_end_sequence 0x01 +#define DW_LNE_set_address 0x02 +#define DW_LNE_define_file 0x03 + +#define DW_CFA_advance_loc 0x01 +#define DW_CFA_offset 0x02 +#define DW_CFA_restore 0x03 +#define DW_CFA_set_loc 0x01 +#define DW_CFA_advance_loc1 0x02 +#define DW_CFA_advance_loc2 0x03 +#define DW_CFA_advance_loc4 0x04 +#define DW_CFA_offset_extended 0x05 +#define DW_CFA_restore_extended 0x06 +#define DW_CFA_undefined 0x07 +#define DW_CFA_same_value 0x08 +#define DW_CFA_register 0x09 +#define DW_CFA_remember_state 0x0a +#define DW_CFA_restore_state 0x0b +#define DW_CFA_def_cfa 0x0c +#define DW_CFA_def_cfa_register 0x0d +#define DW_CFA_def_cfa_offset 0x0e +#define DW_CFA_nop 0x00 + +#define CASE_TYPE_TAG \ + case DW_TAG_const_type:\ + case DW_TAG_volatile_type:\ + case DW_TAG_pointer_type:\ + case DW_TAG_base_type:\ + case DW_TAG_array_type:\ + case DW_TAG_structure_type:\ + case DW_TAG_union_type:\ + case DW_TAG_typedef:\ + case DW_TAG_subroutine_type:\ + case DW_TAG_enumeration_type:\ + case DW_TAG_enumerator:\ + case DW_TAG_reference_type + +struct ELFcie { + ELFcie *next; + u32 offset; + u8 *augmentation; + u32 codeAlign; + s32 dataAlign; + int returnAddress; + u8 *data; + u32 dataLen; +}; + +struct ELFfde { + ELFcie *cie; + u32 address; + u32 end; + u8 *data; + u32 dataLen; +}; + +enum ELFRegMode { + REG_NOT_SET, + REG_OFFSET, + REG_REGISTER +}; + + +struct ELFFrameStateRegister { + ELFRegMode mode; + int reg; + s32 offset; +}; + +struct ELFFrameStateRegisters { + ELFFrameStateRegister regs[16]; + ELFFrameStateRegisters *previous; +}; + +enum ELFCfaMode { + CFA_NOT_SET, + CFA_REG_OFFSET +}; + +struct ELFFrameState { + ELFFrameStateRegisters registers; + + ELFCfaMode cfaMode; + int cfaRegister; + s32 cfaOffset; + + u32 pc; + + int dataAlign; + int codeAlign; + int returnAddress; +}; + +extern bool cpuIsMultiBoot; + +Symbol *elfSymbols = NULL; +char *elfSymbolsStrTab = NULL; +int elfSymbolsCount = 0; + +ELFSectionHeader **elfSectionHeaders = NULL; +char *elfSectionHeadersStringTable = NULL; +int elfSectionHeadersCount = 0; +u8 *elfFileData = NULL; + +CompileUnit *elfCompileUnits = NULL; +DebugInfo *elfDebugInfo = NULL; +char *elfDebugStrings = NULL; + +ELFcie *elfCies = NULL; +ELFfde **elfFdes = NULL; +int elfFdeCount = 0; + +CompileUnit *elfCurrentUnit = NULL; + +u32 elfRead4Bytes(u8 *); +u16 elfRead2Bytes(u8 *); + +CompileUnit *elfGetCompileUnit(u32 addr) +{ + if(elfCompileUnits) { + CompileUnit *unit = elfCompileUnits; + while(unit) { + if(unit->lowPC) { + if(addr >= unit->lowPC && addr < unit->highPC) + return unit; + } else { + ARanges *r = unit->ranges; + if(r) { + int count = r->count; + for(int j = 0; j < count; j++) { + if(addr >= r->ranges[j].lowPC && addr < r->ranges[j].highPC) + return unit; + } + } + } + unit = unit->next; + } + } + return NULL; +} + +char *elfGetAddressSymbol(u32 addr) +{ + static char buffer[256]; + + CompileUnit *unit = elfGetCompileUnit(addr); + // found unit, need to find function + if(unit) { + Function *func = unit->functions; + while(func) { + if(addr >= func->lowPC && addr < func->highPC) { + int offset = addr - func->lowPC; + char *name = func->name; + if(!name) + name = ""; + if(offset) + sprintf(buffer, "%s+%d", name, offset); + else + strcpy(buffer, name); + return buffer; + } + func = func->next; + } + } + + if(elfSymbolsCount) { + for(int i = 0; i < elfSymbolsCount; i++) { + Symbol *s = &elfSymbols[i]; + if((addr >= s->value) && addr < (s->value+s->size)) { + int offset = addr-s->value; + char *name = s->name; + if(name == NULL) + name = ""; + if(offset) + sprintf(buffer, "%s+%d", name, addr-s->value); + else + strcpy(buffer, name); + return buffer; + } else if(addr == s->value) { + if(s->name) + strcpy(buffer, s->name); + else + strcpy(buffer, ""); + return buffer; + } + } + } + + return ""; +} + +bool elfFindLineInModule(u32 *addr, char *name, int line) +{ + CompileUnit *unit = elfCompileUnits; + + while(unit) { + if(unit->lineInfoTable) { + int i; + int count = unit->lineInfoTable->fileCount; + char *found = NULL; + for(i = 0; i < count; i++) { + if(strcmp(name, unit->lineInfoTable->files[i]) == 0) { + found = unit->lineInfoTable->files[i]; + break; + } + } + // found a matching filename... try to find line now + if(found) { + LineInfoItem *table = unit->lineInfoTable->lines; + count = unit->lineInfoTable->number; + for(i = 0; i < count; i++) { + if(table[i].file == found && table[i].line == line) { + *addr = table[i].address; + return true; + } + } + // we can only find a single match + return false; + } + } + unit = unit->next; + } + return false; +} + +int elfFindLine(CompileUnit *unit, Function * /* func */, u32 addr, char **f) +{ + int currentLine = -1; + if(unit->hasLineInfo) { + int count = unit->lineInfoTable->number; + LineInfoItem *table = unit->lineInfoTable->lines; + int i; + for(i = 0; i < count; i++) { + if(addr <= table[i].address) + break; + } + if(i == count) + i--; + *f = table[i].file; + currentLine = table[i].line; + } + return currentLine; +} + +bool elfFindLineInUnit(u32 *addr, CompileUnit *unit, int line) +{ + if(unit->hasLineInfo) { + int count = unit->lineInfoTable->number; + LineInfoItem *table = unit->lineInfoTable->lines; + int i; + for(i = 0; i < count; i++) { + if(line == table[i].line) { + *addr = table[i].address; + return true; + } + } + } + return false; +} + +bool elfGetCurrentFunction(u32 addr, Function **f, CompileUnit **u) +{ + CompileUnit *unit = elfGetCompileUnit(addr); + // found unit, need to find function + if(unit) { + Function *func = unit->functions; + while(func) { + if(addr >= func->lowPC && addr < func->highPC) { + *f = func; + *u = unit; + return true; + } + func = func->next; + } + } + return false; +} + +bool elfGetObject(char *name, Function *f, CompileUnit *u, Object **o) +{ + if(f && u) { + Object *v = f->variables; + + while(v) { + if(strcmp(name, v->name) == 0) { + *o = v; + return true; + } + v = v->next; + } + v = f->parameters; + while(v) { + if(strcmp(name, v->name) == 0) { + *o = v; + return true; + } + v = v->next; + } + v = u->variables; + while(v) { + if(strcmp(name, v->name) == 0) { + *o = v; + return true; + } + v = v->next; + } + } + + CompileUnit *c = elfCompileUnits; + + while(c) { + if(c != u) { + Object *v = c->variables; + while(v) { + if(strcmp(name, v->name) == 0) { + *o = v; + return true; + } + v = v->next; + } + } + c = c->next; + } + + return false; +} + +char *elfGetSymbol(int i, u32 *value, u32 *size, int *type) +{ + if(i < elfSymbolsCount) { + Symbol *s = &elfSymbols[i]; + *value = s->value; + *size = s->size; + *type = s->type; + return s->name; + } + return NULL; +} + +bool elfGetSymbolAddress(char *sym, u32 *addr, u32 *size, int *type) +{ + if(elfSymbolsCount) { + for(int i = 0; i < elfSymbolsCount; i++) { + Symbol *s = &elfSymbols[i]; + if(strcmp(sym, s->name) == 0) { + *addr = s->value; + *size = s->size; + *type = s->type; + return true; + } + } + } + return false; +} + +ELFfde *elfGetFde(u32 address) +{ + if(elfFdes) { + int i; + for(i = 0; i < elfFdeCount; i++) { + if(address >= elfFdes[i]->address && + address < elfFdes[i]->end) { + return elfFdes[i]; + } + } + } + + return NULL; +} + +void elfExecuteCFAInstructions(ELFFrameState *state, u8 *data, u32 len, + u32 pc) +{ + u8 *end = data + len; + int bytes; + int reg; + ELFFrameStateRegisters *fs; + + while(data < end && state->pc < pc) { + u8 op = *data++; + + switch(op >> 6) { + case DW_CFA_advance_loc: + state->pc += (op & 0x3f) * state->codeAlign; + break; + case DW_CFA_offset: + reg = op & 0x3f; + state->registers.regs[reg].mode = REG_OFFSET; + state->registers.regs[reg].offset = state->dataAlign * + (s32)elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_CFA_restore: + // we don't care much about the other possible settings, + // so just setting to unset is enough for now + state->registers.regs[op & 0x3f].mode = REG_NOT_SET; + break; + case 0: + switch(op & 0x3f) { + case DW_CFA_nop: + break; + case DW_CFA_advance_loc1: + state->pc += state->codeAlign * (*data++); + break; + case DW_CFA_advance_loc2: + state->pc += state->codeAlign * elfRead2Bytes(data); + data += 2; + break; + case DW_CFA_advance_loc4: + state->pc += state->codeAlign * elfRead4Bytes(data); + data += 4; + break; + case DW_CFA_offset_extended: + reg = elfReadLEB128(data, &bytes); + data += bytes; + state->registers.regs[reg].mode = REG_OFFSET; + state->registers.regs[reg].offset = state->dataAlign * + (s32)elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_CFA_restore_extended: + case DW_CFA_undefined: + case DW_CFA_same_value: + reg = elfReadLEB128(data, &bytes); + data += bytes; + state->registers.regs[reg].mode = REG_NOT_SET; + break; + case DW_CFA_register: + reg = elfReadLEB128(data, &bytes); + data += bytes; + state->registers.regs[reg].mode = REG_REGISTER; + state->registers.regs[reg].reg = elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_CFA_remember_state: + fs = (ELFFrameStateRegisters *)calloc(1, + sizeof(ELFFrameStateRegisters)); + memcpy(fs, &state->registers, sizeof(ELFFrameStateRegisters)); + state->registers.previous = fs; + break; + case DW_CFA_restore_state: + if(state->registers.previous == NULL) { + printf("Error: previous frame state is NULL.\n"); + return; + } + fs = state->registers.previous; + memcpy(&state->registers, fs, sizeof(ELFFrameStateRegisters)); + free(fs); + break; + case DW_CFA_def_cfa: + state->cfaRegister = elfReadLEB128(data, &bytes); + data += bytes; + state->cfaOffset = (s32)elfReadLEB128(data, &bytes); + data += bytes; + state->cfaMode = CFA_REG_OFFSET; + break; + case DW_CFA_def_cfa_register: + state->cfaRegister = elfReadLEB128(data, &bytes); + data += bytes; + state->cfaMode = CFA_REG_OFFSET; + break; + case DW_CFA_def_cfa_offset: + state->cfaOffset = (s32)elfReadLEB128(data, &bytes); + data += bytes; + state->cfaMode = CFA_REG_OFFSET; + break; + default: + printf("Unknown CFA opcode %08x\n", op); + return; + } + break; + default: + printf("Unknown CFA opcode %08x\n", op); + return; + } + } +} + +ELFFrameState *elfGetFrameState(ELFfde *fde, u32 address) +{ + ELFFrameState *state = (ELFFrameState *)calloc(1, sizeof(ELFFrameState)); + state->pc = fde->address; + state->dataAlign = fde->cie->dataAlign; + state->codeAlign = fde->cie->codeAlign; + state->returnAddress = fde->cie->returnAddress; + + elfExecuteCFAInstructions(state, + fde->cie->data, + fde->cie->dataLen, + 0xffffffff); + elfExecuteCFAInstructions(state, + fde->data, + fde->dataLen, + address); + + return state; +} + +void elfPrintCallChain(u32 address) +{ + int count = 1; + + reg_pair regs[15]; + reg_pair newRegs[15]; + + memcpy(®s[0], ®[0], sizeof(reg_pair) * 15); + + while(count < 20) { + char *addr = elfGetAddressSymbol(address); + if(*addr == 0) + addr = "???"; + + printf("%08x %s\n", address, addr); + + ELFfde *fde = elfGetFde(address); + + if(fde == NULL) { + break; + } + + ELFFrameState *state = elfGetFrameState(fde, address); + + if(!state) { + break; + } + + if(state->cfaMode == CFA_REG_OFFSET) { + memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15); + u32 addr = 0; + for(int i = 0; i < 15; i++) { + ELFFrameStateRegister *r = &state->registers. + regs[i]; + + switch(r->mode) { + case REG_NOT_SET: + newRegs[i].I = regs[i].I; + break; + case REG_OFFSET: + newRegs[i].I = elfReadMemory(regs[state->cfaRegister].I + + state->cfaOffset + + r->offset); + break; + case REG_REGISTER: + newRegs[i].I = regs[r->reg].I; + break; + default: + printf("Unknown register mode: %d\n", r->mode); + break; + } + } + memcpy(regs, newRegs, sizeof(reg_pair)*15); + addr = newRegs[14].I; + addr &= 0xfffffffe; + address = addr; + count++; + } else { + printf("CFA not set\n"); + break; + } + if(state->registers.previous) { + ELFFrameStateRegisters *prev = state->registers.previous; + + while(prev) { + ELFFrameStateRegisters *p = prev->previous; + free(prev); + prev = p; + } + } + free(state); + } +} + +u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base) +{ + u32 framebase = 0; + if(f && f->frameBase) { + ELFBlock *b = f->frameBase; + switch(*b->data) { + case DW_OP_reg0: + case DW_OP_reg1: + case DW_OP_reg2: + case DW_OP_reg3: + case DW_OP_reg4: + case DW_OP_reg5: + case DW_OP_reg6: + case DW_OP_reg7: + case DW_OP_reg8: + case DW_OP_reg9: + case DW_OP_reg10: + case DW_OP_reg11: + case DW_OP_reg12: + case DW_OP_reg13: + case DW_OP_reg14: + case DW_OP_reg15: + framebase = reg[*b->data-0x50].I; + break; + default: + fprintf(stderr, "Unknown frameBase %02x\n", *b->data); + break; + } + } + + ELFBlock *loc = o; + u32 location = 0; + int bytes = 0; + if(loc) { + switch(*loc->data) { + case DW_OP_addr: + location = elfRead4Bytes(loc->data+1); + *type = LOCATION_memory; + break; + case DW_OP_plus_uconst: + location = base + elfReadLEB128(loc->data+1, &bytes); + *type = LOCATION_memory; + break; + case DW_OP_reg0: + case DW_OP_reg1: + case DW_OP_reg2: + case DW_OP_reg3: + case DW_OP_reg4: + case DW_OP_reg5: + case DW_OP_reg6: + case DW_OP_reg7: + case DW_OP_reg8: + case DW_OP_reg9: + case DW_OP_reg10: + case DW_OP_reg11: + case DW_OP_reg12: + case DW_OP_reg13: + case DW_OP_reg14: + case DW_OP_reg15: + location = *loc->data - 0x50; + *type = LOCATION_register; + break; + case DW_OP_fbreg: + { + int bytes; + s32 off = elfReadSignedLEB128(loc->data+1, &bytes); + location = framebase + off; + *type = LOCATION_memory; + } + break; + default: + fprintf(stderr, "Unknown location %02x\n", *loc->data); + break; + } + } + return location; +} + +u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type) +{ + return elfDecodeLocation(f, o, type, 0); +} + +// reading function + +u32 elfRead4Bytes(u8 *data) +{ + u32 value = *data++; + value |= (*data++ << 8); + value |= (*data++ << 16); + value |= (*data << 24); + return value; +} + +u16 elfRead2Bytes(u8 *data) +{ + u16 value = *data++; + value |= (*data << 8); + return value; +} + +char *elfReadString(u8 *data, int *bytesRead) +{ + if(*data == 0) { + *bytesRead = 1; + return NULL; + } + *bytesRead = strlen((char *)data) + 1; + return (char *)data; +} + +s32 elfReadSignedLEB128(u8 *data, int *bytesRead) +{ + s32 result = 0; + int shift = 0; + int count = 0; + + u8 byte; + do { + byte = *data++; + count++; + result |= (byte & 0x7f) << shift; + shift += 7; + } while(byte & 0x80); + if((shift < 32) && (byte & 0x40)) + result |= -(1 << shift); + *bytesRead = count; + return result; +} + +u32 elfReadLEB128(u8 *data, int *bytesRead) +{ + u32 result = 0; + int shift = 0; + int count = 0; + u8 byte; + do { + byte = *data++; + count++; + result |= (byte & 0x7f) << shift; + shift += 7; + } while(byte & 0x80); + *bytesRead = count; + return result; +} + +u8 *elfReadSection(u8 *data, ELFSectionHeader *sh) +{ + return data + READ32LE(&sh->offset); +} + +ELFSectionHeader *elfGetSectionByName(char *name) +{ + for(int i = 0; i < elfSectionHeadersCount; i++) { + if(strcmp(name, + &elfSectionHeadersStringTable[READ32LE(&elfSectionHeaders[i]-> + name)]) == 0) { + return elfSectionHeaders[i]; + } + } + return NULL; +} + +ELFSectionHeader *elfGetSectionByNumber(int number) +{ + if(number < elfSectionHeadersCount) { + return elfSectionHeaders[number]; + } + return NULL; +} + +CompileUnit *elfGetCompileUnitForData(u8 *data) +{ + u8 *end = elfCurrentUnit->top + 4 + elfCurrentUnit->length; + + if(data >= elfCurrentUnit->top && data < end) + return elfCurrentUnit; + + CompileUnit *unit = elfCompileUnits; + + while(unit) { + end = unit->top + 4 + unit->length; + + if(data >= unit->top && data < end) + return unit; + + unit = unit->next; + } + + printf("Error: cannot find reference to compile unit at offset %08x\n", + (int)(data - elfDebugInfo->infodata)); + exit(-1); +} + +u8 *elfReadAttribute(u8 *data, ELFAttr *attr) +{ + int bytes; + int form = attr->form; + start: + switch(form) { + case DW_FORM_addr: + attr->value = elfRead4Bytes(data); + data += 4; + break; + case DW_FORM_data2: + attr->value = elfRead2Bytes(data); + data += 2; + break; + case DW_FORM_data4: + attr->value = elfRead4Bytes(data); + data += 4; + break; + case DW_FORM_string: + attr->string = (char *)data; + data += strlen(attr->string)+1; + break; + case DW_FORM_strp: + attr->string = elfDebugStrings + elfRead4Bytes(data); + data += 4; + break; + case DW_FORM_block: + attr->block = (ELFBlock *)malloc(sizeof(ELFBlock)); + attr->block->length = elfReadLEB128(data, &bytes); + data += bytes; + attr->block->data = data; + data += attr->block->length; + break; + case DW_FORM_block1: + attr->block = (ELFBlock *)malloc(sizeof(ELFBlock)); + attr->block->length = *data++; + attr->block->data = data; + data += attr->block->length; + break; + case DW_FORM_data1: + attr->value = *data++; + break; + case DW_FORM_flag: + attr->flag = (*data++) ? true : false; + break; + case DW_FORM_sdata: + attr->value = elfReadSignedLEB128(data, &bytes); + data += bytes; + break; + case DW_FORM_udata: + attr->value = elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_FORM_ref_addr: + attr->value = (elfDebugInfo->infodata + elfRead4Bytes(data)) - + elfGetCompileUnitForData(data)->top; + data += 4; + break; + case DW_FORM_ref4: + attr->value = elfRead4Bytes(data); + data += 4; + break; + case DW_FORM_ref_udata: + attr->value = (elfDebugInfo->infodata + + (elfGetCompileUnitForData(data)->top - + elfDebugInfo->infodata) + + elfReadLEB128(data, &bytes)) - + elfCurrentUnit->top; + data += bytes; + break; + case DW_FORM_indirect: + form = elfReadLEB128(data, &bytes); + data += bytes; + goto start; + default: + fprintf(stderr, "Unsupported FORM %02x\n", form); + exit(-1); + } + return data; +} + +ELFAbbrev *elfGetAbbrev(ELFAbbrev **table, u32 number) +{ + int hash = number % 121; + + ELFAbbrev *abbrev = table[hash]; + + while(abbrev) { + if(abbrev->number == number) + return abbrev; + abbrev = abbrev->next; + } + return NULL; +} + +ELFAbbrev **elfReadAbbrevs(u8 *data, u32 offset) +{ + data += offset; + ELFAbbrev **abbrevs = (ELFAbbrev **)calloc(sizeof(ELFAbbrev *)*121,1); + int bytes = 0; + u32 number = elfReadLEB128(data, &bytes); + data += bytes; + while(number) { + ELFAbbrev *abbrev = (ELFAbbrev *)calloc(sizeof(ELFAbbrev),1); + + // read tag information + abbrev->number = number; + abbrev->tag = elfReadLEB128(data, &bytes); + data += bytes; + abbrev->hasChildren = *data++ ? true: false; + + // read attributes + int name = elfReadLEB128(data, &bytes); + data += bytes; + int form = elfReadLEB128(data, &bytes); + data += bytes; + + while(name) { + if((abbrev->numAttrs % 4) == 0) { + abbrev->attrs = (ELFAttr *)realloc(abbrev->attrs, + (abbrev->numAttrs + 4) * + sizeof(ELFAttr)); + } + abbrev->attrs[abbrev->numAttrs].name = name; + abbrev->attrs[abbrev->numAttrs++].form = form; + + name = elfReadLEB128(data, &bytes); + data += bytes; + form = elfReadLEB128(data, &bytes); + data += bytes; + } + + int hash = number % 121; + abbrev->next = abbrevs[hash]; + abbrevs[hash] = abbrev; + + number = elfReadLEB128(data, &bytes); + data += bytes; + + if(elfGetAbbrev(abbrevs, number) != NULL) + break; + } + + return abbrevs; +} + +void elfParseCFA(u8 *top) +{ + ELFSectionHeader *h = elfGetSectionByName(".debug_frame"); + + if(h == NULL) { + return; + } + + u8 *data = elfReadSection(top, h); + + u8 *topOffset = data; + + u8 *end = data + READ32LE(&h->size); + + ELFcie *cies = NULL; + + while(data < end) { + u32 offset = data - topOffset; + u32 len = elfRead4Bytes(data); + data += 4; + + u8 *dataEnd = data + len; + + u32 id = elfRead4Bytes(data); + data += 4; + + if(id == 0xffffffff) { + // skip version + *data++; + + ELFcie *cie = (ELFcie *)calloc(1, sizeof(ELFcie)); + + cie->next = cies; + cies = cie; + + cie->offset = offset; + + cie->augmentation = data; + while(*data) + data++; + data++; + + if(*cie->augmentation) { + fprintf(stderr, "Error: augmentation not supported\n"); + exit(-1); + } + + int bytes; + cie->codeAlign = elfReadLEB128(data, &bytes); + data += bytes; + + cie->dataAlign = elfReadSignedLEB128(data, &bytes); + data += bytes; + + cie->returnAddress = *data++; + + cie->data = data; + cie->dataLen = dataEnd - data; + } else { + ELFfde *fde = (ELFfde *)calloc(1, sizeof(ELFfde)); + + ELFcie *cie = cies; + + while(cie != NULL) { + if(cie->offset == id) + break; + cie = cie->next; + } + + if(!cie) { + fprintf(stderr, "Cannot find CIE %08x\n", id); + exit(-1); + } + + fde->cie = cie; + + fde->address = elfRead4Bytes(data); + data += 4; + + fde->end = fde->address + elfRead4Bytes(data); + data += 4; + + fde->data = data; + fde->dataLen = dataEnd - data; + + if((elfFdeCount %10) == 0) { + elfFdes = (ELFfde **)realloc(elfFdes, (elfFdeCount+10) * + sizeof(ELFfde *)); + } + elfFdes[elfFdeCount++] = fde; + } + data = dataEnd; + } + + elfCies = cies; +} + +void elfAddLine(LineInfo *l, u32 a, int file, int line, int *max) +{ + if(l->number == *max) { + *max += 1000; + l->lines = (LineInfoItem *)realloc(l->lines, *max*sizeof(LineInfoItem)); + } + LineInfoItem *li = &l->lines[l->number]; + li->file = l->files[file-1]; + li->address = a; + li->line = line; + l->number++; +} + +void elfParseLineInfo(CompileUnit *unit, u8 *top) +{ + ELFSectionHeader *h = elfGetSectionByName(".debug_line"); + if(h == NULL) { + fprintf(stderr, "No line information found\n"); + return; + } + LineInfo *l = unit->lineInfoTable = (LineInfo *)calloc(1, sizeof(LineInfo)); + l->number = 0; + int max = 1000; + l->lines = (LineInfoItem *)malloc(1000*sizeof(LineInfoItem)); + + u8 *data = elfReadSection(top, h); + data += unit->lineInfo; + u32 totalLen = elfRead4Bytes(data); + data += 4; + u8 *end = data + totalLen; + // u16 version = elfRead2Bytes(data); + data += 2; + // u32 offset = elfRead4Bytes(data); + data += 4; + int minInstrSize = *data++; + int defaultIsStmt = *data++; + int lineBase = (s8)*data++; + int lineRange = *data++; + int opcodeBase = *data++; + u8 *stdOpLen = (u8 *)malloc(opcodeBase * sizeof(u8)); + stdOpLen[0] = 1; + int i; + for(i = 1; i < opcodeBase; i++) + stdOpLen[i] = *data++; + + free(stdOpLen);// todo + int bytes = 0; + + char *s; + while((s = elfReadString(data, &bytes)) != NULL) { + data += bytes; + // fprintf(stderr, "Directory is %s\n", s); + } + data += bytes; + int count = 4; + int index = 0; + l->files = (char **)malloc(sizeof(char *)*count); + + while((s = elfReadString(data, &bytes)) != NULL) { + l->files[index++] = s; + + data += bytes; + // directory + elfReadLEB128(data, &bytes); + data += bytes; + // time + elfReadLEB128(data, &bytes); + data += bytes; + // size + elfReadLEB128(data, &bytes); + data += bytes; + // fprintf(stderr, "File is %s\n", s); + if(index == count) { + count += 4; + l->files = (char **)realloc(l->files, sizeof(char *)*count); + } + } + l->fileCount = index; + data += bytes; + + while(data < end) { + u32 address = 0; + int file = 1; + int line = 1; + int col = 0; + int isStmt = defaultIsStmt; + int basicBlock = 0; + int endSeq = 0; + + while(!endSeq) { + int op = *data++; + switch(op) { + case DW_LNS_extended_op: + { + data++; + op = *data++; + switch(op) { + case DW_LNE_end_sequence: + endSeq = 1; + break; + case DW_LNE_set_address: + address = elfRead4Bytes(data); + data += 4; + break; + default: + fprintf(stderr, "Unknown extended LINE opcode %02x\n", op); + exit(-1); + } + } + break; + case DW_LNS_copy: + // fprintf(stderr, "Address %08x line %d (%d)\n", address, line, file); + elfAddLine(l, address, file, line, &max); + basicBlock = 0; + break; + case DW_LNS_advance_pc: + address += minInstrSize * elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_LNS_advance_line: + line += elfReadSignedLEB128(data, &bytes); + data += bytes; + break; + case DW_LNS_set_file: + file = elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_LNS_set_column: + col = elfReadLEB128(data, &bytes); + data += bytes; + break; + case DW_LNS_negate_stmt: + isStmt = !isStmt; + break; + case DW_LNS_set_basic_block: + basicBlock = 1; + break; + case DW_LNS_const_add_pc: + address += (minInstrSize *((255 - opcodeBase)/lineRange)); + break; + case DW_LNS_fixed_advance_pc: + address += elfRead2Bytes(data); + data += 2; + break; + default: + op = op - opcodeBase; + address += (op / lineRange) * minInstrSize; + line += lineBase + (op % lineRange); + elfAddLine(l, address, file, line, &max); + // fprintf(stderr, "Address %08x line %d (%d)\n", address, line,file); + basicBlock = 1; + break; + } + } + } + l->lines = (LineInfoItem *)realloc(l->lines, l->number*sizeof(LineInfoItem)); +} + +u8 *elfSkipData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs) +{ + int i; + int bytes; + + for(i = 0; i < abbrev->numAttrs; i++) { + data = elfReadAttribute(data, &abbrev->attrs[i]); + if(abbrev->attrs[i].form == DW_FORM_block1) + free(abbrev->attrs[i].block); + } + + if(abbrev->hasChildren) { + int nesting = 1; + while(nesting) { + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + nesting--; + continue; + } + + abbrev = elfGetAbbrev(abbrevs, abbrevNum); + + for(i = 0; i < abbrev->numAttrs; i++) { + data = elfReadAttribute(data, &abbrev->attrs[i]); + if(abbrev->attrs[i].form == DW_FORM_block1) + free(abbrev->attrs[i].block); + } + + if(abbrev->hasChildren) { + nesting++; + } + } + } + return data; +} + +Type *elfParseType(CompileUnit *unit, u32); +u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, + Object **object); +u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, + Function **function); +void elfCleanUp(Function *); + +void elfAddType(Type *type, CompileUnit *unit, u32 offset) +{ + if(type->next == NULL) { + if(unit->types != type && type->offset == 0) { + type->offset = offset; + type->next = unit->types; + unit->types = type; + } + } +} + +void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit, + Type **type) +{ + switch(abbrev->tag) { + case DW_TAG_typedef: + { + u32 typeref = 0; + char *name = NULL; + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + name = attr->string; + break; + case DW_AT_type: + typeref = attr->value; + break; + case DW_AT_decl_file: + case DW_AT_decl_line: + break; + default: + fprintf(stderr, "Unknown attribute for typedef %02x\n", attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for typedef\n"); + *type = elfParseType(unit, typeref); + if(name) + (*type)->name = name; + return; + } + break; + case DW_TAG_union_type: + case DW_TAG_structure_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + if(abbrev->tag == DW_TAG_structure_type) + t->type = TYPE_struct; + else + t->type = TYPE_union; + + Struct *s = (Struct *)calloc(sizeof(Struct), 1); + t->structure = s; + elfAddType(t, unit, offset); + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + t->name = attr->string; + break; + case DW_AT_byte_size: + t->size = attr->value; + break; + case DW_AT_decl_file: + case DW_AT_decl_line: + case DW_AT_sibling: + case DW_AT_containing_type: // todo? + case DW_AT_declaration: + case DW_AT_specification: // TODO: + break; + default: + fprintf(stderr, "Unknown attribute for struct %02x\n", attr->name); + break; + } + } + if(abbrev->hasChildren) { + int bytes; + u32 num = elfReadLEB128(data, &bytes); + data += bytes; + int index = 0; + while(num) { + ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); + + switch(abbr->tag) { + case DW_TAG_member: + { + if((index % 4) == 0) + s->members = (Member *)realloc(s->members, + sizeof(Member)*(index+4)); + Member *m = &s->members[index]; + m->location = NULL; + m->bitOffset = 0; + m->bitSize = 0; + m->byteSize = 0; + for(int i = 0; i < abbr->numAttrs; i++) { + ELFAttr *attr = &abbr->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + m->name = attr->string; + break; + case DW_AT_type: + m->type = elfParseType(unit, attr->value); + break; + case DW_AT_data_member_location: + m->location = attr->block; + break; + case DW_AT_byte_size: + m->byteSize = attr->value; + break; + case DW_AT_bit_offset: + m->bitOffset = attr->value; + break; + case DW_AT_bit_size: + m->bitSize = attr->value; + break; + case DW_AT_decl_file: + case DW_AT_decl_line: + case DW_AT_accessibility: + case DW_AT_artificial: // todo? + break; + default: + fprintf(stderr, "Unknown member attribute %02x\n", + attr->name); + } + } + index++; + } + break; + case DW_TAG_subprogram: + { + Function *fnc = NULL; + data = elfParseFunction(data, abbr, unit, &fnc); + if(fnc != NULL) { + if(unit->lastFunction) + unit->lastFunction->next = fnc; + else + unit->functions = fnc; + unit->lastFunction = fnc; + } + } + break; + case DW_TAG_inheritance: + // TODO: add support + data = elfSkipData(data, abbr, unit->abbrevs); + break; + CASE_TYPE_TAG: + // skip types... parsed only when used + data = elfSkipData(data, abbr, unit->abbrevs); + break; + case DW_TAG_variable: + data = elfSkipData(data, abbr, unit->abbrevs); + break; + default: + fprintf(stderr, "Unknown struct tag %02x %s\n", abbr->tag, t->name); + data = elfSkipData(data, abbr, unit->abbrevs); + break; + } + num = elfReadLEB128(data, &bytes); + data += bytes; + } + s->memberCount = index; + } + *type = t; + return; + } + break; + case DW_TAG_base_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + + t->type = TYPE_base; + elfAddType(t, unit, offset); + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + t->name = attr->string; + break; + case DW_AT_encoding: + t->encoding = attr->value; + break; + case DW_AT_byte_size: + t->size = attr->value; + break; + case DW_AT_bit_size: + t->bitSize = attr->value; + break; + default: + fprintf(stderr, "Unknown attribute for base type %02x\n", + attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for base type\n"); + *type = t; + return; + } + break; + case DW_TAG_pointer_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + + t->type = TYPE_pointer; + + elfAddType(t, unit, offset); + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data =elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_type: + t->pointer = elfParseType(unit, attr->value); + break; + case DW_AT_byte_size: + t->size = attr->value; + break; + default: + fprintf(stderr, "Unknown pointer type attribute %02x\n", attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for pointer type\n"); + *type = t; + return; + } + break; + case DW_TAG_reference_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + + t->type = TYPE_reference; + + elfAddType(t, unit, offset); + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data =elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_type: + t->pointer = elfParseType(unit, attr->value); + break; + case DW_AT_byte_size: + t->size = attr->value; + break; + default: + fprintf(stderr, "Unknown ref type attribute %02x\n", attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for ref type\n"); + *type = t; + return; + } + break; + case DW_TAG_volatile_type: + { + u32 typeref = 0; + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_type: + typeref = attr->value; + break; + default: + fprintf(stderr, "Unknown volatile attribute for type %02x\n", + attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for volatile type\n"); + *type = elfParseType(unit, typeref); + return; + } + break; + case DW_TAG_const_type: + { + u32 typeref = 0; + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_type: + typeref = attr->value; + break; + default: + fprintf(stderr, "Unknown const attribute for type %02x\n", + attr->name); + break; + } + } + if(abbrev->hasChildren) + fprintf(stderr, "Unexpected children for const type\n"); + *type = elfParseType(unit, typeref); + return; + } + break; + case DW_TAG_enumeration_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + t->type = TYPE_enum; + Enum *e = (Enum *)calloc(sizeof(Enum), 1); + t->enumeration = e; + elfAddType(t, unit, offset); + int count = 0; + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + t->name = attr->string; + break; + case DW_AT_byte_size: + t->size = attr->value; + break; + case DW_AT_sibling: + case DW_AT_decl_file: + case DW_AT_decl_line: + break; + default: + fprintf(stderr, "Unknown enum attribute %02x\n", attr->name); + } + } + if(abbrev->hasChildren) { + int bytes; + u32 num = elfReadLEB128(data, &bytes); + data += bytes; + while(num) { + ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); + + switch(abbr->tag) { + case DW_TAG_enumerator: + { + count++; + e->members = (EnumMember *)realloc(e->members, + count*sizeof(EnumMember)); + EnumMember *m = &e->members[count-1]; + for(int i = 0; i < abbr->numAttrs; i++) { + ELFAttr *attr = &abbr->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_name: + m->name = attr->string; + break; + case DW_AT_const_value: + m->value = attr->value; + break; + default: + fprintf(stderr, "Unknown sub param attribute %02x\n", + attr->name); + } + } + } + break; + default: + fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag); + data = elfSkipData(data, abbr, unit->abbrevs); + break; + } + num = elfReadLEB128(data, &bytes); + data += bytes; + } + } + e->count = count; + *type = t; + return; + } + break; + case DW_TAG_subroutine_type: + { + Type *t = (Type *)calloc(sizeof(Type), 1); + t->type = TYPE_function; + FunctionType *f = (FunctionType *)calloc(sizeof(FunctionType), 1); + t->function = f; + elfAddType(t, unit, offset); + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_prototyped: + case DW_AT_sibling: + break; + case DW_AT_type: + f->returnType = elfParseType(unit, attr->value); + break; + default: + fprintf(stderr, "Unknown subroutine attribute %02x\n", attr->name); + } + } + if(abbrev->hasChildren) { + int bytes; + u32 num = elfReadLEB128(data, &bytes); + data += bytes; + Object *lastVar = NULL; + while(num) { + ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); + + switch(abbr->tag) { + case DW_TAG_formal_parameter: + { + Object *o; + data = elfParseObject(data, abbr, unit, &o); + if(f->args) + lastVar->next = o; + else + f->args = o; + lastVar = o; + } + break; + case DW_TAG_unspecified_parameters: + // no use in the debugger yet + data = elfSkipData(data, abbr, unit->abbrevs); + break; + CASE_TYPE_TAG: + // skip types... parsed only when used + data = elfSkipData(data, abbr, unit->abbrevs); + break; + default: + fprintf(stderr, "Unknown subroutine tag %02x\n", abbr->tag); + data = elfSkipData(data, abbr, unit->abbrevs); + break; + } + num = elfReadLEB128(data, &bytes); + data += bytes; + } + } + *type = t; + return; + } + break; + case DW_TAG_array_type: + { + u32 typeref = 0; + int i; + Array *array = (Array *)calloc(sizeof(Array), 1); + Type *t = (Type *)calloc(sizeof(Type), 1); + t->type = TYPE_array; + elfAddType(t, unit, offset); + + for(i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_sibling: + break; + case DW_AT_type: + typeref = attr->value; + array->type = elfParseType(unit, typeref); + break; + default: + fprintf(stderr, "Unknown array attribute %02x\n", attr->name); + } + } + if(abbrev->hasChildren) { + int bytes; + u32 num = elfReadLEB128(data, &bytes); + data += bytes; + int index = 0; + int maxBounds = 0; + while(num) { + ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); + + switch(abbr->tag) { + case DW_TAG_subrange_type: + { + if(maxBounds == index) { + maxBounds += 4; + array->bounds = (int *)realloc(array->bounds, + sizeof(int)*maxBounds); + } + for(int i = 0; i < abbr->numAttrs; i++) { + ELFAttr *attr = &abbr->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_upper_bound: + array->bounds[index] = attr->value+1; + break; + case DW_AT_type: // ignore + break; + default: + fprintf(stderr, "Unknown subrange attribute %02x\n", + attr->name); + } + } + index++; + } + break; + default: + fprintf(stderr, "Unknown array tag %02x\n", abbr->tag); + data = elfSkipData(data, abbr, unit->abbrevs); + break; + } + num = elfReadLEB128(data, &bytes); + data += bytes; + } + array->maxBounds = index; + } + t->size = array->type->size; + for(i = 0; i < array->maxBounds; i++) + t->size *= array->bounds[i]; + t->array = array; + *type = t; + return; + } + break; + default: + fprintf(stderr, "Unknown type TAG %02x\n", abbrev->tag); + exit(-1); + } +} + +Type *elfParseType(CompileUnit *unit, u32 offset) +{ + Type *t = unit->types; + + while(t) { + if(t->offset == offset) + return t; + t = t->next; + } + if(offset == 0) { + Type *t = (Type *)calloc(sizeof(Type), 1); + t->type = TYPE_void; + t->offset = 0; + elfAddType(t, unit, 0); + return t; + } + u8 *data = unit->top + offset; + int bytes; + int abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + Type *type = NULL; + + ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + elfParseType(data, offset, abbrev, unit, &type); + return type; +} + +void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o) +{ + u8 *data = unit->top + offset; + int bytes; + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + return; + } + + ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_location: + o->location = attr->block; + break; + case DW_AT_name: + if(o->name == NULL) + o->name = attr->string; + break; + case DW_AT_MIPS_linkage_name: + o->name = attr->string; + break; + case DW_AT_decl_file: + o->file = attr->value; + break; + case DW_AT_decl_line: + o->line = attr->value; + break; + case DW_AT_type: + o->type = elfParseType(unit, attr->value); + break; + case DW_AT_external: + o->external = attr->flag; + break; + case DW_AT_const_value: + case DW_AT_abstract_origin: + case DW_AT_declaration: + case DW_AT_artificial: + // todo + break; + case DW_AT_specification: + // TODO: + break; + default: + fprintf(stderr, "Unknown object attribute %02x\n", attr->name); + break; + } + } +} + +u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, + Object **object) +{ + Object *o = (Object *)calloc(sizeof(Object), 1); + + o->next = NULL; + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_location: + o->location = attr->block; + break; + case DW_AT_name: + if(o->name == NULL) + o->name = attr->string; + break; + case DW_AT_MIPS_linkage_name: + o->name = attr->string; + break; + case DW_AT_decl_file: + o->file = attr->value; + break; + case DW_AT_decl_line: + o->line = attr->value; + break; + case DW_AT_type: + o->type = elfParseType(unit, attr->value); + break; + case DW_AT_external: + o->external = attr->flag; + break; + case DW_AT_abstract_origin: + elfGetObjectAttributes(unit, attr->value, o); + break; + case DW_AT_const_value: + case DW_AT_declaration: + case DW_AT_artificial: + break; + case DW_AT_specification: + // TODO: + break; + default: + fprintf(stderr, "Unknown object attribute %02x\n", attr->name); + break; + } + } + *object = o; + return data; +} + +u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, + Function *func, Object **lastVar) +{ + int bytes; + u32 start = func->lowPC; + u32 end = func->highPC; + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_sibling: + break; + case DW_AT_low_pc: + start = attr->value; + break; + case DW_AT_high_pc: + end = attr->value; + break; + case DW_AT_ranges: // ignore for now + break; + default: + fprintf(stderr, "Unknown block attribute %02x\n", attr->name); + break; + } + } + + if(abbrev->hasChildren) { + int nesting = 1; + + while(nesting) { + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + nesting--; + continue; + } + + abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + switch(abbrev->tag) { + CASE_TYPE_TAG: // types only parsed when used + case DW_TAG_label: // not needed + data = elfSkipData(data, abbrev, unit->abbrevs); + break; + case DW_TAG_lexical_block: + data = elfParseBlock(data, abbrev, unit, func, lastVar); + break; + case DW_TAG_subprogram: + { + Function *f = NULL; + data = elfParseFunction(data, abbrev, unit, &f); + if(f != NULL) { + if(unit->lastFunction) + unit->lastFunction->next = f; + else + unit->functions = f; + unit->lastFunction = f; + } + } + break; + case DW_TAG_variable: + { + Object *o; + data = elfParseObject(data, abbrev, unit, &o); + if(o->startScope == 0) + o->startScope = start; + if(o->endScope == 0) + o->endScope = 0; + if(func->variables) + (*lastVar)->next = o; + else + func->variables = o; + *lastVar = o; + } + break; + case DW_TAG_inlined_subroutine: + // TODO: + data = elfSkipData(data, abbrev, unit->abbrevs); + break; + default: + { + fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag); + data = elfSkipData(data, abbrev, unit->abbrevs); + } + break; + } + } + } + return data; +} + +void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func) +{ + u8 *data = unit->top + offset; + int bytes; + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + return; + } + + ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + + switch(attr->name) { + case DW_AT_sibling: + break; + case DW_AT_name: + if(func->name == NULL) + func->name = attr->string; + break; + case DW_AT_MIPS_linkage_name: + func->name = attr->string; + break; + case DW_AT_low_pc: + func->lowPC = attr->value; + break; + case DW_AT_high_pc: + func->highPC = attr->value; + break; + case DW_AT_decl_file: + func->file = attr->value; + break; + case DW_AT_decl_line: + func->line = attr->value; + break; + case DW_AT_external: + func->external = attr->flag; + break; + case DW_AT_frame_base: + func->frameBase = attr->block; + break; + case DW_AT_type: + func->returnType = elfParseType(unit, attr->value); + break; + case DW_AT_inline: + case DW_AT_specification: + case DW_AT_declaration: + case DW_AT_artificial: + case DW_AT_prototyped: + case DW_AT_proc_body: + case DW_AT_save_offset: + case DW_AT_user_2002: + case DW_AT_virtuality: + case DW_AT_containing_type: + case DW_AT_accessibility: + // todo; + break; + case DW_AT_vtable_elem_location: + free(attr->block); + break; + default: + fprintf(stderr, "Unknown function attribute %02x\n", attr->name); + break; + } + } + + return; +} + +u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, + Function **f) +{ + Function *func = (Function *)calloc(sizeof(Function), 1); + *f = func; + + int bytes; + bool mangled = false; + bool declaration = false; + for(int i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + switch(attr->name) { + case DW_AT_sibling: + break; + case DW_AT_name: + if(func->name == NULL) + func->name = attr->string; + break; + case DW_AT_MIPS_linkage_name: + func->name = attr->string; + mangled = true; + break; + case DW_AT_low_pc: + func->lowPC = attr->value; + break; + case DW_AT_high_pc: + func->highPC = attr->value; + break; + case DW_AT_prototyped: + break; + case DW_AT_decl_file: + func->file = attr->value; + break; + case DW_AT_decl_line: + func->line = attr->value; + break; + case DW_AT_external: + func->external = attr->flag; + break; + case DW_AT_frame_base: + func->frameBase = attr->block; + break; + case DW_AT_type: + func->returnType = elfParseType(unit, attr->value); + break; + case DW_AT_abstract_origin: + elfGetFunctionAttributes(unit, attr->value, func); + break; + case DW_AT_declaration: + declaration = attr->flag; + break; + case DW_AT_inline: + case DW_AT_specification: + case DW_AT_artificial: + case DW_AT_proc_body: + case DW_AT_save_offset: + case DW_AT_user_2002: + case DW_AT_virtuality: + case DW_AT_containing_type: + case DW_AT_accessibility: + // todo; + break; + case DW_AT_vtable_elem_location: + free(attr->block); + break; + default: + fprintf(stderr, "Unknown function attribute %02x\n", attr->name); + break; + } + } + + if(declaration) { + elfCleanUp(func); + free(func); + *f = NULL; + + while(1) { + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + return data; + } + + abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + data = elfSkipData(data, abbrev, unit->abbrevs); + } + } + + if(abbrev->hasChildren) { + int nesting = 1; + Object *lastParam = NULL; + Object *lastVar = NULL; + + while(nesting) { + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + nesting--; + continue; + } + + abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + + switch(abbrev->tag) { + CASE_TYPE_TAG: // no need to parse types. only parsed when used + case DW_TAG_label: // not needed + data = elfSkipData(data, abbrev, unit->abbrevs); + break; + case DW_TAG_subprogram: + { + Function *fnc=NULL; + data = elfParseFunction(data, abbrev, unit, &fnc); + if(fnc != NULL) { + if(unit->lastFunction == NULL) + unit->functions = fnc; + else + unit->lastFunction->next = fnc; + unit->lastFunction = fnc; + } + } + break; + case DW_TAG_lexical_block: + { + data = elfParseBlock(data, abbrev, unit, func, &lastVar); + } + break; + case DW_TAG_formal_parameter: + { + Object *o; + data = elfParseObject(data, abbrev, unit, &o); + if(func->parameters) + lastParam->next = o; + else + func->parameters = o; + lastParam = o; + } + break; + case DW_TAG_variable: + { + Object *o; + data = elfParseObject(data, abbrev, unit, &o); + if(func->variables) + lastVar->next = o; + else + func->variables = o; + lastVar = o; + } + break; + case DW_TAG_unspecified_parameters: + case DW_TAG_inlined_subroutine: + { + // todo + for(int i = 0; i < abbrev->numAttrs; i++) { + data = elfReadAttribute(data, &abbrev->attrs[i]); + if(abbrev->attrs[i].form == DW_FORM_block1) + free(abbrev->attrs[i].block); + } + + if(abbrev->hasChildren) + nesting++; + } + break; + default: + { + fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag); + data = elfSkipData(data, abbrev, unit->abbrevs); + } + break; + } + } + } + return data; +} + +u8 *elfParseUnknownData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs) +{ + int i; + int bytes; + // switch(abbrev->tag) { + // default: + fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag); + + for(i = 0; i < abbrev->numAttrs; i++) { + data = elfReadAttribute(data, &abbrev->attrs[i]); + if(abbrev->attrs[i].form == DW_FORM_block1) + free(abbrev->attrs[i].block); + } + + if(abbrev->hasChildren) { + int nesting = 1; + while(nesting) { + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + if(!abbrevNum) { + nesting--; + continue; + } + + abbrev = elfGetAbbrev(abbrevs, abbrevNum); + + fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag); + + for(i = 0; i < abbrev->numAttrs; i++) { + data = elfReadAttribute(data, &abbrev->attrs[i]); + if(abbrev->attrs[i].form == DW_FORM_block1) + free(abbrev->attrs[i].block); + } + + if(abbrev->hasChildren) { + nesting++; + } + } + } + // } + return data; +} + +u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit) +{ + int bytes; + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + Object *lastObj = NULL; + while(abbrevNum) { + ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); + switch(abbrev->tag) { + case DW_TAG_subprogram: + { + Function *func = NULL; + data = elfParseFunction(data, abbrev, unit, &func); + if(func != NULL) { + if(unit->lastFunction) + unit->lastFunction->next = func; + else + unit->functions = func; + unit->lastFunction = func; + } + } + break; + CASE_TYPE_TAG: + data = elfSkipData(data, abbrev, unit->abbrevs); + break; + case DW_TAG_variable: + { + Object *var = NULL; + data = elfParseObject(data, abbrev, unit, &var); + if(lastObj) + lastObj->next = var; + else + unit->variables = var; + lastObj = var; + } + break; + default: + data = elfParseUnknownData(data, abbrev, unit->abbrevs); + break; + } + + abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + } + return data; +} + + +CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData) +{ + int bytes; + u8 *top = data; + + u32 length = elfRead4Bytes(data); + data += 4; + + u16 version = elfRead2Bytes(data); + data += 2; + + u32 offset = elfRead4Bytes(data); + data += 4; + + u8 addrSize = *data++; + + if(version != 2) { + fprintf(stderr, "Unsupported debugging information version %d\n", version); + return NULL; + } + + if(addrSize != 4) { + fprintf(stderr, "Unsupported address size %d\n", addrSize); + return NULL; + } + + ELFAbbrev **abbrevs = elfReadAbbrevs(abbrevData, offset); + + u32 abbrevNum = elfReadLEB128(data, &bytes); + data += bytes; + + ELFAbbrev *abbrev = elfGetAbbrev(abbrevs, abbrevNum); + + CompileUnit *unit = (CompileUnit *)calloc(sizeof(CompileUnit), 1); + unit->top = top; + unit->length = length; + unit->abbrevs = abbrevs; + unit->next = NULL; + + elfCurrentUnit = unit; + + int i; + + for(i = 0; i < abbrev->numAttrs; i++) { + ELFAttr *attr = &abbrev->attrs[i]; + data = elfReadAttribute(data, attr); + + switch(attr->name) { + case DW_AT_name: + unit->name = attr->string; + break; + case DW_AT_stmt_list: + unit->hasLineInfo = true; + unit->lineInfo = attr->value; + break; + case DW_AT_low_pc: + unit->lowPC = attr->value; + break; + case DW_AT_high_pc: + unit->highPC = attr->value; + break; + case DW_AT_compdir: + unit->compdir = attr->string; + break; + // ignore + case DW_AT_language: + case DW_AT_producer: + case DW_AT_macro_info: + case DW_AT_entry_pc: + break; + default: + fprintf(stderr, "Unknown attribute %02x\n", attr->name); + break; + } + } + + if(abbrev->hasChildren) + elfParseCompileUnitChildren(data, unit); + + return unit; +} + +void elfParseAranges(u8 *data) +{ + ELFSectionHeader *sh = elfGetSectionByName(".debug_aranges"); + if(sh == NULL) { + fprintf(stderr, "No aranges found\n"); + return; + } + + data = elfReadSection(data, sh); + u8 *end = data + READ32LE(&sh->size); + + int max = 4; + ARanges *ranges = (ARanges *)calloc(sizeof(ARanges), 4); + + int index = 0; + + while(data < end) { + u32 len = elfRead4Bytes(data); + data += 4; + // u16 version = elfRead2Bytes(data); + data += 2; + u32 offset = elfRead4Bytes(data); + data += 4; + // u8 addrSize = *data++; + // u8 segSize = *data++; + data += 2; // remove if uncommenting above + data += 4; + ranges[index].count = (len-20)/8; + ranges[index].offset = offset; + ranges[index].ranges = (ARange *)calloc(sizeof(ARange), (len-20)/8); + int i = 0; + while(true) { + u32 addr = elfRead4Bytes(data); + data += 4; + u32 len = elfRead4Bytes(data); + data += 4; + if(addr == 0 && len == 0) + break; + ranges[index].ranges[i].lowPC = addr; + ranges[index].ranges[i].highPC = addr+len; + i++; + } + index++; + if(index == max) { + max += 4; + ranges = (ARanges *)realloc(ranges, max*sizeof(ARanges)); + } + } + elfDebugInfo->numRanges = index; + elfDebugInfo->ranges = ranges; +} + +void elfReadSymtab(u8 *data) +{ + ELFSectionHeader *sh = elfGetSectionByName(".symtab"); + int table = READ32LE(&sh->link); + + char *strtable = (char *)elfReadSection(data, elfGetSectionByNumber(table)); + + ELFSymbol *symtab = (ELFSymbol *)elfReadSection(data, sh); + + int count = READ32LE(&sh->size) / sizeof(ELFSymbol); + elfSymbolsCount = 0; + + elfSymbols = (Symbol *)malloc(sizeof(Symbol)*count); + + int i; + + for(i = 0; i < count; i++) { + ELFSymbol *s = &symtab[i]; + int type = s->info & 15; + int binding = s->info >> 4; + + if(binding) { + Symbol *sym = &elfSymbols[elfSymbolsCount]; + sym->name = &strtable[READ32LE(&s->name)]; + sym->binding = binding; + sym->type = type; + sym->value = READ32LE(&s->value); + sym->size = READ32LE(&s->size); + elfSymbolsCount++; + } + } + for(i = 0; i < count; i++) { + ELFSymbol *s = &symtab[i]; + int bind = s->info>>4; + int type = s->info & 15; + + if(!bind) { + Symbol *sym = &elfSymbols[elfSymbolsCount]; + sym->name = &strtable[READ32LE(&s->name)]; + sym->binding = (s->info >> 4); + sym->type = type; + sym->value = READ32LE(&s->value); + sym->size = READ32LE(&s->size); + elfSymbolsCount++; + } + } + elfSymbolsStrTab = strtable; + // free(symtab); +} + +bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug) +{ + int count = READ16LE(&eh->e_phnum); + int i; + + if(READ32LE(&eh->e_entry) == 0x2000000) + cpuIsMultiBoot = true; + + // read program headers... should probably move this code down + u8 *p = data + READ32LE(&eh->e_phoff); + size = 0; + for(i = 0; i < count; i++) { + ELFProgramHeader *ph = (ELFProgramHeader *)p; + p += sizeof(ELFProgramHeader); + if(READ16LE(&eh->e_phentsize) != sizeof(ELFProgramHeader)) { + p += READ16LE(&eh->e_phentsize) - sizeof(ELFProgramHeader); + } + + // printf("PH %d %08x %08x %08x %08x %08x %08x %08x %08x\n", + // i, ph->type, ph->offset, ph->vaddr, ph->paddr, + // ph->filesz, ph->memsz, ph->flags, ph->align); + if(cpuIsMultiBoot) { + if(READ32LE(&ph->paddr) >= 0x2000000 && + READ32LE(&ph->paddr) <= 0x203ffff) { + memcpy(&workRAM[READ32LE(&ph->paddr) & 0x3ffff], + data + READ32LE(&ph->offset), + READ32LE(&ph->filesz)); + } + } else { + if(READ32LE(&ph->paddr) >= 0x8000000 && + READ32LE(&ph->paddr) <= 0x9ffffff) { + memcpy(&rom[READ32LE(&ph->paddr) & 0x1ffffff], + data + READ32LE(&ph->offset), + READ32LE(&ph->filesz)); + size += READ32LE(&ph->filesz); + } + } + } + + char *stringTable = NULL; + + // read section headers + p = data + READ32LE(&eh->e_shoff); + count = READ16LE(&eh->e_shnum); + + ELFSectionHeader **sh = (ELFSectionHeader **) + malloc(sizeof(ELFSectionHeader *) * count); + + for(i = 0; i < count; i++) { + sh[i] = (ELFSectionHeader *)p; + p += sizeof(ELFSectionHeader); + if(READ16LE(&eh->e_shentsize) != sizeof(ELFSectionHeader)) + p += READ16LE(&eh->e_shentsize) - sizeof(ELFSectionHeader); + } + + if(READ16LE(&eh->e_shstrndx) != 0) { + stringTable = (char *)elfReadSection(data, + sh[READ16LE(&eh->e_shstrndx)]); + } + + elfSectionHeaders = sh; + elfSectionHeadersStringTable = stringTable; + elfSectionHeadersCount = count; + + for(i = 0; i < count; i++) { + // printf("SH %d %-20s %08x %08x %08x %08x %08x %08x %08x %08x\n", + // i, &stringTable[sh[i]->name], sh[i]->name, sh[i]->type, + // sh[i]->flags, sh[i]->addr, sh[i]->offset, sh[i]->size, + // sh[i]->link, sh[i]->info); + if(READ32LE(&sh[i]->flags) & 2) { // load section + if(cpuIsMultiBoot) { + if(READ32LE(&sh[i]->addr) >= 0x2000000 && + READ32LE(&sh[i]->addr) <= 0x203ffff) { + memcpy(&workRAM[READ32LE(&sh[i]->addr) & 0x3ffff], data + + READ32LE(&sh[i]->offset), + READ32LE(&sh[i]->size)); + } + } else { + if(READ32LE(&sh[i]->addr) >= 0x8000000 && + READ32LE(&sh[i]->addr) <= 0x9ffffff) { + memcpy(&rom[READ32LE(&sh[i]->addr) & 0x1ffffff], + data + READ32LE(&sh[i]->offset), + READ32LE(&sh[i]->size)); + size += READ32LE(&sh[i]->size); + } + } + } + } + + if(parseDebug) { + fprintf(stderr, "Parsing debug info\n"); + + ELFSectionHeader *dbgHeader = elfGetSectionByName(".debug_info"); + if(dbgHeader == NULL) { + fprintf(stderr, "Cannot find debug information\n"); + goto end; + } + + ELFSectionHeader *h = elfGetSectionByName(".debug_abbrev"); + if(h == NULL) { + fprintf(stderr, "Cannot find abbreviation table\n"); + goto end; + } + + elfDebugInfo = (DebugInfo *)calloc(sizeof(DebugInfo), 1); + u8 *abbrevdata = elfReadSection(data, h); + + h = elfGetSectionByName(".debug_str"); + + if(h == NULL) + elfDebugStrings = NULL; + else + elfDebugStrings = (char *)elfReadSection(data, h); + + u8 *debugdata = elfReadSection(data, dbgHeader); + + elfDebugInfo->debugdata = data; + elfDebugInfo->infodata = debugdata; + + u32 total = READ32LE(&dbgHeader->size); + u8 *end = debugdata + total; + u8 *ddata = debugdata; + + CompileUnit *last = NULL; + CompileUnit *unit = NULL; + + while(ddata < end) { + unit = elfParseCompUnit(ddata, abbrevdata); + unit->offset = ddata-debugdata; + elfParseLineInfo(unit, data); + if(last == NULL) + elfCompileUnits = unit; + else + last->next = unit; + last = unit; + ddata += 4 + unit->length; + } + elfParseAranges(data); + CompileUnit *comp = elfCompileUnits; + while(comp) { + ARanges *r = elfDebugInfo->ranges; + for(int i = 0; i < elfDebugInfo->numRanges; i++) + if(r[i].offset == comp->offset) { + comp->ranges = &r[i]; + break; + } + comp = comp->next; + } + elfParseCFA(data); + elfReadSymtab(data); + } + end: + if(sh) { + free(sh); + } + + elfSectionHeaders = NULL; + elfSectionHeadersStringTable = NULL; + elfSectionHeadersCount = 0; + + return true; +} + +extern bool parseDebug; + +bool elfRead(const char *name, int& siz, FILE *f) +{ + fseek(f, 0, SEEK_END); + long size = ftell(f); + elfFileData = (u8 *)malloc(size); + fseek(f, 0, SEEK_SET); + fread(elfFileData, 1, size, f); + fclose(f); + + ELFHeader *header = (ELFHeader *)elfFileData; + + if(READ32LE(&header->magic) != 0x464C457F || + READ16LE(&header->e_machine) != 40 || + header->clazz != 1) { + systemMessage(0, N_("Not a valid ELF file %s"), name); + free(elfFileData); + elfFileData = NULL; + return false; + } + + if(!elfReadProgram(header, elfFileData, siz, parseDebug)) { + free(elfFileData); + elfFileData = NULL; + return false; + } + + return true; +} + +void elfCleanUp(Object *o) +{ + free(o->location); +} + +void elfCleanUp(Function *func) +{ + Object *o = func->parameters; + while(o) { + elfCleanUp(o); + Object *next = o->next; + free(o); + o = next; + } + + o = func->variables; + while(o) { + elfCleanUp(o); + Object *next = o->next; + free(o); + o = next; + } + free(func->frameBase); +} + +void elfCleanUp(ELFAbbrev **abbrevs) +{ + for(int i = 0; i < 121; i++) { + ELFAbbrev *abbrev = abbrevs[i]; + + while(abbrev) { + free(abbrev->attrs); + ELFAbbrev *next = abbrev->next; + free(abbrev); + + abbrev = next; + } + } +} + +void elfCleanUp(Type *t) +{ + switch(t->type) { + case TYPE_function: + if(t->function) { + Object *o = t->function->args; + while(o) { + elfCleanUp(o); + Object *next = o->next; + free(o); + o = next; + } + free(t->function); + } + break; + case TYPE_array: + if(t->array) { + free(t->array->bounds); + free(t->array); + } + break; + case TYPE_struct: + case TYPE_union: + if(t->structure) { + for(int i = 0; i < t->structure->memberCount; i++) { + free(t->structure->members[i].location); + } + free(t->structure->members); + free(t->structure); + } + break; + case TYPE_enum: + if(t->enumeration) { + free(t->enumeration->members); + free(t->enumeration); + } + break; + case TYPE_base: + case TYPE_pointer: + case TYPE_void: + case TYPE_reference: + break; // nothing to do + } +} + +void elfCleanUp(CompileUnit *comp) +{ + elfCleanUp(comp->abbrevs); + free(comp->abbrevs); + Function *func = comp->functions; + while(func) { + elfCleanUp(func); + Function *next = func->next; + free(func); + func = next; + } + Type *t = comp->types; + while(t) { + elfCleanUp(t); + Type *next = t->next; + free(t); + t = next; + } + Object *o = comp->variables; + while(o) { + elfCleanUp(o); + Object *next = o->next; + free(o); + o = next; + } + if(comp->lineInfoTable) { + free(comp->lineInfoTable->lines); + free(comp->lineInfoTable->files); + free(comp->lineInfoTable); + } +} + +void elfCleanUp() +{ + CompileUnit *comp = elfCompileUnits; + + while(comp) { + elfCleanUp(comp); + CompileUnit *next = comp->next; + free(comp); + comp = next; + } + elfCompileUnits = NULL; + free(elfSymbols); + elfSymbols = NULL; + // free(elfSymbolsStrTab); + elfSymbolsStrTab = NULL; + + elfDebugStrings = NULL; + if(elfDebugInfo) { + int num = elfDebugInfo->numRanges; + int i; + for(i = 0; i < num; i++) { + free(elfDebugInfo->ranges[i].ranges); + } + free(elfDebugInfo->ranges); + free(elfDebugInfo); + elfDebugInfo = NULL; + } + + if(elfFdes) { + if(elfFdeCount) { + for(int i = 0; i < elfFdeCount; i++) + free(elfFdes[i]); + } + free(elfFdes); + + elfFdes = NULL; + elfFdeCount = 0; + } + + ELFcie *cie = elfCies; + while(cie) { + ELFcie *next = cie->next; + free(cie); + cie = next; + } + elfCies = NULL; + + if(elfFileData) { + free(elfFileData); + elfFileData = NULL; + } +} diff --git a/src/elf.h b/src/elf.h new file mode 100644 index 0000000..8ce4379 --- /dev/null +++ b/src/elf.h @@ -0,0 +1,283 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_ELF_H +#define VBA_ELF_H + +enum LocationType { + LOCATION_register, + LOCATION_memory, + LOCATION_value +}; + +#define DW_ATE_boolean 0x02 +#define DW_ATE_signed 0x05 +#define DW_ATE_unsigned 0x07 +#define DW_ATE_unsigned_char 0x08 + +struct ELFHeader { + u32 magic; + u8 clazz; + u8 data; + u8 version; + u8 pad[9]; + u16 e_type; + u16 e_machine; + u32 e_version; + u32 e_entry; + u32 e_phoff; + u32 e_shoff; + u32 e_flags; + u16 e_ehsize; + u16 e_phentsize; + u16 e_phnum; + u16 e_shentsize; + u16 e_shnum; + u16 e_shstrndx; +}; + +struct ELFProgramHeader { + u32 type; + u32 offset; + u32 vaddr; + u32 paddr; + u32 filesz; + u32 memsz; + u32 flags; + u32 align; +}; + +struct ELFSectionHeader { + u32 name; + u32 type; + u32 flags; + u32 addr; + u32 offset; + u32 size; + u32 link; + u32 info; + u32 addralign; + u32 entsize; +}; + +struct ELFSymbol { + u32 name; + u32 value; + u32 size; + u8 info; + u8 other; + u16 shndx; +}; + +struct ELFBlock { + int length; + u8 *data; +}; + +struct ELFAttr { + u32 name; + u32 form; + union { + u32 value; + char *string; + u8 *data; + bool flag; + ELFBlock *block; + }; +}; + +struct ELFAbbrev { + u32 number; + u32 tag; + bool hasChildren; + int numAttrs; + ELFAttr *attrs; + ELFAbbrev *next; +}; + +enum TypeEnum { + TYPE_base, + TYPE_pointer, + TYPE_function, + TYPE_void, + TYPE_array, + TYPE_struct, + TYPE_reference, + TYPE_enum, + TYPE_union +}; + +struct Type; +struct Object; + +struct FunctionType { + Type *returnType; + Object *args; +}; + +struct Member { + char *name; + Type *type; + int bitSize; + int bitOffset; + int byteSize; + ELFBlock *location; +}; + +struct Struct { + int memberCount; + Member *members; +}; + +struct Array { + Type *type; + int maxBounds; + int *bounds; +}; + +struct EnumMember { + char *name; + u32 value; +}; + +struct Enum { + int count; + EnumMember *members; +}; + +struct Type { + u32 offset; + TypeEnum type; + char *name; + int encoding; + int size; + int bitSize; + union { + Type *pointer; + FunctionType *function; + Array *array; + Struct *structure; + Enum *enumeration; + }; + Type *next; +}; + +struct Object { + char *name; + int file; + int line; + bool external; + Type *type; + ELFBlock *location; + u32 startScope; + u32 endScope; + Object *next; +}; + +struct Function { + char *name; + u32 lowPC; + u32 highPC; + int file; + int line; + bool external; + Type *returnType; + Object *parameters; + Object *variables; + ELFBlock *frameBase; + Function *next; +}; + +struct LineInfoItem { + u32 address; + char *file; + int line; +}; + +struct LineInfo { + int fileCount; + char **files; + int number; + LineInfoItem *lines; +}; + +struct ARange { + u32 lowPC; + u32 highPC; +}; + +struct ARanges { + u32 offset; + int count; + ARange *ranges; +}; + +struct CompileUnit { + u32 length; + u8 *top; + u32 offset; + ELFAbbrev **abbrevs; + ARanges *ranges; + char *name; + char *compdir; + u32 lowPC; + u32 highPC; + bool hasLineInfo; + u32 lineInfo; + LineInfo *lineInfoTable; + Function *functions; + Function *lastFunction; + Object *variables; + Type *types; + CompileUnit *next; +}; + +struct DebugInfo { + u8 *debugfile; + u8 *abbrevdata; + u8 *debugdata; + u8 *infodata; + int numRanges; + ARanges *ranges; +}; + +struct Symbol { + char *name; + int type; + int binding; + u32 address; + u32 value; + u32 size; +}; + +extern u32 elfReadLEB128(u8 *, int *); +extern s32 elfReadSignedLEB128(u8 *, int *); +extern bool elfRead(const char *, int &, FILE *f); +extern bool elfGetSymbolAddress(char *,u32 *, u32 *, int *); +extern char *elfGetAddressSymbol(u32); +extern char *elfGetSymbol(int, u32 *, u32 *, int *); +extern void elfCleanUp(); +extern bool elfGetCurrentFunction(u32, Function **, CompileUnit **c); +extern bool elfGetObject(char *, Function *, CompileUnit *, Object **); +extern bool elfFindLineInUnit(u32 *, CompileUnit *, int); +extern bool elfFindLineInModule(u32 *, char *, int); +u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *); +u32 elfDecodeLocation(Function *, ELFBlock *, LocationType *, u32); +int elfFindLine(CompileUnit *unit, Function *func, u32 addr, char **); +#endif diff --git a/src/expr-lex.cpp b/src/expr-lex.cpp new file mode 100644 index 0000000..91f1074 --- /dev/null +++ b/src/expr-lex.cpp @@ -0,0 +1,1590 @@ +#line 2 "expr-lex.cpp" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /cvsroot/vba/VisualBoyAdvance/src/expr-lex.cpp,v 1.2 2003/06/06 14:17:21 forgotten Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#ifdef __GNUC__ +#include +#endif + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 10 +#define YY_END_OF_BUFFER 11 +static yyconst short int yy_accept[24] = + { 0, + 0, 0, 11, 9, 8, 8, 6, 7, 9, 4, + 3, 2, 2, 8, 5, 3, 2, 2, 2, 2, + 2, 1, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 4, 1, 1, + 1, 5, 1, 1, 6, 7, 1, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, + 1, 9, 1, 1, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 1, 1, 1, 10, 1, 10, 10, 10, 10, + + 11, 12, 10, 10, 13, 10, 10, 10, 10, 10, + 14, 10, 10, 10, 15, 10, 10, 10, 10, 10, + 10, 16, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[17] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, + 2, 2, 2, 2, 2, 2 + } ; + +static yyconst short int yy_base[25] = + { 0, + 0, 0, 32, 33, 15, 17, 33, 33, 22, 33, + 22, 0, 16, 19, 33, 20, 0, 11, 15, 11, + 12, 0, 33, 21 + } ; + +static yyconst short int yy_def[25] = + { 0, + 23, 1, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 24, 24, 23, 23, 23, 24, 24, 24, 24, + 24, 24, 0, 23 + } ; + +static yyconst short int yy_nxt[50] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 4, 12, + 12, 12, 12, 12, 13, 12, 14, 14, 14, 14, + 14, 14, 17, 22, 21, 20, 19, 16, 18, 16, + 15, 23, 3, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23 + } ; + +static yyconst short int yy_chk[50] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 5, 5, 6, 6, + 14, 14, 24, 21, 20, 19, 18, 16, 13, 11, + 9, 3, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "expr.l" +#define INITIAL 0 +#line 2 "expr.l" +#include "expr.cpp.h" + +#ifndef __GNUC__ +#include +#define isatty _isatty +#endif + +char *exprString; +int exprCol; + +#define YY_INPUT(buf,result,max_size) \ + { \ + int c = *exprString++; \ + exprCol++;\ + result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ + } +#define YY_MAIN 0 +#line 400 "expr-lex.cpp" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 31 "expr.l" + + +#line 554 "expr-lex.cpp" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 24 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 33 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 33 "expr.l" +{ + return TOKEN_SIZEOF; +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 37 "expr.l" +{ + return TOKEN_IDENTIFIER; +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 41 "expr.l" +{ + return TOKEN_NUMBER; +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 45 "expr.l" +{ + return TOKEN_DOT; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 49 "expr.l" +{ + return TOKEN_ARROW; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 53 "expr.l" +{ + return TOKEN_ADDR; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 57 "expr.l" +{ + return TOKEN_STAR; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 61 "expr.l" + + YY_BREAK +case 9: +YY_RULE_SETUP +#line 63 "expr.l" +return *yytext; + YY_BREAK +case 10: +YY_RULE_SETUP +#line 65 "expr.l" +ECHO; + YY_BREAK +#line 701 "expr-lex.cpp" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 24 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 24 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 23); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 65 "expr.l" + + +void exprCleanBuffer() +{ + yy_delete_buffer(yy_current_buffer); + yy_init = 1; +} diff --git a/src/expr.cpp b/src/expr.cpp new file mode 100644 index 0000000..25c68f6 --- /dev/null +++ b/src/expr.cpp @@ -0,0 +1,998 @@ + +/* A Bison parser, made from expr.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define TOKEN_IDENTIFIER 257 +#define TOKEN_DOT 258 +#define TOKEN_STAR 259 +#define TOKEN_ARROW 260 +#define TOKEN_ADDR 261 +#define TOKEN_SIZEOF 262 +#define TOKEN_NUMBER 263 + +#line 1 "expr.y" + +namespace std { +#include +#include +#include +#include +} + +using namespace std; + +#include "System.h" +#include "elf.h" +#include "exprNode.h" + +extern int yyerror(char *); +extern int yylex(); +extern char *yytext; + + +//#define YYERROR_VERBOSE 1 +//#define YYDEBUG 1 + + Node *result = NULL; +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 26 +#define YYFLAG -32768 +#define YYNTBASE 14 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, + 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 10, 2, 13, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 8, 12, 16, 21, 23, 26, 29, + 34, 36 +}; + +static const short yyrhs[] = { 15, + 0, 16, 0, 11, 15, 12, 0, 15, 4, 18, + 0, 15, 6, 18, 0, 15, 10, 17, 13, 0, + 18, 0, 5, 15, 0, 7, 15, 0, 8, 11, + 15, 12, 0, 9, 0, 3, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 32, 35, 36, 37, 38, 39, 42, 43, 44, 45, + 49, 53 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","TOKEN_IDENTIFIER", +"TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER", +"'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL +}; +#endif + +static const short yyr1[] = { 0, + 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, + 17, 18 +}; + +static const short yyr2[] = { 0, + 1, 1, 3, 3, 3, 4, 1, 2, 2, 4, + 1, 1 +}; + +static const short yydefact[] = { 0, + 12, 0, 0, 0, 0, 1, 2, 7, 8, 9, + 0, 0, 0, 0, 0, 0, 3, 4, 5, 11, + 0, 10, 6, 0, 0, 0 +}; + +static const short yydefgoto[] = { 24, + 6, 7, 21, 8 +}; + +static const short yypact[] = { -1, +-32768, -1, -1, -6, -1, 17,-32768,-32768, 17, 17, + -1, 7, 5, 5, 13, 8,-32768,-32768,-32768,-32768, + 11,-32768,-32768, 25, 26,-32768 +}; + +static const short yypgoto[] = {-32768, + -2,-32768,-32768, 2 +}; + + +#define YYLAST 27 + + +static const short yytable[] = { 9, + 10, 1, 12, 2, 11, 3, 4, 1, 16, 5, + 13, 13, 14, 14, 18, 19, 15, 15, 17, 22, + 13, 20, 14, 23, 25, 26, 15 +}; + +static const short yycheck[] = { 2, + 3, 3, 5, 5, 11, 7, 8, 3, 11, 11, + 4, 4, 6, 6, 13, 14, 10, 10, 12, 12, + 4, 9, 6, 13, 0, 0, 10 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/lib/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 32 "expr.y" +{ result = yyvsp[0]; ; + break;} +case 2: +#line 36 "expr.y" +{ yyval = yyvsp[0]; ; + break;} +case 3: +#line 37 "expr.y" +{ yyval = yyvsp[-1]; ; + break;} +case 4: +#line 38 "expr.y" +{ yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ; + break;} +case 5: +#line 39 "expr.y" +{ yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ; + break;} +case 6: +#line 40 "expr.y" +{ yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ; + break;} +case 7: +#line 43 "expr.y" +{ yyval = yyvsp[0]; ; + break;} +case 8: +#line 44 "expr.y" +{ yyval = exprNodeStar(yyvsp[0]); ; + break;} +case 9: +#line 45 "expr.y" +{ yyval = exprNodeAddr(yyvsp[0]); ; + break;} +case 10: +#line 46 "expr.y" +{ yyval = exprNodeSizeof(yyvsp[-1]); ; + break;} +case 11: +#line 50 "expr.y" +{ yyval = exprNodeNumber(); ; + break;} +case 12: +#line 54 "expr.y" +{yyval = exprNodeIdentifier(); ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/lib/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 57 "expr.y" + + +int yyerror(char *s) +{ + return 0; +} + +#ifndef SDL +extern FILE *yyin; +int main(int argc, char **argv) +{ + // yydebug = 1; + ++argv, --argc; + if(argc > 0) + yyin = fopen(argv[0], "r"); + else + yyin = stdin; + if(!yyparse()) + result->print(); +} +#endif diff --git a/src/expr.cpp.h b/src/expr.cpp.h new file mode 100644 index 0000000..9b3fdc3 --- /dev/null +++ b/src/expr.cpp.h @@ -0,0 +1,13 @@ +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#define TOKEN_IDENTIFIER 257 +#define TOKEN_DOT 258 +#define TOKEN_STAR 259 +#define TOKEN_ARROW 260 +#define TOKEN_ADDR 261 +#define TOKEN_SIZEOF 262 +#define TOKEN_NUMBER 263 + + +extern YYSTYPE yylval; diff --git a/src/expr.l b/src/expr.l new file mode 100644 index 0000000..19cd49d --- /dev/null +++ b/src/expr.l @@ -0,0 +1,71 @@ +%{ +#include "expr.cpp.h" + +#ifndef __GNUC__ +#include +#define isatty _isatty +#endif + +char *exprString; +int exprCol; + +#define YY_INPUT(buf,result,max_size) \ + { \ + int c = *exprString++; \ + exprCol++;\ + result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ + } +%} + +%option nomain +%option noyywrap + +SIZEOF "sizeof" +ID [a-zA-Z_][a-zA-Z0-9_]* +NUM [0-9]+ +DOT "." +ARROW "->" +STAR "*" +ADDR "&" + +%% + +{SIZEOF} { + return TOKEN_SIZEOF; +} + +{ID} { + return TOKEN_IDENTIFIER; +} + +{NUM} { + return TOKEN_NUMBER; +} + +{DOT} { + return TOKEN_DOT; +} + +{ARROW} { + return TOKEN_ARROW; +} + +{ADDR} { + return TOKEN_ADDR; +} + +{STAR} { + return TOKEN_STAR; +} + +[ \t\n]+ + +. return *yytext; + +%% + +void exprCleanBuffer() +{ + yy_delete_buffer(yy_current_buffer); + yy_init = 1; +} diff --git a/src/expr.y b/src/expr.y new file mode 100644 index 0000000..0a02026 --- /dev/null +++ b/src/expr.y @@ -0,0 +1,77 @@ +%{ +namespace std { +#include +#include +#include +#include +} + +using namespace std; + +#include "System.h" +#include "elf.h" +#include "exprNode.h" + +extern int yyerror(char *); +extern int yylex(); +extern char *yytext; + + +//#define YYERROR_VERBOSE 1 +//#define YYDEBUG 1 + + Node *result = NULL; +%} + +%token TOKEN_IDENTIFIER TOKEN_DOT TOKEN_STAR TOKEN_ARROW TOKEN_ADDR +%token TOKEN_SIZEOF TOKEN_NUMBER +%left TOKEN_DOT TOKEN_ARROW '[' +%expect 6 +%% + +final: expression { result = $1; } +; + +expression: + simple_expression { $$ = $1; } | + '(' expression ')' { $$ = $2; } | + expression TOKEN_DOT ident { $$ = exprNodeDot($1, $3); } | + expression TOKEN_ARROW ident { $$ = exprNodeArrow($1, $3); } | + expression '[' number ']' { $$ = exprNodeArray($1, $3); } +; +simple_expression: + ident { $$ = $1; } | + TOKEN_STAR expression { $$ = exprNodeStar($2); } | + TOKEN_ADDR expression { $$ = exprNodeAddr($2); } | + TOKEN_SIZEOF '(' expression ')' { $$ = exprNodeSizeof($3); } +; + +number: + TOKEN_NUMBER { $$ = exprNodeNumber(); } +; + +ident: + TOKEN_IDENTIFIER {$$ = exprNodeIdentifier(); } +; + +%% + +int yyerror(char *s) +{ + return 0; +} + +#ifndef SDL +extern FILE *yyin; +int main(int argc, char **argv) +{ + // yydebug = 1; + ++argv, --argc; + if(argc > 0) + yyin = fopen(argv[0], "r"); + else + yyin = stdin; + if(!yyparse()) + result->print(); +} +#endif diff --git a/src/exprNode.cpp b/src/exprNode.cpp new file mode 100644 index 0000000..fab17f8 --- /dev/null +++ b/src/exprNode.cpp @@ -0,0 +1,411 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#include "GBA.h" +#include "Port.h" +#include "elf.h" +#include "exprNode.h" + +extern char *yytext; + +#define debuggerReadMemory(addr) \ + READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +void *exprNodeCleanUpList[100]; +int exprNodeCleanUpCount = 0; +Type exprNodeType = { 0, TYPE_base, "int", DW_ATE_signed, 4, 0, {0}, 0 }; + +void exprNodeClean(void *m) +{ + exprNodeCleanUpList[exprNodeCleanUpCount++] = m; +} + +void exprNodeCleanUp() +{ + for(int i = 0; i < exprNodeCleanUpCount; i++) { + free(exprNodeCleanUpList[i]); + } + exprNodeCleanUpCount = 0; +} + +Node *exprNodeIdentifier() +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + n->name = strdup(yytext); + + exprNodeClean(n->name); + exprNodeClean(n); + + n->print = exprNodeIdentifierPrint; + n->resolve = exprNodeIdentifierResolve; + return n; +} + +bool exprNodeIdentifierResolve(Node *n, Function *f, CompileUnit *u) +{ + Object *o; + if(elfGetObject(n->name, f, u, &o)) { + n->type = o->type; + n->location = elfDecodeLocation(f, o->location, &n->locType); + return true; + } else { + printf("Object %s not found\n", n->name); + } + return false; +} + +void exprNodeIdentifierPrint(Node *n) +{ + printf("%s", n->name); +} + +Node *exprNodeNumber() +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + + exprNodeClean(n); + n->location = atoi(yytext); + n->type = &exprNodeType; + n->locType = LOCATION_value; + n->print = exprNodeNumberPrint; + n->resolve = exprNodeNumberResolve; + return n; +} + +bool exprNodeNumberResolve(Node *n, Function *f, CompileUnit *u) +{ + return true; +} + +void exprNodeNumberPrint(Node *n) +{ + printf("%d", n->location); +} + +Node *exprNodeStar(Node *exp) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + + n->print = exprNodeStarPrint; + n->resolve = exprNodeStarResolve; + return n; +} + +bool exprNodeStarResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + if(n->expression->type->type == TYPE_pointer) { + n->location = n->expression->location; + if(n->expression->locType == LOCATION_memory) { + n->location = debuggerReadMemory(n->location); + } else if(n->expression->locType == LOCATION_register) { + n->location = reg[n->expression->location].I; + } else { + n->location = n->expression->location; + } + n->type = n->expression->type->pointer; + n->locType = LOCATION_memory; + return true; + } else { + printf("Object is not of pointer type\n"); + } + } + return false; +} + +void exprNodeStarPrint(Node *n) +{ + printf("*"); + n->expression->print(n->expression); +} + +Node *exprNodeDot(Node *exp, Node *ident) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + n->name = ident->name; + + n->print = exprNodeDotPrint; + n->resolve = exprNodeDotResolve; + return n; +} + +bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + TypeEnum tt = n->expression->type->type; + + if(tt == TYPE_struct || + tt == TYPE_union) { + u32 loc = n->expression->location; + Type *t = n->expression->type; + int count = t->structure->memberCount; + int i = 0; + while(i < count) { + Member *m = &t->structure->members[i]; + if(strcmp(m->name, n->name) == 0) { + // found member + n->type = m->type; + if(tt == TYPE_struct) { + n->location = elfDecodeLocation(f, m->location, &n->locType, + loc); + n->objLocation = loc; + } else { + n->location = loc; + n->locType = n->expression->locType; + n->objLocation = loc; + } + n->member = m; + return true; + } + i++; + } + printf("Member %s not found\n", n->name); + } else { + printf("Object is not of structure type\n"); + } + } + return false; +} + +void exprNodeDotPrint(Node *n) +{ + n->expression->print(n->expression); + printf(".%s", n->name); +} + +Node *exprNodeArrow(Node *exp, Node *ident) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + n->name = ident->name; + + n->print = exprNodeArrowPrint; + n->resolve = exprNodeArrowResolve; + return n; +} + +bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + TypeEnum tt = n->expression->type->type; + if(tt != TYPE_pointer) { + printf("Object not of pointer type\n"); + return false; + } + tt = n->expression->type->pointer->type; + + if(tt == TYPE_struct || + tt == TYPE_union) { + u32 loc = debuggerReadMemory(n->expression->location); + Type *t = n->expression->type->pointer; + int count = t->structure->memberCount; + int i = 0; + while(i < count) { + Member *m = &t->structure->members[i]; + if(strcmp(m->name, n->name) == 0) { + // found member + n->type = m->type; + if(tt == TYPE_struct) { + n->location = elfDecodeLocation(f, m->location, &n->locType, + loc); + n->objLocation = loc; + } else { + n->location = loc; + n->objLocation = loc; + } + n->locType = LOCATION_memory; + n->member = m; + return true; + } + i++; + } + printf("Member %s not found\n", n->name); + } else { + printf("Object is not of structure type\n"); + } + } + return false; +} + +void exprNodeArrowPrint(Node *n) +{ + n->expression->print(n->expression); + printf("->%s", n->name); +} + +Node *exprNodeAddr(Node *exp) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + + n->print = exprNodeAddrPrint; + n->resolve = exprNodeAddrResolve; + return n; +} + +bool exprNodeAddrResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + if(n->expression->locType == LOCATION_memory) { + n->location = n->expression->location; + n->locType = LOCATION_value; + n->type = &exprNodeType; + } else if(n->expression->locType == LOCATION_register) { + printf("Value is in register %d\n", n->expression->location); + } else { + printf("Direct value is %d\n", n->location); + } + return true; + } + return false; +} + +void exprNodeAddrPrint(Node *n) +{ + printf("*"); + n->expression->print(n->expression); +} + +Node *exprNodeSizeof(Node *exp) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + + n->print = exprNodeSizeofPrint; + n->resolve = exprNodeSizeofResolve; + return n; +} + +bool exprNodeSizeofResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + n->location = n->expression->type->size; + n->locType = LOCATION_value; + n->type = &exprNodeType; + return true; + } + return false; +} + +void exprNodeSizeofPrint(Node *n) +{ + printf("sizeof("); + n->expression->print(n->expression); + printf(")"); +} + +Node *exprNodeArray(Node *exp, Node *number) +{ + Node *n = (Node *)calloc(1, sizeof(Node)); + exprNodeClean(n); + + n->expression = exp; + n->value = number->location; + + n->print = exprNodeArrayPrint; + n->resolve = exprNodeArrayResolve; + return n; +} + +int exprNodeGetSize(Array *a, int index) +{ + index++; + if(index == a->maxBounds) { + return a->type->size; + } else { + int size = a->bounds[a->maxBounds-1] * a->type->size; + + for(int i = index; i < a->maxBounds-1; i++) { + size *= a->bounds[i]; + } + return size; + } +} + +bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u) +{ + if(n->expression->resolve(n->expression, f, u)) { + TypeEnum tt = n->expression->type->type; + if(tt != TYPE_array && + tt != TYPE_pointer) { + printf("Object not of array or pointer type\n"); + return false; + } + + if(tt == TYPE_array) { + Array *a = n->expression->type->array; + + u32 loc = n->expression->location; + Type *t = a->type; + if(a->maxBounds > 1) { + int index = n->expression->index; + + if(index == a->maxBounds) { + printf("Too many indices for array\n"); + return false; + } + + if((index+1) < a->maxBounds) { + n->type = n->expression->type; + n->index = index+1; + n->locType = LOCATION_memory; + n->location = n->expression->location + + n->value * exprNodeGetSize(a, index); + return true; + } + } + n->type = t; + n->location = loc + n->value * t->size; + n->locType = LOCATION_memory; + } else { + Type *t = n->expression->type->pointer; + u32 loc = n->expression->location; + if(n->expression->locType == LOCATION_register) + loc = reg[loc].I; + else + loc = debuggerReadMemory(loc); + n->type = t; + n->location = loc + n->value * t->size; + n->locType = LOCATION_memory; + } + return true; + } + return false; +} + +void exprNodeArrayPrint(Node *n) +{ + n->expression->print(n->expression); + printf("[%d]", n->value); +} diff --git a/src/exprNode.h b/src/exprNode.h new file mode 100644 index 0000000..15c1e4b --- /dev/null +++ b/src/exprNode.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +struct Node { + Type *type; + u32 location; + u32 objLocation; + LocationType locType; + int value; + int index; + char *name; + Node *expression; + Member *member; + void (*print)(Node *); + bool (*resolve)(Node *, Function *f, CompileUnit *u); +}; + +extern void exprNodeCleanUp(); + +extern Node *exprNodeIdentifier(); +extern void exprNodeIdentifierPrint(Node *); +extern bool exprNodeIdentifierResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeNumber(); +extern void exprNodeNumberPrint(Node *); +extern bool exprNodeNumberResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeStar(Node *); +extern void exprNodeStarPrint(Node *); +extern bool exprNodeStarResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeDot(Node *, Node *); +extern void exprNodeDotPrint(Node *); +extern bool exprNodeDotResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeArrow(Node *, Node *); +extern void exprNodeArrowPrint(Node *); +extern bool exprNodeArrowResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeAddr(Node *); +extern void exprNodeAddrPrint(Node *); +extern bool exprNodeAddrResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeSizeof(Node *); +extern void exprNodeSizeofPrint(Node *); +extern bool exprNodeSizeofResolve(Node *, Function *, CompileUnit *); + +extern Node *exprNodeArray(Node *, Node *); +extern void exprNodeArrayPrint(Node *); +extern bool exprNodeArrayResolve(Node *, Function *, CompileUnit *); + +#define YYSTYPE struct Node * diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp new file mode 100644 index 0000000..5471eb9 --- /dev/null +++ b/src/gb/GB.cpp @@ -0,0 +1,3805 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include + +#include "../System.h" +#include "../NLS.h" +#include "GB.h" +#include "gbCheats.h" +#include "gbGlobals.h" +#include "gbMemory.h" +#include "gbSGB.h" +#include "gbSound.h" +#include "../unzip.h" +#include "../Util.h" +#if (defined(WIN32) && !defined(SDL)) +# include "../win32/stdafx.h" +# include "../win32/vba.h" +#endif +#include "../movie.h" + +#ifdef __GNUC__ +#define _stricmp strcasecmp +#endif + +u8 *origPix = NULL; +extern u8 *pix; +extern bool speedup; + +bool gbUpdateSizes(); + +// debugging +bool memorydebug = false; +char gbBuffer[2048]; + +extern u16 gbLineMix[160]; + +// mappers +void (*mapper)(u16,u8) = NULL; +void (*mapperRAM)(u16,u8) = NULL; +u8 (*mapperReadRAM)(u16) = NULL; + +// registers +gbRegister PC; +gbRegister SP; +gbRegister AF; +gbRegister BC; +gbRegister DE; +gbRegister HL; +u16 IFF; +// 0xff04 +u8 register_DIV = 0; +// 0xff05 +u8 register_TIMA = 0; +// 0xff06 +u8 register_TMA = 0; +// 0xff07 +u8 register_TAC = 0; +// 0xff0f +u8 register_IF = 0; +// 0xff40 +u8 register_LCDC = 0; +// 0xff41 +u8 register_STAT = 0; +// 0xff42 +u8 register_SCY = 0; +// 0xff43 +u8 register_SCX = 0; +// 0xff44 +u8 register_LY = 0; +// 0xff45 +u8 register_LYC = 0; +// 0xff46 +u8 register_DMA = 0; +// 0xff4a +u8 register_WY = 0; +// 0xff4b +u8 register_WX = 0; +// 0xff4f +u8 register_VBK = 0; +// 0xff51 +u8 register_HDMA1 = 0; +// 0xff52 +u8 register_HDMA2 = 0; +// 0xff53 +u8 register_HDMA3 = 0; +// 0xff54 +u8 register_HDMA4 = 0; +// 0xff55 +u8 register_HDMA5 = 0; +// 0xff70 +u8 register_SVBK = 0; +// 0xffff +u8 register_IE = 0; + +// ticks definition +int GBDIV_CLOCK_TICKS = 64; +int GBLCD_MODE_0_CLOCK_TICKS = 51; +int GBLCD_MODE_1_CLOCK_TICKS = 1140; +int GBLCD_MODE_2_CLOCK_TICKS = 20; +int GBLCD_MODE_3_CLOCK_TICKS = 43; +int GBLY_INCREMENT_CLOCK_TICKS = 114; +int GBTIMER_MODE_0_CLOCK_TICKS = 256; +int GBTIMER_MODE_1_CLOCK_TICKS = 4; +int GBTIMER_MODE_2_CLOCK_TICKS = 16; +int GBTIMER_MODE_3_CLOCK_TICKS = 64; +int GBSERIAL_CLOCK_TICKS = 128; +int GBSYNCHRONIZE_CLOCK_TICKS = 52920; + +// state variables + +// interrupt +int gbInterrupt = 0; +int gbInterruptWait = 0; +// serial +int gbSerialOn = 0; +int gbSerialTicks = 0; +int gbSerialBits = 0; +// timer +int gbTimerOn = 0; +int gbTimerTicks = 0; +int gbTimerClockTicks = 0; +int gbTimerMode = 0; +// lcd +int gbLcdMode = 2; +int gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS; +int gbLcdLYIncrementTicks = 0; +// div +int gbDivTicks = GBDIV_CLOCK_TICKS; +// cgb +int gbVramBank = 0; +int gbWramBank = 1; +int gbHdmaSource = 0x0000; +int gbHdmaDestination = 0x8000; +int gbHdmaBytes = 0x0000; +int gbHdmaOn = 0; +int gbSpeed = 0; +// frame counting +int gbFrameCount = 0; +int gbFrameSkip = 0; +int gbFrameSkipCount = 0; +// timing +u32 gbLastTime = 0; +u32 gbElapsedTime = 0; +u32 gbTimeNow = 0; +int gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS; +int gbDMASpeedVersion = 1; +// emulator features +int gbBattery = 0; +int gbCaptureNumber = 0; +bool gbCapture = false; +bool gbCapturePrevious = false; +int gbJoymask[4] = { 0, 0, 0, 0 }; + +static bool pauseAfterFrameAdvance = false; + +int gbRomSizes[] = { 0x00008000, // 32K +0x00010000, // 64K +0x00020000, // 128K +0x00040000, // 256K +0x00080000, // 512K +0x00100000, // 1024K +0x00200000, // 2048K +0x00400000, // 4096K +0x00800000 // 8192K +}; +int gbRomSizesMasks[] = { 0x00007fff, +0x0000ffff, +0x0001ffff, +0x0003ffff, +0x0007ffff, +0x000fffff, +0x001fffff, +0x003fffff, +0x007fffff +}; + +int gbRamSizes[6] = { 0x00000000, // 0K +0x00000800, // 2K +0x00002000, // 8K +0x00008000, // 32K +0x00020000, // 128K +0x00010000 // 64K +}; + +int gbRamSizesMasks[6] = { 0x00000000, +0x000007ff, +0x00001fff, +0x00007fff, +0x0001ffff, +0x0000ffff +}; + +int gbCycles[] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 3, 2, 2, 1, 1, 2, 1, 5, 2, 2, 2, 1, 1, 2, 1, // 0 + 1, 3, 2, 2, 1, 1, 2, 1, 3, 2, 2, 2, 1, 1, 2, 1, // 1 + 2, 3, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 2, 1, // 2 + 2, 3, 2, 2, 3, 3, 3, 1, 2, 2, 2, 2, 1, 1, 2, 1, // 3 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // 4 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // 5 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // 6 + 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, // 7 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // 8 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // 9 + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // a + 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, // b + 2, 3, 3, 4, 3, 4, 2, 4, 2, 4, 3, 2, 3, 6, 2, 4, // c + 2, 3, 3, 0, 3, 4, 2, 4, 2, 4, 3, 0, 3, 0, 2, 4, // d + 3, 3, 2, 0, 0, 4, 2, 4, 4, 1, 4, 0, 0, 0, 2, 4, // e + 3, 3, 2, 1, 0, 4, 2, 4, 3, 2, 4, 1, 0, 0, 2, 4 // f +}; + +int gbCyclesCB[] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, // 0 + 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, // 1 + 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, // 2 + 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 4, 2, // 3 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 4 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 5 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 6 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 7 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 8 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // 9 + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // a + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // b + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // c + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // d + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, // e + 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2 // f +}; + +u16 DAATable[] = +{ + 0x0080,0x0100,0x0200,0x0300,0x0400,0x0500,0x0600,0x0700, + 0x0800,0x0900,0x1020,0x1120,0x1220,0x1320,0x1420,0x1520, + 0x1000,0x1100,0x1200,0x1300,0x1400,0x1500,0x1600,0x1700, + 0x1800,0x1900,0x2020,0x2120,0x2220,0x2320,0x2420,0x2520, + 0x2000,0x2100,0x2200,0x2300,0x2400,0x2500,0x2600,0x2700, + 0x2800,0x2900,0x3020,0x3120,0x3220,0x3320,0x3420,0x3520, + 0x3000,0x3100,0x3200,0x3300,0x3400,0x3500,0x3600,0x3700, + 0x3800,0x3900,0x4020,0x4120,0x4220,0x4320,0x4420,0x4520, + 0x4000,0x4100,0x4200,0x4300,0x4400,0x4500,0x4600,0x4700, + 0x4800,0x4900,0x5020,0x5120,0x5220,0x5320,0x5420,0x5520, + 0x5000,0x5100,0x5200,0x5300,0x5400,0x5500,0x5600,0x5700, + 0x5800,0x5900,0x6020,0x6120,0x6220,0x6320,0x6420,0x6520, + 0x6000,0x6100,0x6200,0x6300,0x6400,0x6500,0x6600,0x6700, + 0x6800,0x6900,0x7020,0x7120,0x7220,0x7320,0x7420,0x7520, + 0x7000,0x7100,0x7200,0x7300,0x7400,0x7500,0x7600,0x7700, + 0x7800,0x7900,0x8020,0x8120,0x8220,0x8320,0x8420,0x8520, + 0x8000,0x8100,0x8200,0x8300,0x8400,0x8500,0x8600,0x8700, + 0x8800,0x8900,0x9020,0x9120,0x9220,0x9320,0x9420,0x9520, + 0x9000,0x9100,0x9200,0x9300,0x9400,0x9500,0x9600,0x9700, + 0x9800,0x9900,0x00B0,0x0130,0x0230,0x0330,0x0430,0x0530, + 0x0090,0x0110,0x0210,0x0310,0x0410,0x0510,0x0610,0x0710, + 0x0810,0x0910,0x1030,0x1130,0x1230,0x1330,0x1430,0x1530, + 0x1010,0x1110,0x1210,0x1310,0x1410,0x1510,0x1610,0x1710, + 0x1810,0x1910,0x2030,0x2130,0x2230,0x2330,0x2430,0x2530, + 0x2010,0x2110,0x2210,0x2310,0x2410,0x2510,0x2610,0x2710, + 0x2810,0x2910,0x3030,0x3130,0x3230,0x3330,0x3430,0x3530, + 0x3010,0x3110,0x3210,0x3310,0x3410,0x3510,0x3610,0x3710, + 0x3810,0x3910,0x4030,0x4130,0x4230,0x4330,0x4430,0x4530, + 0x4010,0x4110,0x4210,0x4310,0x4410,0x4510,0x4610,0x4710, + 0x4810,0x4910,0x5030,0x5130,0x5230,0x5330,0x5430,0x5530, + 0x5010,0x5110,0x5210,0x5310,0x5410,0x5510,0x5610,0x5710, + 0x5810,0x5910,0x6030,0x6130,0x6230,0x6330,0x6430,0x6530, + 0x6010,0x6110,0x6210,0x6310,0x6410,0x6510,0x6610,0x6710, + 0x6810,0x6910,0x7030,0x7130,0x7230,0x7330,0x7430,0x7530, + 0x7010,0x7110,0x7210,0x7310,0x7410,0x7510,0x7610,0x7710, + 0x7810,0x7910,0x8030,0x8130,0x8230,0x8330,0x8430,0x8530, + 0x8010,0x8110,0x8210,0x8310,0x8410,0x8510,0x8610,0x8710, + 0x8810,0x8910,0x9030,0x9130,0x9230,0x9330,0x9430,0x9530, + 0x9010,0x9110,0x9210,0x9310,0x9410,0x9510,0x9610,0x9710, + 0x9810,0x9910,0xA030,0xA130,0xA230,0xA330,0xA430,0xA530, + 0xA010,0xA110,0xA210,0xA310,0xA410,0xA510,0xA610,0xA710, + 0xA810,0xA910,0xB030,0xB130,0xB230,0xB330,0xB430,0xB530, + 0xB010,0xB110,0xB210,0xB310,0xB410,0xB510,0xB610,0xB710, + 0xB810,0xB910,0xC030,0xC130,0xC230,0xC330,0xC430,0xC530, + 0xC010,0xC110,0xC210,0xC310,0xC410,0xC510,0xC610,0xC710, + 0xC810,0xC910,0xD030,0xD130,0xD230,0xD330,0xD430,0xD530, + 0xD010,0xD110,0xD210,0xD310,0xD410,0xD510,0xD610,0xD710, + 0xD810,0xD910,0xE030,0xE130,0xE230,0xE330,0xE430,0xE530, + 0xE010,0xE110,0xE210,0xE310,0xE410,0xE510,0xE610,0xE710, + 0xE810,0xE910,0xF030,0xF130,0xF230,0xF330,0xF430,0xF530, + 0xF010,0xF110,0xF210,0xF310,0xF410,0xF510,0xF610,0xF710, + 0xF810,0xF910,0x00B0,0x0130,0x0230,0x0330,0x0430,0x0530, + 0x0090,0x0110,0x0210,0x0310,0x0410,0x0510,0x0610,0x0710, + 0x0810,0x0910,0x1030,0x1130,0x1230,0x1330,0x1430,0x1530, + 0x1010,0x1110,0x1210,0x1310,0x1410,0x1510,0x1610,0x1710, + 0x1810,0x1910,0x2030,0x2130,0x2230,0x2330,0x2430,0x2530, + 0x2010,0x2110,0x2210,0x2310,0x2410,0x2510,0x2610,0x2710, + 0x2810,0x2910,0x3030,0x3130,0x3230,0x3330,0x3430,0x3530, + 0x3010,0x3110,0x3210,0x3310,0x3410,0x3510,0x3610,0x3710, + 0x3810,0x3910,0x4030,0x4130,0x4230,0x4330,0x4430,0x4530, + 0x4010,0x4110,0x4210,0x4310,0x4410,0x4510,0x4610,0x4710, + 0x4810,0x4910,0x5030,0x5130,0x5230,0x5330,0x5430,0x5530, + 0x5010,0x5110,0x5210,0x5310,0x5410,0x5510,0x5610,0x5710, + 0x5810,0x5910,0x6030,0x6130,0x6230,0x6330,0x6430,0x6530, + 0x0600,0x0700,0x0800,0x0900,0x0A00,0x0B00,0x0C00,0x0D00, + 0x0E00,0x0F00,0x1020,0x1120,0x1220,0x1320,0x1420,0x1520, + 0x1600,0x1700,0x1800,0x1900,0x1A00,0x1B00,0x1C00,0x1D00, + 0x1E00,0x1F00,0x2020,0x2120,0x2220,0x2320,0x2420,0x2520, + 0x2600,0x2700,0x2800,0x2900,0x2A00,0x2B00,0x2C00,0x2D00, + 0x2E00,0x2F00,0x3020,0x3120,0x3220,0x3320,0x3420,0x3520, + 0x3600,0x3700,0x3800,0x3900,0x3A00,0x3B00,0x3C00,0x3D00, + 0x3E00,0x3F00,0x4020,0x4120,0x4220,0x4320,0x4420,0x4520, + 0x4600,0x4700,0x4800,0x4900,0x4A00,0x4B00,0x4C00,0x4D00, + 0x4E00,0x4F00,0x5020,0x5120,0x5220,0x5320,0x5420,0x5520, + 0x5600,0x5700,0x5800,0x5900,0x5A00,0x5B00,0x5C00,0x5D00, + 0x5E00,0x5F00,0x6020,0x6120,0x6220,0x6320,0x6420,0x6520, + 0x6600,0x6700,0x6800,0x6900,0x6A00,0x6B00,0x6C00,0x6D00, + 0x6E00,0x6F00,0x7020,0x7120,0x7220,0x7320,0x7420,0x7520, + 0x7600,0x7700,0x7800,0x7900,0x7A00,0x7B00,0x7C00,0x7D00, + 0x7E00,0x7F00,0x8020,0x8120,0x8220,0x8320,0x8420,0x8520, + 0x8600,0x8700,0x8800,0x8900,0x8A00,0x8B00,0x8C00,0x8D00, + 0x8E00,0x8F00,0x9020,0x9120,0x9220,0x9320,0x9420,0x9520, + 0x9600,0x9700,0x9800,0x9900,0x9A00,0x9B00,0x9C00,0x9D00, + 0x9E00,0x9F00,0x00B0,0x0130,0x0230,0x0330,0x0430,0x0530, + 0x0610,0x0710,0x0810,0x0910,0x0A10,0x0B10,0x0C10,0x0D10, + 0x0E10,0x0F10,0x1030,0x1130,0x1230,0x1330,0x1430,0x1530, + 0x1610,0x1710,0x1810,0x1910,0x1A10,0x1B10,0x1C10,0x1D10, + 0x1E10,0x1F10,0x2030,0x2130,0x2230,0x2330,0x2430,0x2530, + 0x2610,0x2710,0x2810,0x2910,0x2A10,0x2B10,0x2C10,0x2D10, + 0x2E10,0x2F10,0x3030,0x3130,0x3230,0x3330,0x3430,0x3530, + 0x3610,0x3710,0x3810,0x3910,0x3A10,0x3B10,0x3C10,0x3D10, + 0x3E10,0x3F10,0x4030,0x4130,0x4230,0x4330,0x4430,0x4530, + 0x4610,0x4710,0x4810,0x4910,0x4A10,0x4B10,0x4C10,0x4D10, + 0x4E10,0x4F10,0x5030,0x5130,0x5230,0x5330,0x5430,0x5530, + 0x5610,0x5710,0x5810,0x5910,0x5A10,0x5B10,0x5C10,0x5D10, + 0x5E10,0x5F10,0x6030,0x6130,0x6230,0x6330,0x6430,0x6530, + 0x6610,0x6710,0x6810,0x6910,0x6A10,0x6B10,0x6C10,0x6D10, + 0x6E10,0x6F10,0x7030,0x7130,0x7230,0x7330,0x7430,0x7530, + 0x7610,0x7710,0x7810,0x7910,0x7A10,0x7B10,0x7C10,0x7D10, + 0x7E10,0x7F10,0x8030,0x8130,0x8230,0x8330,0x8430,0x8530, + 0x8610,0x8710,0x8810,0x8910,0x8A10,0x8B10,0x8C10,0x8D10, + 0x8E10,0x8F10,0x9030,0x9130,0x9230,0x9330,0x9430,0x9530, + 0x9610,0x9710,0x9810,0x9910,0x9A10,0x9B10,0x9C10,0x9D10, + 0x9E10,0x9F10,0xA030,0xA130,0xA230,0xA330,0xA430,0xA530, + 0xA610,0xA710,0xA810,0xA910,0xAA10,0xAB10,0xAC10,0xAD10, + 0xAE10,0xAF10,0xB030,0xB130,0xB230,0xB330,0xB430,0xB530, + 0xB610,0xB710,0xB810,0xB910,0xBA10,0xBB10,0xBC10,0xBD10, + 0xBE10,0xBF10,0xC030,0xC130,0xC230,0xC330,0xC430,0xC530, + 0xC610,0xC710,0xC810,0xC910,0xCA10,0xCB10,0xCC10,0xCD10, + 0xCE10,0xCF10,0xD030,0xD130,0xD230,0xD330,0xD430,0xD530, + 0xD610,0xD710,0xD810,0xD910,0xDA10,0xDB10,0xDC10,0xDD10, + 0xDE10,0xDF10,0xE030,0xE130,0xE230,0xE330,0xE430,0xE530, + 0xE610,0xE710,0xE810,0xE910,0xEA10,0xEB10,0xEC10,0xED10, + 0xEE10,0xEF10,0xF030,0xF130,0xF230,0xF330,0xF430,0xF530, + 0xF610,0xF710,0xF810,0xF910,0xFA10,0xFB10,0xFC10,0xFD10, + 0xFE10,0xFF10,0x00B0,0x0130,0x0230,0x0330,0x0430,0x0530, + 0x0610,0x0710,0x0810,0x0910,0x0A10,0x0B10,0x0C10,0x0D10, + 0x0E10,0x0F10,0x1030,0x1130,0x1230,0x1330,0x1430,0x1530, + 0x1610,0x1710,0x1810,0x1910,0x1A10,0x1B10,0x1C10,0x1D10, + 0x1E10,0x1F10,0x2030,0x2130,0x2230,0x2330,0x2430,0x2530, + 0x2610,0x2710,0x2810,0x2910,0x2A10,0x2B10,0x2C10,0x2D10, + 0x2E10,0x2F10,0x3030,0x3130,0x3230,0x3330,0x3430,0x3530, + 0x3610,0x3710,0x3810,0x3910,0x3A10,0x3B10,0x3C10,0x3D10, + 0x3E10,0x3F10,0x4030,0x4130,0x4230,0x4330,0x4430,0x4530, + 0x4610,0x4710,0x4810,0x4910,0x4A10,0x4B10,0x4C10,0x4D10, + 0x4E10,0x4F10,0x5030,0x5130,0x5230,0x5330,0x5430,0x5530, + 0x5610,0x5710,0x5810,0x5910,0x5A10,0x5B10,0x5C10,0x5D10, + 0x5E10,0x5F10,0x6030,0x6130,0x6230,0x6330,0x6430,0x6530, + 0x00C0,0x0140,0x0240,0x0340,0x0440,0x0540,0x0640,0x0740, + 0x0840,0x0940,0x0440,0x0540,0x0640,0x0740,0x0840,0x0940, + 0x1040,0x1140,0x1240,0x1340,0x1440,0x1540,0x1640,0x1740, + 0x1840,0x1940,0x1440,0x1540,0x1640,0x1740,0x1840,0x1940, + 0x2040,0x2140,0x2240,0x2340,0x2440,0x2540,0x2640,0x2740, + 0x2840,0x2940,0x2440,0x2540,0x2640,0x2740,0x2840,0x2940, + 0x3040,0x3140,0x3240,0x3340,0x3440,0x3540,0x3640,0x3740, + 0x3840,0x3940,0x3440,0x3540,0x3640,0x3740,0x3840,0x3940, + 0x4040,0x4140,0x4240,0x4340,0x4440,0x4540,0x4640,0x4740, + 0x4840,0x4940,0x4440,0x4540,0x4640,0x4740,0x4840,0x4940, + 0x5040,0x5140,0x5240,0x5340,0x5440,0x5540,0x5640,0x5740, + 0x5840,0x5940,0x5440,0x5540,0x5640,0x5740,0x5840,0x5940, + 0x6040,0x6140,0x6240,0x6340,0x6440,0x6540,0x6640,0x6740, + 0x6840,0x6940,0x6440,0x6540,0x6640,0x6740,0x6840,0x6940, + 0x7040,0x7140,0x7240,0x7340,0x7440,0x7540,0x7640,0x7740, + 0x7840,0x7940,0x7440,0x7540,0x7640,0x7740,0x7840,0x7940, + 0x8040,0x8140,0x8240,0x8340,0x8440,0x8540,0x8640,0x8740, + 0x8840,0x8940,0x8440,0x8540,0x8640,0x8740,0x8840,0x8940, + 0x9040,0x9140,0x9240,0x9340,0x9440,0x9540,0x9640,0x9740, + 0x9840,0x9940,0x3450,0x3550,0x3650,0x3750,0x3850,0x3950, + 0x4050,0x4150,0x4250,0x4350,0x4450,0x4550,0x4650,0x4750, + 0x4850,0x4950,0x4450,0x4550,0x4650,0x4750,0x4850,0x4950, + 0x5050,0x5150,0x5250,0x5350,0x5450,0x5550,0x5650,0x5750, + 0x5850,0x5950,0x5450,0x5550,0x5650,0x5750,0x5850,0x5950, + 0x6050,0x6150,0x6250,0x6350,0x6450,0x6550,0x6650,0x6750, + 0x6850,0x6950,0x6450,0x6550,0x6650,0x6750,0x6850,0x6950, + 0x7050,0x7150,0x7250,0x7350,0x7450,0x7550,0x7650,0x7750, + 0x7850,0x7950,0x7450,0x7550,0x7650,0x7750,0x7850,0x7950, + 0x8050,0x8150,0x8250,0x8350,0x8450,0x8550,0x8650,0x8750, + 0x8850,0x8950,0x8450,0x8550,0x8650,0x8750,0x8850,0x8950, + 0x9050,0x9150,0x9250,0x9350,0x9450,0x9550,0x9650,0x9750, + 0x9850,0x9950,0x9450,0x9550,0x9650,0x9750,0x9850,0x9950, + 0xA050,0xA150,0xA250,0xA350,0xA450,0xA550,0xA650,0xA750, + 0xA850,0xA950,0xA450,0xA550,0xA650,0xA750,0xA850,0xA950, + 0xB050,0xB150,0xB250,0xB350,0xB450,0xB550,0xB650,0xB750, + 0xB850,0xB950,0xB450,0xB550,0xB650,0xB750,0xB850,0xB950, + 0xC050,0xC150,0xC250,0xC350,0xC450,0xC550,0xC650,0xC750, + 0xC850,0xC950,0xC450,0xC550,0xC650,0xC750,0xC850,0xC950, + 0xD050,0xD150,0xD250,0xD350,0xD450,0xD550,0xD650,0xD750, + 0xD850,0xD950,0xD450,0xD550,0xD650,0xD750,0xD850,0xD950, + 0xE050,0xE150,0xE250,0xE350,0xE450,0xE550,0xE650,0xE750, + 0xE850,0xE950,0xE450,0xE550,0xE650,0xE750,0xE850,0xE950, + 0xF050,0xF150,0xF250,0xF350,0xF450,0xF550,0xF650,0xF750, + 0xF850,0xF950,0xF450,0xF550,0xF650,0xF750,0xF850,0xF950, + 0x00D0,0x0150,0x0250,0x0350,0x0450,0x0550,0x0650,0x0750, + 0x0850,0x0950,0x0450,0x0550,0x0650,0x0750,0x0850,0x0950, + 0x1050,0x1150,0x1250,0x1350,0x1450,0x1550,0x1650,0x1750, + 0x1850,0x1950,0x1450,0x1550,0x1650,0x1750,0x1850,0x1950, + 0x2050,0x2150,0x2250,0x2350,0x2450,0x2550,0x2650,0x2750, + 0x2850,0x2950,0x2450,0x2550,0x2650,0x2750,0x2850,0x2950, + 0x3050,0x3150,0x3250,0x3350,0x3450,0x3550,0x3650,0x3750, + 0x3850,0x3950,0x3450,0x3550,0x3650,0x3750,0x3850,0x3950, + 0x4050,0x4150,0x4250,0x4350,0x4450,0x4550,0x4650,0x4750, + 0x4850,0x4950,0x4450,0x4550,0x4650,0x4750,0x4850,0x4950, + 0x5050,0x5150,0x5250,0x5350,0x5450,0x5550,0x5650,0x5750, + 0x5850,0x5950,0x5450,0x5550,0x5650,0x5750,0x5850,0x5950, + 0x6050,0x6150,0x6250,0x6350,0x6450,0x6550,0x6650,0x6750, + 0x6850,0x6950,0x6450,0x6550,0x6650,0x6750,0x6850,0x6950, + 0x7050,0x7150,0x7250,0x7350,0x7450,0x7550,0x7650,0x7750, + 0x7850,0x7950,0x7450,0x7550,0x7650,0x7750,0x7850,0x7950, + 0x8050,0x8150,0x8250,0x8350,0x8450,0x8550,0x8650,0x8750, + 0x8850,0x8950,0x8450,0x8550,0x8650,0x8750,0x8850,0x8950, + 0x9050,0x9150,0x9250,0x9350,0x9450,0x9550,0x9650,0x9750, + 0x9850,0x9950,0x9450,0x9550,0x9650,0x9750,0x9850,0x9950, + 0xFA60,0xFB60,0xFC60,0xFD60,0xFE60,0xFF60,0x00C0,0x0140, + 0x0240,0x0340,0x0440,0x0540,0x0640,0x0740,0x0840,0x0940, + 0x0A60,0x0B60,0x0C60,0x0D60,0x0E60,0x0F60,0x1040,0x1140, + 0x1240,0x1340,0x1440,0x1540,0x1640,0x1740,0x1840,0x1940, + 0x1A60,0x1B60,0x1C60,0x1D60,0x1E60,0x1F60,0x2040,0x2140, + 0x2240,0x2340,0x2440,0x2540,0x2640,0x2740,0x2840,0x2940, + 0x2A60,0x2B60,0x2C60,0x2D60,0x2E60,0x2F60,0x3040,0x3140, + 0x3240,0x3340,0x3440,0x3540,0x3640,0x3740,0x3840,0x3940, + 0x3A60,0x3B60,0x3C60,0x3D60,0x3E60,0x3F60,0x4040,0x4140, + 0x4240,0x4340,0x4440,0x4540,0x4640,0x4740,0x4840,0x4940, + 0x4A60,0x4B60,0x4C60,0x4D60,0x4E60,0x4F60,0x5040,0x5140, + 0x5240,0x5340,0x5440,0x5540,0x5640,0x5740,0x5840,0x5940, + 0x5A60,0x5B60,0x5C60,0x5D60,0x5E60,0x5F60,0x6040,0x6140, + 0x6240,0x6340,0x6440,0x6540,0x6640,0x6740,0x6840,0x6940, + 0x6A60,0x6B60,0x6C60,0x6D60,0x6E60,0x6F60,0x7040,0x7140, + 0x7240,0x7340,0x7440,0x7540,0x7640,0x7740,0x7840,0x7940, + 0x7A60,0x7B60,0x7C60,0x7D60,0x7E60,0x7F60,0x8040,0x8140, + 0x8240,0x8340,0x8440,0x8540,0x8640,0x8740,0x8840,0x8940, + 0x8A60,0x8B60,0x8C60,0x8D60,0x8E60,0x8F60,0x9040,0x9140, + 0x9240,0x9340,0x3450,0x3550,0x3650,0x3750,0x3850,0x3950, + 0x3A70,0x3B70,0x3C70,0x3D70,0x3E70,0x3F70,0x4050,0x4150, + 0x4250,0x4350,0x4450,0x4550,0x4650,0x4750,0x4850,0x4950, + 0x4A70,0x4B70,0x4C70,0x4D70,0x4E70,0x4F70,0x5050,0x5150, + 0x5250,0x5350,0x5450,0x5550,0x5650,0x5750,0x5850,0x5950, + 0x5A70,0x5B70,0x5C70,0x5D70,0x5E70,0x5F70,0x6050,0x6150, + 0x6250,0x6350,0x6450,0x6550,0x6650,0x6750,0x6850,0x6950, + 0x6A70,0x6B70,0x6C70,0x6D70,0x6E70,0x6F70,0x7050,0x7150, + 0x7250,0x7350,0x7450,0x7550,0x7650,0x7750,0x7850,0x7950, + 0x7A70,0x7B70,0x7C70,0x7D70,0x7E70,0x7F70,0x8050,0x8150, + 0x8250,0x8350,0x8450,0x8550,0x8650,0x8750,0x8850,0x8950, + 0x8A70,0x8B70,0x8C70,0x8D70,0x8E70,0x8F70,0x9050,0x9150, + 0x9250,0x9350,0x9450,0x9550,0x9650,0x9750,0x9850,0x9950, + 0x9A70,0x9B70,0x9C70,0x9D70,0x9E70,0x9F70,0xA050,0xA150, + 0xA250,0xA350,0xA450,0xA550,0xA650,0xA750,0xA850,0xA950, + 0xAA70,0xAB70,0xAC70,0xAD70,0xAE70,0xAF70,0xB050,0xB150, + 0xB250,0xB350,0xB450,0xB550,0xB650,0xB750,0xB850,0xB950, + 0xBA70,0xBB70,0xBC70,0xBD70,0xBE70,0xBF70,0xC050,0xC150, + 0xC250,0xC350,0xC450,0xC550,0xC650,0xC750,0xC850,0xC950, + 0xCA70,0xCB70,0xCC70,0xCD70,0xCE70,0xCF70,0xD050,0xD150, + 0xD250,0xD350,0xD450,0xD550,0xD650,0xD750,0xD850,0xD950, + 0xDA70,0xDB70,0xDC70,0xDD70,0xDE70,0xDF70,0xE050,0xE150, + 0xE250,0xE350,0xE450,0xE550,0xE650,0xE750,0xE850,0xE950, + 0xEA70,0xEB70,0xEC70,0xED70,0xEE70,0xEF70,0xF050,0xF150, + 0xF250,0xF350,0xF450,0xF550,0xF650,0xF750,0xF850,0xF950, + 0xFA70,0xFB70,0xFC70,0xFD70,0xFE70,0xFF70,0x00D0,0x0150, + 0x0250,0x0350,0x0450,0x0550,0x0650,0x0750,0x0850,0x0950, + 0x0A70,0x0B70,0x0C70,0x0D70,0x0E70,0x0F70,0x1050,0x1150, + 0x1250,0x1350,0x1450,0x1550,0x1650,0x1750,0x1850,0x1950, + 0x1A70,0x1B70,0x1C70,0x1D70,0x1E70,0x1F70,0x2050,0x2150, + 0x2250,0x2350,0x2450,0x2550,0x2650,0x2750,0x2850,0x2950, + 0x2A70,0x2B70,0x2C70,0x2D70,0x2E70,0x2F70,0x3050,0x3150, + 0x3250,0x3350,0x3450,0x3550,0x3650,0x3750,0x3850,0x3950, + 0x3A70,0x3B70,0x3C70,0x3D70,0x3E70,0x3F70,0x4050,0x4150, + 0x4250,0x4350,0x4450,0x4550,0x4650,0x4750,0x4850,0x4950, + 0x4A70,0x4B70,0x4C70,0x4D70,0x4E70,0x4F70,0x5050,0x5150, + 0x5250,0x5350,0x5450,0x5550,0x5650,0x5750,0x5850,0x5950, + 0x5A70,0x5B70,0x5C70,0x5D70,0x5E70,0x5F70,0x6050,0x6150, + 0x6250,0x6350,0x6450,0x6550,0x6650,0x6750,0x6850,0x6950, + 0x6A70,0x6B70,0x6C70,0x6D70,0x6E70,0x6F70,0x7050,0x7150, + 0x7250,0x7350,0x7450,0x7550,0x7650,0x7750,0x7850,0x7950, + 0x7A70,0x7B70,0x7C70,0x7D70,0x7E70,0x7F70,0x8050,0x8150, + 0x8250,0x8350,0x8450,0x8550,0x8650,0x8750,0x8850,0x8950, + 0x8A70,0x8B70,0x8C70,0x8D70,0x8E70,0x8F70,0x9050,0x9150, + 0x9250,0x9350,0x9450,0x9550,0x9650,0x9750,0x9850,0x9950, +}; + +u8 ZeroTable[] = +{ + 0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 +}; + +#define GBSAVE_GAME_VERSION_1 1 +#define GBSAVE_GAME_VERSION_2 2 +#define GBSAVE_GAME_VERSION_3 3 +#define GBSAVE_GAME_VERSION_4 4 +#define GBSAVE_GAME_VERSION_5 5 +#define GBSAVE_GAME_VERSION_6 6 +#define GBSAVE_GAME_VERSION_7 7 +#define GBSAVE_GAME_VERSION_8 8 +#define GBSAVE_GAME_VERSION_9 9 +#define GBSAVE_GAME_VERSION_10 10 +#define GBSAVE_GAME_VERSION_11 11 +#define GBSAVE_GAME_VERSION_12 12 +#define GBSAVE_GAME_VERSION GBSAVE_GAME_VERSION_12 + +int inline gbGetValue(int min,int max,int v) +{ + return (int)(min+(float)(max-min)*(2.0*(v/31.0)-(v/31.0)*(v/31.0))); +} + +void gbGenFilter() +{ + for (int r=0;r<32;r++) + { + for (int g=0;g<32;g++) + { + for (int b=0;b<32;b++) + { + int nr=gbGetValue(gbGetValue(4,14,g), + gbGetValue(24,29,g),r)-4; + int ng=gbGetValue(gbGetValue(4+gbGetValue(0,5,r), + 14+gbGetValue(0,3,r),b), + gbGetValue(24+gbGetValue(0,3,r), + 29+gbGetValue(0,1,r),b),g)-4; + int nb=gbGetValue(gbGetValue(4+gbGetValue(0,5,r), + 14+gbGetValue(0,3,r),g), + gbGetValue(24+gbGetValue(0,3,r), + 29+gbGetValue(0,1,r),g),b)-4; + gbColorFilter[(b<<10)|(g<<5)|r]=(nb<<10)|(ng<<5)|nr; + } + } + } +} + +bool gbIsGameboyRom(char * file) +{ + if(strlen(file) > 4) + { + char * p = strrchr(file,'.'); + + if(p != NULL) + { + if(_stricmp(p, ".gb") == 0) + return true; + if(_stricmp(p, ".gbc") == 0) + return true; + if(_stricmp(p, ".cgb") == 0) + return true; + if(_stricmp(p, ".sgb") == 0) + return true; + } + } + + return false; +} + +void gbCopyMemory(u16 d, u16 s, int count) +{ + while(count) + { + gbMemoryMap[d>>12][d & 0x0fff] = gbMemoryMap[s>>12][s & 0x0fff]; + s++; + d++; + count--; + } +} + +void gbDoHdma() +{ + gbCopyMemory(gbHdmaDestination, + gbHdmaSource, + 0x10); + + gbHdmaDestination += 0x10; + gbHdmaSource += 0x10; + + register_HDMA2 += 0x10; + if(register_HDMA2 == 0x00) + register_HDMA1++; + + register_HDMA4 += 0x10; + if(register_HDMA4 == 0x00) + register_HDMA3++; + + if(gbHdmaDestination == 0x96b0) + gbHdmaBytes = gbHdmaBytes; + gbHdmaBytes -= 0x10; + register_HDMA5--; + if(register_HDMA5 == 0xff) + gbHdmaOn = 0; +} + +// fix for Harley and Lego Racers +void gbCompareLYToLYC() +{ + if(register_LY == register_LYC) + { + // mark that we have a match + register_STAT |= 4; + + // check if we need an interrupt + if((register_STAT & 0x40) && (register_IE & 2)) + gbInterrupt |= 2; + } else // no match + register_STAT &= 0xfb; +} + +void gbWriteMemory(register u16 address, register u8 value) +{ + if(address < 0x8000) + { +#ifndef FINAL_VERSION + if(memorydebug && (address>0x3fff || address < 0x2000)) + { + log("Memory register write %04x=%02x PC=%04x\n", + address, + value, + PC.W); + } +#endif + if(mapper) + (*mapper)(address, value); + return; + } + + if(address < 0xa000) + { + gbMemoryMap[address>>12][address&0x0fff] = value; + return; + } + + if(address < 0xc000) + { +#ifndef FINAL_VERSION + if(memorydebug) + { + log("Memory register write %04x=%02x PC=%04x\n", + address, + value, + PC.W); + } +#endif + + if(mapper) + (*mapperRAM)(address, value); + return; + } + + if(address < 0xfe00) + { + gbMemoryMap[address>>12][address & 0x0fff] = value; + return; + } + + if(address < 0xff00) + { + gbMemory[address] = value; + return; + } + + switch(address & 0x00ff) + { + case 0x00: + { + gbMemory[0xff00] = ((gbMemory[0xff00] & 0xcf) | + (value & 0x30)); + if(gbSgbMode) + { + gbSgbDoBitTransfer(value); + } + + return; + } + + case 0x01: + { + gbMemory[0xff01] = value; + return; + } + + // serial control + case 0x02: + { + gbSerialOn = (value & 0x80); + gbMemory[0xff02] = value; + if(gbSerialOn) + { + gbSerialTicks = GBSERIAL_CLOCK_TICKS; +#ifdef LINK_EMULATION + if(linkConnected) + { + if(value & 1) + { + linkSendByte(0x100|gbMemory[0xFF01]); + Sleep(5); + } + } +#endif + } + + gbSerialBits = 0; + return; + } + + // DIV register resets on any write + case 0x04: + { + register_DIV = 0; + return; + } + case 0x05: + register_TIMA = value; + return; + + case 0x06: + register_TMA = value; + return; + + // TIMER control + case 0x07: + { + register_TAC = value; + + gbTimerOn = (value & 4); + gbTimerMode = value & 3; + // register_TIMA = register_TMA; + switch(gbTimerMode) + { + case 0: + gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_0_CLOCK_TICKS; + break; + case 1: + gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_1_CLOCK_TICKS; + break; + case 2: + gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_2_CLOCK_TICKS; + break; + case 3: + gbTimerClockTicks = gbTimerTicks = GBTIMER_MODE_3_CLOCK_TICKS; + break; + } + return; + } + + case 0x0f: + { + register_IF = value; + gbInterrupt = value; + return; + } + + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1a: + case 0x1b: + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + { + SOUND_EVENT(address,value); + return; + } + case 0x40: + { + int lcdChange = (register_LCDC & 0x80) ^ (value & 0x80); + + if(lcdChange) + { + if(value & 0x80) + { + gbLcdTicks = GBLCD_MODE_1_CLOCK_TICKS; + gbLcdMode = 0; + register_STAT &= 0xfc; + register_LY = 0x00; + } else + { + gbLcdTicks = 0; + gbLcdMode = 0; + register_STAT &= 0xfc; + register_LY = 0x00; + } + // compareLYToLYC(); + } + // don't draw the window if it was not enabled and not being drawn before + if(!(register_LCDC & 0x20) && (value & 0x20) && gbWindowLine == -1 && + register_LY > register_WY) + gbWindowLine = 144; + + register_LCDC = value; + + return; + } + + // STAT + case 0x41: + { + //register_STAT = (register_STAT & 0x87) | + // (value & 0x7c); + register_STAT = (value & 0xf8) | (register_STAT & 0x07); // fix ? + // GB bug from Devrs FAQ + if(!gbCgbMode && (register_LCDC & 0x80) && gbLcdMode < 2) + gbInterrupt |= 2; + return; + } + + // SCY + case 0x42: + { + register_SCY = value; + return; + } + + // SCX + case 0x43: + { + register_SCX = value; + return; + } + + // LY + case 0x44: + { + // read only + return; + } + + // LYC + case 0x45: + { + register_LYC = value; + if((register_LCDC & 0x80)) + { + gbCompareLYToLYC(); + } + return; + } + + // DMA! + case 0x46: + { + int source = value * 0x0100; + + gbCopyMemory(0xfe00, + source, + 0xa0); + register_DMA = value; + return; + } + + // BGP + case 0x47: + { + gbBgp[0] = value & 0x03; + gbBgp[1] = (value & 0x0c)>>2; + gbBgp[2] = (value & 0x30)>>4; + gbBgp[3] = (value & 0xc0)>>6; + break; + } + + // OBP0 + case 0x48: + { + gbObp0[0] = value & 0x03; + gbObp0[1] = (value & 0x0c)>>2; + gbObp0[2] = (value & 0x30)>>4; + gbObp0[3] = (value & 0xc0)>>6; + break; + } + + // OBP1 + case 0x49: + { + gbObp1[0] = value & 0x03; + gbObp1[1] = (value & 0x0c)>>2; + gbObp1[2] = (value & 0x30)>>4; + gbObp1[3] = (value & 0xc0)>>6; + break; + } + + case 0x4a: + register_WY = value; + return; + + case 0x4b: + register_WX = value; + return; + + // KEY1 + case 0x4d: + { + if(gbCgbMode) + { + gbMemory[0xff4d] = (gbMemory[0xff4d] & 0x80) | (value & 1); + return; + } + } + break; + + // VBK + case 0x4f: + { + if(gbCgbMode) + { + value = value & 1; + if(value == gbVramBank) + return; + + int vramAddress = value * 0x2000; + gbMemoryMap[0x08] = &gbVram[vramAddress]; + gbMemoryMap[0x09] = &gbVram[vramAddress + 0x1000]; + + gbVramBank = value; + register_VBK = value; + } + return; + } + break; + + // HDMA1 + case 0x51: + { + if(gbCgbMode) + { + if(value > 0x7f && value < 0xa0) + value = 0; + + gbHdmaSource = (value << 8) | (register_HDMA2 & 0xf0); + + register_HDMA1 = value; + return; + } + } + break; + + // HDMA2 + case 0x52: + { + if(gbCgbMode) + { + value = value & 0xf0; + + gbHdmaSource = (register_HDMA1 << 8) | (value); + + register_HDMA2 = value; + return; + } + } + break; + + // HDMA3 + case 0x53: + { + if(gbCgbMode) + { + value = value & 0x1f; + gbHdmaDestination = (value << 8) | (register_HDMA4 & 0xf0); + gbHdmaDestination += 0x8000; + register_HDMA3 = value; + return; + } + } + break; + + // HDMA4 + case 0x54: + { + if(gbCgbMode) + { + value = value & 0xf0; + gbHdmaDestination = ((register_HDMA3 & 0x1f) << 8) | value; + gbHdmaDestination += 0x8000; + register_HDMA4 = value; + return; + } + } + break; + + // HDMA5 + case 0x55: + { + if(gbCgbMode) + { + gbHdmaBytes = 16 + (value & 0x7f) * 16; + if(gbHdmaOn) + { + if(value & 0x80) + { + register_HDMA5 = (value & 0x7f); + } else + { + register_HDMA5 = 0xff; + gbHdmaOn = 0; + } + } else + { + if(value & 0x80) + { + gbHdmaOn = 1; + register_HDMA5 = value & 0x7f; + if(gbLcdMode == 0) + gbDoHdma(); + } else + { + // we need to take the time it takes to complete the transfer into + // account... according to GB DEV FAQs, the setup time is the same + // for single and double speed, but the actual transfer takes the + // same time // (is that a typo?) + switch(gbDMASpeedVersion) + { + case 1: // I believe this is more correct + // the lower 7 bits of FF55 specify the Transfer Length (divided by 16, minus 1) + // and we make gbDmaTicks twice as many cycles at double speed to make the transfer take the same time + if(gbSpeed) + gbDmaTicks = 16 * ((value & 0x7f) + 1); + else + gbDmaTicks = 8 * ((value & 0x7f) + 1); + break; + case 0: // here for backward compatibility + // I think this was a guess that approximates the above in most but not all games + if(gbSpeed) + gbDmaTicks = 231 + 16 * (value & 0x7f); + else + gbDmaTicks = 231 + 8 * (value & 0x7f); + break; + default: // shouldn't happen + //assert(0); + break; + } + gbCopyMemory(gbHdmaDestination, + gbHdmaSource, + gbHdmaBytes); + gbHdmaDestination += gbHdmaBytes; + gbHdmaSource += gbHdmaBytes; + + register_HDMA3 = ((gbHdmaDestination - 0x8000) >> 8) & 0x1f; + register_HDMA4 = gbHdmaDestination & 0xf0; + register_HDMA1 = (gbHdmaSource >> 8) & 0xff; + register_HDMA2 = gbHdmaSource & 0xf0; + } + } + return; + } + } + break; + + // BCPS + case 0x68: + { + if(gbCgbMode) + { + int paletteIndex = (value & 0x3f) >> 1; + int paletteHiLo = (value & 0x01); + + gbMemory[0xff68] = value; + gbMemory[0xff69] = (paletteHiLo ? + (gbPalette[paletteIndex] >> 8) : + (gbPalette[paletteIndex] & 0x00ff)); + return; + } + } + break; + + // BCPD + case 0x69: + { + if(gbCgbMode) + { + int v = gbMemory[0xff68]; + int paletteIndex = (v & 0x3f) >> 1; + int paletteHiLo = (v & 0x01); + gbMemory[0xff69] = value; + gbPalette[paletteIndex] = (paletteHiLo ? + ((value << 8) | (gbPalette[paletteIndex] & 0xff)) : + ((gbPalette[paletteIndex] & 0xff00) | (value))) & 0x7fff; + + if(gbMemory[0xff68] & 0x80) + { + int index = ((gbMemory[0xff68] & 0x3f) + 1) & 0x3f; + + gbMemory[0xff68] = (gbMemory[0xff68] & 0x80) | index; + + gbMemory[0xff69] = (index & 1 ? + (gbPalette[index>>1] >> 8) : + (gbPalette[index>>1] & 0x00ff)); + + } + return; + } + } + break; + + // OCPS + case 0x6a: + { + if(gbCgbMode) + { + int paletteIndex = (value & 0x3f) >> 1; + int paletteHiLo = (value & 0x01); + + paletteIndex += 32; + + gbMemory[0xff6a] = value; + gbMemory[0xff6b] = (paletteHiLo ? + (gbPalette[paletteIndex] >> 8) : + (gbPalette[paletteIndex] & 0x00ff)); + return; + } + } + break; + + // OCPD + case 0x6b: + { + if(gbCgbMode) + { + int v = gbMemory[0xff6a]; + int paletteIndex = (v & 0x3f) >> 1; + int paletteHiLo = (v & 0x01); + + paletteIndex += 32; + + gbMemory[0xff6b] = value; + gbPalette[paletteIndex] = (paletteHiLo ? + ((value << 8) | (gbPalette[paletteIndex] & 0xff)) : + ((gbPalette[paletteIndex] & 0xff00) | (value))) & 0x7fff; + if(gbMemory[0xff6a] & 0x80) + { + int index = ((gbMemory[0xff6a] & 0x3f) + 1) & 0x3f; + + gbMemory[0xff6a] = (gbMemory[0xff6a] & 0x80) | index; + + gbMemory[0xff6b] = (index & 1 ? + (gbPalette[(index>>1) + 32] >> 8) : + (gbPalette[(index>>1) + 32] & 0x00ff)); + + } + return; + } + } + break; + + // SVBK + case 0x70: + { + if(gbCgbMode) + { + value = value & 7; + + int bank = value; + if(value == 0) + bank = 1; + + if(bank == gbWramBank) + return; + + int wramAddress = bank * 0x1000; + gbMemoryMap[0x0d] = &gbWram[wramAddress]; + + gbWramBank = bank; + register_SVBK = value; + return; + } + } + break; + + case 0xff: + { + register_IE = value; + register_IF &= value; + return; + } + } + + gbMemory[address] = value; +} + +u8 gbReadOpcode(register u16 address) +{ + if(gbCheatMap[address]) + return gbCheatRead(address); + + switch(address & 0xf000) + { + case 0x0a: + case 0x0b: + if(mapperReadRAM) + return mapperReadRAM(address); + break; + case 0x0f: + if(address > 0xff00) + { + switch(address & 0x00ff) + { + case 0x04: + return register_DIV; + case 0x05: + return register_TIMA; + case 0x06: + return register_TMA; + case 0x07: + return (0xf8 | register_TAC); + case 0x0f: + return (0xe0 | register_IF); + case 0x40: + return register_LCDC; + case 0x41: + return (0x80 | register_STAT); + case 0x42: + return register_SCY; + case 0x43: + return register_SCX; + case 0x44: + return register_LY; + case 0x45: + return register_LYC; + case 0x46: + return register_DMA; + case 0x4a: + return register_WY; + case 0x4b: + return register_WX; + case 0x4f: + return (0xfe | register_VBK); + case 0x51: + return register_HDMA1; + case 0x52: + return register_HDMA2; + case 0x53: + return register_HDMA3; + case 0x54: + return register_HDMA4; + case 0x55: + return register_HDMA5; + case 0x70: + return (0xf8 | register_SVBK); + case 0xff: + return register_IE; + } + } + break; + } + return gbMemoryMap[address>>12][address & 0x0fff]; +} + +u8 gbReadMemory(register u16 address) +{ + if(gbCheatMap[address]) + return gbCheatRead(address); + + if(address < 0xa000) + return gbMemoryMap[address>>12][address&0x0fff]; + + if(address < 0xc000) + { +#ifndef FINAL_VERSION + if(memorydebug) + { + log("Memory register read %04x PC=%04x\n", + address, + PC.W); + } +#endif + + if(mapperReadRAM) + return mapperReadRAM(address); + return gbMemoryMap[address>>12][address & 0x0fff]; + } + + if(address >= 0xff00) + { + switch(address & 0x00ff) + { + case 0x00: + { + if(gbSgbMode) + { + gbSgbReadingController |= 4; + gbSgbResetPacketState(); + } + + int b = gbMemory[0xff00]; + + if((b & 0x30) == 0x20) + { + b &= 0xf0; + + int joy = 0; + if(gbSgbMode && gbSgbMultiplayer) + { + switch(gbSgbNextController) + { + case 0x0f: + joy = 0; + break; + case 0x0e: + joy = 1; + break; + case 0x0d: + joy = 2; + break; + case 0x0c: + joy = 3; + break; + default: + joy = 0; + } + } + int joystate = gbJoymask[joy]; + if(!(joystate & 128)) + b |= 0x08; + if(!(joystate & 64)) + b |= 0x04; + if(!(joystate & 32)) + b |= 0x02; + if(!(joystate & 16)) + b |= 0x01; + + gbMemory[0xff00] = b; + } else if((b & 0x30) == 0x10) + { + b &= 0xf0; + + int joy = 0; + if(gbSgbMode && gbSgbMultiplayer) + { + switch(gbSgbNextController) + { + case 0x0f: + joy = 0; + break; + case 0x0e: + joy = 1; + break; + case 0x0d: + joy = 2; + break; + case 0x0c: + joy = 3; + break; + default: + joy = 0; + } + } + int joystate = gbJoymask[joy]; + if(!(joystate & 8)) + b |= 0x08; + if(!(joystate & 4)) + b |= 0x04; + if(!(joystate & 2)) + b |= 0x02; + if(!(joystate & 1)) + b |= 0x01; + + gbMemory[0xff00] = b; + } else + { + if(gbSgbMode && gbSgbMultiplayer) + { + gbMemory[0xff00] = 0xf0 | gbSgbNextController; + } else + { + gbMemory[0xff00] = 0xff; + } + } + } + return gbMemory[0xff00]; + break; + case 0x01: + return gbMemory[0xff01]; + case 0x04: + return register_DIV; + case 0x05: + return register_TIMA; + case 0x06: + return register_TMA; + case 0x07: + return (0xf8 | register_TAC); + case 0x0f: + return (0xe0 | register_IF); + case 0x40: + return register_LCDC; + case 0x41: + return (0x80 | register_STAT); + case 0x42: + return register_SCY; + case 0x43: + return register_SCX; + case 0x44: + return register_LY; + case 0x45: + return register_LYC; + case 0x46: + return register_DMA; + case 0x4a: + return register_WY; + case 0x4b: + return register_WX; + case 0x4f: + return (0xfe | register_VBK); + case 0x51: + return register_HDMA1; + case 0x52: + return register_HDMA2; + case 0x53: + return register_HDMA3; + case 0x54: + return register_HDMA4; + case 0x55: + return register_HDMA5; + case 0x70: + return (0xf8 | register_SVBK); + case 0xff: + return register_IE; + } + } + + return gbMemoryMap[address>>12][address & 0x0fff]; +} + +void gbVblank_interrupt() +{ + if(IFF & 0x80) + { + PC.W++; + IFF &= 0x7f; + } + gbInterrupt &= 0xfe; + + IFF &= 0x7e; + register_IF &= 0xfe; + + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + PC.W = 0x40; +} + +void gbLcd_interrupt() +{ + if(IFF & 0x80) + { + PC.W++; + IFF &= 0x7f; + } + gbInterrupt &= 0xfd; + IFF &= 0x7e; + register_IF &= 0xfd; + + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + + PC.W = 0x48; +} + +void gbTimer_interrupt() +{ + if(IFF & 0x80) + { + PC.W++; + IFF &= 0x7f; + } + IFF &= 0x7e; + gbInterrupt &= 0xfb; + register_IF &= 0xfb; + + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + + PC.W = 0x50; +} + +void gbSerial_interrupt() +{ + if(IFF & 0x80) + { + PC.W++; + IFF &= 0x7f; + } + IFF &= 0x7e; + gbInterrupt &= 0xf7; + register_IF &= 0xf7; + + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + + PC.W = 0x58; +} + +void gbJoypad_interrupt() +{ + if(IFF & 0x80) + { + PC.W++; + IFF &= 0x7f; + } + IFF &= 0x7e; + gbInterrupt &= 0xef; + register_IF &= 0xef; + + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + + PC.W = 0x60; +} + +void gbSpeedSwitch() +{ + if(gbSpeed == 0) + { + gbSpeed = 1; + GBLCD_MODE_0_CLOCK_TICKS = 51 * 2; //127; //51 * 2; + GBLCD_MODE_1_CLOCK_TICKS = 1140 * 2; + GBLCD_MODE_2_CLOCK_TICKS = 20 * 2; //52; //20 * 2; + GBLCD_MODE_3_CLOCK_TICKS = 43 * 2; //99; //43 * 2; + GBDIV_CLOCK_TICKS = 64 * 2; + GBLY_INCREMENT_CLOCK_TICKS = 114 * 2; + GBTIMER_MODE_0_CLOCK_TICKS = 256; //256*2; + GBTIMER_MODE_1_CLOCK_TICKS = 4; //4*2; + GBTIMER_MODE_2_CLOCK_TICKS = 16; //16*2; + GBTIMER_MODE_3_CLOCK_TICKS = 64; //64*2; + GBSERIAL_CLOCK_TICKS = 128 * 2; + gbDivTicks *= 2; + gbLcdTicks *= 2; + gbLcdLYIncrementTicks *= 2; + // timerTicks *= 2; + // timerClockTicks *= 2; + gbSerialTicks *= 2; + SOUND_CLOCK_TICKS = soundQuality * 24 * 2; + soundTicks *= 2; + // synchronizeTicks *= 2; + // SYNCHRONIZE_CLOCK_TICKS *= 2; + } else + { + gbSpeed = 0; + GBLCD_MODE_0_CLOCK_TICKS = 51; + GBLCD_MODE_1_CLOCK_TICKS = 1140; + GBLCD_MODE_2_CLOCK_TICKS = 20; + GBLCD_MODE_3_CLOCK_TICKS = 43; + GBDIV_CLOCK_TICKS = 64; + GBLY_INCREMENT_CLOCK_TICKS = 114; + GBTIMER_MODE_0_CLOCK_TICKS = 256; + GBTIMER_MODE_1_CLOCK_TICKS = 4; + GBTIMER_MODE_2_CLOCK_TICKS = 16; + GBTIMER_MODE_3_CLOCK_TICKS = 64; + GBSERIAL_CLOCK_TICKS = 128; + gbDivTicks /= 2; + gbLcdTicks /= 2; + gbLcdLYIncrementTicks /= 2; + // timerTicks /= 2; + // timerClockTicks /= 2; + gbSerialTicks /= 2; + SOUND_CLOCK_TICKS = soundQuality * 24; + soundTicks /= 2; + // synchronizeTicks /= 2; + // SYNCHRONIZE_CLOCK_TICKS /= 2; + } +} + +void gbReset() +{ +#if (defined(WIN32) && !defined(SDL)) + theApp.globalFrameCount = 0; +#endif + VBAMovieSignalReset(); + + SP.W = 0xfffe; + AF.W = 0x01b0; + BC.W = 0x0013; + DE.W = 0x00d8; + HL.W = 0x014d; + PC.W = 0x0100; + IFF = 0; + gbInterrupt = 1; + gbInterruptWait = 0; + + register_DIV = 0; + register_TIMA = 0; + register_TMA = 0; + register_TAC = 0; + register_IF = 1; + register_LCDC = 0x91; + register_STAT = 0; + register_SCY = 0; + register_SCX = 0; + register_LY = 0; + register_LYC = 0; + register_DMA = 0; + register_WY = 0; + register_WX = 0; + register_VBK = 0; + register_HDMA1 = 0; + register_HDMA2 = 0; + register_HDMA3 = 0; + register_HDMA4 = 0; + register_HDMA5 = 0; + register_SVBK = 0; + register_IE = 0; + + if(gbCgbMode) + { + if(gbSgbMode) + { + if(gbEmulatorType == 5) + AF.W = 0xffb0; + else + AF.W = 0x01b0; + BC.W = 0x0013; + DE.W = 0x00d8; + HL.W = 0x014d; + for(int i = 0; i < 8; i++) + gbPalette[i] = systemGbPalette[gbPaletteOption*8+i]; + } else + { + AF.W = 0x11b0; + BC.W = 0x0000; + DE.W = 0xff56; + HL.W = 0x000d; + } + if(gbEmulatorType == 4) + BC.B.B1 |= 0x01; + + register_HDMA5 = 0xff; + gbMemory[0xff68] = 0xc0; + gbMemory[0xff6a] = 0xc0; + } else + { + for(int i = 0; i < 8; i++) + gbPalette[i] = systemGbPalette[gbPaletteOption*8+i]; + } + + if(gbSpeed) + { + gbSpeedSwitch(); + gbMemory[0xff4d] = 0; + } + + gbDivTicks = GBDIV_CLOCK_TICKS; + gbLcdMode = 2; + gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS; + gbLcdLYIncrementTicks = 0; + gbTimerTicks = 0; + gbTimerClockTicks = 0; + gbSerialTicks = 0; + gbSerialBits = 0; + gbSerialOn = 0; + gbWindowLine = -1; + gbTimerOn = 0; + gbTimerMode = 0; + // gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS; + gbSpeed = 0; + gbJoymask[0] = gbJoymask[1] = gbJoymask[2] = gbJoymask[3] = 0; + + if(gbCgbMode) + { + gbSpeed = 0; + gbHdmaOn = 0; + gbHdmaSource = 0x0000; + gbHdmaDestination = 0x8000; + gbVramBank = 0; + gbWramBank = 1; + register_LY = 0x90; + gbLcdMode = 1; + for(int i = 0; i < 64; i++) + gbPalette[i] = 0x7fff; + } + + if(gbSgbMode) + { + gbSgbReset(); + } + + for(int i =0; i < 4; i++) + gbBgp[i] = gbObp0[i] = gbObp1[i] = i; + + memset(&gbDataMBC1,0, sizeof(gbDataMBC1)); + gbDataMBC1.mapperROMBank = 1; + + gbDataMBC2.mapperRAMEnable = 0; + gbDataMBC2.mapperROMBank = 1; + + memset(&gbDataMBC3,0, 6 * sizeof(int)); + gbDataMBC3.mapperROMBank = 1; + + memset(&gbDataMBC5, 0, sizeof(gbDataMBC5)); + gbDataMBC5.mapperROMBank = 1; + + memset(&gbDataHuC1, 0, sizeof(gbDataHuC1)); + gbDataHuC1.mapperROMBank = 1; + + memset(&gbDataHuC3, 0, sizeof(gbDataHuC3)); + gbDataHuC3.mapperROMBank = 1; + + gbMemoryMap[0x00] = &gbRom[0x0000]; + gbMemoryMap[0x01] = &gbRom[0x1000]; + gbMemoryMap[0x02] = &gbRom[0x2000]; + gbMemoryMap[0x03] = &gbRom[0x3000]; + gbMemoryMap[0x04] = &gbRom[0x4000]; + gbMemoryMap[0x05] = &gbRom[0x5000]; + gbMemoryMap[0x06] = &gbRom[0x6000]; + gbMemoryMap[0x07] = &gbRom[0x7000]; + if(gbCgbMode) + { + gbMemoryMap[0x08] = &gbVram[0x0000]; + gbMemoryMap[0x09] = &gbVram[0x1000]; + gbMemoryMap[0x0a] = &gbMemory[0xa000]; + gbMemoryMap[0x0b] = &gbMemory[0xb000]; + gbMemoryMap[0x0c] = &gbMemory[0xc000]; + gbMemoryMap[0x0d] = &gbWram[0x1000]; + gbMemoryMap[0x0e] = &gbMemory[0xe000]; + gbMemoryMap[0x0f] = &gbMemory[0xf000]; + } else + { + gbMemoryMap[0x08] = &gbMemory[0x8000]; + gbMemoryMap[0x09] = &gbMemory[0x9000]; + gbMemoryMap[0x0a] = &gbMemory[0xa000]; + gbMemoryMap[0x0b] = &gbMemory[0xb000]; + gbMemoryMap[0x0c] = &gbMemory[0xc000]; + gbMemoryMap[0x0d] = &gbMemory[0xd000]; + gbMemoryMap[0x0e] = &gbMemory[0xe000]; + gbMemoryMap[0x0f] = &gbMemory[0xf000]; + } + + if(gbRam) + { + gbMemoryMap[0x0a] = &gbRam[0x0000]; + gbMemoryMap[0x0b] = &gbRam[0x1000]; + } + + gbSoundReset(); + +#if (defined(WIN32) && !defined(SDL)) + theApp.sensorX = theApp.sensorY = 2047; +#else + extern int sensorX, sensorY; // from SDL.cpp + sensorX = sensorY = 2047; +#endif + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + gbLastTime = systemGetClock(); + gbFrameCount = 0; +} + +void gbWriteSaveMBC1(const char * name) +{ + FILE *gzFile = fopen(name,"wb"); + + if(gzFile == NULL) + { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name); + return; + } + + fwrite(gbRam, + 1, + gbRamSize, + gzFile); + + fclose(gzFile); +} + +void gbWriteSaveMBC2(const char * name) +{ + FILE *file = fopen(name, "wb"); + + if(file == NULL) + { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name); + return; + } + + fwrite(&gbMemory[0xa000], + 1, + 256, + file); + + fclose(file); +} + +void gbWriteSaveMBC3(const char * name, bool extendedSave) +{ + FILE *gzFile = fopen(name,"wb"); + + if(gzFile == NULL) + { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name); + return; + } + + fwrite(gbRam, + 1, + gbRamSize, + gzFile); + + if(extendedSave) + fwrite(&gbDataMBC3.mapperSeconds, + 1, + 10*sizeof(int) + sizeof(time_t), + gzFile); + + fclose(gzFile); +} + +void gbWriteSaveMBC5(const char * name) +{ + FILE *gzFile = fopen(name,"wb"); + + if(gzFile == NULL) + { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name); + return; + } + + fwrite(gbRam, + 1, + gbRamSize, + gzFile); + + fclose(gzFile); +} + +void gbWriteSaveMBC7(const char * name) +{ + FILE *file = fopen(name, "wb"); + + if(file == NULL) + { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), name); + return; + } + + fwrite(&gbMemory[0xa000], + 1, + 256, + file); + + fclose(file); +} + +bool gbReadSaveMBC1(const char * name) +{ + gzFile gzFile = gzopen(name, "rb"); + + if(gzFile == NULL) + { + return false; + } + + int read = gzread(gzFile, + gbRam, + gbRamSize); + + if(read != gbRamSize) + { + systemMessage(MSG_FAILED_TO_READ_SGM, N_("Failed to read complete save game %s (%d)"), name, read); + gzclose(gzFile); + return false; + } + + gzclose(gzFile); + return true; +} + +bool gbReadSaveMBC2(const char * name) +{ + FILE *file = fopen(name, "rb"); + + if(file == NULL) + { + return false; + } + + int read = fread(&gbMemory[0xa000], + 1, + 256, + file); + + if(read != 256) + { + systemMessage(MSG_FAILED_TO_READ_SGM, + N_("Failed to read complete save game %s (%d)"), name, read); + fclose(file); + return false; + } + + fclose(file); + return true; +} + +bool gbReadSaveMBC3(const char * name) +{ + gzFile gzFile = gzopen(name, "rb"); + + if(gzFile == NULL) + { + return false; + } + + int read = gzread(gzFile, + gbRam, + gbRamSize); + + bool res = true; + + if(read != gbRamSize) + { + systemMessage(MSG_FAILED_TO_READ_SGM, + N_("Failed to read complete save game %s (%d)"), name, read); + } else + { + read = gzread(gzFile, + &gbDataMBC3.mapperSeconds, + sizeof(int)*10 + sizeof(time_t)); + + if(read != (sizeof(int)*10 + sizeof(time_t)) && read != 0) + { + systemMessage(MSG_FAILED_TO_READ_RTC, + N_("Failed to read RTC from save game %s (continuing)"), + name); + res = false; + } + } + + gzclose(gzFile); + return res; +} + +bool gbReadSaveMBC5(const char * name) +{ + gzFile gzFile = gzopen(name, "rb"); + + if(gzFile == NULL) + { + return false; + } + + int read = gzread(gzFile, + gbRam, + gbRamSize); + + if(read != gbRamSize) + { + systemMessage(MSG_FAILED_TO_READ_SGM, + N_("Failed to read complete save game %s (%d)"), name, read); + gzclose(gzFile); + return false; + } + + gzclose(gzFile); + return true; +} + +bool gbReadSaveMBC7(const char * name) +{ + FILE *file = fopen(name, "rb"); + + if(file == NULL) + { + return false; + } + + int read = fread(&gbMemory[0xa000], + 1, + 256, + file); + + if(read != 256) + { + systemMessage(MSG_FAILED_TO_READ_SGM, + N_("Failed to read complete save game %s (%d)"), name, read); + fclose(file); + return false; + } + + fclose(file); + return true; +} + +void gbInit() +{ + gbGenFilter(); + gbSgbInit(); + + gbMemory = (u8 *)malloc(65536); + memset(gbMemory,0, 65536); + + // HACK: +4 at start to accomodate the 2xSaI filter reading out of bounds of the leftmost pixel + origPix = (u8 *)calloc(1,4*257*226 +4); + pix = origPix + 4; + + gbLineBuffer = (u16 *)malloc(160 * sizeof(u16)); +} + +bool gbWriteBatteryFile(const char *file, bool extendedSave) +{ + if(gbBattery) + { + int type = gbRom[0x147]; + + switch(type) + { + case 0x03: + gbWriteSaveMBC1(file); + break; + case 0x06: + gbWriteSaveMBC2(file); + break; + case 0x0f: + case 0x10: + case 0x13: + gbWriteSaveMBC3(file, extendedSave); + break; + case 0x1b: + case 0x1e: + gbWriteSaveMBC5(file); + break; + case 0x22: + gbWriteSaveMBC7(file); + break; + case 0xff: + gbWriteSaveMBC1(file); + break; + } + } + return true; +} + +bool gbWriteBatteryFile(const char *file) +{ + gbWriteBatteryFile(file, true); + return true; +} + +bool gbWriteBatteryToStream(gzFile gzfile) +{ + /// XXX FIXME: probably broken - reading it fails + + // the GB save code is ugly, so rather than convert it all to use gzFiles, just save it to a temp file... +#define TEMP_SAVE_FNAME ("tempvbawrite.sav") + bool retVal = gbWriteBatteryFile(TEMP_SAVE_FNAME, true); + + // ...open the temp file and figure out its size... + gzFile gzFileTemp = utilGzOpen(TEMP_SAVE_FNAME, "rb"); + gzseek(gzFileTemp, 0, SEEK_END); + int len = gztell(gzFileTemp); + + // ...copy over the temp file... + char * temp = new char [len]; + if(temp == NULL) return false; + gzseek(gzFileTemp, 0, SEEK_SET); + utilGzRead(gzFileTemp, temp, len); + utilGzClose(gzFileTemp); + utilGzWrite(gzfile, temp, len); + delete [] temp; + + // ... and delete the temp file + remove(TEMP_SAVE_FNAME); +#undef TEMP_SAVE_FNAME + + return retVal; +} + + +bool gbReadBatteryFile(const char *file) +{ + bool res = false; + if(gbBattery) + { + int type = gbRom[0x147]; + + switch(type) + { + case 0x03: + res = gbReadSaveMBC1(file); + break; + case 0x06: + res = gbReadSaveMBC2(file); + break; + case 0x0f: + case 0x10: + case 0x13: + if(!gbReadSaveMBC3(file)) + { + struct tm *lt; + + if(VBAMovieActive() || VBAMovieLoading()) + { + gbDataMBC3.mapperLastTime = VBAMovieGetId() + VBAMovieGetFrameCounter()/60; + lt = gmtime(&gbDataMBC3.mapperLastTime); + } + else + { + time(&gbDataMBC3.mapperLastTime); + lt = localtime(&gbDataMBC3.mapperLastTime); + } + systemScreenMessage(ctime(&gbDataMBC3.mapperLastTime), 4); + + gbDataMBC3.mapperSeconds = lt->tm_sec; + gbDataMBC3.mapperMinutes = lt->tm_min; + gbDataMBC3.mapperHours = lt->tm_hour; + gbDataMBC3.mapperDays = lt->tm_yday & 255; + gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) | + (lt->tm_yday > 255 ? 1: 0); + res = false; + break; + } + systemScreenMessage(ctime(&gbDataMBC3.mapperLastTime), 4); + res = true; + break; + case 0x1b: + case 0x1e: + res = gbReadSaveMBC5(file); + break; + case 0x22: + res = gbReadSaveMBC7(file); + case 0xff: + res = gbReadSaveMBC1(file); + break; + } + } + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + return res; +} + +bool gbReadBatteryFromStream(gzFile gzfile) +{ + /// XXX FIXME: probably broken - fails to read save + + // the GB save code is ugly, so rather than convert it all to use gzFiles, just copy it to temp RAM... +#define TEMP_SAVE_FNAME ("tempvbaread.sav") + int pos = gztell(gzfile); + gzseek(gzfile, 0, SEEK_END); + int len = gztell(gzfile); + gzseek(gzfile, pos, SEEK_SET); + char * temp = new char [len]; + if(temp == NULL) return false; + + // ...make a temp file and write it there... + gzFile gzFileTemp = utilGzOpen(TEMP_SAVE_FNAME, "wb"); + utilGzRead(gzfile, temp, len); + gzseek(gzfile, pos, SEEK_SET); /// FIXME: leaves pos in gzfile before save instead of after it (everything that calls this right now does a seek afterwards so it doesn't matter for now, but it's still bad) + utilGzWrite(gzFileTemp, temp, len); + delete [] temp; + + // ... load from the temp file... + bool retVal = gbReadBatteryFile(TEMP_SAVE_FNAME); + + // ... and delete the temp file + remove(TEMP_SAVE_FNAME); +#undef TEMP_SAVE_FNAME + + return retVal; +} + +bool gbReadGSASnapshot(const char *fileName) +{ + FILE *file = fopen(fileName, "rb"); + + if(!file) + { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName); + return false; + } + + // long size = ftell(file); + fseek(file, 0x4, SEEK_SET); + char buffer[16]; + char buffer2[16]; + fread(buffer, 1, 15, file); + buffer[15] = 0; + memcpy(buffer2, &gbRom[0x134], 15); + buffer2[15] = 0; + if(memcmp(buffer, buffer2, 15)) + { + systemMessage(MSG_CANNOT_IMPORT_SNAPSHOT_FOR, + N_("Cannot import snapshot for %s. Current game is %s"), + buffer, + buffer2); + fclose(file); + return false; + } + fseek(file, 0x13, SEEK_SET); + int read = 0; + int toRead = 0; + switch(gbRom[0x147]) + { + case 0x03: + case 0x0f: + case 0x10: + case 0x13: + case 0x1b: + case 0x1e: + case 0xff: + read = fread(gbRam, 1, gbRamSize, file); + toRead = gbRamSize; + break; + case 0x06: + case 0x22: + read = fread(&gbMemory[0xa000],1,256,file); + toRead = 256; + break; + default: + systemMessage(MSG_UNSUPPORTED_SNAPSHOT_FILE, + N_("Unsupported snapshot file %s"), + fileName); + fclose(file); + return false; + } + fclose(file); + gbReset(); + return true; +} + +variable_desc gbSaveGameStruct[] = +{ + { &PC.W, sizeof(u16) }, + { &SP.W, sizeof(u16) }, + { &AF.W, sizeof(u16) }, + { &BC.W, sizeof(u16) }, + { &DE.W, sizeof(u16) }, + { &HL.W, sizeof(u16) }, + { &IFF, sizeof(u8) }, + { &GBLCD_MODE_0_CLOCK_TICKS, sizeof(int) }, + { &GBLCD_MODE_1_CLOCK_TICKS, sizeof(int) }, + { &GBLCD_MODE_2_CLOCK_TICKS, sizeof(int) }, + { &GBLCD_MODE_3_CLOCK_TICKS, sizeof(int) }, + { &GBDIV_CLOCK_TICKS, sizeof(int) }, + { &GBLY_INCREMENT_CLOCK_TICKS, sizeof(int) }, + { &GBTIMER_MODE_0_CLOCK_TICKS, sizeof(int) }, + { &GBTIMER_MODE_1_CLOCK_TICKS, sizeof(int) }, + { &GBTIMER_MODE_2_CLOCK_TICKS, sizeof(int) }, + { &GBTIMER_MODE_3_CLOCK_TICKS, sizeof(int) }, + { &GBSERIAL_CLOCK_TICKS, sizeof(int) }, + { &GBSYNCHRONIZE_CLOCK_TICKS, sizeof(int) }, + { &gbDivTicks, sizeof(int) }, + { &gbLcdMode, sizeof(int) }, + { &gbLcdTicks, sizeof(int) }, + { &gbLcdLYIncrementTicks, sizeof(int) }, + { &gbTimerTicks, sizeof(int) }, + { &gbTimerClockTicks, sizeof(int) }, + { &gbSerialTicks, sizeof(int) }, + { &gbSerialBits, sizeof(int) }, + { &gbInterrupt, sizeof(int) }, + { &gbInterruptWait, sizeof(int) }, + { &gbSynchronizeTicks, sizeof(int) }, + { &gbTimerOn, sizeof(int) }, + { &gbTimerMode, sizeof(int) }, + { &gbSerialOn, sizeof(int) }, + { &gbWindowLine, sizeof(int) }, + { &gbCgbMode, sizeof(int) }, + { &gbVramBank, sizeof(int) }, + { &gbWramBank, sizeof(int) }, + { &gbHdmaSource, sizeof(int) }, + { &gbHdmaDestination, sizeof(int) }, + { &gbHdmaBytes, sizeof(int) }, + { &gbHdmaOn, sizeof(int) }, + { &gbSpeed, sizeof(int) }, + { &gbSgbMode, sizeof(int) }, + { ®ister_DIV, sizeof(u8) }, + { ®ister_TIMA, sizeof(u8) }, + { ®ister_TMA, sizeof(u8) }, + { ®ister_TAC, sizeof(u8) }, + { ®ister_IF, sizeof(u8) }, + { ®ister_LCDC, sizeof(u8) }, + { ®ister_STAT, sizeof(u8) }, + { ®ister_SCY, sizeof(u8) }, + { ®ister_SCX, sizeof(u8) }, + { ®ister_LY, sizeof(u8) }, + { ®ister_LYC, sizeof(u8) }, + { ®ister_DMA, sizeof(u8) }, + { ®ister_WY, sizeof(u8) }, + { ®ister_WX, sizeof(u8) }, + { ®ister_VBK, sizeof(u8) }, + { ®ister_HDMA1, sizeof(u8) }, + { ®ister_HDMA2, sizeof(u8) }, + { ®ister_HDMA3, sizeof(u8) }, + { ®ister_HDMA4, sizeof(u8) }, + { ®ister_HDMA5, sizeof(u8) }, + { ®ister_SVBK, sizeof(u8) }, + { ®ister_IE , sizeof(u8) }, + { &gbBgp[0], sizeof(u8) }, + { &gbBgp[1], sizeof(u8) }, + { &gbBgp[2], sizeof(u8) }, + { &gbBgp[3], sizeof(u8) }, + { &gbObp0[0], sizeof(u8) }, + { &gbObp0[1], sizeof(u8) }, + { &gbObp0[2], sizeof(u8) }, + { &gbObp0[3], sizeof(u8) }, + { &gbObp1[0], sizeof(u8) }, + { &gbObp1[1], sizeof(u8) }, + { &gbObp1[2], sizeof(u8) }, + { &gbObp1[3], sizeof(u8) }, + { NULL, 0 } +}; + + +bool gbWriteSaveStateToStream(gzFile gzFile) +{ + utilWriteInt(gzFile, GBSAVE_GAME_VERSION); + + utilGzWrite(gzFile, &gbRom[0x134], 15); + + utilWriteData(gzFile, gbSaveGameStruct); + + utilGzWrite(gzFile, &IFF, 2); + + if(gbSgbMode) + { + gbSgbSaveGame(gzFile); + } + + utilGzWrite(gzFile, &gbDataMBC1, sizeof(gbDataMBC1)); + utilGzWrite(gzFile, &gbDataMBC2, sizeof(gbDataMBC2)); + utilGzWrite(gzFile, &gbDataMBC3, sizeof(gbDataMBC3)); + utilGzWrite(gzFile, &gbDataMBC5, sizeof(gbDataMBC5)); + utilGzWrite(gzFile, &gbDataHuC1, sizeof(gbDataHuC1)); + utilGzWrite(gzFile, &gbDataHuC3, sizeof(gbDataHuC3)); + + // yes, this definitely needs to be saved, or loading paused games will show a black screen + // this is also necessary to be consistent with what the GBA saving does + utilGzWrite(gzFile, pix, 4*257*226); + + utilGzWrite(gzFile, gbPalette, 128 * sizeof(u16)); + // todo: remove + utilGzWrite(gzFile, gbPalette, 128 * sizeof(u16)); + + utilGzWrite(gzFile, &gbMemory[0x8000], 0x8000); + + if(gbRamSize && gbRam) + { + utilGzWrite(gzFile, gbRam, gbRamSize); + } + + if(gbCgbMode) + { + utilGzWrite(gzFile, gbVram, 0x4000); + utilGzWrite(gzFile, gbWram, 0x8000); + } + + gbSoundSaveGame(gzFile); + + gbCheatsSaveGame(gzFile); + + // new to re-recording version: + { +#if (defined(WIN32) && !defined(SDL)) + utilGzWrite(gzFile, &theApp.sensorX, sizeof(theApp.sensorX)); + utilGzWrite(gzFile, &theApp.sensorY, sizeof(theApp.sensorY)); +#else + extern int sensorX, sensorY; // from SDL.cpp + utilGzWrite(gzFile, &sensorX, sizeof(sensorX)); + utilGzWrite(gzFile, &sensorY, sizeof(sensorY)); +#endif + utilGzWrite(gzFile, gbJoymask, 4*sizeof(*gbJoymask)); // this has to be saved or old input will incorrectly get carried back on loading a snapshot! + + bool8 movieActive = VBAMovieActive(); + utilGzWrite(gzFile, &movieActive, sizeof(movieActive)); + if(movieActive) + { + uint8* movie_freeze_buf = NULL; + uint32 movie_freeze_size = 0; + + VBAMovieFreeze(&movie_freeze_buf, &movie_freeze_size); + if(movie_freeze_buf) + { + utilGzWrite(gzFile, &movie_freeze_size, sizeof(movie_freeze_size)); + utilGzWrite(gzFile, movie_freeze_buf, movie_freeze_size); + delete [] movie_freeze_buf; + } + else + { + systemMessage(0, N_("Failed to save movie snapshot.")); + return false; + } + } +#if (defined(WIN32) && !defined(SDL)) + utilGzWrite(gzFile, &theApp.globalFrameCount, sizeof(theApp.globalFrameCount)); +#else + int dummy = 0; + utilGzWrite(gzFile, &dummy, sizeof(dummy)); +#endif + } + + return true; +} + +bool gbWriteMemSaveState(char *memory, int available) +{ + gzFile gzFile = utilMemGzOpen(memory, available, "w"); + + if(gzFile == NULL) + { + return false; + } + + bool res = gbWriteSaveStateToStream(gzFile); + + long pos = utilGzMemTell(gzFile)+8; + + if(pos >= (available)) + res = false; + + utilGzClose(gzFile); + + return res; +} + +bool gbWriteSaveState(const char *name) +{ + gzFile gzFile = utilGzOpen(name,"wb"); + + if(gzFile == NULL) + return false; + + bool res = gbWriteSaveStateToStream(gzFile); + + utilGzClose(gzFile); + return res; +} + +static int tempStateID = 0; +static int tempFailCount = 0; +static bool backupSafe = true; + +bool gbReadSaveStateFromStream(gzFile gzFile) +{ + int type; + char tempBackupName [128]; + if(backupSafe) + { + sprintf(tempBackupName, "gbatempsave%d.sav", tempStateID++); + gbWriteSaveState(tempBackupName); + } + + int version = utilReadInt(gzFile); + + if(version > GBSAVE_GAME_VERSION || version < 0) + { + systemMessage(MSG_UNSUPPORTED_VB_SGM, + N_("Unsupported VisualBoy save game version %d"), version); + goto failedLoadGB; + } + + u8 romname[20]; + + utilGzRead(gzFile, romname, 15); + + if(memcmp(&gbRom[0x134], romname, 15) != 0) + { + systemMessage(MSG_CANNOT_LOAD_SGM_FOR, + N_("Cannot load save game for %s. Playing %s"), + romname, &gbRom[0x134]); + goto failedLoadGB; + } + + utilReadData(gzFile, gbSaveGameStruct); + + if(version >= GBSAVE_GAME_VERSION_7) + { + utilGzRead(gzFile, &IFF, 2); + } + + if(gbSgbMode) + { + gbSgbReadGame(gzFile, version); + } else + { + gbSgbMask = 0; // loading a game at the wrong time causes no display + } + + utilGzRead(gzFile, &gbDataMBC1, sizeof(gbDataMBC1)); + utilGzRead(gzFile, &gbDataMBC2, sizeof(gbDataMBC2)); + if(version < GBSAVE_GAME_VERSION_4) + // prior to version 4, there was no adjustment for the time the game + // was last played, so we have less to read. This needs update if the + // structure changes again. + utilGzRead(gzFile, &gbDataMBC3, sizeof(gbDataMBC3)-sizeof(time_t)); + else + utilGzRead(gzFile, &gbDataMBC3, sizeof(gbDataMBC3)); + utilGzRead(gzFile, &gbDataMBC5, sizeof(gbDataMBC5)); + utilGzRead(gzFile, &gbDataHuC1, sizeof(gbDataHuC1)); + utilGzRead(gzFile, &gbDataHuC3, sizeof(gbDataHuC3)); + + if(version >= GBSAVE_GAME_VERSION_12) + { + utilGzRead(gzFile, pix, 4*257*226); + } + else + { + memset(pix, 0, 257*226*sizeof(u32)); +// if(version < GBSAVE_GAME_VERSION_5) +// utilGzRead(gzFile, pix, 256*224*sizeof(u16)); + } + + if(version < GBSAVE_GAME_VERSION_6) + { + utilGzRead(gzFile, gbPalette, 64 * sizeof(u16)); + } + else + utilGzRead(gzFile, gbPalette, 128 * sizeof(u16)); + + // todo: remove + utilGzRead(gzFile, gbPalette, 128 * sizeof(u16)); + + if(version < GBSAVE_GAME_VERSION_10) + { + if(!gbCgbMode && !gbSgbMode) + { + for(int i = 0; i < 8; i++) + gbPalette[i] = systemGbPalette[gbPaletteOption*8+i]; + } + } + + utilGzRead(gzFile, &gbMemory[0x8000], 0x8000); + + if(gbRamSize && gbRam) + { + utilGzRead(gzFile, gbRam, gbRamSize); + } + + gbMemoryMap[0x00] = &gbRom[0x0000]; + gbMemoryMap[0x01] = &gbRom[0x1000]; + gbMemoryMap[0x02] = &gbRom[0x2000]; + gbMemoryMap[0x03] = &gbRom[0x3000]; + gbMemoryMap[0x04] = &gbRom[0x4000]; + gbMemoryMap[0x05] = &gbRom[0x5000]; + gbMemoryMap[0x06] = &gbRom[0x6000]; + gbMemoryMap[0x07] = &gbRom[0x7000]; + gbMemoryMap[0x08] = &gbMemory[0x8000]; + gbMemoryMap[0x09] = &gbMemory[0x9000]; + gbMemoryMap[0x0a] = &gbMemory[0xa000]; + gbMemoryMap[0x0b] = &gbMemory[0xb000]; + gbMemoryMap[0x0c] = &gbMemory[0xc000]; + gbMemoryMap[0x0d] = &gbMemory[0xd000]; + gbMemoryMap[0x0e] = &gbMemory[0xe000]; + gbMemoryMap[0x0f] = &gbMemory[0xf000]; + + type = gbRom[0x147]; + + switch(type) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + // MBC 1 + memoryUpdateMapMBC1(); + break; + case 0x05: + case 0x06: + // MBC2 + memoryUpdateMapMBC2(); + break; + case 0x0f: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + // MBC 3 + memoryUpdateMapMBC3(); + break; + case 0x19: + case 0x1a: + case 0x1b: + // MBC5 + memoryUpdateMapMBC5(); + break; + case 0x1c: + case 0x1d: + case 0x1e: + // MBC 5 Rumble + memoryUpdateMapMBC5(); + break; + case 0x22: + // MBC 7 + memoryUpdateMapMBC7(); + break; + case 0xfe: + // HuC3 + memoryUpdateMapHuC3(); + break; + case 0xff: + // HuC1 + memoryUpdateMapHuC1(); + break; + } + + if(gbCgbMode) + { + utilGzRead(gzFile, gbVram, 0x4000); + utilGzRead(gzFile, gbWram, 0x8000); + + int value = register_SVBK; + if(value == 0) + value = 1; + + gbMemoryMap[0x08] = &gbVram[register_VBK * 0x2000]; + gbMemoryMap[0x09] = &gbVram[register_VBK * 0x2000 + 0x1000]; + gbMemoryMap[0x0d] = &gbWram[value * 0x1000]; + } + + gbSoundReadGame(version, gzFile); + + if(gbBorderOn) + { + gbSgbRenderBorder(); + } +#if (defined(WIN32) && !defined(SDL)) + theApp.painting = true; + systemDrawScreen(); + theApp.painting = false; +#endif + + if(version > GBSAVE_GAME_VERSION_1) + gbCheatsReadGame(gzFile, version); + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + if(version >= GBSAVE_GAME_VERSION_11) // new to re-recording version: + { +#if (defined(WIN32) && !defined(SDL)) + utilGzRead(gzFile, &theApp.sensorX, sizeof(theApp.sensorX)); + utilGzRead(gzFile, &theApp.sensorY, sizeof(theApp.sensorY)); +#else + extern int sensorX, sensorY; // from SDL.cpp + utilGzRead(gzFile, &sensorX, sizeof(sensorX)); + utilGzRead(gzFile, &sensorY, sizeof(sensorY)); +#endif + utilGzRead(gzFile, gbJoymask, 4*sizeof(*gbJoymask)); // this has to be saved or old input will incorrectly get carried back on loading a snapshot! + + bool8 movieSnapshot; + utilGzRead(gzFile, &movieSnapshot, sizeof(movieSnapshot)); + if(VBAMovieActive() && !movieSnapshot) + { + systemMessage(0, N_("Can't load a non-movie snapshot while a movie is active.")); + goto failedLoadGB; + } +#if (defined(WIN32) && !defined(SDL)) + extern bool8 loadedMovieSnapshot; + loadedMovieSnapshot = movieSnapshot; +#endif + if(movieSnapshot) // even if a movie isn't active we still want to parse through this in case other stuff is added later on in the save format + { + uint32 movieInputDataSize = 0; + utilGzRead(gzFile, &movieInputDataSize, sizeof(movieInputDataSize)); + uint8* local_movie_data = new uint8 [movieInputDataSize]; + int readBytes = utilGzRead(gzFile, local_movie_data, movieInputDataSize); + if(readBytes != movieInputDataSize) + { + systemMessage(0, N_("Corrupt movie snapshot.")); + if(local_movie_data) delete [] local_movie_data; + goto failedLoadGB; + } + int code = VBAMovieUnfreeze(local_movie_data, movieInputDataSize); + if(local_movie_data) delete [] local_movie_data; + if(code != SUCCESS && VBAMovieActive()) + { + char errStr [1024]; + strcpy(errStr, "Failed to load movie snapshot"); + switch(code) + { + case NOT_FROM_THIS_MOVIE: strcat(errStr, ";\nSnapshot not from this movie"); break; + case NOT_FROM_A_MOVIE: strcat(errStr, ";\nNot a movie snapshot"); break; // shouldn't get here... + case INVALID_FRAME: strcat(errStr, ";\nInvalid frame number"); break; + case WRONG_FORMAT: strcat(errStr, ";\nWrong format"); break; + } + strcat(errStr, "."); + systemMessage(0, N_(errStr)); + goto failedLoadGB; + } + } +#if (defined(WIN32) && !defined(SDL)) + utilGzRead(gzFile, &theApp.globalFrameCount, sizeof(theApp.globalFrameCount)); +#else + int dummy; + utilGzRead(gzFile, &dummy, sizeof(dummy)); +#endif + } + + if(backupSafe) + { + remove(tempBackupName); + tempFailCount = 0; + } + VBAUpdateFrameCountDisplay(); + return true; + +failedLoadGB: + if(backupSafe) + { + tempFailCount++; + if(tempFailCount < 3) // fail no more than 2 times in a row + gbReadSaveState(tempBackupName); + remove(tempBackupName); + } + return false; +} + +bool gbReadMemSaveState(char *memory, int available) +{ + gzFile gzFile = utilMemGzOpen(memory, available, "r"); + + backupSafe = false; + bool res = gbReadSaveStateFromStream(gzFile); + backupSafe = true; + + utilGzClose(gzFile); + + return res; +} + +bool gbReadSaveState(const char *name) +{ + gzFile gzFile = utilGzOpen(name,"rb"); + + if(gzFile == NULL) + { + return false; + } + + bool res = gbReadSaveStateFromStream(gzFile); + + utilGzClose(gzFile); + + return res; +} + +bool gbWritePNGFile(const char *fileName) +{ + if(gbBorderOn) + return utilWritePNGFile(fileName, 256, 224, pix); + return utilWritePNGFile(fileName, 160, 144, pix); +} + +bool gbWriteBMPFile(const char *fileName) +{ + if(gbBorderOn) + return utilWriteBMPFile(fileName, 256, 224, pix); + return utilWriteBMPFile(fileName, 160, 144, pix); +} + +static bool frameBoundary = false; + +void gbCleanUp() +{ + frameBoundary = false; + +#if (defined(WIN32) && !defined(SDL)) + theApp.globalFrameCount = 0; +#endif + + if(gbRam != NULL) + { + free(gbRam); + gbRam = NULL; + } + + if(gbRom != NULL) + { + free(gbRom); + gbRom = NULL; + } + + if(gbMemory != NULL) + { + free(gbMemory); + gbMemory = NULL; + } + + if(gbLineBuffer != NULL) + { + free(gbLineBuffer); + gbLineBuffer = NULL; + } + + if(origPix != NULL) + { + free(origPix); + origPix = NULL; + } + pix = NULL; + + gbSgbShutdown(); + + if(gbVram != NULL) + { + free(gbVram); + gbVram = NULL; + } + + if(gbWram != NULL) + { + free(gbWram); + gbWram = NULL; + } + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; +} + +bool gbLoadRom(const char *szFile) +{ + int size = 0; + + if(gbRom != NULL) + { + gbCleanUp(); + } + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + gbRom = utilLoad(szFile, + utilIsGBImage, + NULL, + size); + if(!gbRom) + return false; + + gbRomSize = size; + + return gbUpdateSizes(); +} + +bool gbUpdateSizes() +{ + if(gbRom[0x148] > 8) + { + systemMessage(MSG_UNSUPPORTED_ROM_SIZE, + N_("Unsupported rom size %02x"), gbRom[0x148]); + return false; + } + + if(gbRomSize < gbRomSizes[gbRom[0x148]]) + { + gbRom = (u8 *)realloc(gbRom, gbRomSizes[gbRom[0x148]]); + } + gbRomSize = gbRomSizes[gbRom[0x148]]; + gbRomSizeMask = gbRomSizesMasks[gbRom[0x148]]; + + if(gbRom[0x149] > 5) + { + systemMessage(MSG_UNSUPPORTED_RAM_SIZE, + N_("Unsupported ram size %02x"), gbRom[0x149]); + return false; + } + + gbRamSize = gbRamSizes[gbRom[0x149]]; + gbRamSizeMask = gbRamSizesMasks[gbRom[0x149]]; + + if(gbRamSize) + { + gbRam = (u8 *)malloc(gbRamSize); + memset(gbRam, 0xFF, gbRamSize); + } + + int type = gbRom[0x147]; + + mapperReadRAM = NULL; + + switch(type) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + // MBC 1 + mapper = mapperMBC1ROM; + mapperRAM = mapperMBC1RAM; + break; + case 0x05: + case 0x06: + // MBC2 + mapper = mapperMBC2ROM; + mapperRAM = mapperMBC2RAM; + gbRamSize = 0x200; + gbRamSizeMask = 0x1ff; + break; + case 0x0f: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + // MBC 3 + mapper = mapperMBC3ROM; + mapperRAM = mapperMBC3RAM; + mapperReadRAM = mapperMBC3ReadRAM; + break; + case 0x19: + case 0x1a: + case 0x1b: + // MBC5 + mapper = mapperMBC5ROM; + mapperRAM = mapperMBC5RAM; + break; + case 0x1c: + case 0x1d: + case 0x1e: + // MBC 5 Rumble + mapper = mapperMBC5ROM; + mapperRAM = mapperMBC5RAM; + break; + case 0x22: + // MBC 7 + mapper = mapperMBC7ROM; + mapperRAM = mapperMBC7RAM; + mapperReadRAM = mapperMBC7ReadRAM; + break; + case 0xfe: + // HuC3 + mapper = mapperHuC3ROM; + mapperRAM = mapperHuC3RAM; + mapperReadRAM = mapperHuC3ReadRAM; + break; + case 0xff: + // HuC1 + mapper = mapperHuC1ROM; + mapperRAM = mapperHuC1RAM; + break; + default: + systemMessage(MSG_UNKNOWN_CARTRIDGE_TYPE, + N_("Unknown cartridge type %02x"), type); + return false; + } + + switch(type) + { + case 0x03: + case 0x06: + case 0x0f: + case 0x10: + case 0x13: + case 0x1b: + case 0x1d: + case 0x1e: + case 0x22: + case 0xff: + gbBattery = 1; + break; + } + + if(gbRom[0x146] == 0x03) + { + if(gbEmulatorType == 0 || + gbEmulatorType == 2 || + gbEmulatorType == 5 || + (!(gbRom[0x143] & 0x80) && (gbEmulatorType == 1 || gbEmulatorType == 4))) + gbSgbMode = 1; + else + gbSgbMode = 0; + } else + gbSgbMode = 0; + + if(gbRom[0x143] & 0x80) + { + if(gbEmulatorType == 0 || + gbEmulatorType == 1 || + gbEmulatorType == 4 || + gbEmulatorType == 5 || + (gbRom[0x146] != 0x03 && (gbEmulatorType == 2))) + { + gbCgbMode = 1; + gbVram = (u8 *)malloc(0x4000); + gbWram = (u8 *)malloc(0x8000); + memset(gbVram,0,0x4000); + memset(gbWram,0,0x8000); + memset(gbPalette,0, 2*128); + } else + { + gbCgbMode = 0; + } + } else + gbCgbMode = 0; + + gbInit(); + gbReset(); + + switch(type) + { + case 0x1c: + case 0x1d: + case 0x1e: + gbDataMBC5.isRumbleCartridge = 1; + } + + return true; +} + + +#if (defined(WIN32) && !defined(SDL)) +# define USE_OLD_GB_TIMING (theApp.useOldGBTiming) +#else +# define USE_OLD_GB_TIMING (false) /// SDL FIXME +#endif + + +void gbEmulate(int ticksToStop) +{ + gbRegister tempRegister; + u8 tempValue; + s8 offset; + + int clockTicks = 0; + gbDmaTicks = 0; + + register int opcode = 0; + + while(1) + { +#ifndef FINAL_VERSION + if(systemDebug) + { + if(!(IFF & 0x80)) + { + if(systemDebug > 1) + { + sprintf(gbBuffer,"PC=%04x AF=%04x BC=%04x DE=%04x HL=%04x SP=%04x I=%04x\n", + PC.W, AF.W, BC.W, DE.W,HL.W,SP.W,IFF); + } else + { + sprintf(gbBuffer,"PC=%04x I=%02x\n", PC.W, IFF); + } + log(gbBuffer); + } + } +#endif + if(IFF & 0x80) + { + if(register_LCDC & 0x80) + { + clockTicks = gbLcdTicks; + } else + clockTicks = 100; + + if(gbLcdMode == 1 && (gbLcdLYIncrementTicks < clockTicks)) + clockTicks = gbLcdLYIncrementTicks; + + if(gbSerialOn && (gbSerialTicks < clockTicks)) + clockTicks = gbSerialTicks; + + if(gbTimerOn && (gbTimerTicks < clockTicks)) + clockTicks = gbTimerTicks; + + if(soundTicks && (soundTicks < clockTicks)) + clockTicks = soundTicks; + } else + { + opcode = gbReadOpcode(PC.W++); + + if(IFF & 0x100) + { + IFF &= 0xff; + PC.W--; + } + + clockTicks = gbCycles[opcode]; + + switch(opcode) + { + case 0xCB: + // extended opcode + opcode = gbReadOpcode(PC.W++); + clockTicks = gbCyclesCB[opcode]; + switch(opcode) + { +#include "gbCodesCB.h" + } + break; +#include "gbCodes.h" + } + } + + if(!emulating) + return; + + if(gbDmaTicks) + { + clockTicks += gbDmaTicks; + gbDmaTicks = 0; + } + + if(gbSgbMode) + { + if(gbSgbPacketTimeout) + { + gbSgbPacketTimeout -= clockTicks; + + if(gbSgbPacketTimeout <= 0) + gbSgbResetPacketState(); + } + } + + ticksToStop -= clockTicks; + + // DIV register emulation + gbDivTicks -= clockTicks; + while(gbDivTicks <= 0) + { + register_DIV++; + gbDivTicks += GBDIV_CLOCK_TICKS; + } + + if(register_LCDC & 0x80) + { + // LCD stuff + gbLcdTicks -= clockTicks; + if(gbLcdMode == 1) + { + // during V-BLANK,we need to increment LY at the same rate! + gbLcdLYIncrementTicks -= clockTicks; + while(gbLcdLYIncrementTicks <= 0) + { + gbLcdLYIncrementTicks += GBLY_INCREMENT_CLOCK_TICKS; + + if(register_LY < 153) + { + register_LY++; + + gbCompareLYToLYC(); + + if(register_LY >= 153) + gbLcdLYIncrementTicks = 6; + } else + { + register_LY = 0x00; + // reset the window line + gbWindowLine = -1; + gbLcdLYIncrementTicks = GBLY_INCREMENT_CLOCK_TICKS * 2; + gbCompareLYToLYC(); + } + } + } + + // our counter is off, see what we need to do + while(gbLcdTicks <= 0) + { + int framesToSkip = systemFrameSkip; + + bool fastForward = speedup; + +#if (defined(WIN32) && !defined(SDL)) + int throttle = theApp.throttle; + if(theApp.frameSearching && throttle < 100) + throttle = 100; + fastForward |= theApp.frameSearchSkipping; +#else + extern int throttle; +#endif + + if(fastForward) + framesToSkip = 9; // try 6 FPS during speedup + else if(throttle != 100) + framesToSkip = (framesToSkip * throttle) / 100; + + switch(gbLcdMode) + { + case 0: + // H-Blank + register_LY++; + + gbCompareLYToLYC(); + + // check if we reached the V-Blank period + if(register_LY == 144) + { + // Yes, V-Blank + // set the LY increment counter + gbLcdLYIncrementTicks = gbLcdTicks + GBLY_INCREMENT_CLOCK_TICKS; + gbLcdTicks += GBLCD_MODE_1_CLOCK_TICKS; + gbLcdMode = 1; + if(register_LCDC & 0x80) + { + gbInterrupt |= 1; // V-Blank interrupt + gbInterruptWait = 6; + if(register_STAT & 0x10) + gbInterrupt |= 2; + } + + gbFrameCount++; + + systemFrame(60); + + if(gbFrameCount >= 60) + { + u32 currentTime = systemGetClock(); + if(currentTime != gbLastTime) + systemShowSpeed(100000/(currentTime - gbLastTime)); + else + systemShowSpeed(0); + gbLastTime = currentTime; + gbFrameCount = 0; + } + + if(systemReadJoypads()) + { + bool sensor = (gbRom[0x147] == 0x22); + + // read joystick + if(gbSgbMode && gbSgbMultiplayer) + { + if(gbSgbFourPlayers) + { + gbJoymask[0] = systemReadJoypad(0,sensor); + gbJoymask[1] = systemReadJoypad(1,false); + gbJoymask[2] = systemReadJoypad(2,false); + gbJoymask[3] = systemReadJoypad(3,false); + } else + { + gbJoymask[0] = systemReadJoypad(0,sensor); + gbJoymask[1] = systemReadJoypad(1,false); + } + } else + { + gbJoymask[0] = systemReadJoypad(-1,sensor); + } + } + + frameBoundary = true; + + int newmask = gbJoymask[0] & 255; + + if(newmask) + { + gbInterrupt |= 16; + } + + newmask = (gbJoymask[0] >> 10); + + speedup = (newmask & 1) ? true : false; + gbCapture = (newmask & 2) ? true : false; + + if(gbCapture && !gbCapturePrevious) + { + gbCaptureNumber++; + systemScreenCapture(gbCaptureNumber); + } + gbCapturePrevious = gbCapture; + + pauseAfterFrameAdvance = systemPauseOnFrame(); + + if(gbFrameSkipCount >= framesToSkip || pauseAfterFrameAdvance) + { + systemDrawScreen(); + gbFrameSkipCount = 0; + } else + gbFrameSkipCount++; + + if(pauseAfterFrameAdvance) + { +#if (defined(WIN32) && !defined(SDL)) + if(theApp.muteFrameAdvance) + theApp.frameAdvanceMuteNow = true; + theApp.paused = true; + if(theApp.sound) + theApp.sound->pause(); // prevents the sound from looping annoyingly after a frame advance in GBA games +#else + extern bool paused; // from SDL.cpp + paused = true; + systemSoundPause(); +#endif + } + else + { +#if (defined(WIN32) && !defined(SDL)) + theApp.frameAdvanceMuteNow = false; +#endif + } + + + } else + { + // go the the OAM being accessed mode + gbLcdTicks += GBLCD_MODE_2_CLOCK_TICKS; + gbLcdMode = 2; + + // only one LCD interrupt per line. may need to generalize... + if(!(register_STAT & 0x40) || + (register_LY != register_LYC)) + { + if((register_STAT & 0x28) == 0x20) + gbInterrupt |= 2; + } + } + + break; + case 1: + // V-Blank + // next mode is OAM being accessed mode + gbLcdTicks += GBLCD_MODE_2_CLOCK_TICKS; + gbLcdMode = 2; + if(!(register_STAT & 0x40) || + (register_LY != register_LYC)) + { + if((register_STAT & 0x28) == 0x20) + gbInterrupt |= 2; + } + break; + case 2: + // OAM being accessed mode + + // next mode is OAM and VRAM in use + gbLcdTicks += GBLCD_MODE_3_CLOCK_TICKS; + gbLcdMode = 3; + break; + case 3: + // OAM and VRAM in use + // next mode is H-Blank + if(register_LY < 144) + { + if(!gbSgbMask) + { + if(gbFrameSkipCount >= framesToSkip || pauseAfterFrameAdvance) + { + gbRenderLine(); + gbDrawSprites(); + + switch(systemColorDepth) + { + case 16: + + { + + u16 * dest = (u16 *)pix + + (gbBorderLineSkip+2) * (register_LY + gbBorderRowSkip+1) + + gbBorderColumnSkip; + for(int x = 0; x < 160; ) + { + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + *dest++ = systemColorMap16[gbLineMix[x++]]; + } + if(gbBorderOn) + dest += gbBorderColumnSkip; + *dest++ = 0; // for filters that read one pixel more + } + break; + case 24: + + { + u8 *dest = (u8 *)pix + + 3*(gbBorderLineSkip * (register_LY + gbBorderRowSkip) + + gbBorderColumnSkip); + for(int x = 0; x < 160;) + { + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + *((u32 *)dest) = systemColorMap32[gbLineMix[x++]]; + dest+= 3; + } + } + break; + case 32: + + { + u32 * dest = (u32 *)pix + + (gbBorderLineSkip+1) * (register_LY + gbBorderRowSkip+1) + + gbBorderColumnSkip; + for(int x = 0; x < 160;) + { + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + *dest++ = systemColorMap32[gbLineMix[x++]]; + } + } + break; + } + } + } + } + gbLcdTicks += GBLCD_MODE_0_CLOCK_TICKS; + gbLcdMode = 0; + // only one LCD interrupt per line. may need to generalize... + if(!(register_STAT & 0x40) || + (register_LY != register_LYC)) + { + if(register_STAT & 0x08) + gbInterrupt |= 2; + } + if(gbHdmaOn) + { + gbDoHdma(); + } + break; + } + // mark the correct lcd mode on STAT register + register_STAT = (register_STAT & 0xfc) | gbLcdMode; + } + } + + // serial emulation + if(gbSerialOn) + { +#ifdef LINK_EMULATION + if(linkConnected) + { + gbSerialTicks -= clockTicks; + + while(gbSerialTicks <= 0) + { + // increment number of shifted bits + gbSerialBits++; + linkProc(); + if(gbSerialOn && (gbMemory[0xff02] & 1)) + { + if(gbSerialBits == 8) + { + gbSerialBits = 0; + gbMemory[0xff01] = 0xff; + gbMemory[0xff02] &= 0x7f; + gbSerialOn = 0; + gbInterrupt |= 8; + gbSerialTicks = 0; + } + } + gbSerialTicks += GBSERIAL_CLOCK_TICKS; + } + } else + { +#endif + if(gbMemory[0xff02] & 1) + { + gbSerialTicks -= clockTicks; + + // overflow + while(gbSerialTicks <= 0) + { + // shift serial byte to right and put a 1 bit in its place + // gbMemory[0xff01] = 0x80 | (gbMemory[0xff01]>>1); + // increment number of shifted bits + gbSerialBits++; + if(gbSerialBits == 8) + { + // end of transmission + if(gbSerialFunction) // external device + gbMemory[0xff01] = gbSerialFunction(gbMemory[0xff01]); + else + gbMemory[0xff01] = 0xff; + gbSerialTicks = 0; + gbMemory[0xff02] &= 0x7f; + gbSerialOn = 0; + gbInterrupt |= 8; + gbSerialBits = 0; + } else + gbSerialTicks += GBSERIAL_CLOCK_TICKS; + } + } +#ifdef LINK_EMULATION + } +#endif + } + + // timer emulation + if(gbTimerOn) + { + gbTimerTicks -= clockTicks; + + while(gbTimerTicks <= 0) + { + register_TIMA++; + + if(register_TIMA == 0) + { + // timer overflow! + + // reload timer modulo + register_TIMA = register_TMA; + + // flag interrupt + gbInterrupt |= 4; + } + + gbTimerTicks += gbTimerClockTicks; + } + } + + /* + if(soundOffFlag) + { + if(synchronize && !speedup) + { + synchronizeTicks -= clockTicks; + + while(synchronizeTicks < 0) + { + synchronizeTicks += SYNCHRONIZE_CLOCK_TICKS; + + DWORD now = timeGetTime(); + gbElapsedTime += (now - timeNow); + + if(gbElapsedTime < 50) + { + DWORD diff = 50 - gbElapsedTime; + Sleep(diff); + timeNow = timeGetTime(); + elapsedTime = timeNow - now - diff; + if((int)elapsedTime < 0) + elapsedTime = 0; + } else + { + timeNow = timeGetTime(); + elapsedTime = 0; + } + } + } + } + */ + + soundTicks -= clockTicks; + while(soundTicks < 0) + { + soundTicks += SOUND_CLOCK_TICKS; + + gbSoundTick(); + } + + + register_IF = gbInterrupt; + + if(IFF & 0x20) + { + IFF &= 0xdf; + IFF |= 0x01; + gbInterruptWait = 0; + } else if(gbInterrupt) + { + if(gbInterruptWait == 0) + { + // gbInterruptWait = 0; + + if(IFF & 0x01) + { + if((gbInterrupt & 1) && (register_IE & 1)) + { + gbVblank_interrupt(); + continue; + } + + if((gbInterrupt & 2) && (register_IE & 2)) + { + gbLcd_interrupt(); + continue; + } + + if((gbInterrupt & 4) && (register_IE & 4)) + { + gbTimer_interrupt(); + continue; + } + + if((gbInterrupt & 8) && (register_IE & 8)) + { + gbSerial_interrupt(); + continue; + } + + if((gbInterrupt & 16) && (register_IE & 16)) + { + gbJoypad_interrupt(); + continue; + } + } + } else + { + gbInterruptWait -= clockTicks; + if(gbInterruptWait < 0) + gbInterruptWait = 0; + } + } + + if(USE_OLD_GB_TIMING) + { + // old timing code + + if(ticksToStop > 0) + continue; + } + else + { + if(!frameBoundary && (register_LCDC & 0x80) != 0) + continue; + } + + + + if(!(register_LCDC & 0x80)) + { + // Apparently it IS necessary to do something on this condition or games like + // Megaman will freeze upon low-level restart interrupt sequence (Start+Select+A+B). + if(USE_OLD_GB_TIMING) + { + if(systemReadJoypads()) + { + if(gbSgbMode && gbSgbMultiplayer) + { + if(gbSgbFourPlayers) + { + gbJoymask[0] = systemReadJoypad(0,false); + gbJoymask[1] = systemReadJoypad(1,false); + gbJoymask[2] = systemReadJoypad(2,false); + gbJoymask[3] = systemReadJoypad(3,false); + } + else + { + gbJoymask[0] = systemReadJoypad(0,false); + gbJoymask[1] = systemReadJoypad(1,false); + } + } + else + { + gbJoymask[0] = systemReadJoypad(-1,false); + } + } + } + else + { + // For the benefit of (movies) having a constant rate of input, just reset this to 0 (same as user letting go of the button) immediately, + // otherwise an internal timer variables will change independently of how many frames of input pass by. + // (This fake-input is merely used to make the system wait at a certain frame until you let go of the buttons, + // if it is used at all, sometimes it is sampled at the same frame as other input and completely ignored.) + + gbJoymask[0] = gbJoymask[1] = gbJoymask[2] = gbJoymask[3] = 0; + } + + if(!USE_OLD_GB_TIMING) + frameBoundary = true; + } + + // makes sure frames are really divided across input sampling boundaries which occur at a constant rate + if(frameBoundary || USE_OLD_GB_TIMING) + { + frameBoundary = false; + return; + } + } +} + +struct EmulatedSystem GBSystem = +{ + // emuMain + gbEmulate, + // emuReset + gbReset, + // emuCleanUp + gbCleanUp, + // emuReadBattery + gbReadBatteryFile, + // emuWriteBattery + gbWriteBatteryFile, + // emuReadBatteryFromStream + gbReadBatteryFromStream, + // emuWriteBatteryToStream + gbWriteBatteryToStream, + // emuReadState + gbReadSaveState, + // emuWriteState + gbWriteSaveState, + // emuReadStateFromStream + gbReadSaveStateFromStream, + // emuWriteStateToStream + gbWriteSaveStateToStream, + // emuReadMemState + gbReadMemSaveState, + // emuWriteMemState + gbWriteMemSaveState, + // emuWritePNG + gbWritePNGFile, + // emuWriteBMP + gbWriteBMPFile, + // emuUpdateCPSR + NULL, + // emuHasDebugger + false, + // emuCount +#ifdef FINAL_VERSION + 70000/4, +#else + 1000, +#endif +}; diff --git a/src/gb/GB.h b/src/gb/GB.h new file mode 100644 index 0000000..a95cda2 --- /dev/null +++ b/src/gb/GB.h @@ -0,0 +1,64 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_GB_GB_H +#define VBA_GB_GB_H + +#define C_FLAG 0x10 +#define H_FLAG 0x20 +#define N_FLAG 0x40 +#define Z_FLAG 0x80 + +typedef union { + struct { +#ifdef WORDS_BIGENDIAN + u8 B1, B0; +#else + u8 B0,B1; +#endif + } B; + u16 W; +} gbRegister; + +extern bool gbLoadRom(const char *); +extern void gbEmulate(int); +extern bool gbIsGameboyRom(const char *); +extern void gbSoundReset(); +extern void gbSoundSetQuality(int); +extern void gbReset(); +extern void gbCleanUp(); +extern bool gbWriteBatteryFile(const char *); +extern bool gbWriteBatteryFile(const char *, bool); +extern bool gbWriteBatteryToStream(gzFile); +extern bool gbReadBatteryFile(const char *); +extern bool gbReadBatteryFromStream(gzFile); +extern bool gbWriteSaveState(const char *); +extern bool gbWriteMemSaveState(char *, int); +extern bool gbReadSaveState(const char *); +extern bool gbReadMemSaveState(char *, int); +extern bool gbReadSaveStateFromStream(gzFile); +extern bool gbWriteSaveStateToStream(gzFile); +extern void gbSgbRenderBorder(); +extern bool gbWritePNGFile(const char *); +extern bool gbWriteBMPFile(const char *); +extern bool gbReadGSASnapshot(const char *); + +extern struct EmulatedSystem GBSystem; + +#endif diff --git a/src/gb/Makefile.am b/src/gb/Makefile.am new file mode 100644 index 0000000..a318425 --- /dev/null +++ b/src/gb/Makefile.am @@ -0,0 +1,21 @@ +noinst_LIBRARIES = libgb.a + +libgb_a_SOURCES = \ + gbCheats.cpp \ + gbCheats.h \ + gbCodesCB.h \ + gbCodes.h \ + GB.cpp \ + GB.h \ + gbDis.cpp \ + gbGfx.cpp \ + gbGlobals.cpp \ + gbGlobals.h \ + gbMemory.cpp \ + gbMemory.h \ + gbPrinter.cpp \ + gbPrinter.h \ + gbSGB.cpp \ + gbSGB.h \ + gbSound.cpp \ + gbSound.h diff --git a/src/gb/Makefile.in b/src/gb/Makefile.in new file mode 100644 index 0000000..e5dc92b --- /dev/null +++ b/src/gb/Makefile.in @@ -0,0 +1,442 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +noinst_LIBRARIES = libgb.a + +libgb_a_SOURCES = \ + gbCheats.cpp \ + gbCheats.h \ + gbCodesCB.h \ + gbCodes.h \ + GB.cpp \ + GB.h \ + gbDis.cpp \ + gbGfx.cpp \ + gbGlobals.cpp \ + gbGlobals.h \ + gbMemory.cpp \ + gbMemory.h \ + gbPrinter.cpp \ + gbPrinter.h \ + gbSGB.cpp \ + gbSGB.h \ + gbSound.cpp \ + gbSound.h + +subdir = src/gb +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + +libgb_a_AR = $(AR) cru +libgb_a_LIBADD = +am_libgb_a_OBJECTS = gbCheats.$(OBJEXT) GB.$(OBJEXT) gbDis.$(OBJEXT) \ + gbGfx.$(OBJEXT) gbGlobals.$(OBJEXT) gbMemory.$(OBJEXT) \ + gbPrinter.$(OBJEXT) gbSGB.$(OBJEXT) gbSound.$(OBJEXT) +libgb_a_OBJECTS = $(am_libgb_a_OBJECTS) + +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/GB.Po ./$(DEPDIR)/gbCheats.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gbDis.Po ./$(DEPDIR)/gbGfx.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gbGlobals.Po ./$(DEPDIR)/gbMemory.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gbPrinter.Po ./$(DEPDIR)/gbSGB.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gbSound.Po +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = $(libgb_a_SOURCES) +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am +SOURCES = $(libgb_a_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/gb/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + +AR = ar + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libgb.a: $(libgb_a_OBJECTS) $(libgb_a_DEPENDENCIES) + -rm -f libgb.a + $(libgb_a_AR) libgb.a $(libgb_a_OBJECTS) $(libgb_a_LIBADD) + $(RANLIB) libgb.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GB.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbCheats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbDis.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbGfx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbGlobals.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbMemory.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbPrinter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbSGB.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbSound.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/gb/gbCheats.cpp b/src/gb/gbCheats.cpp new file mode 100644 index 0000000..941bb16 --- /dev/null +++ b/src/gb/gbCheats.cpp @@ -0,0 +1,462 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include + +#include "../System.h" +#include "../NLS.h" +#include "../Util.h" + +#include "gbCheats.h" +#include "gbGlobals.h" + +gbCheat gbCheatList[100]; +int gbCheatNumber = 0; +bool gbCheatMap[0x10000]; + +extern bool cheatsEnabled; + +#define GBCHEAT_IS_HEX(a) ( ((a)>='A' && (a) <='F') || ((a) >='0' && (a) <= '9')) +#define GBCHEAT_HEX_VALUE(a) ( (a) >= 'A' ? (a) - 'A' + 10 : (a) - '0') + +void gbCheatUpdateMap() +{ + memset(gbCheatMap, 0, 0x10000); + + for(int i = 0; i < gbCheatNumber; i++) { + if(gbCheatList[i].enabled) + gbCheatMap[gbCheatList[i].address] = true; + } +} + +void gbCheatsSaveGame(gzFile gzFile) +{ + utilWriteInt(gzFile, gbCheatNumber); + if(gbCheatNumber) + utilGzWrite(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber); +} + +void gbCheatsReadGame(gzFile gzFile, int version) +{ + if(version <= 8) { + int gbGgOn = utilReadInt(gzFile); + + if(gbGgOn) { + int n = utilReadInt(gzFile); + gbXxCheat tmpCheat; + for(int i = 0; i < n; i++) { + utilGzRead(gzFile,&tmpCheat, sizeof(gbXxCheat)); + gbAddGgCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc); + } + } + + int gbGsOn = utilReadInt(gzFile); + + if(gbGsOn) { + int n = utilReadInt(gzFile); + gbXxCheat tmpCheat; + for(int i = 0; i < n; i++) { + utilGzRead(gzFile,&tmpCheat, sizeof(gbXxCheat)); + gbAddGsCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc); + } + } + } else { + gbCheatNumber = utilReadInt(gzFile); + + if(gbCheatNumber) { + utilGzRead(gzFile, &gbCheatList[0], sizeof(gbCheat)*gbCheatNumber); + } + } + + gbCheatUpdateMap(); +} + +void gbCheatsSaveCheatList(const char *file) +{ + if(gbCheatNumber == 0) + return; + FILE *f = fopen(file, "wb"); + if(f == NULL) + return; + int version = 1; + fwrite(&version, 1, sizeof(version), f); + int type = 1; + fwrite(&type, 1, sizeof(type), f); + fwrite(&gbCheatNumber, 1, sizeof(gbCheatNumber), f); + fwrite(gbCheatList, 1, sizeof(gbCheatList), f); + fclose(f); +} + +bool gbCheatsLoadCheatList(const char *file) +{ + gbCheatNumber = 0; + + gbCheatUpdateMap(); + + int count = 0; + + FILE *f = fopen(file, "rb"); + + if(f == NULL) + return false; + + int version = 0; + + if(fread(&version, 1, sizeof(version), f) != sizeof(version)) { + fclose(f); + return false; + } + + if(version != 1) { + systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION, + N_("Unsupported cheat list version %d"), version); + fclose(f); + return false; + } + + int type = 0; + if(fread(&type, 1, sizeof(type), f) != sizeof(type)) { + fclose(f); + return false; + } + + if(type != 1) { + systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_TYPE, + N_("Unsupported cheat list type %d"), type); + fclose(f); + return false; + } + + if(fread(&count, 1, sizeof(count), f) != sizeof(count)) { + fclose(f); + return false; + } + + if(fread(gbCheatList, 1, sizeof(gbCheatList), f) != sizeof(gbCheatList)) { + fclose(f); + return false; + } + + gbCheatNumber = count; + gbCheatUpdateMap(); + + return true; +} + +bool gbVerifyGsCode(const char *code) +{ + int len = strlen(code); + + if(len == 0) + return true; + + if(len != 8) + return false; + + for(int i = 0; i < 8; i++) + if(!GBCHEAT_IS_HEX(code[i])) + return false; + + int address = GBCHEAT_HEX_VALUE(code[6]) << 12 | + GBCHEAT_HEX_VALUE(code[7]) << 8 | + GBCHEAT_HEX_VALUE(code[4]) << 4 | + GBCHEAT_HEX_VALUE(code[5]); + + if(address < 0xa000 || + address > 0xdfff) + return false; + + return true; +} + +void gbAddGsCheat(const char *code, const char *desc) +{ + if(gbCheatNumber > 99) { + systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS, + N_("Maximum number of cheats reached.")); + return; + } + + if(!gbVerifyGsCode(code)) { + systemMessage(MSG_INVALID_GAMESHARK_CODE, + N_("Invalid GameShark code: %s"), code); + return; + } + + int i = gbCheatNumber; + + strcpy(gbCheatList[i].cheatCode, code); + strcpy(gbCheatList[i].cheatDesc, desc); + + gbCheatList[i].code = GBCHEAT_HEX_VALUE(code[0]) << 4 | + GBCHEAT_HEX_VALUE(code[1]); + + gbCheatList[i].value = GBCHEAT_HEX_VALUE(code[2]) << 4 | + GBCHEAT_HEX_VALUE(code[3]); + + gbCheatList[i].address = GBCHEAT_HEX_VALUE(code[6]) << 12 | + GBCHEAT_HEX_VALUE(code[7]) << 8 | + GBCHEAT_HEX_VALUE(code[4]) << 4 | + GBCHEAT_HEX_VALUE(code[5]); + + gbCheatList[i].compare = 0; + + gbCheatList[i].enabled = true; + + gbCheatMap[gbCheatList[i].address] = true; + + gbCheatNumber++; +} + +bool gbVerifyGgCode(const char *code) +{ + int len = strlen(code); + + if(len != 11 && + len != 7 && + len != 6 && + len != 0) + return false; + + if(len == 0) + return true; + + if(!GBCHEAT_IS_HEX(code[0])) + return false; + if(!GBCHEAT_IS_HEX(code[1])) + return false; + if(!GBCHEAT_IS_HEX(code[2])) + return false; + if(code[3] != '-') + return false; + if(!GBCHEAT_IS_HEX(code[4])) + return false; + if(!GBCHEAT_IS_HEX(code[5])) + return false; + if(!GBCHEAT_IS_HEX(code[6])) + return false; + if(code[7] != 0) { + if(code[7] != '-') + return false; + if(code[8] != 0) { + if(!GBCHEAT_IS_HEX(code[8])) + return false; + if(!GBCHEAT_IS_HEX(code[9])) + return false; + if(!GBCHEAT_IS_HEX(code[10])) + return false; + } + } + + // int replace = (GBCHEAT_HEX_VALUE(code[0]) << 4) + + // GBCHEAT_HEX_VALUE(code[1]); + + int address = (GBCHEAT_HEX_VALUE(code[2]) << 8) + + (GBCHEAT_HEX_VALUE(code[4]) << 4) + + (GBCHEAT_HEX_VALUE(code[5])) + + ((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12); + + if(address >= 0x8000 && address <= 0x9fff) + return false; + + if(address >= 0xc000) + return false; + + if(code[7] == 0 || code[8] == '0') + return true; + + int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) + + (GBCHEAT_HEX_VALUE(code[10])); + compare = compare ^ 0xff; + compare = (compare >> 2) | ( (compare << 6) & 0xc0); + compare ^= 0x45; + + int cloak = (GBCHEAT_HEX_VALUE(code[8])) ^ (GBCHEAT_HEX_VALUE(code[9])); + + if(cloak >=1 && cloak <= 7) + return false; + + return true; +} + +void gbAddGgCheat(const char *code, const char *desc) +{ + if(gbCheatNumber > 99) { + systemMessage(MSG_MAXIMUM_NUMBER_OF_CHEATS, + N_("Maximum number of cheats reached.")); + return; + } + + if(!gbVerifyGgCode(code)) { + systemMessage(MSG_INVALID_GAMEGENIE_CODE, + N_("Invalid GameGenie code: %s"), code); + return; + } + + int i = gbCheatNumber; + + int len = strlen(code); + + strcpy(gbCheatList[i].cheatCode, code); + strcpy(gbCheatList[i].cheatDesc, desc); + + gbCheatList[i].code = 1; + gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) + + GBCHEAT_HEX_VALUE(code[1]); + + gbCheatList[i].address = (GBCHEAT_HEX_VALUE(code[2]) << 8) + + (GBCHEAT_HEX_VALUE(code[4]) << 4) + + (GBCHEAT_HEX_VALUE(code[5])) + + ((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12); + + gbCheatList[i].compare = 0; + + if(len != 7 && len != 8) { + + int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) + + (GBCHEAT_HEX_VALUE(code[10])); + compare = compare ^ 0xff; + compare = (compare >> 2) | ( (compare << 6) & 0xc0); + compare ^= 0x45; + + gbCheatList[i].compare = compare; + gbCheatList[i].code = 0; + } + + gbCheatList[i].enabled = true; + + gbCheatMap[gbCheatList[i].address] = true; + + gbCheatNumber++; +} + +void gbCheatRemove(int i) +{ + if(i < 0 || i >= gbCheatNumber) { + systemMessage(MSG_INVALID_CHEAT_TO_REMOVE, + N_("Invalid cheat to remove %d"), i); + return; + } + + if((i+1) < gbCheatNumber) { + memcpy(&gbCheatList[i], &gbCheatList[i+1], sizeof(gbCheat)* + (gbCheatNumber-i-1)); + } + + gbCheatNumber--; + + gbCheatUpdateMap(); +} + +void gbCheatRemoveAll() +{ + gbCheatNumber = 0; + gbCheatUpdateMap(); +} + +void gbCheatEnable(int i) +{ + if(i >=0 && i < gbCheatNumber) { + if(!gbCheatList[i].enabled) { + gbCheatList[i].enabled = true; + gbCheatUpdateMap(); + } + } +} + +void gbCheatDisable(int i) +{ + if(i >=0 && i < gbCheatNumber) { + if(gbCheatList[i].enabled) { + gbCheatList[i].enabled = false; + gbCheatUpdateMap(); + } + } +} + +bool gbCheatReadGSCodeFile(const char *fileName) +{ + FILE *file = fopen(fileName, "rb"); + + if(!file) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName); + return false; + } + + fseek(file, 0x18, SEEK_SET); + int count = 0; + fread(&count, 1, 2, file); + int dummy = 0; + gbCheatRemoveAll(); + char desc[13]; + char code[9]; + int i; + for(i = 0; i < count; i++) { + fread(&dummy, 1, 2, file); + fread(desc, 1, 12, file); + desc[12] = 0; + fread(code, 1, 8, file); + code[8] = 0; + gbAddGsCheat(code, desc); + } + + for(i = 0; i < gbCheatNumber; i++) + gbCheatDisable(i); + + fclose(file); + return true; +} + +u8 gbCheatRead(u16 address) +{ + if(!cheatsEnabled) + return gbMemoryMap[address>>12][address & 0xFFF]; + + for(int i = 0; i < gbCheatNumber; i++) { + if(gbCheatList[i].enabled && gbCheatList[i].address == address) { + switch(gbCheatList[i].code) { + case 0x100: // GameGenie support + if(gbMemoryMap[address>>12][address&0xFFF] == gbCheatList[i].compare) + return gbCheatList[i].value; + break; + case 0x00: + case 0x01: + case 0x80: + return gbCheatList[i].value; + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + if(address >= 0xd000 && address < 0xe000) { + if(((gbMemoryMap[0x0d] - gbWram)/0x1000) == + (gbCheatList[i].code - 0x90)) + return gbCheatList[i].value; + } else + return gbCheatList[i].value; + } + } + } + return gbMemoryMap[address>>12][address&0xFFF]; +} diff --git a/src/gb/gbCheats.h b/src/gb/gbCheats.h new file mode 100644 index 0000000..3845a53 --- /dev/null +++ b/src/gb/gbCheats.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_GB_GBCHEATS_H +#define __VBA_GB_GBCHEATS_H + +#include "../System.h" + +struct gbXxCheat { + char cheatDesc[100]; + char cheatCode[20]; +}; + +struct gbCheat { + char cheatCode[20]; + char cheatDesc[32]; + u16 address; + int code; + u8 compare; + u8 value; + bool enabled; +}; + +extern void gbCheatsSaveGame(gzFile); +extern void gbCheatsReadGame(gzFile, int); +extern void gbCheatsSaveCheatList(const char *); +extern bool gbCheatsLoadCheatList(const char *); +extern bool gbCheatReadGSCodeFile(const char *); + +extern void gbAddGsCheat(const char *, const char*); +extern void gbAddGgCheat(const char *, const char*); +extern void gbCheatRemove(int); +extern void gbCheatRemoveAll(); +extern void gbCheatEnable(int); +extern void gbCheatDisable(int); +extern u8 gbCheatRead(u16); + +extern int gbCheatNumber; +extern gbCheat gbCheatList[100]; +extern bool gbCheatMap[0x10000]; +#endif + diff --git a/src/gb/gbCodes.h b/src/gb/gbCodes.h new file mode 100644 index 0000000..43c4519 --- /dev/null +++ b/src/gb/gbCodes.h @@ -0,0 +1,1407 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + case 0x00: + // NOP + break; + case 0x01: + // LD BC, NNNN + BC.B.B0=gbReadMemory(PC.W++); + BC.B.B1=gbReadMemory(PC.W++); + break; + case 0x02: + // LD (BC),A + gbWriteMemory(BC.W,AF.B.B1); + break; + case 0x03: + // INC BC + BC.W++; + break; + case 0x04: + // INC B + BC.B.B1++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| (BC.B.B1&0x0F? 0:H_FLAG); + break; + case 0x05: + // DEC B + BC.B.B1--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| + ((BC.B.B1&0x0F)==0x0F? H_FLAG:0); + break; + case 0x06: + // LD B, NN + BC.B.B1=gbReadOpcode(PC.W++); + break; + case 0x07: + // RLCA + tempValue=AF.B.B1&0x80? C_FLAG:0; + AF.B.B1=(AF.B.B1<<1)|(AF.B.B1>>7); + AF.B.B0=tempValue; + break; + case 0x08: + // LD (NNNN), SP + tempRegister.B.B0=gbReadOpcode(PC.W++); + tempRegister.B.B1=gbReadOpcode(PC.W++); + gbWriteMemory(tempRegister.W++,SP.B.B0); + gbWriteMemory(tempRegister.W,SP.B.B1); + break; + case 0x09: + // ADD HL,BC + tempRegister.W=(HL.W+BC.W)&0xFFFF; + AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^BC.W^tempRegister.W)&0x1000? H_FLAG:0)| + (((long)HL.W+(long)BC.W)&0x10000? C_FLAG:0); + HL.W=tempRegister.W; + break; + case 0x0a: + // LD A,(BC) + AF.B.B1=gbReadMemory(BC.W); + break; + case 0x0b: + // DEC BC + BC.W--; + break; + case 0x0c: + // INC C + BC.B.B0++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]| (BC.B.B0&0x0F? 0:H_FLAG); + break; + case 0x0d: + // DEC C + BC.B.B0--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]| + ((BC.B.B0&0x0F)==0x0F? H_FLAG:0); + break; + case 0x0e: + // LD C, NN + BC.B.B0=gbReadOpcode(PC.W++); + break; + case 0x0f: + // RRCA + tempValue=AF.B.B1&0x01; + AF.B.B1=(AF.B.B1>>1)|(tempValue? 0x80:0); + AF.B.B0=(tempValue<<4); + break; + case 0x10: + // STOP + opcode = gbReadOpcode(PC.W++); + if(gbCgbMode) { + if(gbMemory[0xff4d] & 1) { + gbSpeedSwitch(); + + if(gbSpeed == 0) + gbMemory[0xff4d] = 0x00; + else + gbMemory[0xff4d] = 0x80; + } + } + break; + case 0x11: + // LD DE, NNNN + DE.B.B0=gbReadMemory(PC.W++); + DE.B.B1=gbReadMemory(PC.W++); + break; + case 0x12: + // LD (DE),A + gbWriteMemory(DE.W,AF.B.B1); + break; + case 0x13: + // INC DE + DE.W++; + break; + case 0x14: + // INC D + DE.B.B1++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]| (DE.B.B1&0x0F? 0:H_FLAG); + break; + case 0x15: + // DEC D + DE.B.B1--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]| + ((DE.B.B1&0x0F)==0x0F? H_FLAG:0); + break; + case 0x16: + // LD D,NN + DE.B.B1=gbReadOpcode(PC.W++); + break; + case 0x17: + // RLA + tempValue=AF.B.B1&0x80? C_FLAG:0; + AF.B.B1=(AF.B.B1<<1)|((AF.B.B0&C_FLAG)>>4); + AF.B.B0=tempValue; + break; + case 0x18: + // JR NN + PC.W+=(s8)gbReadMemory(PC.W)+1; + break; + case 0x19: + // ADD HL,DE + tempRegister.W=(HL.W+DE.W)&0xFFFF; + AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^DE.W^tempRegister.W)&0x1000? H_FLAG:0)| + (((long)HL.W+(long)DE.W)&0x10000? C_FLAG:0); + HL.W=tempRegister.W; + break; + case 0x1a: + // LD A,(DE) + AF.B.B1=gbReadMemory(DE.W); + break; + case 0x1b: + // DEC DE + DE.W--; + break; + case 0x1c: + // INC E + DE.B.B0++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]| (DE.B.B0&0x0F? 0:H_FLAG); + break; + case 0x1d: + // DEC E + DE.B.B0--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]| + ((DE.B.B0&0x0F)==0x0F? H_FLAG:0); + break; + case 0x1e: + // LD E,NN + DE.B.B0=gbReadOpcode(PC.W++); + break; + case 0x1f: + // RRA + tempValue=AF.B.B1&0x01; + AF.B.B1=(AF.B.B1>>1)|(AF.B.B0&C_FLAG? 0x80:0); + AF.B.B0=(tempValue<<4); + break; + case 0x20: + // JR NZ,NN + if(AF.B.B0&Z_FLAG) + PC.W++; + else { + PC.W+=(s8)gbReadMemory(PC.W)+1; + clockTicks++; + } + break; + case 0x21: + // LD HL,NNNN + HL.B.B0=gbReadMemory(PC.W++); + HL.B.B1=gbReadMemory(PC.W++); + break; + case 0x22: + // LDI (HL),A + gbWriteMemory(HL.W++,AF.B.B1); + break; + case 0x23: + // INC HL + HL.W++; + break; + case 0x24: + // INC H + HL.B.B1++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]| (HL.B.B1&0x0F? 0:H_FLAG); + break; + case 0x25: + // DEC H + HL.B.B1--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]| + ((HL.B.B1&0x0F)==0x0F? H_FLAG:0); + break; + case 0x26: + // LD H,NN + HL.B.B1=gbReadOpcode(PC.W++); + break; + case 0x27: + // DAA + tempRegister.W=AF.B.B1; + if(AF.B.B0&C_FLAG) tempRegister.W|=256; + if(AF.B.B0&H_FLAG) tempRegister.W|=512; + if(AF.B.B0&N_FLAG) tempRegister.W|=1024; + AF.W=DAATable[tempRegister.W]; + break; + case 0x28: + // JR Z,NN + if(AF.B.B0&Z_FLAG) { + PC.W+=(s8)gbReadMemory(PC.W)+1; + clockTicks++; + } else + PC.W++; + break; + case 0x29: + // ADD HL,HL + tempRegister.W=(HL.W+HL.W)&0xFFFF; AF.B.B0= (AF.B.B0 & Z_FLAG)| + ((HL.W^HL.W^tempRegister.W)&0x1000? H_FLAG:0)| + (((long)HL.W+(long)HL.W)&0x10000? C_FLAG:0); + HL.W=tempRegister.W; + break; + case 0x2a: + // LDI A,(HL) + AF.B.B1 = gbReadMemory(HL.W++); + break; + case 0x2b: + // DEC HL + HL.W--; + break; + case 0x2c: + // INC L + HL.B.B0++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]| (HL.B.B0&0x0F? 0:H_FLAG); + break; + case 0x2d: + // DEC L + HL.B.B0--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]| + ((HL.B.B0&0x0F)==0x0F? H_FLAG:0); + break; + case 0x2e: + // LD L,NN + HL.B.B0=gbReadOpcode(PC.W++); + break; + case 0x2f: + // CPL + AF.B.B1 ^= 255; + AF.B.B0|=N_FLAG|H_FLAG; + break; + case 0x30: + // JR NC,NN + if(AF.B.B0&C_FLAG) + PC.W++; + else { + PC.W+=(s8)gbReadMemory(PC.W)+1; + clockTicks++; + } + break; + case 0x31: + // LD SP,NNNN + SP.B.B0=gbReadMemory(PC.W++); + SP.B.B1=gbReadMemory(PC.W++); + break; + case 0x32: + // LDD (HL),A + gbWriteMemory(HL.W--,AF.B.B1); + break; + case 0x33: + // INC SP + SP.W++; + break; + case 0x34: + // INC (HL) + tempValue=gbReadMemory(HL.W)+1; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[tempValue]| (tempValue&0x0F? 0:H_FLAG); + gbWriteMemory(HL.W,tempValue); + break; + case 0x35: + // DEC (HL) + tempValue=gbReadMemory(HL.W)-1; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[tempValue]| + ((tempValue&0x0F)==0x0F? H_FLAG:0);gbWriteMemory(HL.W,tempValue); + break; + case 0x36: + // LD (HL),NN + gbWriteMemory(HL.W,gbReadOpcode(PC.W++)); + break; + case 0x37: + // SCF + AF.B.B0 = AF.B.B0 & Z_FLAG | C_FLAG; + break; +case 0x38: + // JR C,NN + if(AF.B.B0&C_FLAG) { + PC.W+=(s8)gbReadMemory(PC.W)+1; + clockTicks ++; + } else + PC.W++; + break; + case 0x39: + // ADD HL,SP + tempRegister.W=(HL.W+SP.W)&0xFFFF; + AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^SP.W^tempRegister.W)&0x1000? H_FLAG:0)| + (((long)HL.W+(long)SP.W)&0x10000? C_FLAG:0); + HL.W=tempRegister.W; + break; + case 0x3a: + // LDD A,(HL) + AF.B.B1 = gbReadMemory(HL.W--); + break; + case 0x3b: + // DEC SP + SP.W--; + break; + case 0x3c: + // INC A + AF.B.B1++; + AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]| (AF.B.B1&0x0F? 0:H_FLAG); + break; + case 0x3d: + // DEC A + AF.B.B1--; + AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]| + ((AF.B.B1&0x0F)==0x0F? H_FLAG:0); + break; + case 0x3e: + // LD A,NN + AF.B.B1=gbReadOpcode(PC.W++); + break; + case 0x3f: + // CCF + AF.B.B0^=C_FLAG;AF.B.B0&=~(N_FLAG|H_FLAG); + break; + case 0x40: + // LD B,B + BC.B.B1=BC.B.B1; + break; + case 0x41: + // LD B,C + BC.B.B1=BC.B.B0; + break; + case 0x42: + // LD B,D + BC.B.B1=DE.B.B1; + break; + case 0x43: + // LD B,E + BC.B.B1=DE.B.B0; + break; + case 0x44: + // LD B,H + BC.B.B1=HL.B.B1; + break; + case 0x45: + // LD B,L + BC.B.B1=HL.B.B0; + break; + case 0x46: + // LD B,(HL) + BC.B.B1=gbReadMemory(HL.W); + break; + case 0x47: + // LD B,A + BC.B.B1=AF.B.B1; + break; + case 0x48: + // LD C,B + BC.B.B0=BC.B.B1; + break; + case 0x49: + // LD C,C + BC.B.B0=BC.B.B0; + break; + case 0x4a: + // LD C,D + BC.B.B0=DE.B.B1; + break; + case 0x4b: + // LD C,E + BC.B.B0=DE.B.B0; + break; + case 0x4c: + // LD C,H + BC.B.B0=HL.B.B1; + break; + case 0x4d: + // LD C,L + BC.B.B0=HL.B.B0; + break; + case 0x4e: + // LD C,(HL) + BC.B.B0=gbReadMemory(HL.W); + break; + case 0x4f: + // LD C,A + BC.B.B0=AF.B.B1; + break; + case 0x50: + // LD D,B + DE.B.B1=BC.B.B1; + break; + case 0x51: + // LD D,C + DE.B.B1=BC.B.B0; + break; + case 0x52: + // LD D,D + DE.B.B1=DE.B.B1; + break; + case 0x53: + // LD D,E + DE.B.B1=DE.B.B0; + break; + case 0x54: + // LD D,H + DE.B.B1=HL.B.B1; + break; + case 0x55: + // LD D,L + DE.B.B1=HL.B.B0; + break; + case 0x56: + // LD D,(HL) + DE.B.B1=gbReadMemory(HL.W); + break; + case 0x57: + // LD D,A + DE.B.B1=AF.B.B1; + break; + case 0x58: + // LD E,B + DE.B.B0=BC.B.B1; + break; + case 0x59: + // LD E,C + DE.B.B0=BC.B.B0; + break; + case 0x5a: + // LD E,D + DE.B.B0=DE.B.B1; + break; + case 0x5b: + // LD E,E + DE.B.B0=DE.B.B0; + break; + case 0x5c: + // LD E,H + DE.B.B0=HL.B.B1; + break; + case 0x5d: + // LD E,L + DE.B.B0=HL.B.B0; + break; + case 0x5e: + // LD E,(HL) + DE.B.B0=gbReadMemory(HL.W); + break; + case 0x5f: + // LD E,A + DE.B.B0=AF.B.B1; + break; + case 0x60: + // LD H,B + HL.B.B1=BC.B.B1; + break; + case 0x61: + // LD H,C + HL.B.B1=BC.B.B0; + break; + case 0x62: + // LD H,D + HL.B.B1=DE.B.B1; + break; + case 0x63: + // LD H,E + HL.B.B1=DE.B.B0; + break; + case 0x64: + // LD H,H + HL.B.B1=HL.B.B1; + break; + case 0x65: + // LD H,L + HL.B.B1=HL.B.B0; + break; + case 0x66: + // LD H,(HL) + HL.B.B1=gbReadMemory(HL.W); + break; + case 0x67: + // LD H,A + HL.B.B1=AF.B.B1; + break; + case 0x68: + // LD L,B + HL.B.B0=BC.B.B1; + break; + case 0x69: + // LD L,C + HL.B.B0=BC.B.B0; + break; + case 0x6a: + // LD L,D + HL.B.B0=DE.B.B1; + break; + case 0x6b: + // LD L,E + HL.B.B0=DE.B.B0; + break; + case 0x6c: + // LD L,H + HL.B.B0=HL.B.B1; + break; + case 0x6d: + // LD L,L + HL.B.B0=HL.B.B0; + break; + case 0x6e: + // LD L,(HL) + HL.B.B0=gbReadMemory(HL.W); + break; + case 0x6f: + // LD L,A + HL.B.B0=AF.B.B1; + break; + case 0x70: + // LD (HL),B + gbWriteMemory(HL.W,BC.B.B1); + break; + case 0x71: + // LD (HL),C + gbWriteMemory(HL.W,BC.B.B0); + break; + case 0x72: + // LD (HL),D + gbWriteMemory(HL.W,DE.B.B1); + break; + case 0x73: + // LD (HL),E + gbWriteMemory(HL.W,DE.B.B0); + break; + case 0x74: + // LD (HL),H + gbWriteMemory(HL.W,HL.B.B1); + break; + case 0x75: + // LD (HL),L + gbWriteMemory(HL.W,HL.B.B0); + break; + case 0x76: + // HALT + if(IFF & 1) { + PC.W--; + IFF |= 0x80; + } else { + if((register_IE & register_IF) > 0) + IFF |= 0x100; + else { + PC.W--; + IFF |= 0x81; + } + } + break; + case 0x77: + // LD (HL),A + gbWriteMemory(HL.W,AF.B.B1); + break; + case 0x78: + // LD A,B + AF.B.B1=BC.B.B1; + break; + case 0x79: + // LD A,C + AF.B.B1=BC.B.B0; + break; + case 0x7a: + // LD A,D + AF.B.B1=DE.B.B1; + break; + case 0x7b: + // LD A,E + AF.B.B1=DE.B.B0; + break; + case 0x7c: + // LD A,H + AF.B.B1=HL.B.B1; + break; + case 0x7d: + // LD A,L + AF.B.B1=HL.B.B0; + break; + case 0x7e: + // LD A,(HL) + AF.B.B1=gbReadMemory(HL.W); + break; + case 0x7f: + // LD A,A + AF.B.B1=AF.B.B1; + break; + case 0x80: + // ADD B + tempRegister.W=AF.B.B1+BC.B.B1; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x81: + // ADD C + tempRegister.W=AF.B.B1+BC.B.B0; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x82: + // ADD D + tempRegister.W=AF.B.B1+DE.B.B1; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x83: + // ADD E + tempRegister.W=AF.B.B1+DE.B.B0; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x84: + // ADD H + tempRegister.W=AF.B.B1+HL.B.B1; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x85: + // ADD L + tempRegister.W=AF.B.B1+HL.B.B0; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x86: + // ADD (HL) + tempValue=gbReadMemory(HL.W); + tempRegister.W=AF.B.B1+tempValue; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x87: + // ADD A + tempRegister.W=AF.B.B1+AF.B.B1; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x88: + // ADC B: + tempRegister.W=AF.B.B1+BC.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x89: + // ADC C + tempRegister.W=AF.B.B1+BC.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x8a: + // ADC D + tempRegister.W=AF.B.B1+DE.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x8b: + // ADC E + tempRegister.W=AF.B.B1+DE.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x8c: + // ADC H + tempRegister.W=AF.B.B1+HL.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); AF.B.B1=tempRegister.B.B0; + break; + case 0x8d: + // ADC L + tempRegister.W=AF.B.B1+HL.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x8e: + // ADC (HL) + tempValue=gbReadMemory(HL.W); + tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x8f: + // ADC A + tempRegister.W=AF.B.B1+AF.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x90: + // SUB B + tempRegister.W=AF.B.B1-BC.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x91: + // SUB C + tempRegister.W=AF.B.B1-BC.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x92: + // SUB D + tempRegister.W=AF.B.B1-DE.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x93: + // SUB E + tempRegister.W=AF.B.B1-DE.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x94: + // SUB H + tempRegister.W=AF.B.B1-HL.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x95: + // SUB L + tempRegister.W=AF.B.B1-HL.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x96: + // SUB (HL) + tempValue=gbReadMemory(HL.W); + tempRegister.W=AF.B.B1-tempValue; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x97: + // SUB A + AF.B.B1=0; + AF.B.B0=N_FLAG|Z_FLAG; + break; + case 0x98: + // SBC B + tempRegister.W=AF.B.B1-BC.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x99: + // SBC C + tempRegister.W=AF.B.B1-BC.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9a: + // SBC D + tempRegister.W=AF.B.B1-DE.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9b: + // SBC E + tempRegister.W=AF.B.B1-DE.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9c: + // SBC H + tempRegister.W=AF.B.B1-HL.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9d: + // SBC L + tempRegister.W=AF.B.B1-HL.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9e: + // SBC (HL) + tempValue=gbReadMemory(HL.W); + tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0x9f: + // SBC A + tempRegister.W=AF.B.B1-AF.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0xa0: + // AND B + AF.B.B1&=BC.B.B1; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa1: + // AND C + AF.B.B1&=BC.B.B0; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa2: + // AND_D + AF.B.B1&=DE.B.B1; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa3: + // AND E + AF.B.B1&=DE.B.B0; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa4: + // AND H + AF.B.B1&=HL.B.B1; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa5: + // AND L + AF.B.B1&=HL.B.B0; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa6: + // AND (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B1&=tempValue; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa7: + // AND A + AF.B.B1&=AF.B.B1; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xa8: + // XOR B + AF.B.B1^=BC.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xa9: + // XOR C + AF.B.B1^=BC.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xaa: + // XOR D + AF.B.B1^=DE.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xab: + // XOR E + AF.B.B1^=DE.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xac: + // XOR H + AF.B.B1^=HL.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xad: + // XOR L + AF.B.B1^=HL.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xae: + // XOR (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B1^=tempValue; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xaf: + // XOR A + AF.B.B1=0; + AF.B.B0=Z_FLAG; + break; + case 0xb0: + // OR B + AF.B.B1|=BC.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb1: + // OR C + AF.B.B1|=BC.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb2: + // OR D + AF.B.B1|=DE.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb3: + // OR E + AF.B.B1|=DE.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb4: + // OR H + AF.B.B1|=HL.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb5: + // OR L + AF.B.B1|=HL.B.B0; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb6: + // OR (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B1|=tempValue; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb7: + // OR A + AF.B.B1|=AF.B.B1; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xb8: + // CP B: + tempRegister.W=AF.B.B1-BC.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xb9: + // CP C + tempRegister.W=AF.B.B1-BC.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xba: + // CP D + tempRegister.W=AF.B.B1-DE.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xbb: + // CP E + tempRegister.W=AF.B.B1-DE.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xbc: + // CP H + tempRegister.W=AF.B.B1-HL.B.B1; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xbd: + // CP L + tempRegister.W=AF.B.B1-HL.B.B0; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xbe: + // CP (HL) + tempValue=gbReadMemory(HL.W); + tempRegister.W=AF.B.B1-tempValue; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xbf: + // CP A + AF.B.B0=N_FLAG|Z_FLAG; + break; + case 0xc0: + // RET NZ + if(!(AF.B.B0&Z_FLAG)) { + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + clockTicks += 3; + } + break; + case 0xc1: + // POP BC + BC.B.B0=gbReadMemory(SP.W++); + BC.B.B1=gbReadMemory(SP.W++); + break; + case 0xc2: + // JP NZ,NNNN + if(AF.B.B0&Z_FLAG) + PC.W+=2; + else { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W); + PC.W=tempRegister.W; + clockTicks++; + } + break; + case 0xc3: + // JP NNNN + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W); + PC.W=tempRegister.W; + break; + case 0xc4: + // CALL NZ,NNNN + if(AF.B.B0&Z_FLAG) + PC.W+=2; + else { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W++); + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=tempRegister.W; + clockTicks += 3; + } + break; + case 0xc5: + // PUSH BC + gbWriteMemory(--SP.W,BC.B.B1); + gbWriteMemory(--SP.W,BC.B.B0); + break; + case 0xc6: + // ADD NN + tempValue=gbReadOpcode(PC.W++); + tempRegister.W=AF.B.B1+tempValue; + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0xc7: + // RST 00 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0000; + break; + case 0xc8: + // RET Z + if(AF.B.B0&Z_FLAG) { + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + clockTicks += 3; + } + break; + case 0xc9: + // RET + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + break; + case 0xca: + // JP Z,NNNN + if(AF.B.B0&Z_FLAG) { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W); + PC.W=tempRegister.W; + clockTicks++; + } else + PC.W+=2; + break; + // CB done outside + case 0xcc: + // CALL Z,NNNN + if(AF.B.B0&Z_FLAG) { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W++); + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=tempRegister.W; + clockTicks += 3; + } else + PC.W+=2; + break; + case 0xcd: + // CALL NNNN + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W++); + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=tempRegister.W; + break; + case 0xce: + // ADC NN + tempValue=gbReadOpcode(PC.W++); + tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0xcf: + // RST 08 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0008; + break; + case 0xd0: + // RET NC + if(!(AF.B.B0&C_FLAG)) { + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + clockTicks += 3; + } + break; + case 0xd1: + // POP DE + DE.B.B0=gbReadMemory(SP.W++); + DE.B.B1=gbReadMemory(SP.W++); + break; + case 0xd2: + // JP NC,NNNN + if(AF.B.B0&C_FLAG) + PC.W+=2; + else { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W); + PC.W=tempRegister.W; + clockTicks++; + } + break; + // D3 illegal + case 0xd4: + // CALL NC,NNNN + if(AF.B.B0&C_FLAG) + PC.W+=2; + else { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W++); + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=tempRegister.W; + clockTicks += 3; + } + break; + case 0xd5: + // PUSH DE + gbWriteMemory(--SP.W,DE.B.B1); + gbWriteMemory(--SP.W,DE.B.B0); + break; + case 0xd6: + // SUB NN + tempValue=gbReadOpcode(PC.W++); + tempRegister.W=AF.B.B1-tempValue; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0xd7: + // RST 10 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0010; + break; + case 0xd8: + // RET C + if(AF.B.B0&C_FLAG) { + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + clockTicks += 4; + } + break; + case 0xd9: + // RETI + PC.B.B0=gbReadMemory(SP.W++); + PC.B.B1=gbReadMemory(SP.W++); + IFF |= 0x01; + break; + case 0xda: + // JP C,NNNN + if(AF.B.B0&C_FLAG) { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W); + PC.W=tempRegister.W; + clockTicks++; + } else + PC.W+=2; + break; + // DB illegal + case 0xdc: + // CALL C,NNNN + if(AF.B.B0&C_FLAG) { + tempRegister.B.B0=gbReadMemory(PC.W++); + tempRegister.B.B1=gbReadMemory(PC.W++); + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=tempRegister.W; + clockTicks += 3; + } else + PC.W+=2; + break; + // DD illegal + case 0xde: + // SBC NN + tempValue=gbReadOpcode(PC.W++); + tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + AF.B.B1=tempRegister.B.B0; + break; + case 0xdf: + // RST 18 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0018; + break; + case 0xe0: + // LD (FF00+NN),A + gbWriteMemory(0xff00 + gbReadOpcode(PC.W++),AF.B.B1); + break; + case 0xe1: + // POP HL + HL.B.B0=gbReadMemory(SP.W++); + HL.B.B1=gbReadMemory(SP.W++); + break; + case 0xe2: + // LD (FF00+C),A + gbWriteMemory(0xff00 + BC.B.B0,AF.B.B1); + break; + // E3 illegal + // E4 illegal + case 0xe5: + // PUSH HL + gbWriteMemory(--SP.W,HL.B.B1); + gbWriteMemory(--SP.W,HL.B.B0); + break; + case 0xe6: + // AND NN + tempValue=gbReadOpcode(PC.W++); + AF.B.B1&=tempValue; + AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; + break; + case 0xe7: + // RST 20 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0020; + break; + case 0xe8: + // ADD SP,NN + offset = (s8)gbReadOpcode(PC.W++); + + if(offset >= 0) { + tempRegister.W = SP.W + offset; + AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) | + ((SP.W^offset^tempRegister.W)&0x1000? H_FLAG:0); + SP.W = tempRegister.W; + } else { + tempRegister.W = SP.W + offset; + AF.B.B0 = (SP.W < tempRegister.W ? C_FLAG : 0) | + ((SP.W^offset^tempRegister.W)&0x1000?H_FLAG:0); + SP.W = tempRegister.W; + } + break; + case 0xe9: + // LD PC,HL + PC.W=HL.W; + break; + case 0xea: + // LD (NNNN),A + tempRegister.B.B0=gbReadOpcode(PC.W++); + tempRegister.B.B1=gbReadOpcode(PC.W++); + gbWriteMemory(tempRegister.W,AF.B.B1); + break; + // EB illegal + // EC illegal + // ED illegal + case 0xee: + // XOR NN + tempValue=gbReadOpcode(PC.W++); + AF.B.B1^=tempValue; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xef: + // RST 28 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0028; + break; + case 0xf0: + // LD A,(FF00+NN) + AF.B.B1 = gbReadMemory(0xff00+gbReadOpcode(PC.W++)); + break; + case 0xf1: + // POP AF + AF.B.B0=gbReadMemory(SP.W++); + AF.B.B1=gbReadMemory(SP.W++); + break; + case 0xf2: + // LD A,(FF00+C) + AF.B.B1 = gbReadMemory(0xff00+BC.B.B0); + break; + case 0xf3: + // DI + // IFF&=0xFE; + IFF&=(~0x21); + break; + // F4 illegal + case 0xf5: + // PUSH AF + gbWriteMemory(--SP.W,AF.B.B1); + gbWriteMemory(--SP.W,AF.B.B0); + break; + case 0xf6: + // OR NN + tempValue=gbReadOpcode(PC.W++); + AF.B.B1|=tempValue; + AF.B.B0=ZeroTable[AF.B.B1]; + break; + case 0xf7: + // RST 30 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0030; + break; + case 0xf8: + // LD HL,SP+NN + offset = (s8)gbReadOpcode(PC.W++); + if(offset >= 0) { + tempRegister.W = SP.W + offset; + AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) | + ((SP.W^offset^tempRegister.W)&0x1000? H_FLAG:0); + HL.W = tempRegister.W; + } else { + tempRegister.W = SP.W + offset; + AF.B.B0 = (SP.W < tempRegister.W ? C_FLAG : 0) | + ((SP.W^offset^tempRegister.W)&0x1000?H_FLAG:0); + HL.W = tempRegister.W; + } + break; + case 0xf9: + // LD SP,HL + SP.W=HL.W; + break; + case 0xfa: + // LD A,(NNNN) + tempRegister.B.B0=gbReadOpcode(PC.W++); + tempRegister.B.B1=gbReadOpcode(PC.W++); + AF.B.B1=gbReadMemory(tempRegister.W); + break; + case 0xfb: + // EI + IFF|=0x20; + break; + // FC illegal + // FD illegal + case 0xfe: + // CP NN + tempValue=gbReadOpcode(PC.W++); + tempRegister.W=AF.B.B1-tempValue; + AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| + ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); + break; + case 0xff: + // RST 38 + gbWriteMemory(--SP.W,PC.B.B1); + gbWriteMemory(--SP.W,PC.B.B0); + PC.W=0x0038; + break; + default: + systemMessage(0, N_("Unknown opcode %02x at %04x"), + gbReadOpcode(PC.W-1),PC.W-1); + emulating = false; + return; diff --git a/src/gb/gbCodesCB.h b/src/gb/gbCodesCB.h new file mode 100644 index 0000000..05dce6e --- /dev/null +++ b/src/gb/gbCodesCB.h @@ -0,0 +1,1288 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + case 0x00: + // RLC B + AF.B.B0 = (BC.B.B1 & 0x80)?C_FLAG:0; + BC.B.B1 = (BC.B.B1<<1) | (BC.B.B1>>7); + AF.B.B0 |= ZeroTable[BC.B.B1]; + break; + case 0x01: + // RLC C + AF.B.B0 = (BC.B.B0 & 0x80)?C_FLAG:0; + BC.B.B0 = (BC.B.B0<<1) | (BC.B.B0>>7); + AF.B.B0 |= ZeroTable[BC.B.B0]; + break; + case 0x02: + // RLC D + AF.B.B0 = (DE.B.B1 & 0x80)?C_FLAG:0; + DE.B.B1 = (DE.B.B1<<1) | (DE.B.B1>>7); + AF.B.B0 |= ZeroTable[DE.B.B1]; + break; + case 0x03: + // RLC E + AF.B.B0 = (DE.B.B0 & 0x80)?C_FLAG:0; + DE.B.B0 = (DE.B.B0<<1) | (DE.B.B0>>7); + AF.B.B0 |= ZeroTable[DE.B.B0]; + break; + case 0x04: + // RLC H + AF.B.B0 = (HL.B.B1 & 0x80)?C_FLAG:0; + HL.B.B1 = (HL.B.B1<<1) | (HL.B.B1>>7); + AF.B.B0 |= ZeroTable[HL.B.B1]; + break; + case 0x05: + // RLC L + AF.B.B0 = (HL.B.B0 & 0x80)?C_FLAG:0; + HL.B.B0 = (HL.B.B0<<1) | (HL.B.B0>>7); + AF.B.B0 |= ZeroTable[HL.B.B0]; + break; + case 0x06: + // RLC (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0 = (tempValue & 0x80)?C_FLAG:0; + tempValue = (tempValue<<1) | (tempValue>>7); + AF.B.B0 |= ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x07: + // RLC A + AF.B.B0 = (AF.B.B1 & 0x80)?C_FLAG:0; + AF.B.B1 = (AF.B.B1<<1) | (AF.B.B1>>7); + AF.B.B0 |= ZeroTable[AF.B.B1]; + break; + case 0x08: + // RRC B + AF.B.B0=(BC.B.B1&0x01 ? C_FLAG : 0); + BC.B.B1=(BC.B.B1>>1)|(BC.B.B1<<7); + AF.B.B0|=ZeroTable[BC.B.B1]; + break; + case 0x09: + // RRC C + AF.B.B0=(BC.B.B0&0x01 ? C_FLAG : 0); + BC.B.B0=(BC.B.B0>>1)|(BC.B.B0<<7); + AF.B.B0|=ZeroTable[BC.B.B0]; + break; + case 0x0a: + // RRC D + AF.B.B0=(DE.B.B1&0x01 ? C_FLAG : 0); + DE.B.B1=(DE.B.B1>>1)|(DE.B.B1<<7); + AF.B.B0|=ZeroTable[DE.B.B1]; + break; + case 0x0b: + // RRC E + AF.B.B0=(DE.B.B0&0x01 ? C_FLAG : 0); + DE.B.B0=(DE.B.B0>>1)|(DE.B.B0<<7); + AF.B.B0|=ZeroTable[DE.B.B0]; + break; + case 0x0c: + // RRC H + AF.B.B0=(HL.B.B1&0x01 ? C_FLAG : 0); + HL.B.B1=(HL.B.B1>>1)|(HL.B.B1<<7); + AF.B.B0|=ZeroTable[HL.B.B1]; + break; + case 0x0d: + // RRC L + AF.B.B0=(HL.B.B0&0x01 ? C_FLAG : 0); + HL.B.B0=(HL.B.B0>>1)|(HL.B.B0<<7); + AF.B.B0|=ZeroTable[HL.B.B0]; + break; + case 0x0e: + // RRC (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(tempValue&0x01 ? C_FLAG : 0); + tempValue=(tempValue>>1)|(tempValue<<7); + AF.B.B0|=ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x0f: + // RRC A + AF.B.B0=(AF.B.B1&0x01 ? C_FLAG : 0); + AF.B.B1=(AF.B.B1>>1)|(AF.B.B1<<7); + AF.B.B0|=ZeroTable[AF.B.B1]; + break; + case 0x10: + // RL B + if(BC.B.B1&0x80) { + BC.B.B1=(BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG; + } else { + BC.B.B1=(BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[BC.B.B1]; + } + break; + case 0x11: + // RL C + if(BC.B.B0&0x80) { + BC.B.B0=(BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG; + } else { + BC.B.B0=(BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[BC.B.B0]; + } + break; + case 0x12: + // RL D + if(DE.B.B1&0x80) { + DE.B.B1=(DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG; + } else { + DE.B.B1=(DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[DE.B.B1]; + } + break; + case 0x13: + // RL E + if(DE.B.B0&0x80) { + DE.B.B0=(DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG; + } else { + DE.B.B0=(DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[DE.B.B0]; + } + break; + case 0x14: + // RL H + if(HL.B.B1&0x80) { + HL.B.B1=(HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG; + } else { + HL.B.B1=(HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[HL.B.B1]; + } + break; + case 0x15: + // RL L + if(HL.B.B0&0x80) { + HL.B.B0=(HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG; + } else { + HL.B.B0=(HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[HL.B.B0]; + } + break; + case 0x16: + // RL (HL) + tempValue=gbReadMemory(HL.W); + if(tempValue&0x80) { + tempValue=(tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[tempValue]|C_FLAG; + } else { + tempValue=(tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[tempValue]; + } + gbWriteMemory(HL.W,tempValue); + break; + case 0x17: + // RL A + if(AF.B.B1&0x80) { + AF.B.B1=(AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG; + } else { + AF.B.B1=(AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); + AF.B.B0=ZeroTable[AF.B.B1]; + } + break; + case 0x18: + // RR B + if(BC.B.B1&0x01) { + BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG; + } else { + BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[BC.B.B1]; + } + break; + case 0x19: + // RR C + if(BC.B.B0&0x01) { + BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG; + } else { + BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[BC.B.B0]; + } + break; + case 0x1a: + // RR D + if(DE.B.B1&0x01) { + DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG; + } else { + DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[DE.B.B1]; + } + break; + case 0x1b: + // RR E + if(DE.B.B0&0x01) { + DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG; + } else { + DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[DE.B.B0]; + } + break; + case 0x1c: + // RR H + if(HL.B.B1&0x01) { + HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG; + } else { + HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[HL.B.B1]; + } + break; + case 0x1d: + // RR L + if(HL.B.B0&0x01) { + HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG; + } else { + HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[HL.B.B0]; + } + break; + case 0x1e: + // RR (HL) + tempValue=gbReadMemory(HL.W); + if(tempValue&0x01) { + tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[tempValue]|C_FLAG; + } else { + tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[tempValue]; + } + gbWriteMemory(HL.W,tempValue); + break; + case 0x1f: + // RR A + if(AF.B.B1&0x01) { + AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG; + } else { + AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); + AF.B.B0=ZeroTable[AF.B.B1]; + } + break; + case 0x20: + // SLA B + AF.B.B0=(BC.B.B1&0x80?C_FLAG : 0); + BC.B.B1<<=1; + AF.B.B0|=ZeroTable[BC.B.B1]; + break; + case 0x21: + // SLA C + AF.B.B0=(BC.B.B0&0x80?C_FLAG : 0); + BC.B.B0<<=1; + AF.B.B0|=ZeroTable[BC.B.B0]; + break; + case 0x22: + // SLA D + AF.B.B0=(DE.B.B1&0x80?C_FLAG : 0); + DE.B.B1<<=1; + AF.B.B0|=ZeroTable[DE.B.B1]; + break; + case 0x23: + // SLA E + AF.B.B0=(DE.B.B0&0x80?C_FLAG : 0); + DE.B.B0<<=1; + AF.B.B0|=ZeroTable[DE.B.B0]; + break; + case 0x24: + // SLA H + AF.B.B0=(HL.B.B1&0x80?C_FLAG : 0); + HL.B.B1<<=1; + AF.B.B0|=ZeroTable[HL.B.B1]; + break; + case 0x25: + // SLA L + AF.B.B0=(HL.B.B0&0x80?C_FLAG : 0); + HL.B.B0<<=1; + AF.B.B0|=ZeroTable[HL.B.B0]; + break; + case 0x26: + // SLA (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(tempValue&0x80?C_FLAG : 0); + tempValue<<=1; + AF.B.B0|=ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x27: + // SLA A + AF.B.B0=(AF.B.B1&0x80?C_FLAG : 0); + AF.B.B1<<=1; + AF.B.B0|=ZeroTable[AF.B.B1]; + break; + case 0x28: + // SRA B + AF.B.B0=(BC.B.B1&0x01 ? C_FLAG: 0); + BC.B.B1=(BC.B.B1>>1)|(BC.B.B1&0x80); + AF.B.B0|=ZeroTable[BC.B.B1]; + break; + case 0x29: + // SRA C + AF.B.B0=(BC.B.B0&0x01 ? C_FLAG: 0); + BC.B.B0=(BC.B.B0>>1)|(BC.B.B0&0x80); + AF.B.B0|=ZeroTable[BC.B.B0]; + break; + case 0x2a: + // SRA D + AF.B.B0=(DE.B.B1&0x01 ? C_FLAG: 0); + DE.B.B1=(DE.B.B1>>1)|(DE.B.B1&0x80); + AF.B.B0|=ZeroTable[DE.B.B1]; + break; + case 0x2b: + // SRA E + AF.B.B0=(DE.B.B0&0x01 ? C_FLAG: 0); + DE.B.B0=(DE.B.B0>>1)|(DE.B.B0&0x80); + AF.B.B0|=ZeroTable[DE.B.B0]; + break; + case 0x2c: + // SRA H + AF.B.B0=(HL.B.B1&0x01 ? C_FLAG: 0); + HL.B.B1=(HL.B.B1>>1)|(HL.B.B1&0x80); + AF.B.B0|=ZeroTable[HL.B.B1]; + break; + case 0x2d: + // SRA L + AF.B.B0=(HL.B.B0&0x01 ? C_FLAG: 0); + HL.B.B0=(HL.B.B0>>1)|(HL.B.B0&0x80); + AF.B.B0|=ZeroTable[HL.B.B0]; + break; + case 0x2e: + // SRA (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(tempValue&0x01 ? C_FLAG: 0); + tempValue=(tempValue>>1)|(tempValue&0x80); + AF.B.B0|=ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x2f: + // SRA A + AF.B.B0=(AF.B.B1&0x01 ? C_FLAG: 0); + AF.B.B1=(AF.B.B1>>1)|(AF.B.B1&0x80); + AF.B.B0|=ZeroTable[AF.B.B1]; + break; + case 0x30: + // SWAP B + BC.B.B1 = (BC.B.B1&0xf0)>>4 | (BC.B.B1&0x0f)<<4; + AF.B.B0 = ZeroTable[BC.B.B1]; + break; + case 0x31: + // SWAP C + BC.B.B0 = (BC.B.B0&0xf0)>>4 | (BC.B.B0&0x0f)<<4; + AF.B.B0 = ZeroTable[BC.B.B0]; + break; + case 0x32: + // SWAP D + DE.B.B1 = (DE.B.B1&0xf0)>>4 | (DE.B.B1&0x0f)<<4; + AF.B.B0 = ZeroTable[DE.B.B1]; + break; + case 0x33: + // SWAP E + DE.B.B0 = (DE.B.B0&0xf0)>>4 | (DE.B.B0&0x0f)<<4; + AF.B.B0 = ZeroTable[DE.B.B0]; + break; + case 0x34: + // SWAP H + HL.B.B1 = (HL.B.B1&0xf0)>>4 | (HL.B.B1&0x0f)<<4; + AF.B.B0 = ZeroTable[HL.B.B1]; + break; + case 0x35: + // SWAP L + HL.B.B0 = (HL.B.B0&0xf0)>>4 | (HL.B.B0&0x0f)<<4; + AF.B.B0 = ZeroTable[HL.B.B0]; + break; + case 0x36: + // SWAP (HL) + tempValue=gbReadMemory(HL.W); + tempValue = (tempValue&0xf0)>>4 | (tempValue&0x0f)<<4; + AF.B.B0 = ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x37: + // SWAP A + AF.B.B1 = (AF.B.B1&0xf0)>>4 | (AF.B.B1&0x0f)<<4; + AF.B.B0 = ZeroTable[AF.B.B1]; + break; + case 0x38: + // SRL B + AF.B.B0=(BC.B.B1&0x01)?C_FLAG:0; + BC.B.B1>>=1; + AF.B.B0|=ZeroTable[BC.B.B1]; + break; + case 0x39: + // SRL C + AF.B.B0=(BC.B.B0&0x01)?C_FLAG:0; + BC.B.B0>>=1; + AF.B.B0|=ZeroTable[BC.B.B0]; + break; + case 0x3a: + // SRL D + AF.B.B0=(DE.B.B1&0x01)?C_FLAG:0; + DE.B.B1>>=1; + AF.B.B0|=ZeroTable[DE.B.B1]; + break; + case 0x3b: + // SRL E + AF.B.B0=(DE.B.B0&0x01)?C_FLAG:0; + DE.B.B0>>=1; + AF.B.B0|=ZeroTable[DE.B.B0]; + break; + case 0x3c: + // SRL H + AF.B.B0=(HL.B.B1&0x01)?C_FLAG:0; + HL.B.B1>>=1; + AF.B.B0|=ZeroTable[HL.B.B1]; + break; + case 0x3d: + // SRL L + AF.B.B0=(HL.B.B0&0x01)?C_FLAG:0; + HL.B.B0>>=1; + AF.B.B0|=ZeroTable[HL.B.B0]; + break; + case 0x3e: + // SRL (HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(tempValue&0x01)?C_FLAG:0; + tempValue>>=1; + AF.B.B0|=ZeroTable[tempValue]; + gbWriteMemory(HL.W,tempValue); + break; + case 0x3f: + // SRL A + AF.B.B0=(AF.B.B1&0x01)?C_FLAG:0; + AF.B.B1>>=1; + AF.B.B0|=ZeroTable[AF.B.B1]; + break; + case 0x40: + // BIT 0,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<0)? 0:Z_FLAG); + break; + case 0x41: + // BIT 0,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<0)? 0:Z_FLAG); + break; + case 0x42: + // BIT 0,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<0)? 0:Z_FLAG); + break; + case 0x43: + // BIT 0,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<0)? 0:Z_FLAG); + break; + case 0x44: + // BIT 0,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<0)? 0:Z_FLAG); + break; + case 0x45: + // BIT 0,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<0)? 0:Z_FLAG); + break; + case 0x46: + // BIT 0,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<0)? 0:Z_FLAG); + break; + case 0x47: + // BIT 0,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<0)? 0:Z_FLAG); + break; + case 0x48: + // BIT 1,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<1)? 0:Z_FLAG); + break; + case 0x49: + // BIT 1,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<1)? 0:Z_FLAG); + break; + case 0x4a: + // BIT 1,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<1)? 0:Z_FLAG); + break; + case 0x4b: + // BIT 1,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<1)? 0:Z_FLAG); + break; + case 0x4c: + // BIT 1,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<1)? 0:Z_FLAG); + break; + case 0x4d: + // BIT 1,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<1)? 0:Z_FLAG); + break; + case 0x4e: + // BIT 1,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<1)? 0:Z_FLAG); + break; + case 0x4f: + // BIT 1,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<1)? 0:Z_FLAG); + break; + case 0x50: + // BIT 2,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<2)? 0:Z_FLAG); + break; + case 0x51: + // BIT 2,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<2)? 0:Z_FLAG); + break; + case 0x52: + // BIT 2,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<2)? 0:Z_FLAG); + break; + case 0x53: + // BIT 2,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<2)? 0:Z_FLAG); + break; + case 0x54: + // BIT 2,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<2)? 0:Z_FLAG); + break; + case 0x55: + // BIT 2,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<2)? 0:Z_FLAG); + break; + case 0x56: + // BIT 2,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<2)? 0:Z_FLAG); + break; + case 0x57: + // BIT 2,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<2)? 0:Z_FLAG); + break; + case 0x58: + // BIT 3,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<3)? 0:Z_FLAG); + break; + case 0x59: + // BIT 3,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<3)? 0:Z_FLAG); + break; + case 0x5a: + // BIT 3,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<3)? 0:Z_FLAG); + break; + case 0x5b: + // BIT 3,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<3)? 0:Z_FLAG); + break; + case 0x5c: + // BIT 3,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<3)? 0:Z_FLAG); + break; + case 0x5d: + // BIT 3,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<3)? 0:Z_FLAG); + break; + case 0x5e: + // BIT 3,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<3)? 0:Z_FLAG); + break; + case 0x5f: + // BIT 3,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<3)? 0:Z_FLAG); + break; + case 0x60: + // BIT 4,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<4)? 0:Z_FLAG); + break; + case 0x61: + // BIT 4,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<4)? 0:Z_FLAG); + break; + case 0x62: + // BIT 4,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<4)? 0:Z_FLAG); + break; + case 0x63: + // BIT 4,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<4)? 0:Z_FLAG); + break; + case 0x64: + // BIT 4,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<4)? 0:Z_FLAG); + break; + case 0x65: + // BIT 4,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<4)? 0:Z_FLAG); + break; + case 0x66: + // BIT 4,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<4)? 0:Z_FLAG); + break; + case 0x67: + // BIT 4,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<4)? 0:Z_FLAG); + break; + case 0x68: + // BIT 5,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<5)? 0:Z_FLAG); + break; + case 0x69: + // BIT 5,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<5)? 0:Z_FLAG); + break; + case 0x6a: + // BIT 5,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<5)? 0:Z_FLAG); + break; + case 0x6b: + // BIT 5,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<5)? 0:Z_FLAG); + break; + case 0x6c: + // BIT 5,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<5)? 0:Z_FLAG); + break; + case 0x6d: + // BIT 5,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<5)? 0:Z_FLAG); + break; + case 0x6e: + // BIT 5,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<5)? 0:Z_FLAG); + break; + case 0x6f: + // BIT 5,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<5)? 0:Z_FLAG); + break; + case 0x70: + // BIT 6,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<6)? 0:Z_FLAG); + break; + case 0x71: + // BIT 6,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<6)? 0:Z_FLAG); + break; + case 0x72: + // BIT 6,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<6)? 0:Z_FLAG); + break; + case 0x73: + // BIT 6,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<6)? 0:Z_FLAG); + break; + case 0x74: + // BIT 6,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<6)? 0:Z_FLAG); + break; + case 0x75: + // BIT 6,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<6)? 0:Z_FLAG); + break; + case 0x76: + // BIT 6,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<6)? 0:Z_FLAG); + break; + case 0x77: + // BIT 6,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<6)? 0:Z_FLAG); + break; + case 0x78: + // BIT 7,B + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<7)? 0:Z_FLAG); + break; + case 0x79: + // BIT 7,C + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<7)? 0:Z_FLAG); + break; + case 0x7a: + // BIT 7,D + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<7)? 0:Z_FLAG); + break; + case 0x7b: + // BIT 7,E + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<7)? 0:Z_FLAG); + break; + case 0x7c: + // BIT 7,H + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<7)? 0:Z_FLAG); + break; + case 0x7d: + // BIT 7,L + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<7)? 0:Z_FLAG); + break; + case 0x7e: + // BIT 7,(HL) + tempValue=gbReadMemory(HL.W); + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<7)? 0:Z_FLAG); + break; + case 0x7f: + // BIT 7,A + AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<7)? 0:Z_FLAG); + break; + case 0x80: + // RES 0,B + BC.B.B1&=~(1<<0); + break; + case 0x81: + // RES 0,C + BC.B.B0&=~(1<<0); + break; + case 0x82: + // RES 0,D + DE.B.B1&=~(1<<0); + break; + case 0x83: + // RES 0,E + DE.B.B0&=~(1<<0); + break; + case 0x84: + // RES 0,H + HL.B.B1&=~(1<<0); + break; + case 0x85: + // RES 0,L + HL.B.B0&=~(1<<0); + break; + case 0x86: + // RES 0,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<0); + gbWriteMemory(HL.W,tempValue); + break; + case 0x87: + // RES 0,A + AF.B.B1&=~(1<<0); + break; + case 0x88: + // RES 1,B + BC.B.B1&=~(1<<1); + break; + case 0x89: + // RES 1,C + BC.B.B0&=~(1<<1); + break; + case 0x8a: + // RES 1,D + DE.B.B1&=~(1<<1); + break; + case 0x8b: + // RES 1,E + DE.B.B0&=~(1<<1); + break; + case 0x8c: + // RES 1,H + HL.B.B1&=~(1<<1); + break; + case 0x8d: + // RES 1,L + HL.B.B0&=~(1<<1); + break; + case 0x8e: + // RES 1,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<1); + gbWriteMemory(HL.W,tempValue); + break; + case 0x8f: + // RES 1,A + AF.B.B1&=~(1<<1); + break; + case 0x90: + // RES 2,B + BC.B.B1&=~(1<<2); + break; + case 0x91: + // RES 2,C + BC.B.B0&=~(1<<2); + break; + case 0x92: + // RES 2,D + DE.B.B1&=~(1<<2); + break; + case 0x93: + // RES 2,E + DE.B.B0&=~(1<<2); + break; + case 0x94: + // RES 2,H + HL.B.B1&=~(1<<2); + break; + case 0x95: + // RES 2,L + HL.B.B0&=~(1<<2); + break; + case 0x96: + // RES 2,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<2); + gbWriteMemory(HL.W,tempValue); + break; + case 0x97: + // RES 2,A + AF.B.B1&=~(1<<2); + break; + case 0x98: + // RES 3,B + BC.B.B1&=~(1<<3); + break; + case 0x99: + // RES 3,C + BC.B.B0&=~(1<<3); + break; + case 0x9a: + // RES 3,D + DE.B.B1&=~(1<<3); + break; + case 0x9b: + // RES 3,E + DE.B.B0&=~(1<<3); + break; + case 0x9c: + // RES 3,H + HL.B.B1&=~(1<<3); + break; + case 0x9d: + // RES 3,L + HL.B.B0&=~(1<<3); + break; + case 0x9e: + // RES 3,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<3); + gbWriteMemory(HL.W,tempValue); + break; + case 0x9f: + // RES 3,A + AF.B.B1&=~(1<<3); + break; + case 0xa0: + // RES 4,B + BC.B.B1&=~(1<<4); + break; + case 0xa1: + // RES 4,C + BC.B.B0&=~(1<<4); + break; + case 0xa2: + // RES 4,D + DE.B.B1&=~(1<<4); + break; + case 0xa3: + // RES 4,E + DE.B.B0&=~(1<<4); + break; + case 0xa4: + // RES 4,H + HL.B.B1&=~(1<<4); + break; + case 0xa5: + // RES 4,L + HL.B.B0&=~(1<<4); + break; + case 0xa6: + // RES 4,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<4); + gbWriteMemory(HL.W,tempValue); + break; + case 0xa7: + // RES 4,A + AF.B.B1&=~(1<<4); + break; + case 0xa8: + // RES 5,B + BC.B.B1&=~(1<<5); + break; + case 0xa9: + // RES 5,C + BC.B.B0&=~(1<<5); + break; + case 0xaa: + // RES 5,D + DE.B.B1&=~(1<<5); + break; + case 0xab: + // RES 5,E + DE.B.B0&=~(1<<5); + break; + case 0xac: + // RES 5,H + HL.B.B1&=~(1<<5); + break; + case 0xad: + // RES 5,L + HL.B.B0&=~(1<<5); + break; + case 0xae: + // RES 5,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<5); + gbWriteMemory(HL.W,tempValue); + break; + case 0xaf: + // RES 5,A + AF.B.B1&=~(1<<5); + break; + case 0xb0: + // RES 6,B + BC.B.B1&=~(1<<6); + break; + case 0xb1: + // RES 6,C + BC.B.B0&=~(1<<6); + break; + case 0xb2: + // RES 6,D + DE.B.B1&=~(1<<6); + break; + case 0xb3: + // RES 6,E + DE.B.B0&=~(1<<6); + break; + case 0xb4: + // RES 6,H + HL.B.B1&=~(1<<6); + break; + case 0xb5: + // RES 6,L + HL.B.B0&=~(1<<6); + break; + case 0xb6: + // RES 6,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<6); + gbWriteMemory(HL.W,tempValue); + break; + case 0xb7: + // RES 6,A + AF.B.B1&=~(1<<6); + break; + case 0xb8: + // RES 7,B + BC.B.B1&=~(1<<7); + break; + case 0xb9: + // RES 7,C + BC.B.B0&=~(1<<7); + break; + case 0xba: + // RES 7,D + DE.B.B1&=~(1<<7); + break; + case 0xbb: + // RES 7,E + DE.B.B0&=~(1<<7); + break; + case 0xbc: + // RES 7,H + HL.B.B1&=~(1<<7); + break; + case 0xbd: + // RES 7,L + HL.B.B0&=~(1<<7); + break; + case 0xbe: + // RES 7,(HL) + tempValue=gbReadMemory(HL.W); + tempValue&=~(1<<7); + gbWriteMemory(HL.W,tempValue); + break; + case 0xbf: + // RES 7,A + AF.B.B1&=~(1<<7); + break; + case 0xc0: + // SET 0,B + BC.B.B1|=1<<0; + break; + case 0xc1: + // SET 0,C + BC.B.B0|=1<<0; + break; + case 0xc2: + // SET 0,D + DE.B.B1|=1<<0; + break; + case 0xc3: + // SET 0,E + DE.B.B0|=1<<0; + break; + case 0xc4: + // SET 0,H + HL.B.B1|=1<<0; + break; + case 0xc5: + // SET 0,L + HL.B.B0|=1<<0; + break; + case 0xc6: + // SET 0,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<0; + gbWriteMemory(HL.W,tempValue); + break; + case 0xc7: + // SET 0,A + AF.B.B1|=1<<0; + break; + case 0xc8: + // SET 1,B + BC.B.B1|=1<<1; + break; + case 0xc9: + // SET 1,C + BC.B.B0|=1<<1; + break; + case 0xca: + // SET 1,D + DE.B.B1|=1<<1; + break; + case 0xcb: + // SET 1,E + DE.B.B0|=1<<1; + break; + case 0xcc: + // SET 1,H + HL.B.B1|=1<<1; + break; + case 0xcd: + // SET 1,L + HL.B.B0|=1<<1; + break; + case 0xce: + // SET 1,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<1; + gbWriteMemory(HL.W,tempValue); + break; + case 0xcf: + // SET 1,A + AF.B.B1|=1<<1; + break; + case 0xd0: + // SET 2,B + BC.B.B1|=1<<2; + break; + case 0xd1: + // SET 2,C + BC.B.B0|=1<<2; + break; + case 0xd2: + // SET 2,D + DE.B.B1|=1<<2; + break; + case 0xd3: + // SET 2,E + DE.B.B0|=1<<2; + break; + case 0xd4: + // SET 2,H + HL.B.B1|=1<<2; + break; + case 0xd5: + // SET 2,L + HL.B.B0|=1<<2; + break; + case 0xd6: + // SET 2,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<2; + gbWriteMemory(HL.W,tempValue); + break; + case 0xd7: + // SET 2,A + AF.B.B1|=1<<2; + break; + case 0xd8: + // SET 3,B + BC.B.B1|=1<<3; + break; + case 0xd9: + // SET 3,C + BC.B.B0|=1<<3; + break; + case 0xda: + // SET 3,D + DE.B.B1|=1<<3; + break; + case 0xdb: + // SET 3,E + DE.B.B0|=1<<3; + break; + case 0xdc: + // SET 3,H + HL.B.B1|=1<<3; + break; + case 0xdd: + // SET 3,L + HL.B.B0|=1<<3; + break; + case 0xde: + // SET 3,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<3; + gbWriteMemory(HL.W,tempValue); + break; + case 0xdf: + // SET 3,A + AF.B.B1|=1<<3; + break; + case 0xe0: + // SET 4,B + BC.B.B1|=1<<4; + break; + case 0xe1: + // SET 4,C + BC.B.B0|=1<<4; + break; + case 0xe2: + // SET 4,D + DE.B.B1|=1<<4; + break; + case 0xe3: + // SET 4,E + DE.B.B0|=1<<4; + break; + case 0xe4: + // SET 4,H + HL.B.B1|=1<<4; + break; + case 0xe5: + // SET 4,L + HL.B.B0|=1<<4; + break; + case 0xe6: + // SET 4,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<4; + gbWriteMemory(HL.W,tempValue); + break; + case 0xe7: + // SET 4,A + AF.B.B1|=1<<4; + break; + case 0xe8: + // SET 5,B + BC.B.B1|=1<<5; + break; + case 0xe9: + // SET 5,C + BC.B.B0|=1<<5; + break; + case 0xea: + // SET 5,D + DE.B.B1|=1<<5; + break; + case 0xeb: + // SET 5,E + DE.B.B0|=1<<5; + break; + case 0xec: + // SET 5,H + HL.B.B1|=1<<5; + break; + case 0xed: + // SET 5,L + HL.B.B0|=1<<5; + break; + case 0xee: + // SET 5,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<5; + gbWriteMemory(HL.W,tempValue); + break; + case 0xef: + // SET 5,A + AF.B.B1|=1<<5; + break; + case 0xf0: + // SET 6,B + BC.B.B1|=1<<6; + break; + case 0xf1: + // SET 6,C + BC.B.B0|=1<<6; + break; + case 0xf2: + // SET 6,D + DE.B.B1|=1<<6; + break; + case 0xf3: + // SET 6,E + DE.B.B0|=1<<6; + break; + case 0xf4: + // SET 6,H + HL.B.B1|=1<<6; + break; + case 0xf5: + // SET 6,L + HL.B.B0|=1<<6; + break; + case 0xf6: + // SET 6,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<6; + gbWriteMemory(HL.W,tempValue); + break; + case 0xf7: + // SET 6,A + AF.B.B1|=1<<6; + break; + case 0xf8: + // SET 7,B + BC.B.B1|=1<<7; + break; + case 0xf9: + // SET 7,C + BC.B.B0|=1<<7; + break; + case 0xfa: + // SET 7,D + DE.B.B1|=1<<7; + break; + case 0xfb: + // SET 7,E + DE.B.B0|=1<<7; + break; + case 0xfc: + // SET 7,H + HL.B.B1|=1<<7; + break; + case 0xfd: + // SET 7,L + HL.B.B0|=1<<7; + break; + case 0xfe: + // SET 7,(HL) + tempValue=gbReadMemory(HL.W); + tempValue|=1<<7; + gbWriteMemory(HL.W,tempValue); + break; + case 0xff: + // SET 7,A + AF.B.B1|=1<<7; + break; + default: + systemMessage(0, N_("Unknown opcode %02x at %04x"), + gbReadOpcode(PC.W-1),PC.W-1); + emulating = false; + return; diff --git a/src/gb/gbDis.cpp b/src/gb/gbDis.cpp new file mode 100644 index 0000000..bf85f3a --- /dev/null +++ b/src/gb/gbDis.cpp @@ -0,0 +1,249 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include + +#include "../System.h" +#include "gbGlobals.h" + +typedef struct { + u8 mask; + u8 value; + char *mnen; +} GBOPCODE; + +#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff] + +static char *registers[] = + { "B", "C", "D", "E", "H", "L", "(HL)", "A" }; + +static char *registers16[] = + { "BC", "DE", "HL", "SP", // for some operations + "BC", "DE", "HL", "AF" }; // for push/pop + +static char *cond[] = + { "NZ", "Z", "NC", "C" }; + +static char hexDigits[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' +}; + +static GBOPCODE opcodes[] = { + { 0xff, 0x00, "NOP" }, + { 0xcf, 0x01, "LD %R4,%W" }, + { 0xff, 0x02, "LD (BC),A" }, + { 0xcf, 0x03, "INC %R4" }, + { 0xc7, 0x04, "INC %r3" }, + { 0xc7, 0x05, "DEC %r3" }, + { 0xc7, 0x06, "LD %r3,%B" }, + { 0xff, 0x07, "RLCA" }, + { 0xff, 0x08, "LD (%W),SP" }, + { 0xcf, 0x09, "ADD HL,%R4" }, + { 0xff, 0x0a, "LD A,(BC)" }, + { 0xcf, 0x0b, "DEC %R4" }, + { 0xff, 0x0f, "RRCA" }, + { 0xff, 0x10, "STOP" }, + { 0xff, 0x12, "LD (DE),A" }, + { 0xff, 0x17, "RLA" }, + { 0xff, 0x18, "JR %d" }, + { 0xff, 0x1a, "LD A,(DE)" }, + { 0xff, 0x1f, "RRA" }, + { 0xe7, 0x20, "JR %c3,%d" }, + { 0xff, 0x22, "LDI (HL),A" }, + { 0xff, 0x27, "DAA" }, + { 0xff, 0x2a, "LDI A,(HL)" }, + { 0xff, 0x2f, "CPL" }, + { 0xff, 0x32, "LDD (HL),A" }, + { 0xff, 0x37, "SCF" }, + { 0xff, 0x3a, "LDD A,(HL)" }, + { 0xff, 0x3f, "CCF" }, + { 0xff, 0x76, "HALT" }, + { 0xc0, 0x40, "LD %r3,%r0" }, + { 0xf8, 0x80, "ADD A,%r0" }, + { 0xf8, 0x88, "ADC A,%r0" }, + { 0xf8, 0x90, "SUB %r0" }, + { 0xf8, 0x98, "SBC A,%r0" }, + { 0xf8, 0xa0, "AND %r0" }, + { 0xf8, 0xa8, "XOR %r0" }, + { 0xf8, 0xb0, "OR %r0" }, + { 0xf8, 0xb8, "CP %r0" }, + { 0xe7, 0xc0, "RET %c3" }, + { 0xcf, 0xc1, "POP %t4" }, + { 0xe7, 0xc2, "JP %c3,%W" }, + { 0xff, 0xc3, "JP %W" }, + { 0xe7, 0xc4, "CALL %c3,%W" }, + { 0xcf, 0xc5, "PUSH %t4" }, + { 0xff, 0xc6, "ADD A,%B" }, + { 0xc7, 0xc7, "RST %P" }, + { 0xff, 0xc9, "RET" }, + { 0xff, 0xcd, "CALL %W" }, + { 0xff, 0xce, "ADC %B" }, + { 0xff, 0xd6, "SUB %B" }, + { 0xff, 0xd9, "RETI" }, + { 0xff, 0xde, "SBC %B" }, + { 0xff, 0xe0, "LD (FF%B),A" }, + { 0xff, 0xe2, "LD (FF00h+C),A" }, + { 0xff, 0xe6, "AND %B" }, + { 0xff, 0xe8, "ADD SP,%D" }, + { 0xff, 0xe9, "LD PC,HL" }, + { 0xff, 0xea, "LD (%W),A" }, + { 0xff, 0xee, "XOR %B" }, + { 0xff, 0xf0, "LD A,(FF%B)" }, + { 0xff, 0xf2, "LD A,(FF00h+C)" }, + { 0xff, 0xf3, "DI" }, + { 0xff, 0xf6, "OR %B" }, + { 0xff, 0xf8, "LD HL,SP%D" }, + { 0xff, 0xf9, "LD SP,HL" }, + { 0xff, 0xfa, "LD A,(%W)" }, + { 0xff, 0xfb, "EI" }, + { 0xff, 0xfe, "CP %B" }, + { 0x00, 0x00, "DB %B" } +}; + +static GBOPCODE cbOpcodes[] = { + { 0xf8, 0x00, "RLC %r0" }, + { 0xf8, 0x08, "RRC %r0" }, + { 0xf8, 0x10, "RL %r0" }, + { 0xf8, 0x18, "RR %r0" }, + { 0xf8, 0x20, "SLA %r0" }, + { 0xf8, 0x28, "SRA %r0" }, + { 0xf8, 0x30, "SWAP %r0" }, + { 0xf8, 0x38, "SRL %r0" }, + { 0xc0, 0x40, "BIT %b,%r0" }, + { 0xc0, 0x80, "RES %b,%r0" }, + { 0xc0, 0xc0, "SET %b,%r0" }, + { 0x00, 0x00, "DB CBh,%B" } +}; + +static char *addHex(char *p, u8 value) +{ + *p++ = hexDigits[value >> 4]; + *p++ = hexDigits[value & 15]; + return p; +} + +static char *addHex16(char *p, u16 value) +{ + p = addHex(p, value>>8); + return addHex(p, value & 255); +} + +static char *addStr(char *p, char *s) +{ + while(*s) { + *p++ = *s++; + } + return p; +} + +int gbDis(char *buffer, u16 address) +{ + char *p = buffer; + int instr = 1; + u16 addr = address; + sprintf(p, "%04x ", address); + p += 12; + + u8 opcode = GB_READ(address); + address++; + char *mnen; + GBOPCODE *op; + if(opcode == 0xcb) { + opcode = GB_READ(address); + address++; + instr++; + op = cbOpcodes; + } else { + op = opcodes; + } + while(op->value != (opcode & op->mask)) op++; + mnen = op->mnen; + + u8 b0, b1; + s8 disp; + int shift; + + while(*mnen) { + if(*mnen == '%') { + mnen++; + switch(*mnen++) { + case 'W': + b0 = GB_READ(address); + address++; + b1 = GB_READ(address); + address++; + p = addHex16(p, b0|b1<<8); + instr += 2; + *p++ = 'h'; + break; + case 'B': + p = addHex(p, GB_READ(address)); + *p++ = 'h'; + address++; + instr++; + break; + case 'D': + disp = GB_READ(address); + if(disp >= 0) + *p++ = '+'; + p += sprintf(p, "%d", disp); + instr++; + break; + case 'd': + disp = GB_READ(address); + address++; + p = addHex16(p, address+disp); + *p++ = 'h'; + instr++; + break; + case 'b': + // kind of a hack, but it works :-) + *p++ = hexDigits[(opcode >> 3) & 7]; + break; + case 'r': + shift = *mnen++ - '0'; + p = addStr(p, registers[(opcode >> shift) & 7]); + break; + case 'R': + shift = *mnen++ - '0'; + p = addStr(p, registers16[(opcode >> shift) & 3]); + break; + case 't': + shift = *mnen++ - '0'; + p = addStr(p, registers16[4+((opcode >> shift) & 3)]); + break; + case 'P': + p = addHex(p, ((opcode >> 3) & 7) * 8); + break; + case 'c': + shift = *mnen++ - '0'; + p = addStr(p, cond[(opcode >> shift) & 3]); + break; + } + } else + *p++ = *mnen++; + } + for(int i = 0; i < instr; i++) { + u16 a = addr + i; + addHex(buffer+5+i*2, GB_READ(a)); + } + *p = 0; + return instr; +} diff --git a/src/gb/gbGfx.cpp b/src/gb/gbGfx.cpp new file mode 100644 index 0000000..aa63966 --- /dev/null +++ b/src/gb/gbGfx.cpp @@ -0,0 +1,490 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include + +#include "../GBA.h" +#include "gbGlobals.h" +#include "gbSGB.h" + +u8 gbInvertTab[256] = { + 0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0, + 0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0, + 0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8, + 0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8, + 0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4, + 0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4, + 0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec, + 0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc, + 0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2, + 0x12,0x92,0x52,0xd2,0x32,0xb2,0x72,0xf2, + 0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea, + 0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfa, + 0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6, + 0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0xf6, + 0x0e,0x8e,0x4e,0xce,0x2e,0xae,0x6e,0xee, + 0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe, + 0x01,0x81,0x41,0xc1,0x21,0xa1,0x61,0xe1, + 0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0xf1, + 0x09,0x89,0x49,0xc9,0x29,0xa9,0x69,0xe9, + 0x19,0x99,0x59,0xd9,0x39,0xb9,0x79,0xf9, + 0x05,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5, + 0x15,0x95,0x55,0xd5,0x35,0xb5,0x75,0xf5, + 0x0d,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed, + 0x1d,0x9d,0x5d,0xdd,0x3d,0xbd,0x7d,0xfd, + 0x03,0x83,0x43,0xc3,0x23,0xa3,0x63,0xe3, + 0x13,0x93,0x53,0xd3,0x33,0xb3,0x73,0xf3, + 0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb, + 0x1b,0x9b,0x5b,0xdb,0x3b,0xbb,0x7b,0xfb, + 0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7, + 0x17,0x97,0x57,0xd7,0x37,0xb7,0x77,0xf7, + 0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef, + 0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff +}; + +u16 gbLineMix[160]; + +void gbRenderLine() +{ + u8 * bank0; + u8 * bank1; + if(gbCgbMode) { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } else { + bank0 = &gbMemory[0x8000]; + bank1 = NULL; + } + + int tile_map = 0x1800; + if((register_LCDC & 8) != 0) + tile_map = 0x1c00; + + int tile_pattern = 0x0800; + + if((register_LCDC & 16) != 0) + tile_pattern = 0x0000; + + int x = 0; + int y = register_LY; + + if(y >= 144) + return; + + // int yLine = (y + gbBorderRowSkip) * gbBorderLineSkip; + + int sx = register_SCX; + int sy = register_SCY; + + sy+=y; + + sy &= 255; + + int tx = sx >> 3; + int ty = sy >> 3; + + int bx = 1 << (7 - (sx & 7)); + int by = sy & 7; + + int tile_map_line_y = tile_map + ty * 32; + + int tile_map_address = tile_map_line_y + tx; + + u8 attrs = 0; + if(bank1 != NULL) + attrs = bank1[tile_map_address]; + + u8 tile = bank0[tile_map_address]; + + tile_map_address++; + + if((register_LCDC & 16) == 0) { + if(tile < 128) tile += 128; + else tile -= 128; + } + + int tile_pattern_address = tile_pattern + tile * 16 + by*2; + + if(register_LCDC & 0x80) { + if((register_LCDC & 0x01 || gbCgbMode) && (layerSettings & 0x0100)) { + while(x < 160) { + u8 tile_a = 0; + u8 tile_b = 0; + + if(attrs & 0x40) { + tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2; + } + + if(attrs & 0x08) { + tile_a = bank1[tile_pattern_address++]; + tile_b = bank1[tile_pattern_address]; + } else { + tile_a = bank0[tile_pattern_address++]; + tile_b = bank0[tile_pattern_address]; + } + + if(attrs & 0x20) { + tile_a = gbInvertTab[tile_a]; + tile_b = gbInvertTab[tile_b]; + } + + while(bx > 0) { + u8 c = (tile_a & bx) ? 1 : 0; + c += ((tile_b & bx) ? 2 : 0); + + gbLineBuffer[x] = c; // mark the gbLineBuffer color + + if(attrs & 0x80) + gbLineBuffer[x] |= 0x300; + + if(gbCgbMode) { + c = c + (attrs & 7)*4; + } else { + c = gbBgp[c]; + if(gbSgbMode && !gbCgbMode) { + int dx = x >> 3; + int dy = y >> 3; + + int palette = gbSgbATF[dy * 20 + dx]; + + if(c == 0) + palette = 0; + + c = c + 4*palette; + } + } + gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] : + gbPalette[c]; + x++; + if(x >= 160) + break; + bx >>= 1; + } + tx++; + if(tx == 32) + tx = 0; + bx = 128; + + if(bank1) + attrs = bank1[tile_map_line_y + tx]; + + tile = bank0[tile_map_line_y + tx]; + + if((register_LCDC & 16) == 0) { + if(tile < 128) tile += 128; + else tile -= 128; + } + tile_pattern_address = tile_pattern + tile * 16 + by * 2; + } + } else { + for(int i = 0; i < 160; i++) { + gbLineMix[i] = gbPalette[0]; + gbLineBuffer[i] = 0; + } + } + + // do the window display + if((register_LCDC & 0x20) && (layerSettings & 0x2000)) { + int wy = register_WY; + + if(y >= wy) { + int wx = register_WX; + wx -= 7; + + if( wx <= 159 && gbWindowLine <= 143) { + + tile_map = 0x1800; + + if((register_LCDC & 0x40) != 0) + tile_map = 0x1c00; + + if(gbWindowLine == -1) { + gbWindowLine = 0; + } + + tx = 0; + ty = gbWindowLine >> 3; + + bx = 128; + by = gbWindowLine & 7; + + if(wx < 0) { + bx >>= (-wx); + wx = 0; + } + + tile_map_line_y = tile_map + ty * 32; + + tile_map_address = tile_map_line_y + tx; + + x = wx; + + tile = bank0[tile_map_address]; + u8 attrs = 0; + if(bank1) + attrs = bank1[tile_map_address]; + tile_map_address++; + + if((register_LCDC & 16) == 0) { + if(tile < 128) tile += 128; + else tile -= 128; + } + + tile_pattern_address = tile_pattern + tile * 16 + by*2; + + while(x < 160) { + u8 tile_a = 0; + u8 tile_b = 0; + + if(attrs & 0x40) { + tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2; + } + + if(attrs & 0x08) { + tile_a = bank1[tile_pattern_address++]; + tile_b = bank1[tile_pattern_address]; + } else { + tile_a = bank0[tile_pattern_address++]; + tile_b = bank0[tile_pattern_address]; + } + + if(attrs & 0x20) { + tile_a = gbInvertTab[tile_a]; + tile_b = gbInvertTab[tile_b]; + } + + while(bx > 0) { + u8 c = (tile_a & bx) != 0 ? 1 : 0; + c += ((tile_b & bx) != 0 ? 2 : 0); + + if(attrs & 0x80) + gbLineBuffer[x] = 0x300 + c; + else + gbLineBuffer[x] = 0x100 + c; + + if(gbCgbMode) { + c = c + (attrs & 7) * 4; + } else { + c = gbBgp[c]; + if(gbSgbMode && ! gbCgbMode) { + int dx = x >> 3; + int dy = y >> 3; + + int palette = gbSgbATF[dy * 20 + dx]; + + if(c == 0) + palette = 0; + + c = c + 4*palette; + } + } + gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c]] : + gbPalette[c]; + x++; + if(x >= 160) + break; + bx >>= 1; + } + tx++; + if(tx == 32) + tx = 0; + bx = 128; + tile = bank0[tile_map_line_y + tx]; + if(bank1) + attrs = bank1[tile_map_line_y + tx]; + + if((register_LCDC & 16) == 0) { + if(tile < 128) tile += 128; + else tile -= 128; + } + tile_pattern_address = tile_pattern + tile * 16 + by * 2; + } + gbWindowLine++; + } + } + } + } else { + for(int i = 0; i < 160; i++) { + gbLineMix[i] = gbPalette[0]; + gbLineBuffer[i] = 0; + } + } +} + +void gbDrawSpriteTile(int tile, int x,int y,int t, int flags, + int size,int spriteNumber) +{ + u8 * bank0; + u8 * bank1; + if(gbCgbMode) { + if(register_VBK & 1) { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } else { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } + } else { + bank0 = &gbMemory[0x8000]; + bank1 = NULL; + } + + int init = 0x0000; + + // int yLine = (y+gbBorderRowSkip) * gbBorderLineSkip; + + u8 *pal = gbObp0; + + int flipx = (flags & 0x20); + int flipy = (flags & 0x40); + + if((flags & 0x10)) + pal = gbObp1; + + if(flipy) { + t = (size ? 15 : 7) - t; + } + + int prio = flags & 0x80; + + int address = init + tile * 16 + 2*t; + int a = 0; + int b = 0; + + if(gbCgbMode && flags & 0x08) { + a = bank1[address++]; + b = bank1[address++]; + } else { + a = bank0[address++]; + b = bank0[address++]; + } + + for(int xx = 0; xx < 8; xx++) { + u8 mask = 1 << (7-xx); + u8 c = 0; + if( (a & mask)) + c++; + if( (b & mask)) + c+=2; + + if(c==0) continue; + + int xxx = xx+x; + if(flipx) + xxx = (7-xx+x); + + if(xxx < 0 || xxx > 159) + continue; + + u16 color = gbLineBuffer[xxx]; + + if(prio) { + if(color < 0x200 && ((color & 0xFF) != 0)) + continue; + } + if(color >= 0x300 && color != 0x300) + continue; + else if(color >= 0x200 && color < 0x300) { + int sprite = color & 0xff; + + int spriteX = gbMemory[0xfe00 + 4 * sprite + 1] - 8; + + if(spriteX == x) { + if(sprite < spriteNumber) + continue; + } else { + if(gbCgbMode) { + if(sprite < spriteNumber) + continue; + } else { + if(spriteX < x+8) + continue; + } + } + } + + + gbLineBuffer[xxx] = 0x200 + spriteNumber; + + // make sure that sprites will work even in CGB mode + if(gbCgbMode) { + c = c + (flags & 0x07)*4 + 32; + } else { + c = pal[c]; + + if(gbSgbMode && !gbCgbMode) { + int dx = xxx >> 3; + int dy = y >> 3; + + int palette = gbSgbATF[dy * 20 + dx]; + + if(c == 0) + palette = 0; + + c = c + 4*palette; + } else { + c += 4; + } + } + + gbLineMix[xxx] = gbColorOption ? gbColorFilter[gbPalette[c]] : + gbPalette[c]; + } +} + +void gbDrawSprites() +{ + int x = 0; + int y = 0; + int count = 0; + + int size = (register_LCDC & 4); + + if(!(register_LCDC & 0x80)) + return; + + if((register_LCDC & 2) && (layerSettings & 0x1000)) { + int yc = register_LY; + + int address = 0xfe00; + for(int i = 0; i < 40; i++) { + y = gbMemory[address++]; + x = gbMemory[address++]; + int tile = gbMemory[address++]; + if(size) + tile &= 254; + int flags = gbMemory[address++]; + + if(x > 0 && y > 0 && x < 168 && y < 160) { + // check if sprite intersects current line + int t = yc -y + 16; + if(size && t >=0 && t < 16) { + gbDrawSpriteTile(tile,x-8,yc,t,flags,size,i); + count++; + } else if(!size && t >= 0 && t < 8) { + gbDrawSpriteTile(tile, x-8, yc, t, flags,size,i); + count++; + } + } + // sprite limit reached! + if(count >= 10) + break; + } + } +} + diff --git a/src/gb/gbGlobals.cpp b/src/gb/gbGlobals.cpp new file mode 100644 index 0000000..90b1af1 --- /dev/null +++ b/src/gb/gbGlobals.cpp @@ -0,0 +1,54 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "../GBA.h" + +u8 *gbMemoryMap[16]; + +int gbRomSizeMask = 0; +int gbRomSize = 0; +int gbRamSizeMask = 0; +int gbRamSize = 0; + +u8 *gbMemory = NULL; +u8 *gbVram = NULL; +u8 *gbRom = NULL; +u8 *gbRam = NULL; +u8 *gbWram = NULL; +u16 *gbLineBuffer = NULL; + +u16 gbPalette[128]; +u8 gbBgp[4] = { 0, 1, 2, 3}; +u8 gbObp0[4] = { 0, 1, 2, 3}; +u8 gbObp1[4] = { 0, 1, 2, 3}; +int gbWindowLine = -1; + +int gbCgbMode = 0; + +u16 gbColorFilter[32768]; +int gbColorOption = 0; +int gbPaletteOption = 0; +int gbEmulatorType = 0; +int gbBorderOn = 1; +int gbBorderAutomatic = 0; +int gbBorderLineSkip = 160; +int gbBorderRowSkip = 0; +int gbBorderColumnSkip = 0; +int gbDmaTicks = 0; + +u8 (*gbSerialFunction)(u8) = NULL; diff --git a/src/gb/gbGlobals.h b/src/gb/gbGlobals.h new file mode 100644 index 0000000..380f933 --- /dev/null +++ b/src/gb/gbGlobals.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +extern int gbRomSizeMask; +extern int gbRomSize; +extern int gbRamSize; +extern int gbRamSizeMask; + +extern u8 *gbRom; +extern u8 *gbRam; +extern u8 *gbVram; +extern u8 *gbWram; +extern u8 *gbMemory; +extern u16 *gbLineBuffer; + +extern u8 *gbMemoryMap[16]; + +extern int gbFrameSkip; +extern u16 gbColorFilter[32768]; +extern int gbColorOption; +extern int gbPaletteOption; +extern int gbEmulatorType; +extern int gbBorderOn; +extern int gbBorderAutomatic; +extern int gbCgbMode; +extern int gbSgbMode; +extern int gbWindowLine; +extern int gbSpeed; +extern u8 gbBgp[4]; +extern u8 gbObp0[4]; +extern u8 gbObp1[4]; +extern u16 gbPalette[128]; + +extern u8 register_LCDC; +extern u8 register_LY; +extern u8 register_SCY; +extern u8 register_SCX; +extern u8 register_WY; +extern u8 register_WX; +extern u8 register_VBK; + +extern int emulating; + +extern int gbBorderLineSkip; +extern int gbBorderRowSkip; +extern int gbBorderColumnSkip; +extern int gbDmaTicks; + +extern void gbRenderLine(); +extern void gbDrawSprites(); + +extern u8 (*gbSerialFunction)(u8); diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp new file mode 100644 index 0000000..3723dcd --- /dev/null +++ b/src/gb/gbMemory.cpp @@ -0,0 +1,979 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "../GBA.h" +#include "../Port.h" +#include "gbGlobals.h" +#include "gbMemory.h" +#include "../movie.h" + +mapperMBC1 gbDataMBC1 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // memory model + 0, // ROM high address + 0 // RAM address +}; + +// MBC1 ROM write registers +void mapperMBC1ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: // RAM enable register + gbDataMBC1.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0); + break; + case 0x2000: // ROM bank select + // value = value & 0x1f; + if(value == 0) + value = 1; + if(value == gbDataMBC1.mapperROMBank) + break; + + tmpAddress = value << 14; + + // check current model + if(gbDataMBC1.mapperMemoryModel == 0) { + // model is 16/8, so we have a high address in use + tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19; + } + + tmpAddress &= gbRomSizeMask; + gbDataMBC1.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + break; + case 0x4000: // RAM bank select + if(gbDataMBC1.mapperMemoryModel == 1) { + // 4/32 model, RAM bank switching provided + value = value & 0x03; + if(value == gbDataMBC1.mapperRAMBank) + break; + tmpAddress = value << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + gbDataMBC1.mapperRAMBank = value; + gbDataMBC1.mapperRAMAddress = tmpAddress; + } else { + // 16/8, set the high address + gbDataMBC1.mapperROMHighAddress = value & 0x03; + tmpAddress = gbDataMBC1.mapperROMBank << 14; + tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19; + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + } + break; + case 0x6000: // memory model select + gbDataMBC1.mapperMemoryModel = value & 1; + break; + } +} + +// MBC1 RAM write +void mapperMBC1RAM(u16 address, u8 value) +{ + if(gbDataMBC1.mapperRAMEnable) { + if(gbRamSize) { + gbMemoryMap[address >> 12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } +} + +void memoryUpdateMapMBC1() +{ + int tmpAddress = gbDataMBC1.mapperROMBank << 14; + + // check current model + if(gbDataMBC1.mapperMemoryModel == 1) { + // model is 16/8, so we have a high address in use + tmpAddress |= (gbDataMBC1.mapperROMHighAddress) << 19; + } + + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + if(gbRamSize) { + gbMemoryMap[0x0a] = &gbRam[gbDataMBC1.mapperRAMAddress]; + gbMemoryMap[0x0b] = &gbRam[gbDataMBC1.mapperRAMAddress + 0x1000]; + } +} + +mapperMBC2 gbDataMBC2 = { + 0, // RAM enable + 1 // ROM bank +}; + +// MBC2 ROM write registers +void mapperMBC2ROM(u16 address, u8 value) +{ + switch(address & 0x6000) { + case 0x0000: // RAM enable + if(!(address & 0x0100)) { + gbDataMBC2.mapperRAMEnable = (value & 0x0f) == 0x0a; + } + break; + case 0x2000: // ROM bank select + if(address & 0x0100) { + value &= 0x0f; + + if(value == 0) + value = 1; + if(gbDataMBC2.mapperROMBank != value) { + gbDataMBC2.mapperROMBank = value; + + int tmpAddress = value << 14; + + tmpAddress &= gbRomSizeMask; + + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + } + } + break; + } +} + +// MBC2 RAM write +void mapperMBC2RAM(u16 address, u8 value) +{ + if(gbDataMBC2.mapperRAMEnable) { + if(gbRamSize && address < 0xa200) { + gbMemoryMap[address >> 12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } +} + +void memoryUpdateMapMBC2() +{ + int tmpAddress = gbDataMBC2.mapperROMBank << 14; + + tmpAddress &= gbRomSizeMask; + + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; +} + +mapperMBC3 gbDataMBC3 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // RAM address + 0, // timer clock latch + 0, // timer clock register + 0, // timer seconds + 0, // timer minutes + 0, // timer hours + 0, // timer days + 0, // timer control + 0, // timer latched seconds + 0, // timer latched minutes + 0, // timer latched hours + 0, // timer latched days + 0, // timer latched control + (time_t)-1 // last time +}; + +void memoryUpdateMBC3Clock() +{ + time_t now; + + if(VBAMovieActive() || VBAMovieLoading()) + now = (time_t)(VBAMovieGetId() + VBAMovieGetFrameCounter()/60); /// FIXME: is /60 the right factor? + else + now = time(NULL); + + time_t diff = now - gbDataMBC3.mapperLastTime; + if(diff > 0) { + // update the clock according to the last update time + gbDataMBC3.mapperSeconds += diff % 60; + if(gbDataMBC3.mapperSeconds > 59) { + gbDataMBC3.mapperSeconds -= 60; + gbDataMBC3.mapperMinutes++; + } + + diff /= 60; + + gbDataMBC3.mapperMinutes += diff % 60; + if(gbDataMBC3.mapperMinutes > 60) { + gbDataMBC3.mapperMinutes -= 60; + gbDataMBC3.mapperHours++; + } + + diff /= 60; + + gbDataMBC3.mapperHours += diff % 24; + if(gbDataMBC3.mapperHours > 24) { + gbDataMBC3.mapperHours -= 24; + gbDataMBC3.mapperDays++; + } + diff /= 24; + + gbDataMBC3.mapperDays += diff; + if(gbDataMBC3.mapperDays > 255) { + if(gbDataMBC3.mapperDays > 511) { + gbDataMBC3.mapperDays %= 512; + gbDataMBC3.mapperControl |= 0x80; + } + gbDataMBC3.mapperControl = (gbDataMBC3.mapperControl & 0xfe) | + (gbDataMBC3.mapperDays>255 ? 1 : 0); + } + } + gbDataMBC3.mapperLastTime = now; +} + +// MBC3 ROM write registers +void mapperMBC3ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: // RAM enable register + gbDataMBC3.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0); + break; + case 0x2000: // ROM bank select + value = value & 0x7f; + if(value == 0) + value = 1; + if(value == gbDataMBC3.mapperROMBank) + break; + + tmpAddress = value << 14; + + tmpAddress &= gbRomSizeMask; + gbDataMBC3.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + break; + case 0x4000: // RAM bank select + if(value < 8) { + if(value == gbDataMBC3.mapperRAMBank) + break; + tmpAddress = value << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + gbDataMBC3.mapperRAMBank = value; + gbDataMBC3.mapperRAMAddress = tmpAddress; + } else { + if(gbDataMBC3.mapperRAMEnable) { + gbDataMBC3.mapperRAMBank = -1; + + gbDataMBC3.mapperClockRegister = value; + } + } + break; + case 0x6000: // clock latch + if(gbDataMBC3.mapperClockLatch == 0 && value == 1) { + memoryUpdateMBC3Clock(); + gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds; + gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes; + gbDataMBC3.mapperLHours = gbDataMBC3.mapperHours; + gbDataMBC3.mapperLDays = gbDataMBC3.mapperDays; + gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl; + } + if(value == 0x00 || value == 0x01) + gbDataMBC3.mapperClockLatch = value; + break; + } +} + +// MBC3 RAM write +void mapperMBC3RAM(u16 address, u8 value) +{ + if(gbDataMBC3.mapperRAMEnable) { + if(gbDataMBC3.mapperRAMBank != -1) { + if(gbRamSize) { + gbMemoryMap[address>>12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } else { + if(VBAMovieActive() || VBAMovieLoading()) + gbDataMBC3.mapperLastTime = VBAMovieGetId() + VBAMovieGetFrameCounter()/60; + else + time(&gbDataMBC3.mapperLastTime); + systemScreenMessage(ctime(&gbDataMBC3.mapperLastTime), 4); + + switch(gbDataMBC3.mapperClockRegister) { + case 0x08: + gbDataMBC3.mapperSeconds = value; + break; + case 0x09: + gbDataMBC3.mapperMinutes = value; + break; + case 0x0a: + gbDataMBC3.mapperHours = value; + break; + case 0x0b: + gbDataMBC3.mapperDays = value; + break; + case 0x0c: + if(gbDataMBC3.mapperControl & 0x80) + gbDataMBC3.mapperControl = 0x80 | value; + else + gbDataMBC3.mapperControl = value; + break; + } + } + } +} + +// MBC3 read RAM +u8 mapperMBC3ReadRAM(u16 address) +{ + if(gbDataMBC3.mapperRAMEnable) { + if(gbDataMBC3.mapperRAMBank != -1) { + return gbMemoryMap[address>>12][address & 0x0fff]; + } + + switch(gbDataMBC3.mapperClockRegister) { + case 0x08: + return gbDataMBC3.mapperLSeconds; + break; + case 0x09: + return gbDataMBC3.mapperLMinutes; + break; + case 0x0a: + return gbDataMBC3.mapperLHours; + break; + case 0x0b: + return gbDataMBC3.mapperLDays; + break; + case 0x0c: + return gbDataMBC3.mapperLControl; + } + } + return 0; +} + +void memoryUpdateMapMBC3() +{ + int tmpAddress = gbDataMBC3.mapperROMBank << 14; + + tmpAddress &= gbRomSizeMask; + + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + if(gbDataMBC3.mapperRAMBank >= 0 && gbRamSize) { + tmpAddress = gbDataMBC3.mapperRAMBank << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + } +} + +mapperMBC5 gbDataMBC5 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // ROM high address + 0, // RAM address + 0 // is rumble cartridge? +}; + +// MBC5 ROM write registers +void mapperMBC5ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: // RAM enable register + gbDataMBC5.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0); + break; + case 0x2000: // ROM bank select + if(address < 0x3000) { + value = value & 0xff; + if(value == gbDataMBC5.mapperROMBank) + break; + + tmpAddress = (value << 14) | (gbDataMBC5.mapperROMHighAddress << 22) ; + + tmpAddress &= gbRomSizeMask; + gbDataMBC5.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + } else { + value = value & 1; + if(value == gbDataMBC5.mapperROMHighAddress) + break; + + tmpAddress = (gbDataMBC5.mapperROMBank << 14) | (value << 22); + + tmpAddress &= gbRomSizeMask; + gbDataMBC5.mapperROMHighAddress = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + } + break; + case 0x4000: // RAM bank select + if(gbDataMBC5.isRumbleCartridge) + value &= 0x07; + else + value &= 0x0f; + if(value == gbDataMBC5.mapperRAMBank) + break; + tmpAddress = value << 13; + tmpAddress &= gbRamSizeMask; + if(gbRamSize) { + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + + gbDataMBC5.mapperRAMBank = value; + gbDataMBC5.mapperRAMAddress = tmpAddress; + } + break; + } +} + +// MBC5 RAM write +void mapperMBC5RAM(u16 address, u8 value) +{ + if(gbDataMBC5.mapperRAMEnable) { + if(gbRamSize) { + gbMemoryMap[address >> 12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } +} + +void memoryUpdateMapMBC5() +{ + int tmpAddress = (gbDataMBC5.mapperROMBank << 14) | + (gbDataMBC5.mapperROMHighAddress << 22) ; + + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + if(gbRamSize) { + tmpAddress = gbDataMBC5.mapperRAMBank << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + } +} + +mapperMBC7 gbDataMBC7 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // RAM address + 0, // chip select + 0, // ?? + 0, // mapper state + 0, // buffer for receiving serial data + 0, // idle state + 0, // count of bits received + 0, // command received + 0, // address received + 0, // write enable + 0, // value to return on ram +}; + +// MBC7 ROM write registers +void mapperMBC7ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: + break; + case 0x2000: // ROM bank select + value = value & 0x7f; + if(value == 0) + value = 1; + + if(value == gbDataMBC7.mapperROMBank) + break; + + tmpAddress = (value << 14); + + tmpAddress &= gbRomSizeMask; + gbDataMBC7.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + break; + case 0x4000: // RAM bank select/enable + if(value < 8) { + tmpAddress = (value&3) << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbMemory[0xa000]; + gbMemoryMap[0x0b] = &gbMemory[0xb000]; + + gbDataMBC7.mapperRAMBank = value; + gbDataMBC7.mapperRAMAddress = tmpAddress; + gbDataMBC7.mapperRAMEnable = 0; + } else { + gbDataMBC7.mapperRAMEnable = 0; + } + break; + } +} + +// MBC7 read RAM +u8 mapperMBC7ReadRAM(u16 address) +{ + switch(address & 0xa0f0) { + case 0xa000: + case 0xa010: + case 0xa060: + case 0xa070: + return 0; + case 0xa020: + // sensor X low byte + return systemGetSensorX() & 255; + case 0xa030: + // sensor X high byte + return systemGetSensorX() >> 8; + case 0xa040: + // sensor Y low byte + return systemGetSensorY() & 255; + case 0xa050: + // sensor Y high byte + return systemGetSensorY() >> 8; + case 0xa080: + return gbDataMBC7.value; + } + return 0xff; +} + +// MBC7 RAM write +void mapperMBC7RAM(u16 address, u8 value) +{ + if(address == 0xa080) { + // special processing needed + int oldCs = gbDataMBC7.cs,oldSk=gbDataMBC7.sk; + + gbDataMBC7.cs=value>>7; + gbDataMBC7.sk=(value>>6)&1; + + if(!oldCs && gbDataMBC7.cs) { + if(gbDataMBC7.state==5) { + if(gbDataMBC7.writeEnable) { + gbMemory[0xa000+gbDataMBC7.address*2]=gbDataMBC7.buffer>>8; + gbMemory[0xa000+gbDataMBC7.address*2+1]=gbDataMBC7.buffer&0xff; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + gbDataMBC7.state=0; + gbDataMBC7.value=1; + } else { + gbDataMBC7.idle=true; + gbDataMBC7.state=0; + } + } + + if(!oldSk && gbDataMBC7.sk) { + if(gbDataMBC7.idle) { + if(value & 0x02) { + gbDataMBC7.idle=false; + gbDataMBC7.count=0; + gbDataMBC7.state=1; + } + } else { + switch(gbDataMBC7.state) { + case 1: + // receiving command + gbDataMBC7.buffer <<= 1; + gbDataMBC7.buffer |= (value & 0x02)?1:0; + gbDataMBC7.count++; + if(gbDataMBC7.count==2) { + // finished receiving command + gbDataMBC7.state=2; + gbDataMBC7.count=0; + gbDataMBC7.code=gbDataMBC7.buffer & 3; + } + break; + case 2: + // receive address + gbDataMBC7.buffer <<= 1; + gbDataMBC7.buffer |= (value&0x02)?1:0; + gbDataMBC7.count++; + if(gbDataMBC7.count==8) { + // finish receiving + gbDataMBC7.state=3; + gbDataMBC7.count=0; + gbDataMBC7.address=gbDataMBC7.buffer&0xff; + if(gbDataMBC7.code==0) { + if((gbDataMBC7.address>>6)==0) { + gbDataMBC7.writeEnable=0; + gbDataMBC7.state=0; + } else if((gbDataMBC7.address>>6) == 3) { + gbDataMBC7.writeEnable=1; + gbDataMBC7.state=0; + } + } + } + break; + case 3: + gbDataMBC7.buffer <<= 1; + gbDataMBC7.buffer |= (value&0x02)?1:0; + gbDataMBC7.count++; + + switch(gbDataMBC7.code) { + case 0: + if(gbDataMBC7.count==16) { + if((gbDataMBC7.address>>6)==0) { + gbDataMBC7.writeEnable = 0; + gbDataMBC7.state=0; + } else if((gbDataMBC7.address>>6)==1) { + if (gbDataMBC7.writeEnable) { + for(int i=0;i<256;i++) { + gbMemory[0xa000+i*2] = gbDataMBC7.buffer >> 8; + gbMemory[0xa000+i*2+1] = gbDataMBC7.buffer & 0xff; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } + gbDataMBC7.state=5; + } else if((gbDataMBC7.address>>6) == 2) { + if (gbDataMBC7.writeEnable) { + for(int i=0;i<256;i++) + WRITE16LE((u16 *)&gbMemory[0xa000+i*2], 0xffff); + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + gbDataMBC7.state=5; + } else if((gbDataMBC7.address>>6)==3) { + gbDataMBC7.writeEnable = 1; + gbDataMBC7.state=0; + } + gbDataMBC7.count=0; + } + break; + case 1: + if(gbDataMBC7.count==16) { + gbDataMBC7.count=0; + gbDataMBC7.state=5; + gbDataMBC7.value=0; + } + break; + case 2: + if(gbDataMBC7.count==1) { + gbDataMBC7.state=4; + gbDataMBC7.count=0; + gbDataMBC7.buffer = (gbMemory[0xa000+gbDataMBC7.address*2]<<8)| + (gbMemory[0xa000+gbDataMBC7.address*2+1]); + } + break; + case 3: + if(gbDataMBC7.count==16) { + gbDataMBC7.count=0; + gbDataMBC7.state=5; + gbDataMBC7.value=0; + gbDataMBC7.buffer=0xffff; + } + break; + } + break; + } + } + } + + if (oldSk && !gbDataMBC7.sk) { + if (gbDataMBC7.state==4) { + gbDataMBC7.value = (gbDataMBC7.buffer & 0x8000)?1:0; + gbDataMBC7.buffer <<= 1; + gbDataMBC7.count++; + if (gbDataMBC7.count==16) { + gbDataMBC7.count=0; + gbDataMBC7.state=0; + } + } + } + } +} + +void memoryUpdateMapMBC7() +{ + int tmpAddress = (gbDataMBC5.mapperROMBank << 14); + + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; +} + +mapperHuC1 gbDataHuC1 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // memory model + 0, // ROM high address + 0 // RAM address +}; + +// HuC1 ROM write registers +void mapperHuC1ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: // RAM enable register + gbDataHuC1.mapperRAMEnable = ( ( value & 0x0a) == 0x0a ? 1 : 0); + break; + case 0x2000: // ROM bank select + value = value & 0x3f; + if(value == 0) + value = 1; + if(value == gbDataHuC1.mapperROMBank) + break; + + tmpAddress = value << 14; + + tmpAddress &= gbRomSizeMask; + gbDataHuC1.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + break; + case 0x4000: // RAM bank select + if(gbDataHuC1.mapperMemoryModel == 1) { + // 4/32 model, RAM bank switching provided + value = value & 0x03; + if(value == gbDataHuC1.mapperRAMBank) + break; + tmpAddress = value << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + gbDataHuC1.mapperRAMBank = value; + gbDataHuC1.mapperRAMAddress = tmpAddress; + } else { + // 16/8, set the high address + gbDataHuC1.mapperROMHighAddress = value & 0x03; + tmpAddress = gbDataHuC1.mapperROMBank << 14; + tmpAddress |= (gbDataHuC1.mapperROMHighAddress) << 19; + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + } + break; + case 0x6000: // memory model select + gbDataHuC1.mapperMemoryModel = value & 1; + break; + } +} + +// HuC1 RAM write +void mapperHuC1RAM(u16 address, u8 value) +{ + if(gbDataHuC1.mapperRAMEnable) { + if(gbRamSize) { + gbMemoryMap[address >> 12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } +} + +void memoryUpdateMapHuC1() +{ + int tmpAddress = gbDataHuC1.mapperROMBank << 14; + + tmpAddress &= gbRomSizeMask; + + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + if(gbRamSize) { + tmpAddress = gbDataHuC1.mapperRAMBank << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + } +} + +mapperHuC3 gbDataHuC3 = { + 0, // RAM enable + 1, // ROM bank + 0, // RAM bank + 0, // RAM address + 0, // RAM flag + 0 // RAM read value +}; + + +// HuC3 ROM write registers +void mapperHuC3ROM(u16 address, u8 value) +{ + int tmpAddress = 0; + + switch(address & 0x6000) { + case 0x0000: // RAM enable register + gbDataHuC3.mapperRAMEnable = ( value == 0x0a ? 1 : 0); + gbDataHuC3.mapperRAMFlag = value; + if(gbDataHuC3.mapperRAMFlag != 0x0a) + gbDataHuC3.mapperRAMBank = -1; + break; + case 0x2000: // ROM bank select + value = value & 0x7f; + if(value == 0) + value = 1; + if(value == gbDataHuC3.mapperROMBank) + break; + + tmpAddress = value << 14; + + tmpAddress &= gbRomSizeMask; + gbDataHuC3.mapperROMBank = value; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + break; + case 0x4000: // RAM bank select + value = value & 0x03; + if(value == gbDataHuC3.mapperRAMBank) + break; + tmpAddress = value << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + gbDataHuC3.mapperRAMBank = value; + gbDataHuC3.mapperRAMAddress = tmpAddress; + break; + case 0x6000: // nothing to do! + break; + } +} + +// HuC3 read RAM +u8 mapperHuC3ReadRAM(u16 address) +{ + if(gbDataHuC3.mapperRAMFlag > 0x0b && + gbDataHuC3.mapperRAMFlag < 0x0e) { + if(gbDataHuC3.mapperRAMFlag != 0x0c) + return 1; + return gbDataHuC3.mapperRAMValue; + } else + return gbMemoryMap[address >> 12][address & 0x0fff]; +} + +// HuC3 RAM write +void mapperHuC3RAM(u16 address, u8 value) +{ + int *p; + + if(gbDataHuC3.mapperRAMFlag < 0x0b || + gbDataHuC3.mapperRAMFlag > 0x0e) { + if(gbDataHuC3.mapperRAMEnable) { + if(gbRamSize) { + gbMemoryMap[address >> 12][address & 0x0fff] = value; + systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; + } + } + } else { + if(gbDataHuC3.mapperRAMFlag == 0x0b) { + if(value == 0x62) { + gbDataHuC3.mapperRAMValue = 1; + } else { + switch(value & 0xf0) { + case 0x10: + p = &gbDataHuC3.mapperRegister2; + gbDataHuC3.mapperRAMValue = *(p+gbDataHuC3.mapperRegister1++); + if(gbDataHuC3.mapperRegister1 > 6) + gbDataHuC3.mapperRegister1 = 0; + break; + case 0x30: + p = &gbDataHuC3.mapperRegister2; + *(p+gbDataHuC3.mapperRegister1++) = value & 0x0f; + if(gbDataHuC3.mapperRegister1 > 6) + gbDataHuC3.mapperRegister1 = 0; + gbDataHuC3.mapperAddress = + (gbDataHuC3.mapperRegister6 << 24) | + (gbDataHuC3.mapperRegister5 << 16) | + (gbDataHuC3.mapperRegister4 << 8) | + (gbDataHuC3.mapperRegister3 << 4) | + (gbDataHuC3.mapperRegister2); + break; + case 0x40: + gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0xf0) | + (value & 0x0f); + gbDataHuC3.mapperRegister2 = (gbDataHuC3.mapperAddress & 0x0f); + gbDataHuC3.mapperRegister3 = ((gbDataHuC3.mapperAddress>>4)&0x0f); + gbDataHuC3.mapperRegister4 = ((gbDataHuC3.mapperAddress>>8)&0x0f); + gbDataHuC3.mapperRegister5 = ((gbDataHuC3.mapperAddress>>16)&0x0f); + gbDataHuC3.mapperRegister6 = ((gbDataHuC3.mapperAddress>>24)&0x0f); + gbDataHuC3.mapperRegister7 = 0; + gbDataHuC3.mapperRegister8 = 0; + gbDataHuC3.mapperRAMValue = 0; + break; + case 0x50: + gbDataHuC3.mapperRegister1 = (gbDataHuC3.mapperRegister1 & 0x0f) | + ((value << 4)&0x0f); + break; + default: + gbDataHuC3.mapperRAMValue = 1; + break; + } + } + } + } +} + +void memoryUpdateMapHuC3() +{ + int tmpAddress = gbDataHuC3.mapperROMBank << 14; + + tmpAddress &= gbRomSizeMask; + gbMemoryMap[0x04] = &gbRom[tmpAddress]; + gbMemoryMap[0x05] = &gbRom[tmpAddress + 0x1000]; + gbMemoryMap[0x06] = &gbRom[tmpAddress + 0x2000]; + gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000]; + + if(gbRamSize) { + tmpAddress = gbDataHuC3.mapperRAMBank << 13; + tmpAddress &= gbRamSizeMask; + gbMemoryMap[0x0a] = &gbRam[tmpAddress]; + gbMemoryMap[0x0b] = &gbRam[tmpAddress + 0x1000]; + } +} diff --git a/src/gb/gbMemory.h b/src/gb/gbMemory.h new file mode 100644 index 0000000..9ce19ed --- /dev/null +++ b/src/gb/gbMemory.h @@ -0,0 +1,149 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include + +struct mapperMBC1 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperMemoryModel; + int mapperROMHighAddress; + int mapperRAMAddress; +}; + +struct mapperMBC2 { + int mapperRAMEnable; + int mapperROMBank; +}; + +struct mapperMBC3 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int mapperClockLatch; + int mapperClockRegister; + int mapperSeconds; + int mapperMinutes; + int mapperHours; + int mapperDays; + int mapperControl; + int mapperLSeconds; + int mapperLMinutes; + int mapperLHours; + int mapperLDays; + int mapperLControl; + time_t mapperLastTime; +}; + +struct mapperMBC5 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperROMHighAddress; + int mapperRAMAddress; + int isRumbleCartridge; +}; + +struct mapperMBC7 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int cs; + int sk; + int state; + int buffer; + int idle; + int count; + int code; + int address; + int writeEnable; + int value; +}; + +struct mapperHuC1 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperMemoryModel; + int mapperROMHighAddress; + int mapperRAMAddress; +}; + +struct mapperHuC3 { + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int mapperAddress; + int mapperRAMFlag; + int mapperRAMValue; + int mapperRegister1; + int mapperRegister2; + int mapperRegister3; + int mapperRegister4; + int mapperRegister5; + int mapperRegister6; + int mapperRegister7; + int mapperRegister8; +}; + +extern mapperMBC1 gbDataMBC1; +extern mapperMBC2 gbDataMBC2; +extern mapperMBC3 gbDataMBC3; +extern mapperMBC5 gbDataMBC5; +extern mapperHuC1 gbDataHuC1; +extern mapperHuC3 gbDataHuC3; + +void mapperMBC1ROM(u16,u8); +void mapperMBC1RAM(u16,u8); +void mapperMBC2ROM(u16,u8); +void mapperMBC2RAM(u16,u8); +void mapperMBC3ROM(u16,u8); +void mapperMBC3RAM(u16,u8); +u8 mapperMBC3ReadRAM(u16); +void mapperMBC5ROM(u16,u8); +void mapperMBC5RAM(u16,u8); +void mapperMBC7ROM(u16,u8); +void mapperMBC7RAM(u16,u8); +u8 mapperMBC7ReadRAM(u16); +void mapperHuC1ROM(u16,u8); +void mapperHuC1RAM(u16,u8); +void mapperHuC3ROM(u16,u8); +void mapperHuC3RAM(u16,u8); +u8 mapperHuC3ReadRAM(u16); + +//extern void (*mapper)(u16,u8); +//extern void (*mapperRAM)(u16,u8); +//extern u8 (*mapperReadRAM)(u16); + +extern void memoryUpdateMapMBC1(); +extern void memoryUpdateMapMBC2(); +extern void memoryUpdateMapMBC3(); +extern void memoryUpdateMapMBC5(); +extern void memoryUpdateMapMBC7(); +extern void memoryUpdateMapHuC1(); +extern void memoryUpdateMapHuC3(); + + + + + diff --git a/src/gb/gbPrinter.cpp b/src/gb/gbPrinter.cpp new file mode 100644 index 0000000..cf676c9 --- /dev/null +++ b/src/gb/gbPrinter.cpp @@ -0,0 +1,229 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include "../GBA.h" + +u8 gbPrinterStatus = 0; +int gbPrinterState = 0; +u8 gbPrinterData[0x280*9]; +u8 gbPrinterPacket[0x400]; +int gbPrinterCount = 0; +int gbPrinterDataCount = 0; +int gbPrinterDataSize = 0; +int gbPrinterResult = 0; + +bool gbPrinterCheckCRC() +{ + u16 crc = 0; + + for(int i = 2; i < (6+gbPrinterDataSize); i++) { + crc += gbPrinterPacket[i]; + } + + int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] + + (gbPrinterPacket[7+gbPrinterDataSize]<<8); + + return msgCrc == crc; +} + +void gbPrinterReset() +{ + gbPrinterState = 0; + gbPrinterDataSize = 0; + gbPrinterDataCount = 0; + gbPrinterCount = 0; + gbPrinterStatus = 0; + gbPrinterResult = 0; +} + +void gbPrinterShowData() +{ + systemGbPrint(gbPrinterData, + gbPrinterPacket[6], + gbPrinterPacket[7], + gbPrinterPacket[8], + gbPrinterPacket[9]); + /* + allegro_init(); + install_keyboard(); + set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0); + PALETTE pal; + pal[0].r = 255; + pal[0].g = 255; + pal[0].b = 255; + pal[1].r = 168; + pal[1].g = 168; + pal[1].b = 168; + pal[2].r = 96; + pal[2].g = 96; + pal[2].b = 96; + pal[3].r = 0; + pal[3].g = 0; + pal[3].b = 0; + set_palette(pal); + acquire_screen(); + u8 *data = gbPrinterData; + for(int y = 0; y < 0x12; y++) { + for(int x = 0; x < 0x14; x++) { + for(int k = 0; k < 8; k++) { + int a = *data++; + int b = *data++; + for(int j = 0; j < 8; j++) { + int mask = 1 << (7-j); + int c = 0; + if(a & mask) + c++; + if(b & mask) + c+=2; + putpixel(screen, x*8+j, y*8+k, c); + } + } + } + } + release_screen(); + while(!keypressed()) { + } + */ +} + +void gbPrinterReceiveData() +{ + if(gbPrinterPacket[3]) { // compressed + u8 *data = &gbPrinterPacket[6]; + u8 *dest = &gbPrinterData[gbPrinterDataCount]; + int len = 0; + while(len < gbPrinterDataSize) { + u8 control = *data++; + if(control & 0x80) { // repeated data + control &= 0x7f; + control += 2; + memset(dest, *data++, control); + len += control; + dest += control; + } else { // raw data + control++; + memcpy(dest, data, control); + dest += control; + data += control; + len += control; + } + } + } else { + memcpy(&gbPrinterData[gbPrinterDataCount], + &gbPrinterPacket[6], + gbPrinterDataSize); + gbPrinterDataCount += gbPrinterDataSize; + } +} + +void gbPrinterCommand() +{ + switch(gbPrinterPacket[2]) { + case 0x01: + // reset/initialize packet + gbPrinterDataCount = 0; + gbPrinterStatus = 0; + break; + case 0x02: + // print packet + gbPrinterShowData(); + break; + case 0x04: + // data packet + gbPrinterReceiveData(); + break; + case 0x0f: + // NUL packet + break; + } +} + +u8 gbPrinterSend(u8 b) +{ + switch(gbPrinterState) { + case 0: + gbPrinterCount = 0; + // receiving preamble + if(b == 0x88) { + gbPrinterPacket[gbPrinterCount++] = b; + gbPrinterState++; + } else { + // todo: handle failure + gbPrinterReset(); + } + break; + case 1: + // receiving preamble + if(b == 0x33) { + gbPrinterPacket[gbPrinterCount++] = b; + gbPrinterState++; + } else { + // todo: handle failure + gbPrinterReset(); + } + break; + case 2: + // receiving header + gbPrinterPacket[gbPrinterCount++] = b; + if(gbPrinterCount == 6) { + gbPrinterState++; + gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8); + } + break; + case 3: + // receiving data + if(gbPrinterDataSize) { + gbPrinterPacket[gbPrinterCount++] = b; + if(gbPrinterCount == (6+gbPrinterDataSize)) { + gbPrinterState++; + } + break; + } + gbPrinterState++; + // intentionally move to next if no data to receive + case 4: + // receiving CRC + gbPrinterPacket[gbPrinterCount++] = b; + gbPrinterState++; + break; + case 5: + // receiving CRC-2 + gbPrinterPacket[gbPrinterCount++] = b; + if(gbPrinterCheckCRC()) { + gbPrinterCommand(); + } + gbPrinterState++; + break; + case 6: + // receiving dummy 1 + gbPrinterPacket[gbPrinterCount++] = b; + gbPrinterResult = 0x81; + gbPrinterState++; + break; + case 7: + // receiving dummy 2 + gbPrinterPacket[gbPrinterCount++] = b; + gbPrinterResult = gbPrinterStatus; + gbPrinterState = 0; + gbPrinterCount = 0; + break; + } + return gbPrinterResult; +} diff --git a/src/gb/gbPrinter.h b/src/gb/gbPrinter.h new file mode 100644 index 0000000..9bebd4e --- /dev/null +++ b/src/gb/gbPrinter.h @@ -0,0 +1,20 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +extern u8 gbPrinterSend(u8 b); diff --git a/src/gb/gbSGB.cpp b/src/gb/gbSGB.cpp new file mode 100644 index 0000000..29d2e81 --- /dev/null +++ b/src/gb/gbSGB.cpp @@ -0,0 +1,919 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include + +#include "../System.h" +#include "../Port.h" +#include "../Util.h" +#include "GB.h" +#include "gbGlobals.h" +#include "../movie.h" + +extern u8 *pix; +extern bool speedup; + +#define GBSGB_NONE 0 +#define GBSGB_RESET 1 +#define GBSGB_PACKET_TRANSMIT 2 + +u8 gbSgbBorderChar [32 * 256]; +u8 gbSgbBorder [2048]; + +int gbSgbCGBSupport = 0; +int gbSgbMask = 0; +int gbSgbMode = 0; +int gbSgbPacketState = GBSGB_NONE; +int gbSgbBit = 0; +int gbSgbPacketTimeout = 0; +int GBSGB_PACKET_TIMEOUT = 66666; +u8 gbSgbPacket[16*7]; +int gbSgbPacketNBits = 0; +int gbSgbPacketByte = 0; +int gbSgbPacketNumber = 0; +int gbSgbMultiplayer = 0; +int gbSgbFourPlayers = 0; +u8 gbSgbNextController = 0x0f; +u8 gbSgbReadingController = 0; +u16 gbSgbSCPPalette[4*512]; +u8 gbSgbATF[20 * 18]; +u8 gbSgbATFList[45 * 20 * 18]; +u8 gbSgbScreenBuffer[4160]; + +inline void gbSgbDraw24Bit(u8 *p, u16 v) +{ + *((u32*) p) = systemColorMap32[v]; +} + +inline void gbSgbDraw32Bit(u32 *p, u16 v) +{ + *p = systemColorMap32[v]; +} + +inline void gbSgbDraw16Bit(u16 *p, u16 v) +{ + *p = systemColorMap16[v]; +} + +void gbSgbReset() +{ + gbSgbPacketTimeout = 0; + gbSgbCGBSupport = 0; + gbSgbMask = 0; + gbSgbPacketState = GBSGB_NONE; + gbSgbBit = 0; + gbSgbPacketNBits = 0; + gbSgbPacketNumber = 0; + gbSgbMultiplayer = 0; + gbSgbFourPlayers = 0; + gbSgbNextController = 0x0f; + gbSgbReadingController = 0; + + memset(gbSgbSCPPalette, 0, 512*4); + memset(gbSgbATF, 0, 20*18); + memset(gbSgbATFList, 0, 45 * 20 * 18); + memset(gbSgbPacket, 0, 16 * 7); + memset(gbSgbBorderChar, 0, 32*256); + memset(gbSgbBorder, 0, 2048); + + int i; + for(i = 1; i < 2048; i+=2) { + gbSgbBorder[i] = 1 << 2; + } + + for(i = 0; i < 4; i++) { + gbPalette[i*4] = (0x1f) | (0x1f << 5) | (0x1f << 10); + gbPalette[i*4+1] = (0x15) | (0x15 << 5) | (0x15 << 10); + gbPalette[i*4+2] = (0x0c) | (0x0c << 5) | (0x0c << 10); + gbPalette[i*4+3] = 0; + } +} + +void gbSgbInit() +{ + gbSgbReset(); +} + +void gbSgbShutdown() +{ + memset(gbSgbBorderChar, 0, 32*256); + memset(gbSgbBorder, 0, 2048); +} + +void gbSgbFillScreen(u16 color) +{ + switch(systemColorDepth) { + case 16: + { + for(int y = 0; y < 144; y++) { + int yLine = (y+gbBorderRowSkip+1)*(gbBorderLineSkip+2) + + gbBorderColumnSkip; + u16 *dest = (u16*)pix + yLine; + for(register int x = 0; x < 160; x++) + gbSgbDraw16Bit(dest++, color); + } + } + break; + case 24: + { + for(int y = 0; y < 144; y++) { + int yLine = (y+gbBorderRowSkip)*gbBorderLineSkip + gbBorderColumnSkip; + u8 *dest = (u8 *)pix + yLine*3; + for(register int x = 0; x < 160; x++) { + gbSgbDraw24Bit(dest, color); + dest += 3; + } + } + } + break; + case 32: + { + for(int y = 0; y < 144; y++) { + int yLine = (y+gbBorderRowSkip+1)*(gbBorderLineSkip+1) + gbBorderColumnSkip; + u32 *dest = (u32 *)pix + yLine; + for(register int x = 0; x < 160; x++) { + gbSgbDraw32Bit(dest++, color); + } + } + } + break; + } +} + +#define getmem(x) gbMemoryMap[(x) >> 12][(x) & 0xfff] + +void gbSgbRenderScreenToBuffer() +{ + u16 mapAddress = 0x9800; + + if(register_LCDC & 0x08) + mapAddress = 0x9c00; + + u16 patternAddress = 0x8800; + + int flag = 1; + + if(register_LCDC & 0x10) { + patternAddress = 0x8000; + flag = 0; + } + + u8 *toAddress = gbSgbScreenBuffer; + + for(int i = 0; i < 13; i++) { + for(int j = 0; j < 20; j++) { + int tile = getmem(mapAddress); + mapAddress++; + + if(flag) { + if(tile > 127) + tile -= 128; + else + tile += 128; + } + for(int k = 0; k < 16; k++) + *toAddress++ = getmem(patternAddress + tile*16 + k); + } + mapAddress += 12; + } +} + +void gbSgbDrawBorderTile(int x, int y, int tile, int attr) +{ + u16 *dest = (u16*)pix + ((y+1) * (256+2)) + x; + u8 *dest8 = (u8*)pix + ((y*256)+x)*3; + u32 *dest32 = (u32*)pix + ((y+1)*257) + x; + + u8 *tileAddress = &gbSgbBorderChar[tile * 32]; + u8 *tileAddress2 = &gbSgbBorderChar[tile * 32 + 16]; + + u8 l = 8; + + u8 palette = ((attr >> 2 ) & 7); + + if(palette < 4) + palette += 4; + + palette *= 16; + + u8 xx = 0; + u8 yy = 0; + + int flipX = attr & 0x40; + int flipY = attr & 0x80; + + while(l > 0) { + u8 mask = 0x80; + u8 a = *tileAddress++; + u8 b = *tileAddress++; + u8 c = *tileAddress2++; + u8 d = *tileAddress2++; + + while(mask > 0) { + + u8 color = 0; + if(a & mask) + color++; + if(b & mask) + color+=2; + if(c & mask) + color+=4; + if(d & mask) + color+=8; + + u8 xxx = xx; + u8 yyy = yy; + + if(flipX) + xxx = 7 - xx; + if(flipY) + yyy = 7 - yy; + + u16 c = gbPalette[palette + color]; + if(!color) + c = gbPalette[0]; + if((yy < 40 || yy >= 184) || (xx < 48 || xx >= 208)) { + switch(systemColorDepth) { + case 16: + gbSgbDraw16Bit(dest + yyy*(256+2) + xxx, c); + break; + case 24: + gbSgbDraw24Bit(dest8 + (yyy*256+xxx)*3, c); + break; + case 32: + gbSgbDraw32Bit(dest32 + yyy*(256+1)+xxx, c); + break; + } + } + + mask >>= 1; + + xx++; + } + yy++; + xx = 0; + l--; + mask = 0x80; + } +} + +void gbSgbRenderBorder() +{ + if(gbBorderOn) { + u8 *fromAddress = gbSgbBorder; + + for(u8 y = 0; y < 28; y++) { + for(u8 x = 0; x< 32; x++) { + u8 tile = *fromAddress++; + u8 attr = *fromAddress++; + + gbSgbDrawBorderTile(x*8,y*8,tile,attr); + } + } + } +} + +void gbSgbPicture() +{ + gbSgbRenderScreenToBuffer(); + + memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048); + + u16 *paletteAddr = (u16 *)&gbSgbScreenBuffer[2048]; + + for(int i = 64; i < 128; i++) { + gbPalette[i] = READ16LE(paletteAddr++); + } + + gbSgbCGBSupport |= 4; + + if(gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4) { + gbBorderOn = 1; + systemGbBorderOn(); + } + + if(gbBorderOn && !gbSgbMask) + gbSgbRenderBorder(); + + if(gbSgbMode && gbCgbMode && gbSgbCGBSupport > 4) { + gbSgbCGBSupport = 0; + gbSgbMode = 0; + gbSgbMask = 0; + gbSgbRenderBorder(); + VBAMovieSignalIgnoreNextReset(); + gbReset(); + } + + if(gbSgbCGBSupport > 4) + gbSgbCGBSupport = 0; +} + +void gbSgbSetPalette(int a,int b,u16 *p) +{ + u16 bit00 = READ16LE(p++); + int i; + + for(i = 1; i < 4; i++) { + gbPalette[a*4+i] = READ16LE(p++); + } + + for(i = 1; i < 4; i++) { + gbPalette[b*4+i] = READ16LE(p++); + } + + gbPalette[0] = gbPalette[4] = gbPalette[8] = gbPalette[12] = bit00; + if(gbBorderOn && !gbSgbMask) + gbSgbRenderBorder(); +} + +void gbSgbScpPalette() +{ + gbSgbRenderScreenToBuffer(); + + u16 *fromAddress = (u16 *)gbSgbScreenBuffer; + + for(int i = 0; i < 512*4; i++) { + gbSgbSCPPalette[i] = READ16LE(fromAddress++); + } +} + +void gbSgbSetATF(int n) +{ + if(n < 0) + n = 0; + if(n > 44) + n = 44; + memcpy(gbSgbATF,&gbSgbATFList[n * 20 * 18], 20 * 18); + + if(gbSgbPacket[1] & 0x40) { + gbSgbMask = 0; + if(gbBorderOn) + gbSgbRenderBorder(); + } +} + +void gbSgbSetPalette() +{ + u16 pal = READ16LE((((u16 *)&gbSgbPacket[1])))&511; + memcpy(&gbPalette[0], &gbSgbSCPPalette[pal*4], 4 * sizeof(u16)); + + pal = READ16LE((((u16 *)&gbSgbPacket[3])))&511; + memcpy(&gbPalette[4], &gbSgbSCPPalette[pal*4], 4 * sizeof(u16)); + + pal = READ16LE((((u16 *)&gbSgbPacket[5])))&511; + memcpy(&gbPalette[8], &gbSgbSCPPalette[pal*4], 4 * sizeof(u16)); + + pal = READ16LE((((u16 *)&gbSgbPacket[7])))&511; + memcpy(&gbPalette[12], &gbSgbSCPPalette[pal*4], 4 * sizeof(u16)); + + u8 atf = gbSgbPacket[9]; + + if(atf & 0x80) { + gbSgbSetATF(atf & 0x3f); + } + + if(atf & 0x40) { + gbSgbMask = 0; + if(gbBorderOn) + gbSgbRenderBorder(); + } +} + +void gbSgbAttributeBlock() +{ + u8 *fromAddress = &gbSgbPacket[1]; + + u8 nDataSet = *fromAddress++; + if(nDataSet > 12) + nDataSet = 12; + if(nDataSet == 0) + nDataSet = 1; + + while(nDataSet) { + u8 controlCode = (*fromAddress++) & 7; + u8 paletteDesignation = (*fromAddress++) & 0x3f; + u8 startH = (*fromAddress++) & 0x1f; + u8 startV = (*fromAddress++) & 0x1f; + u8 endH = (*fromAddress++) & 0x1f; + u8 endV = (*fromAddress++) & 0x1f; + + u8 * toAddress = gbSgbATF; + + for(u8 y = 0; y < 18; y++) { + for(u8 x = 0; x < 20; x++) { + if(x < startH || y < startV || + x > endH || y > endV) { + // outside + if(controlCode & 0x04) + *toAddress = (paletteDesignation >> 4) & 0x03; + } else if(x > startH && x < endH && + y > startV && y < endV) { + // inside + if(controlCode & 0x01) + *toAddress = paletteDesignation & 0x03; + } else { + // surrounding line + if(controlCode & 0x02) + *toAddress = (paletteDesignation>>2) & 0x03; + else if(controlCode == 0x01) + *toAddress = paletteDesignation & 0x03; + } + toAddress++; + } + } + nDataSet--; + } +} + +void gbSgbSetColumnPalette(u8 col, u8 p) +{ + // if(col < 0) + // col = 0; + if(col > 19) + col = 19; + + p &= 3; + + u8 *toAddress = &gbSgbATF[col]; + + for(u8 y = 0; y < 18; y++) { + *toAddress = p; + toAddress += 20; + } +} + +void gbSgbSetRowPalette(u8 row, u8 p) +{ + // if(row < 0) + // row = 0; + if(row > 17) + row = 17; + + p &= 3; + + u8 *toAddress = &gbSgbATF[row*20]; + + for(u8 x = 0; x < 20; x++) { + *toAddress++ = p; + } +} + +void gbSgbAttributeDivide() +{ + u8 control = gbSgbPacket[1]; + u8 coord = gbSgbPacket[2]; + u8 colorBR = control & 3; + u8 colorAL = (control >> 2) & 3; + u8 colorOL = (control >> 4) & 3; + + if(control & 0x40) { + if(coord > 17) + coord = 17; + + for(u8 i = 0; i < 18; i++) { + if(i < coord) + gbSgbSetRowPalette(i, colorAL); + else if ( i > coord) + gbSgbSetRowPalette(i, colorBR); + else + gbSgbSetRowPalette(i, colorOL); + } + } else { + if(coord > 19) + coord = 19; + + for(u8 i = 0; i < 20; i++) { + if(i < coord) + gbSgbSetColumnPalette(i, colorAL); + else if ( i > coord) + gbSgbSetColumnPalette(i, colorBR); + else + gbSgbSetColumnPalette(i, colorOL); + } + } +} + +void gbSgbAttributeLine() +{ + u8 *fromAddress = &gbSgbPacket[1]; + + u8 nDataSet = *fromAddress++; + + if(nDataSet > 0x6e) + nDataSet = 0x6e; + + while(nDataSet) { + u8 line = *fromAddress++; + u8 num = line & 0x1f; + u8 pal = (line >> 5) & 0x03; + if(line & 0x80) { + if(num > 17) + num = 17; + gbSgbSetRowPalette(num,pal); + } else { + if(num > 19) + num = 19; + gbSgbSetColumnPalette(num,pal); + } + nDataSet--; + } +} + +void gbSgbAttributeCharacter() +{ + u8 startH = gbSgbPacket[1] & 0x1f; + u8 startV = gbSgbPacket[2] & 0x1f; + int nDataSet = READ16LE(((u16 *)&gbSgbPacket[3])); + int style = gbSgbPacket[5] & 1; + if(startH > 19) + startH = 19; + if(startV > 17) + startV = 17; + + u8 s = 6; + u8 *fromAddress = &gbSgbPacket[6]; + u8 v = *fromAddress++; + + if(style) { + while(nDataSet) { + u8 p = (v >> s) & 3; + gbSgbATF[startV * 20 + startH] = p; + startV++; + if(startV == 18) { + startV = 0; + startH++; + if(startH == 20) + break; + } + + if(s) + s -= 2; + else { + s = 6; + v = *fromAddress++; + nDataSet--; + } + } + } else { + while(nDataSet) { + u8 p = (v >> s) & 3; + gbSgbATF[startV * 20 + startH] = p; + startH++; + if(startH == 20) { + startH = 0; + startV++; + if(startV == 18) + break; + } + + if(s) + s -= 2; + else { + s = 6; + v = *fromAddress++; + nDataSet--; + } + } + } +} + +void gbSgbSetATFList() +{ + gbSgbRenderScreenToBuffer(); + + u8 *fromAddress = gbSgbScreenBuffer; + u8 *toAddress = gbSgbATFList; + + for(int i = 0; i < 45; i++) { + for(int j = 0; j < 90; j++) { + u8 v = *fromAddress++; + u8 s = 6; + if(i == 2) + s = 6; + for(int k = 0; k < 4; k++) { + *toAddress++ = (v >> s) & 0x03; + s -= 2; + } + } + } +} + +void gbSgbMaskEnable() +{ + int gbSgbMaskFlag = gbSgbPacket[1] & 3; + + gbSgbMask = gbSgbMaskFlag; + + switch(gbSgbMaskFlag) { + case 1: + break; + case 2: + gbSgbFillScreen(0x0000); + // memset(&gbPalette[0], 0, 128*sizeof(u16)); + break; + case 3: + gbSgbFillScreen(gbPalette[0]); + break; + } + if(!gbSgbMask) { + if(gbBorderOn) + gbSgbRenderBorder(); + } +} + +void gbSgbChrTransfer() +{ + gbSgbRenderScreenToBuffer(); + + int address = (gbSgbPacket[1] & 1) * (128*32); + + if(gbSgbPacket[1] & 1) + gbSgbCGBSupport |= 2; + else + gbSgbCGBSupport |= 1; + + memcpy(&gbSgbBorderChar[address], gbSgbScreenBuffer, 128 * 32); + + if(gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4) { + gbBorderOn = 1; + systemGbBorderOn(); + } + + if(gbBorderOn && !gbSgbMask) + gbSgbRenderBorder(); + + if(gbSgbMode && gbCgbMode && gbSgbCGBSupport == 7) { + gbSgbCGBSupport = 0; + gbSgbMode = 0; + gbSgbMask = 0; + gbSgbRenderBorder(); + gbReset(); + } + + if(gbSgbCGBSupport > 4) + gbSgbCGBSupport = 0; +} + +void gbSgbMultiRequest() +{ + if(gbSgbPacket[1] & 1) { + gbSgbMultiplayer = 1; + if(gbSgbPacket[1] & 2) + gbSgbFourPlayers = 1; + else + gbSgbFourPlayers = 0; + gbSgbNextController = 0x0e; + } else { + gbSgbFourPlayers = 0; + gbSgbMultiplayer = 0; + gbSgbNextController = 0x0f; + } +} + +void gbSgbCommand() +{ + int command = gbSgbPacket[0] >> 3; + // int nPacket = gbSgbPacket[0] & 7; + + switch(command) { + case 0x00: + gbSgbSetPalette(0,1,(u16 *)&gbSgbPacket[1]); + break; + case 0x01: + gbSgbSetPalette(2,3,(u16 *)&gbSgbPacket[1]); + break; + case 0x02: + gbSgbSetPalette(0,3,(u16 *)&gbSgbPacket[1]); + break; + case 0x03: + gbSgbSetPalette(1,2,(u16 *)&gbSgbPacket[1]); + break; + case 0x04: + gbSgbAttributeBlock(); + break; + case 0x05: + gbSgbAttributeLine(); + break; + case 0x06: + gbSgbAttributeDivide(); + break; + case 0x07: + gbSgbAttributeCharacter(); + break; + case 0x0a: + gbSgbSetPalette(); + break; + case 0x0b: + gbSgbScpPalette(); + break; + case 0x11: + gbSgbMultiRequest(); + break; + case 0x13: + gbSgbChrTransfer(); + break; + case 0x14: + gbSgbPicture(); + break; + case 0x15: + gbSgbSetATFList(); + break; + case 0x16: + gbSgbSetATF(gbSgbPacket[1] & 0x3f); + break; + case 0x17: + gbSgbMaskEnable(); + break; + } +} + +void gbSgbResetPacketState() +{ + gbSgbPacketState = GBSGB_NONE; + gbSgbPacketTimeout = 0; +} + +void gbSgbDoBitTransfer(u8 value) +{ + value = value & 0x30; + switch(gbSgbPacketState) { + case GBSGB_NONE: + if(value == 0) { + gbSgbPacketState = GBSGB_RESET; + gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT; + } else if (value == 0x30) { + if(gbSgbMultiplayer) { + if((gbSgbReadingController & 7) == 7) { + gbSgbReadingController = 0; + if(gbSgbMultiplayer) { + gbSgbNextController--; + if(gbSgbFourPlayers) { + if(gbSgbNextController == 0x0b) + gbSgbNextController = 0x0f; + } else { + if(gbSgbNextController == 0x0d) + gbSgbNextController = 0x0f; + } + } + } else { + gbSgbReadingController &= 3; + } + } + gbSgbPacketTimeout = 0; + } else { + if(value == 0x10) + gbSgbReadingController |= 0x2; + else if(value == 0x20) + gbSgbReadingController |= 0x01; + gbSgbPacketTimeout = 0; + } + gbSgbPacketTimeout = 0; + break; + case GBSGB_RESET: + if(value == 0x30) { + gbSgbPacketState = GBSGB_PACKET_TRANSMIT; + gbSgbPacketByte = 0; + gbSgbPacketNBits = 0; + gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT; + } else if(value == 0x00) { + gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT; + gbSgbPacketState = GBSGB_RESET; + } else { + gbSgbPacketState = GBSGB_NONE; + gbSgbPacketTimeout = 0; + } + break; + case GBSGB_PACKET_TRANSMIT: + if(value == 0) { + gbSgbPacketState = GBSGB_RESET; + gbSgbPacketTimeout = 0; + } else if (value == 0x30){ + if(gbSgbPacketNBits == 128) { + gbSgbPacketNBits = 0; + gbSgbPacketByte = 0; + gbSgbPacketNumber++; + gbSgbPacketTimeout = 0; + if(gbSgbPacketNumber == (gbSgbPacket[0] & 7)) { + gbSgbCommand(); + gbSgbPacketNumber = 0; + gbSgbPacketState = GBSGB_NONE; + gbSgbPacketTimeout = 0; + } + } else { + if(gbSgbPacketNBits < 128) { + gbSgbPacket[gbSgbPacketNumber * 16 + gbSgbPacketByte] >>= 1; + gbSgbPacket[gbSgbPacketNumber * 16 + gbSgbPacketByte] |= gbSgbBit; + gbSgbPacketNBits++; + if(!(gbSgbPacketNBits & 7)) { + gbSgbPacketByte++; + } + gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT; + } + } + } else { + if(value == 0x20) + gbSgbBit = 0x00; + else + gbSgbBit = 0x80; + gbSgbPacketTimeout = GBSGB_PACKET_TIMEOUT; + } + gbSgbReadingController = 0; + break; + default: + gbSgbPacketState = GBSGB_NONE; + gbSgbPacketTimeout = 0; + break; + } +} + +variable_desc gbSgbSaveStruct[] = { + { &gbSgbMask, sizeof(int) }, + { &gbSgbPacketState, sizeof(int) }, + { &gbSgbBit, sizeof(int) }, + { &gbSgbPacketNBits, sizeof(int) }, + { &gbSgbPacketByte, sizeof(int) }, + { &gbSgbPacketNumber, sizeof(int) }, + { &gbSgbMultiplayer, sizeof(int) }, + { &gbSgbNextController, sizeof(u8) }, + { &gbSgbReadingController, sizeof(u8) }, + { NULL, 0 } +}; + +variable_desc gbSgbSaveStructV3[] = { + { &gbSgbMask, sizeof(int) }, + { &gbSgbPacketState, sizeof(int) }, + { &gbSgbBit, sizeof(int) }, + { &gbSgbPacketNBits, sizeof(int) }, + { &gbSgbPacketByte, sizeof(int) }, + { &gbSgbPacketNumber, sizeof(int) }, + { &gbSgbMultiplayer, sizeof(int) }, + { &gbSgbNextController, sizeof(u8) }, + { &gbSgbReadingController, sizeof(u8) }, + { &gbSgbFourPlayers, sizeof(int) }, + { NULL, 0 } +}; + + +void gbSgbSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, gbSgbSaveStructV3); + + utilGzWrite(gzFile, gbSgbBorder, 2048); + utilGzWrite(gzFile, gbSgbBorderChar, 32*256); + + utilGzWrite(gzFile, gbSgbPacket, 16*7); + + utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); + utilGzWrite(gzFile, gbSgbATF, 20 * 18); + utilGzWrite(gzFile, gbSgbATFList, 45 * 20 * 18); + + utilGzWrite(gzFile, gbSgbScreenBuffer, 4160); + utilGzWrite(gzFile, &gbSgbMode, sizeof(gbSgbMode)); + utilGzWrite(gzFile, &gbSgbCGBSupport, sizeof(gbSgbCGBSupport)); + utilGzWrite(gzFile, &gbSgbPacketTimeout, sizeof(gbSgbPacketTimeout)); +} + +void gbSgbReadGame(gzFile gzFile, int version) +{ + if(version >= 3) + utilReadData(gzFile, gbSgbSaveStructV3); + else { + utilReadData(gzFile, gbSgbSaveStruct); + gbSgbFourPlayers = 0; + } + + if(version >= 8) { + utilGzRead(gzFile, gbSgbBorder, 2048); + utilGzRead(gzFile, gbSgbBorderChar, 32*256); + } + + utilGzRead(gzFile, gbSgbPacket, 16*7); + + utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); + utilGzRead(gzFile, gbSgbATF, 20 * 18); + utilGzRead(gzFile, gbSgbATFList, 45 * 20 * 18); + + if(version >= 11) + { + utilGzRead(gzFile, gbSgbScreenBuffer, 4160); + utilGzRead(gzFile, &gbSgbMode, sizeof(gbSgbMode)); + utilGzRead(gzFile, &gbSgbCGBSupport, sizeof(gbSgbCGBSupport)); + utilGzRead(gzFile, &gbSgbPacketTimeout, sizeof(gbSgbPacketTimeout)); + } +} diff --git a/src/gb/gbSGB.h b/src/gb/gbSGB.h new file mode 100644 index 0000000..95afb2c --- /dev/null +++ b/src/gb/gbSGB.h @@ -0,0 +1,39 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +void gbSgbInit(); +void gbSgbShutdown(); +void gbSgbCommand(); +void gbSgbResetPacketState(); +void gbSgbReset(); +void gbSgbDoBitTransfer(u8); +void gbSgbSaveGame(gzFile); +void gbSgbReadGame(gzFile, int version); +void gbSgbRenderBorder(); + +extern u8 gbSgbATF[20*18]; +extern int gbSgbMode; +extern int gbSgbMask; +extern int gbSgbMultiplayer; +extern u8 gbSgbNextController; +extern int gbSgbPacketTimeout; +extern u8 gbSgbReadingController; +extern int gbSgbFourPlayers; + + diff --git a/src/gb/gbSound.cpp b/src/gb/gbSound.cpp new file mode 100644 index 0000000..b17304d --- /dev/null +++ b/src/gb/gbSound.cpp @@ -0,0 +1,973 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifdef WIN32 +# include "../win32/stdafx.h" +# include "../win32/VBA.h" +#endif + +#include + +#include "../System.h" +#include "../Util.h" +#include "gbGlobals.h" +#include "gbSound.h" + +extern u8 soundBuffer[6][735]; +extern u16 soundFinalWave[1470]; +extern int soundVolume; + +#define SOUND_MAGIC 0x60000000 +#define SOUND_MAGIC_2 0x30000000 +#define NOISE_MAGIC 5 + +extern int speed; + +extern void soundResume(); + +extern u8 soundWavePattern[4][32]; + +extern int soundBufferLen; +extern int soundBufferTotalLen; +extern int soundQuality; +extern int soundPaused; +extern int soundPlay; +extern int soundTicks; +extern int SOUND_CLOCK_TICKS; +extern u32 soundNextPosition; + +extern int soundLevel1; +extern int soundLevel2; +extern int soundBalance; +extern int soundMasterOn; +extern int soundIndex; +extern int soundBufferIndex; +int soundVIN = 0; +extern int soundDebug; + +extern int sound1On; +extern int sound1ATL; +extern int sound1Skip; +extern int sound1Index; +extern int sound1Continue; +extern int sound1EnvelopeVolume; +extern int sound1EnvelopeATL; +extern int sound1EnvelopeUpDown; +extern int sound1EnvelopeATLReload; +extern int sound1SweepATL; +extern int sound1SweepATLReload; +extern int sound1SweepSteps; +extern int sound1SweepUpDown; +extern int sound1SweepStep; +extern u8 *sound1Wave; + +extern int sound2On; +extern int sound2ATL; +extern int sound2Skip; +extern int sound2Index; +extern int sound2Continue; +extern int sound2EnvelopeVolume; +extern int sound2EnvelopeATL; +extern int sound2EnvelopeUpDown; +extern int sound2EnvelopeATLReload; +extern u8 *sound2Wave; + +extern int sound3On; +extern int sound3ATL; +extern int sound3Skip; +extern int sound3Index; +extern int sound3Continue; +extern int sound3OutputLevel; +extern int sound3Last; + +extern int sound4On; +extern int sound4Clock; +extern int sound4ATL; +extern int sound4Skip; +extern int sound4Index; +extern int sound4ShiftRight; +extern int sound4ShiftSkip; +extern int sound4ShiftIndex; +extern int sound4NSteps; +extern int sound4CountDown; +extern int sound4Continue; +extern int sound4EnvelopeVolume; +extern int sound4EnvelopeATL; +extern int sound4EnvelopeUpDown; +extern int sound4EnvelopeATLReload; + +extern int soundEnableFlag; + +extern int soundFreqRatio[8]; +extern int soundShiftClock[16]; + +extern s16 soundFilter[4000]; +extern s16 soundLeft[5]; +extern s16 soundRight[5]; +extern int soundEchoIndex; +extern bool soundEcho; +extern bool soundLowPass; +extern bool soundReverse; +extern bool soundOffFlag; + +bool gbDigitalSound = false; + +void gbSoundEvent(register u16 address, register int data) +{ + int freq = 0; + + gbMemory[address] = data; + +#ifndef FINAL_VERSION + if(soundDebug) { + // don't translate. debug only + log("Sound event: %08lx %02x\n", address, data); + } +#endif + switch(address) { + case NR10: + sound1SweepATL = sound1SweepATLReload = 344 * ((data >> 4) & 7); + sound1SweepSteps = data & 7; + sound1SweepUpDown = data & 0x08; + sound1SweepStep = 0; + break; + case NR11: + sound1Wave = soundWavePattern[data >> 6]; + sound1ATL = 172 * (64 - (data & 0x3f)); + break; + case NR12: + sound1EnvelopeVolume = data >> 4; + sound1EnvelopeUpDown = data & 0x08; + sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (data & 7); + break; + case NR13: + freq = (((int)(gbMemory[NR14] & 7)) << 8) | data; + sound1ATL = 172 * (64 - (gbMemory[NR11] & 0x3f)); + freq = 2048 - freq; + if(freq) { + sound1Skip = SOUND_MAGIC / freq; + } else + sound1Skip = 0; + break; + case NR14: + freq = (((int)(data&7) << 8) | gbMemory[NR13]); + freq = 2048 - freq; + sound1ATL = 172 * (64 - (gbMemory[NR11] & 0x3f)); + sound1Continue = data & 0x40; + if(freq) { + sound1Skip = SOUND_MAGIC / freq; + } else + sound1Skip = 0; + if(data & 0x80) { + gbMemory[NR52] |= 1; + sound1EnvelopeVolume = gbMemory[NR12] >> 4; + sound1EnvelopeUpDown = gbMemory[NR12] & 0x08; + sound1ATL = 172 * (64 - (gbMemory[NR11] & 0x3f)); + sound1EnvelopeATLReload = sound1EnvelopeATL = 689 * (gbMemory[NR12] & 7); + sound1SweepATL = sound1SweepATLReload = 344 * ((gbMemory[NR10] >> 4) & 7); + sound1SweepSteps = gbMemory[NR10] & 7; + sound1SweepUpDown = gbMemory[NR10] & 0x08; + sound1SweepStep = 0; + + sound1Index = 0; + sound1On = 1; + } + break; + case NR21: + sound2Wave = soundWavePattern[data >> 6]; + sound2ATL = 172 * (64 - (data & 0x3f)); + break; + case NR22: + sound2EnvelopeVolume = data >> 4; + sound2EnvelopeUpDown = data & 0x08; + sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (data & 7); + break; + case NR23: + freq = (((int)(gbMemory[NR24] & 7)) << 8) | data; + sound2ATL = 172 * (64 - (gbMemory[NR21] & 0x3f)); + freq = 2048 - freq; + if(freq) { + sound2Skip = SOUND_MAGIC / freq; + } else + sound2Skip = 0; + break; + case NR24: + freq = (((int)(data&7) << 8) | gbMemory[NR23]); + freq = 2048 - freq; + sound2ATL = 172 * (64 - (gbMemory[NR21] & 0x3f)); + sound2Continue = data & 0x40; + if(freq) { + sound2Skip = SOUND_MAGIC / freq; + } else + sound2Skip = 0; + if(data & 0x80) { + gbMemory[NR52] |= 2; + sound2EnvelopeVolume = gbMemory[NR22] >> 4; + sound2EnvelopeUpDown = gbMemory[NR22] & 0x08; + sound2ATL = 172 * (64 - (gbMemory[NR21] & 0x3f)); + sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (gbMemory[NR22] & 7); + + sound2Index = 0; + sound2On = 1; + } + break; + case NR30: + if(!(data & 0x80)) { + gbMemory[NR52] &= 0xfb; + sound3On = 0; + } + break; + case NR31: + sound3ATL = 172 * (256-data); + break; + case NR32: + sound3OutputLevel = (data >> 5) & 3; + break; + case NR33: + freq = 2048 - (((int)(gbMemory[NR34]&7) << 8) | data); + if(freq) { + sound3Skip = SOUND_MAGIC_2 / freq; + } else + sound3Skip = 0; + break; + case NR34: + freq = 2048 - (((data &7) << 8) | (int)gbMemory[NR33]); + if(freq) { + sound3Skip = SOUND_MAGIC_2 / freq; + } else { + sound3Skip = 0; + } + sound3Continue = data & 0x40; + if((data & 0x80) && (gbMemory[NR30] & 0x80)) { + gbMemory[NR52] |= 4; + sound3ATL = 172 * (256 - gbMemory[NR31]); + sound3Index = 0; + sound3On = 1; + } + break; + case NR41: + sound4ATL = 172 * (64 - (data & 0x3f)); + break; + case NR42: + sound4EnvelopeVolume = data >> 4; + sound4EnvelopeUpDown = data & 0x08; + sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (data & 7); + break; + case NR43: + freq = soundFreqRatio[data & 7]; + sound4NSteps = data & 0x08; + + sound4Skip = (freq << 8) / NOISE_MAGIC; + + sound4Clock = data >> 4; + + freq = freq / soundShiftClock[sound4Clock]; + + sound4ShiftSkip = (freq << 8) / NOISE_MAGIC; + + break; + case NR44: + sound4Continue = data & 0x40; + if(data & 0x80) { + gbMemory[NR52] |= 8; + sound4EnvelopeVolume = gbMemory[NR42] >> 4; + sound4EnvelopeUpDown = gbMemory[NR42] & 0x08; + sound4ATL = 172 * (64 - (gbMemory[NR41] & 0x3f)); + sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (gbMemory[NR42] & 7); + + sound4On = 1; + + sound4Index = 0; + sound4ShiftIndex = 0; + + freq = soundFreqRatio[gbMemory[NR43] & 7]; + + sound4Skip = (freq << 8) / NOISE_MAGIC; + + sound4NSteps = gbMemory[NR43] & 0x08; + + freq = freq / soundShiftClock[gbMemory[NR43] >> 4]; + + sound4ShiftSkip = (freq << 8) / NOISE_MAGIC; + if(sound4NSteps) + sound4ShiftRight = 0x7fff; + else + sound4ShiftRight = 0x7f; + } + break; + case NR50: + soundVIN = data & 0x88; + soundLevel1 = data & 7; + soundLevel2 = (data >> 4) & 7; + break; + case NR51: + soundBalance = (data & soundEnableFlag); + gbMemory[address] = data; + break; + case NR52: + soundMasterOn = data & 0x80; + if(!(data & 0x80)) { + sound1On = 0; + sound2On = 0; + sound3On = 0; + sound4On = 0; + } + break; + } + + gbDigitalSound = true; + + if(sound1On && sound1EnvelopeVolume != 0) + gbDigitalSound = false; + if(sound2On && sound2EnvelopeVolume != 0) + gbDigitalSound = false; + if(sound3On && sound3OutputLevel != 0) + gbDigitalSound = false; + if(sound4On && sound4EnvelopeVolume != 0) + gbDigitalSound = false; +} + + void gbSoundChannel1() +{ + int vol = sound1EnvelopeVolume; + + int freq = 0; + + int value = 0; + + if(sound1On && (sound1ATL || !sound1Continue)) { + sound1Index += soundQuality*sound1Skip; + sound1Index &= 0x1fffffff; + + value = ((s8)sound1Wave[sound1Index>>24]) * vol; + } + + soundBuffer[0][soundIndex] = value; + + + if(sound1On) { + if(sound1ATL) { + sound1ATL-=soundQuality; + + if(sound1ATL <=0 && sound1Continue) { + gbMemory[NR52] &= 0xfe; + sound1On = 0; + } + } + + if(sound1EnvelopeATL) { + sound1EnvelopeATL-=soundQuality; + + if(sound1EnvelopeATL<=0) { + if(sound1EnvelopeUpDown) { + if(sound1EnvelopeVolume < 15) + sound1EnvelopeVolume++; + } else { + if(sound1EnvelopeVolume) + sound1EnvelopeVolume--; + } + + sound1EnvelopeATL += sound1EnvelopeATLReload; + } + } + + if(sound1SweepATL) { + sound1SweepATL-=soundQuality; + + if(sound1SweepATL<=0) { + freq = (((int)(gbMemory[NR14]&7) << 8) | gbMemory[NR13]); + + int updown = 1; + + if(sound1SweepUpDown) + updown = -1; + + int newfreq = 0; + if(sound1SweepSteps) { + newfreq = freq + updown * freq / (1 << sound1SweepSteps); + if(newfreq == freq) + newfreq = 0; + } else + newfreq = freq; + + if(newfreq < 0) { + sound1SweepATL += sound1SweepATLReload; + } else if(newfreq > 2047) { + sound1SweepATL = 0; + sound1On = 0; + gbMemory[NR52] &= 0xfe; + } else { + sound1SweepATL += sound1SweepATLReload; + sound1Skip = SOUND_MAGIC/(2048 - newfreq); + + gbMemory[NR13] = newfreq & 0xff; + gbMemory[NR14] = (gbMemory[NR14] & 0xf8) |((newfreq >> 8) & 7); + } + } + } + } +} + +void gbSoundChannel2() +{ + // int freq = 0; + int vol = sound2EnvelopeVolume; + + int value = 0; + + if(sound2On && (sound2ATL || !sound2Continue)) { + sound2Index += soundQuality*sound2Skip; + sound2Index &= 0x1fffffff; + + value = ((s8)sound2Wave[sound2Index>>24]) * vol; + } + + soundBuffer[1][soundIndex] = value; + + if(sound2On) { + if(sound2ATL) { + sound2ATL-=soundQuality; + + if(sound2ATL <= 0 && sound2Continue) { + gbMemory[NR52] &= 0xfd; + sound2On = 0; + } + } + + if(sound2EnvelopeATL) { + sound2EnvelopeATL-=soundQuality; + + if(sound2EnvelopeATL <= 0) { + if(sound2EnvelopeUpDown) { + if(sound2EnvelopeVolume < 15) + sound2EnvelopeVolume++; + } else { + if(sound2EnvelopeVolume) + sound2EnvelopeVolume--; + } + sound2EnvelopeATL += sound2EnvelopeATLReload; + } + } + } +} + +void gbSoundChannel3() +{ + int value = sound3Last; + + if(sound3On && (sound3ATL || !sound3Continue)) { + sound3Index += soundQuality*sound3Skip; + sound3Index &= 0x1fffffff; + + value = gbMemory[0xff30 + (sound3Index>>25)]; + + if( (sound3Index & 0x01000000)) { + value &= 0x0f; + } else { + value >>= 4; + } + + value -= 8; + + switch(sound3OutputLevel) { + case 0: + value = 0; + break; + case 1: + break; + case 2: + value = (value >> 1); + break; + case 3: + value = (value >> 2); + break; + } + sound3Last = value; + } + + soundBuffer[2][soundIndex] = value; + + if(sound3On) { + if(sound3ATL) { + sound3ATL-=soundQuality; + + if(sound3ATL <= 0 && sound3Continue) { + gbMemory[NR52] &= 0xfb; + sound3On = 0; + } + } + } +} + +void gbSoundChannel4() +{ + int vol = sound4EnvelopeVolume; + + int value = 0; + + if(sound4Clock <= 0x0c) { + if(sound4On && (sound4ATL || !sound4Continue)) { + sound4Index += soundQuality*sound4Skip; + sound4ShiftIndex += soundQuality*sound4ShiftSkip; + + if(sound4NSteps) { + while(sound4ShiftIndex > 0x1fffff) { + sound4ShiftRight = (((sound4ShiftRight << 6) ^ + (sound4ShiftRight << 5)) & 0x40) | + (sound4ShiftRight >> 1); + sound4ShiftIndex -= 0x200000; + } + } else { + while(sound4ShiftIndex > 0x1fffff) { + sound4ShiftRight = (((sound4ShiftRight << 14) ^ + (sound4ShiftRight << 13)) & 0x4000) | + (sound4ShiftRight >> 1); + + sound4ShiftIndex -= 0x200000; + } + } + + sound4Index &= 0x1fffff; + sound4ShiftIndex &= 0x1fffff; + + value = ((sound4ShiftRight & 1)*2-1) * vol; + } else { + value = 0; + } + } + + soundBuffer[3][soundIndex] = value; + + if(sound4On) { + if(sound4ATL) { + sound4ATL-=soundQuality; + + if(sound4ATL <= 0 && sound4Continue) { + gbMemory[NR52] &= 0xfd; + sound4On = 0; + } + } + + if(sound4EnvelopeATL) { + sound4EnvelopeATL-=soundQuality; + + if(sound4EnvelopeATL <= 0) { + if(sound4EnvelopeUpDown) { + if(sound4EnvelopeVolume < 15) + sound4EnvelopeVolume++; + } else { + if(sound4EnvelopeVolume) + sound4EnvelopeVolume--; + } + sound4EnvelopeATL += sound4EnvelopeATLReload; + } + } + } +} + +void gbSoundMix() +{ + int res = 0; + + if(soundBalance & 16) { + res += ((s8)soundBuffer[0][soundIndex]); + } + if(soundBalance & 32) { + res += ((s8)soundBuffer[1][soundIndex]); + } + if(soundBalance & 64) { + res += ((s8)soundBuffer[2][soundIndex]); + } + if(soundBalance & 128) { + res += ((s8)soundBuffer[3][soundIndex]); + } + + if(gbDigitalSound) + res = soundLevel1*256; + else + res *= soundLevel1*60; + + if(soundEcho) { + res *= 2; + res += soundFilter[soundEchoIndex]; + res /= 2; + soundFilter[soundEchoIndex++] = res; + } + + if(soundLowPass) { + soundLeft[4] = soundLeft[3]; + soundLeft[3] = soundLeft[2]; + soundLeft[2] = soundLeft[1]; + soundLeft[1] = soundLeft[0]; + soundLeft[0] = res; + res = (soundLeft[4] + 2*soundLeft[3] + 8*soundLeft[2] + 2*soundLeft[1] + + soundLeft[0])/14; + } + + switch(soundVolume) { + case 0: + case 1: + case 2: + case 3: + res *= (soundVolume+1); + break; + case 4: + res >>= 2; + break; + case 5: + res >>= 1; + break; + } + + if(res > 32767) + res = 32767; + if(res < -32768) + res = -32768; + + if(soundReverse) + soundFinalWave[++soundBufferIndex] = res; + else + soundFinalWave[soundBufferIndex++] = res; + + res = 0; + + if(soundBalance & 1) { + res += ((s8)soundBuffer[0][soundIndex]); + } + if(soundBalance & 2) { + res += ((s8)soundBuffer[1][soundIndex]); + } + if(soundBalance & 4) { + res += ((s8)soundBuffer[2][soundIndex]); + } + if(soundBalance & 8) { + res += ((s8)soundBuffer[3][soundIndex]); + } + + if(gbDigitalSound) + res = soundLevel2*256; + else + res *= soundLevel2*60; + + if(soundEcho) { + res *= 2; + res += soundFilter[soundEchoIndex]; + res /= 2; + soundFilter[soundEchoIndex++] = res; + + if(soundEchoIndex >= 4000) + soundEchoIndex = 0; + } + + if(soundLowPass) { + soundRight[4] = soundRight[3]; + soundRight[3] = soundRight[2]; + soundRight[2] = soundRight[1]; + soundRight[1] = soundRight[0]; + soundRight[0] = res; + res = (soundRight[4] + 2*soundRight[3] + 8*soundRight[2] + 2*soundRight[1] + + soundRight[0])/14; + } + + switch(soundVolume) { + case 0: + case 1: + case 2: + case 3: + res *= (soundVolume+1); + break; + case 4: + res >>= 2; + break; + case 5: + res >>= 1; + break; + } + + if(res > 32767) + res = 32767; + if(res < -32768) + res = -32768; + + if(soundReverse) + soundFinalWave[-1+soundBufferIndex++] = res; + else + soundFinalWave[soundBufferIndex++] = res; +} + +void gbSoundTick() +{ + if(systemSoundOn) { + if(soundMasterOn +#if (defined(WIN32) && !defined(SDL)) + && !theApp.frameAdvanceMuteNow +#endif + ) { + gbSoundChannel1(); + gbSoundChannel2(); + gbSoundChannel3(); + gbSoundChannel4(); + + gbSoundMix(); + } else { + soundFinalWave[soundBufferIndex++] = 0; + soundFinalWave[soundBufferIndex++] = 0; + } + + soundIndex++; + + if(2*soundBufferIndex >= soundBufferLen) { + if(systemSoundOn) { + if(soundPaused) { + soundResume(); + } + + systemWriteDataToSoundBuffer(); + } + soundIndex = 0; + soundBufferIndex = 0; + } + } +} + +void gbSoundReset() +{ + soundPaused = 1; + soundPlay = 0; + SOUND_CLOCK_TICKS = soundQuality * 24; +// soundTicks = SOUND_CLOCK_TICKS; + soundTicks = 0; + soundNextPosition = 0; + soundMasterOn = 1; + soundIndex = 0; + soundBufferIndex = 0; + soundLevel1 = 7; + soundLevel2 = 7; + soundVIN = 0; + + sound1On = 0; + sound1ATL = 0; + sound1Skip = 0; + sound1Index = 0; + sound1Continue = 0; + sound1EnvelopeVolume = 0; + sound1EnvelopeATL = 0; + sound1EnvelopeUpDown = 0; + sound1EnvelopeATLReload = 0; + sound1SweepATL = 0; + sound1SweepATLReload = 0; + sound1SweepSteps = 0; + sound1SweepUpDown = 0; + sound1SweepStep = 0; + sound1Wave = soundWavePattern[2]; + + sound2On = 0; + sound2ATL = 0; + sound2Skip = 0; + sound2Index = 0; + sound2Continue = 0; + sound2EnvelopeVolume = 0; + sound2EnvelopeATL = 0; + sound2EnvelopeUpDown = 0; + sound2EnvelopeATLReload = 0; + sound2Wave = soundWavePattern[2]; + + sound3On = 0; + sound3ATL = 0; + sound3Skip = 0; + sound3Index = 0; + sound3Continue = 0; + sound3OutputLevel = 0; + + sound4On = 0; + sound4Clock = 0; + sound4ATL = 0; + sound4Skip = 0; + sound4Index = 0; + sound4ShiftRight = 0x7f; + sound4NSteps = 0; + sound4CountDown = 0; + sound4Continue = 0; + sound4EnvelopeVolume = 0; + sound4EnvelopeATL = 0; + sound4EnvelopeUpDown = 0; + sound4EnvelopeATLReload = 0; + + // don't translate + if(soundDebug) { + log("*** Sound Init ***\n"); + } + + gbSoundEvent(0xff10, 0x80); + gbSoundEvent(0xff11, 0xbf); + gbSoundEvent(0xff12, 0xf3); + gbSoundEvent(0xff14, 0xbf); + gbSoundEvent(0xff16, 0x3f); + gbSoundEvent(0xff17, 0x00); + gbSoundEvent(0xff19, 0xbf); + + gbSoundEvent(0xff1a, 0x7f); + gbSoundEvent(0xff1b, 0xff); + gbSoundEvent(0xff1c, 0xbf); + gbSoundEvent(0xff1e, 0xbf); + + gbSoundEvent(0xff20, 0xff); + gbSoundEvent(0xff21, 0x00); + gbSoundEvent(0xff22, 0x00); + gbSoundEvent(0xff23, 0xbf); + gbSoundEvent(0xff24, 0x77); + gbSoundEvent(0xff25, 0xf3); + + gbSoundEvent(0xff26, 0xf0); + + // don't translate + if(soundDebug) { + log("*** Sound Init Complete ***\n"); + } + + sound1On = 0; + sound2On = 0; + sound3On = 0; + sound4On = 0; + + int addr = 0xff30; + + while(addr < 0xff40) { + gbMemory[addr++] = 0x00; + gbMemory[addr++] = 0xff; + } + + memset(soundFinalWave, 0x00, soundBufferLen); + + + memset(soundFilter, 0, sizeof(soundFilter)); + soundEchoIndex = 0; +} + +extern bool soundInit(); +extern void soundShutdown(); + +void gbSoundSetQuality(int quality) +{ + if(soundQuality != quality && systemCanChangeSoundQuality()) { + if(!soundOffFlag) + soundShutdown(); + soundQuality = quality; + soundNextPosition = 0; + if(!soundOffFlag) + soundInit(); + SOUND_CLOCK_TICKS = (gbSpeed ? 2 : 1) * 24 * soundQuality; + soundIndex = 0; + soundBufferIndex = 0; + } else { + soundNextPosition = 0; + SOUND_CLOCK_TICKS = (gbSpeed ? 2 : 1) * 24 * soundQuality; + soundIndex = 0; + soundBufferIndex = 0; + } +} + +variable_desc gbSoundSaveStruct[] = { + { &soundPaused, sizeof(int) }, + { &soundPlay, sizeof(int) }, + { &soundTicks, sizeof(int) }, + { &SOUND_CLOCK_TICKS, sizeof(int) }, + { &soundLevel1, sizeof(int) }, + { &soundLevel2, sizeof(int) }, + { &soundBalance, sizeof(int) }, + { &soundMasterOn, sizeof(int) }, + { &soundIndex, sizeof(int) }, + { &soundVIN, sizeof(int) }, + { &sound1On, sizeof(int) }, + { &sound1ATL, sizeof(int) }, + { &sound1Skip, sizeof(int) }, + { &sound1Index, sizeof(int) }, + { &sound1Continue, sizeof(int) }, + { &sound1EnvelopeVolume, sizeof(int) }, + { &sound1EnvelopeATL, sizeof(int) }, + { &sound1EnvelopeATLReload, sizeof(int) }, + { &sound1EnvelopeUpDown, sizeof(int) }, + { &sound1SweepATL, sizeof(int) }, + { &sound1SweepATLReload, sizeof(int) }, + { &sound1SweepSteps, sizeof(int) }, + { &sound1SweepUpDown, sizeof(int) }, + { &sound1SweepStep, sizeof(int) }, + { &sound2On, sizeof(int) }, + { &sound2ATL, sizeof(int) }, + { &sound2Skip, sizeof(int) }, + { &sound2Index, sizeof(int) }, + { &sound2Continue, sizeof(int) }, + { &sound2EnvelopeVolume, sizeof(int) }, + { &sound2EnvelopeATL, sizeof(int) }, + { &sound2EnvelopeATLReload, sizeof(int) }, + { &sound2EnvelopeUpDown, sizeof(int) }, + { &sound3On, sizeof(int) }, + { &sound3ATL, sizeof(int) }, + { &sound3Skip, sizeof(int) }, + { &sound3Index, sizeof(int) }, + { &sound3Continue, sizeof(int) }, + { &sound3OutputLevel, sizeof(int) }, + { &sound4On, sizeof(int) }, + { &sound4ATL, sizeof(int) }, + { &sound4Skip, sizeof(int) }, + { &sound4Index, sizeof(int) }, + { &sound4Clock, sizeof(int) }, + { &sound4ShiftRight, sizeof(int) }, + { &sound4ShiftSkip, sizeof(int) }, + { &sound4ShiftIndex, sizeof(int) }, + { &sound4NSteps, sizeof(int) }, + { &sound4CountDown, sizeof(int) }, + { &sound4Continue, sizeof(int) }, + { &sound4EnvelopeVolume, sizeof(int) }, + { &sound4EnvelopeATL, sizeof(int) }, + { &sound4EnvelopeATLReload, sizeof(int) }, + { &sound4EnvelopeUpDown, sizeof(int) }, + { &soundEnableFlag, sizeof(int) }, + { NULL, 0 } +}; + +void gbSoundSaveGame(gzFile gzFile) +{ + utilWriteData(gzFile, gbSoundSaveStruct); + + utilGzWrite(gzFile, soundBuffer, 4*735); + utilGzWrite(gzFile, soundFinalWave, 2*735); + utilGzWrite(gzFile, &soundQuality, sizeof(int)); +} + +void gbSoundReadGame(int version,gzFile gzFile) +{ + utilReadData(gzFile, gbSoundSaveStruct); + + soundBufferIndex = soundIndex * 2; + + utilGzRead(gzFile, soundBuffer, 4*735); + utilGzRead(gzFile, soundFinalWave, 2*735); + + if(version >=7) { + int quality = 1; + utilGzRead(gzFile, &quality, sizeof(int)); + gbSoundSetQuality(quality); + } else { + soundQuality = -1; + gbSoundSetQuality(1); + } + + sound1Wave = soundWavePattern[gbMemory[NR11] >> 6]; + sound2Wave = soundWavePattern[gbMemory[NR21] >> 6]; +} diff --git a/src/gb/gbSound.h b/src/gb/gbSound.h new file mode 100644 index 0000000..50658b2 --- /dev/null +++ b/src/gb/gbSound.h @@ -0,0 +1,59 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#define NR10 0xff10 +#define NR11 0xff11 +#define NR12 0xff12 +#define NR13 0xff13 +#define NR14 0xff14 +#define NR21 0xff16 +#define NR22 0xff17 +#define NR23 0xff18 +#define NR24 0xff19 +#define NR30 0xff1a +#define NR31 0xff1b +#define NR32 0xff1c +#define NR33 0xff1d +#define NR34 0xff1e +#define NR41 0xff20 +#define NR42 0xff21 +#define NR43 0xff22 +#define NR44 0xff23 +#define NR50 0xff24 +#define NR51 0xff25 +#define NR52 0xff26 + +#define SOUND_EVENT(address,value) \ + gbSoundEvent(address,value) + +extern void gbSoundTick(); +extern void gbSoundPause(); +extern void gbSoundResume(); +extern void gbSoundEnable(int); +extern void gbSoundDisable(int); +extern int gbSoundGetEnable(); +extern void gbSoundReset(); +extern void gbSoundSaveGame(gzFile); +extern void gbSoundReadGame(int,gzFile); +extern void gbSoundEvent(register u16, register int); +extern void gbSoundSetQuality(int); + +extern int soundTicks; +extern int soundQuality; +extern int SOUND_CLOCK_TICKS; diff --git a/src/getopt.c b/src/getopt.c new file mode 100644 index 0000000..4235bad --- /dev/null +++ b/src/getopt.c @@ -0,0 +1,1060 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 + Free Software Foundation, Inc. + + NOTE: This source is derived from an old version taken from the GNU C + Library (glibc). + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +# ifdef HAVE_LIBINTL_H +# include +# define _(msgid) gettext (msgid) +# else +# define _(msgid) (msgid) +# endif +#endif + +#ifdef _MSC_VER +#include +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = NULL; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H +# include +# else +# if HAVE_STRINGS_H +# include +# endif +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#ifdef _LIBC + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#ifdef _LIBC + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#ifdef _LIBC +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/src/getopt.h b/src/getopt.h new file mode 100644 index 0000000..cb5feba --- /dev/null +++ b/src/getopt.h @@ -0,0 +1,141 @@ +/* Declarations for getopt. + Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000 + Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@gnu.org. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if defined (__STDC__) && __STDC__ + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#if defined (__STDC__) && __STDC__ +/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is + undefined, we haven't run the autoconf check so provide the + declaration without arguments. If it is 0, we checked and failed + to find the declaration so provide a fully prototyped one. If it + is 1, we found it so don't provide any declaration at all. */ +#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT) +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#else /* not __GNU_LIBRARY__ */ +# if !defined (HAVE_DECL_GETOPT) +extern int getopt (); +# endif +#endif /* __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* getopt.h */ diff --git a/src/getopt1.c b/src/getopt1.c new file mode 100644 index 0000000..a3637c2 --- /dev/null +++ b/src/getopt1.c @@ -0,0 +1,190 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 + Free Software Foundation, Inc. + + NOTE: This source is derived from an old version taken from the GNU C + Library (glibc). + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "getopt.h" + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am new file mode 100644 index 0000000..f55a545 --- /dev/null +++ b/src/gtk/Makefile.am @@ -0,0 +1,110 @@ +SUBDIRS = images + +bin_PROGRAMS = gvba + +noinst_LIBRARIES = libgba.a + +gvba_SOURCES = \ + configfile.cpp \ + configfile.h \ + filters.cpp \ + filters.h \ + input.cpp \ + input.h \ + intl.h \ + joypadconfig.cpp \ + joypadconfig.h \ + main.cpp \ + menuitem.h \ + screenarea.cpp \ + screenarea.h \ + sigccompat.h \ + system.cpp \ + tools.cpp \ + tools.h \ + windowcallbacks.cpp \ + window.cpp \ + window.h + +gvba_LDADD = libgba.a @VBA_LIBS@ @GTKMM_LIBS@ @LIBINTL@ @SDL_LIBS@ + +gvba_DEPENDENCIES = libgba.a @VBA_LIBS@ + +gvba_CPPFLAGS = \ + -DPKGDATADIR=\"$(pkgdatadir)\" \ + -DLOCALEDIR=\"$(datadir)/locale\" \ + -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ + $(GTKMM_CPPFLAGS) + +gvba_CXXFLAGS = @GTKMM_CFLAGS@ @SDL_CFLAGS@ + +libgba_a_SOURCES = \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bilinear.cpp \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../getopt.c \ + ../getopt.h \ + ../getopt1.c \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interframe.cpp \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + +libgba_a_CPPFLAGS = -DSDL + +libgba_a_CXXFLAGS = -fno-exceptions + +dist_pkgdata_DATA = vba.glade diff --git a/src/gtk/Makefile.in b/src/gtk/Makefile.in new file mode 100644 index 0000000..ad2aedc --- /dev/null +++ b/src/gtk/Makefile.in @@ -0,0 +1,1798 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +SUBDIRS = images + +bin_PROGRAMS = gvba + +noinst_LIBRARIES = libgba.a + +gvba_SOURCES = \ + configfile.cpp \ + configfile.h \ + filters.cpp \ + filters.h \ + input.cpp \ + input.h \ + intl.h \ + joypadconfig.cpp \ + joypadconfig.h \ + main.cpp \ + menuitem.h \ + screenarea.cpp \ + screenarea.h \ + sigccompat.h \ + system.cpp \ + tools.cpp \ + tools.h \ + windowcallbacks.cpp \ + window.cpp \ + window.h + + +gvba_LDADD = libgba.a @VBA_LIBS@ @GTKMM_LIBS@ @LIBINTL@ @SDL_LIBS@ + +gvba_DEPENDENCIES = libgba.a @VBA_LIBS@ + +gvba_CPPFLAGS = \ + -DPKGDATADIR=\"$(pkgdatadir)\" \ + -DLOCALEDIR=\"$(datadir)/locale\" \ + -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ + $(GTKMM_CPPFLAGS) + + +gvba_CXXFLAGS = @GTKMM_CFLAGS@ @SDL_CFLAGS@ + +libgba_a_SOURCES = \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bilinear.cpp \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../getopt.c \ + ../getopt.h \ + ../getopt1.c \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interframe.cpp \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + + +libgba_a_CPPFLAGS = -DSDL + +libgba_a_CXXFLAGS = -fno-exceptions + +dist_pkgdata_DATA = vba.glade +subdir = src/gtk +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + +libgba_a_AR = $(AR) cru +libgba_a_LIBADD = +am_libgba_a_OBJECTS = libgba_a-2xSaI.$(OBJEXT) libgba_a-Cheats.$(OBJEXT) \ + libgba_a-EEprom.$(OBJEXT) libgba_a-Flash.$(OBJEXT) \ + libgba_a-GBA.$(OBJEXT) libgba_a-Gfx.$(OBJEXT) \ + libgba_a-Globals.$(OBJEXT) libgba_a-Mode0.$(OBJEXT) \ + libgba_a-Mode1.$(OBJEXT) libgba_a-Mode2.$(OBJEXT) \ + libgba_a-Mode3.$(OBJEXT) libgba_a-Mode4.$(OBJEXT) \ + libgba_a-Mode5.$(OBJEXT) libgba_a-RTC.$(OBJEXT) \ + libgba_a-Sound.$(OBJEXT) libgba_a-Sram.$(OBJEXT) \ + libgba_a-Text.$(OBJEXT) libgba_a-Util.$(OBJEXT) \ + libgba_a-admame.$(OBJEXT) libgba_a-agbprint.$(OBJEXT) \ + libgba_a-armdis.$(OBJEXT) libgba_a-bilinear.$(OBJEXT) \ + libgba_a-bios.$(OBJEXT) libgba_a-elf.$(OBJEXT) \ + libgba_a-getopt.$(OBJEXT) libgba_a-getopt1.$(OBJEXT) \ + libgba_a-hq2x.$(OBJEXT) libgba_a-interframe.$(OBJEXT) \ + libgba_a-memgzio.$(OBJEXT) libgba_a-motionblur.$(OBJEXT) \ + libgba_a-pixel.$(OBJEXT) libgba_a-remote.$(OBJEXT) \ + libgba_a-scanline.$(OBJEXT) libgba_a-simple2x.$(OBJEXT) \ + libgba_a-unzip.$(OBJEXT) +libgba_a_OBJECTS = $(am_libgba_a_OBJECTS) +bin_PROGRAMS = gvba$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +am_gvba_OBJECTS = gvba-configfile.$(OBJEXT) gvba-filters.$(OBJEXT) \ + gvba-input.$(OBJEXT) gvba-joypadconfig.$(OBJEXT) \ + gvba-main.$(OBJEXT) gvba-screenarea.$(OBJEXT) \ + gvba-system.$(OBJEXT) gvba-tools.$(OBJEXT) \ + gvba-windowcallbacks.$(OBJEXT) gvba-window.$(OBJEXT) +gvba_OBJECTS = $(am_gvba_OBJECTS) +gvba_LDFLAGS = + +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/gvba-configfile.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-filters.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-input.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-joypadconfig.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-main.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-screenarea.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-system.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-tools.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-window.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/gvba-windowcallbacks.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-2xSaI.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Cheats.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-EEprom.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Flash.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-GBA.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Gfx.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Globals.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode0.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode1.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode2.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode3.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode4.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Mode5.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-RTC.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Sound.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Sram.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Text.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-Util.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-admame.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-agbprint.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-armdis.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-bilinear.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-bios.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-elf.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-getopt.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-getopt1.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-hq2x.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-interframe.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-memgzio.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-motionblur.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-pixel.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-remote.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-scanline.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-simple2x.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/libgba_a-unzip.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +DIST_SOURCES = $(libgba_a_SOURCES) $(gvba_SOURCES) +DATA = $(dist_pkgdata_DATA) + + +RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ + ps-recursive install-info-recursive uninstall-info-recursive \ + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ + check-recursive installcheck-recursive +DIST_COMMON = $(dist_pkgdata_DATA) $(srcdir)/Makefile.in Makefile.am +DIST_SUBDIRS = $(SUBDIRS) +SOURCES = $(libgba_a_SOURCES) $(gvba_SOURCES) + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .cpp .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/gtk/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + +AR = ar + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libgba.a: $(libgba_a_OBJECTS) $(libgba_a_DEPENDENCIES) + -rm -f libgba.a + $(libgba_a_AR) libgba.a $(libgba_a_OBJECTS) $(libgba_a_LIBADD) + $(RANLIB) libgba.a +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +gvba$(EXEEXT): $(gvba_OBJECTS) $(gvba_DEPENDENCIES) + @rm -f gvba$(EXEEXT) + $(CXXLINK) $(gvba_LDFLAGS) $(gvba_OBJECTS) $(gvba_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-configfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-filters.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-input.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-joypadconfig.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-screenarea.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-system.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-tools.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-window.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvba-windowcallbacks.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-2xSaI.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Cheats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-EEprom.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Flash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-GBA.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Gfx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Globals.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode0.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode3.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode4.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Mode5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-RTC.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Sound.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Sram.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Text.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-Util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-admame.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-agbprint.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-armdis.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-bilinear.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-bios.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-elf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-getopt1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-hq2x.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-interframe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-memgzio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-motionblur.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-pixel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-remote.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-scanline.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-simple2x.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgba_a-unzip.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` + +libgba_a-getopt.o: ../getopt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-getopt.o -MD -MP -MF "$(DEPDIR)/libgba_a-getopt.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-getopt.o `test -f '../getopt.c' || echo '$(srcdir)/'`../getopt.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-getopt.Tpo" "$(DEPDIR)/libgba_a-getopt.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-getopt.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt.c' object='libgba_a-getopt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-getopt.Po' tmpdepfile='$(DEPDIR)/libgba_a-getopt.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-getopt.o `test -f '../getopt.c' || echo '$(srcdir)/'`../getopt.c + +libgba_a-getopt.obj: ../getopt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-getopt.obj -MD -MP -MF "$(DEPDIR)/libgba_a-getopt.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-getopt.obj `if test -f '../getopt.c'; then $(CYGPATH_W) '../getopt.c'; else $(CYGPATH_W) '$(srcdir)/../getopt.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-getopt.Tpo" "$(DEPDIR)/libgba_a-getopt.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-getopt.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt.c' object='libgba_a-getopt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-getopt.Po' tmpdepfile='$(DEPDIR)/libgba_a-getopt.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-getopt.obj `if test -f '../getopt.c'; then $(CYGPATH_W) '../getopt.c'; else $(CYGPATH_W) '$(srcdir)/../getopt.c'; fi` + +libgba_a-getopt1.o: ../getopt1.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-getopt1.o -MD -MP -MF "$(DEPDIR)/libgba_a-getopt1.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-getopt1.o `test -f '../getopt1.c' || echo '$(srcdir)/'`../getopt1.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-getopt1.Tpo" "$(DEPDIR)/libgba_a-getopt1.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-getopt1.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt1.c' object='libgba_a-getopt1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-getopt1.Po' tmpdepfile='$(DEPDIR)/libgba_a-getopt1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-getopt1.o `test -f '../getopt1.c' || echo '$(srcdir)/'`../getopt1.c + +libgba_a-getopt1.obj: ../getopt1.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-getopt1.obj -MD -MP -MF "$(DEPDIR)/libgba_a-getopt1.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-getopt1.obj `if test -f '../getopt1.c'; then $(CYGPATH_W) '../getopt1.c'; else $(CYGPATH_W) '$(srcdir)/../getopt1.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-getopt1.Tpo" "$(DEPDIR)/libgba_a-getopt1.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-getopt1.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt1.c' object='libgba_a-getopt1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-getopt1.Po' tmpdepfile='$(DEPDIR)/libgba_a-getopt1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-getopt1.obj `if test -f '../getopt1.c'; then $(CYGPATH_W) '../getopt1.c'; else $(CYGPATH_W) '$(srcdir)/../getopt1.c'; fi` + +libgba_a-memgzio.o: ../memgzio.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-memgzio.o -MD -MP -MF "$(DEPDIR)/libgba_a-memgzio.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-memgzio.o `test -f '../memgzio.c' || echo '$(srcdir)/'`../memgzio.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-memgzio.Tpo" "$(DEPDIR)/libgba_a-memgzio.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-memgzio.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../memgzio.c' object='libgba_a-memgzio.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-memgzio.Po' tmpdepfile='$(DEPDIR)/libgba_a-memgzio.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-memgzio.o `test -f '../memgzio.c' || echo '$(srcdir)/'`../memgzio.c + +libgba_a-memgzio.obj: ../memgzio.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgba_a-memgzio.obj -MD -MP -MF "$(DEPDIR)/libgba_a-memgzio.Tpo" \ +@am__fastdepCC_TRUE@ -c -o libgba_a-memgzio.obj `if test -f '../memgzio.c'; then $(CYGPATH_W) '../memgzio.c'; else $(CYGPATH_W) '$(srcdir)/../memgzio.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libgba_a-memgzio.Tpo" "$(DEPDIR)/libgba_a-memgzio.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/libgba_a-memgzio.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../memgzio.c' object='libgba_a-memgzio.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libgba_a-memgzio.Po' tmpdepfile='$(DEPDIR)/libgba_a-memgzio.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgba_a-memgzio.obj `if test -f '../memgzio.c'; then $(CYGPATH_W) '../memgzio.c'; else $(CYGPATH_W) '$(srcdir)/../memgzio.c'; fi` + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` + +libgba_a-2xSaI.o: ../2xSaI.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-2xSaI.o -MD -MP -MF "$(DEPDIR)/libgba_a-2xSaI.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-2xSaI.o `test -f '../2xSaI.cpp' || echo '$(srcdir)/'`../2xSaI.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-2xSaI.Tpo" "$(DEPDIR)/libgba_a-2xSaI.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-2xSaI.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../2xSaI.cpp' object='libgba_a-2xSaI.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-2xSaI.Po' tmpdepfile='$(DEPDIR)/libgba_a-2xSaI.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-2xSaI.o `test -f '../2xSaI.cpp' || echo '$(srcdir)/'`../2xSaI.cpp + +libgba_a-2xSaI.obj: ../2xSaI.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-2xSaI.obj -MD -MP -MF "$(DEPDIR)/libgba_a-2xSaI.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-2xSaI.obj `if test -f '../2xSaI.cpp'; then $(CYGPATH_W) '../2xSaI.cpp'; else $(CYGPATH_W) '$(srcdir)/../2xSaI.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-2xSaI.Tpo" "$(DEPDIR)/libgba_a-2xSaI.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-2xSaI.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../2xSaI.cpp' object='libgba_a-2xSaI.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-2xSaI.Po' tmpdepfile='$(DEPDIR)/libgba_a-2xSaI.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-2xSaI.obj `if test -f '../2xSaI.cpp'; then $(CYGPATH_W) '../2xSaI.cpp'; else $(CYGPATH_W) '$(srcdir)/../2xSaI.cpp'; fi` + +libgba_a-Cheats.o: ../Cheats.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Cheats.o -MD -MP -MF "$(DEPDIR)/libgba_a-Cheats.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Cheats.o `test -f '../Cheats.cpp' || echo '$(srcdir)/'`../Cheats.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Cheats.Tpo" "$(DEPDIR)/libgba_a-Cheats.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Cheats.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Cheats.cpp' object='libgba_a-Cheats.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Cheats.Po' tmpdepfile='$(DEPDIR)/libgba_a-Cheats.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Cheats.o `test -f '../Cheats.cpp' || echo '$(srcdir)/'`../Cheats.cpp + +libgba_a-Cheats.obj: ../Cheats.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Cheats.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Cheats.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Cheats.obj `if test -f '../Cheats.cpp'; then $(CYGPATH_W) '../Cheats.cpp'; else $(CYGPATH_W) '$(srcdir)/../Cheats.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Cheats.Tpo" "$(DEPDIR)/libgba_a-Cheats.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Cheats.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Cheats.cpp' object='libgba_a-Cheats.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Cheats.Po' tmpdepfile='$(DEPDIR)/libgba_a-Cheats.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Cheats.obj `if test -f '../Cheats.cpp'; then $(CYGPATH_W) '../Cheats.cpp'; else $(CYGPATH_W) '$(srcdir)/../Cheats.cpp'; fi` + +libgba_a-EEprom.o: ../EEprom.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-EEprom.o -MD -MP -MF "$(DEPDIR)/libgba_a-EEprom.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-EEprom.o `test -f '../EEprom.cpp' || echo '$(srcdir)/'`../EEprom.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-EEprom.Tpo" "$(DEPDIR)/libgba_a-EEprom.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-EEprom.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../EEprom.cpp' object='libgba_a-EEprom.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-EEprom.Po' tmpdepfile='$(DEPDIR)/libgba_a-EEprom.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-EEprom.o `test -f '../EEprom.cpp' || echo '$(srcdir)/'`../EEprom.cpp + +libgba_a-EEprom.obj: ../EEprom.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-EEprom.obj -MD -MP -MF "$(DEPDIR)/libgba_a-EEprom.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-EEprom.obj `if test -f '../EEprom.cpp'; then $(CYGPATH_W) '../EEprom.cpp'; else $(CYGPATH_W) '$(srcdir)/../EEprom.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-EEprom.Tpo" "$(DEPDIR)/libgba_a-EEprom.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-EEprom.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../EEprom.cpp' object='libgba_a-EEprom.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-EEprom.Po' tmpdepfile='$(DEPDIR)/libgba_a-EEprom.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-EEprom.obj `if test -f '../EEprom.cpp'; then $(CYGPATH_W) '../EEprom.cpp'; else $(CYGPATH_W) '$(srcdir)/../EEprom.cpp'; fi` + +libgba_a-Flash.o: ../Flash.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Flash.o -MD -MP -MF "$(DEPDIR)/libgba_a-Flash.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Flash.o `test -f '../Flash.cpp' || echo '$(srcdir)/'`../Flash.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Flash.Tpo" "$(DEPDIR)/libgba_a-Flash.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Flash.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Flash.cpp' object='libgba_a-Flash.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Flash.Po' tmpdepfile='$(DEPDIR)/libgba_a-Flash.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Flash.o `test -f '../Flash.cpp' || echo '$(srcdir)/'`../Flash.cpp + +libgba_a-Flash.obj: ../Flash.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Flash.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Flash.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Flash.obj `if test -f '../Flash.cpp'; then $(CYGPATH_W) '../Flash.cpp'; else $(CYGPATH_W) '$(srcdir)/../Flash.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Flash.Tpo" "$(DEPDIR)/libgba_a-Flash.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Flash.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Flash.cpp' object='libgba_a-Flash.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Flash.Po' tmpdepfile='$(DEPDIR)/libgba_a-Flash.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Flash.obj `if test -f '../Flash.cpp'; then $(CYGPATH_W) '../Flash.cpp'; else $(CYGPATH_W) '$(srcdir)/../Flash.cpp'; fi` + +libgba_a-GBA.o: ../GBA.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-GBA.o -MD -MP -MF "$(DEPDIR)/libgba_a-GBA.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-GBA.o `test -f '../GBA.cpp' || echo '$(srcdir)/'`../GBA.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-GBA.Tpo" "$(DEPDIR)/libgba_a-GBA.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-GBA.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../GBA.cpp' object='libgba_a-GBA.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-GBA.Po' tmpdepfile='$(DEPDIR)/libgba_a-GBA.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-GBA.o `test -f '../GBA.cpp' || echo '$(srcdir)/'`../GBA.cpp + +libgba_a-GBA.obj: ../GBA.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-GBA.obj -MD -MP -MF "$(DEPDIR)/libgba_a-GBA.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-GBA.obj `if test -f '../GBA.cpp'; then $(CYGPATH_W) '../GBA.cpp'; else $(CYGPATH_W) '$(srcdir)/../GBA.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-GBA.Tpo" "$(DEPDIR)/libgba_a-GBA.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-GBA.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../GBA.cpp' object='libgba_a-GBA.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-GBA.Po' tmpdepfile='$(DEPDIR)/libgba_a-GBA.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-GBA.obj `if test -f '../GBA.cpp'; then $(CYGPATH_W) '../GBA.cpp'; else $(CYGPATH_W) '$(srcdir)/../GBA.cpp'; fi` + +libgba_a-Gfx.o: ../Gfx.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Gfx.o -MD -MP -MF "$(DEPDIR)/libgba_a-Gfx.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Gfx.o `test -f '../Gfx.cpp' || echo '$(srcdir)/'`../Gfx.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Gfx.Tpo" "$(DEPDIR)/libgba_a-Gfx.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Gfx.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Gfx.cpp' object='libgba_a-Gfx.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Gfx.Po' tmpdepfile='$(DEPDIR)/libgba_a-Gfx.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Gfx.o `test -f '../Gfx.cpp' || echo '$(srcdir)/'`../Gfx.cpp + +libgba_a-Gfx.obj: ../Gfx.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Gfx.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Gfx.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Gfx.obj `if test -f '../Gfx.cpp'; then $(CYGPATH_W) '../Gfx.cpp'; else $(CYGPATH_W) '$(srcdir)/../Gfx.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Gfx.Tpo" "$(DEPDIR)/libgba_a-Gfx.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Gfx.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Gfx.cpp' object='libgba_a-Gfx.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Gfx.Po' tmpdepfile='$(DEPDIR)/libgba_a-Gfx.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Gfx.obj `if test -f '../Gfx.cpp'; then $(CYGPATH_W) '../Gfx.cpp'; else $(CYGPATH_W) '$(srcdir)/../Gfx.cpp'; fi` + +libgba_a-Globals.o: ../Globals.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Globals.o -MD -MP -MF "$(DEPDIR)/libgba_a-Globals.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Globals.o `test -f '../Globals.cpp' || echo '$(srcdir)/'`../Globals.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Globals.Tpo" "$(DEPDIR)/libgba_a-Globals.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Globals.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Globals.cpp' object='libgba_a-Globals.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Globals.Po' tmpdepfile='$(DEPDIR)/libgba_a-Globals.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Globals.o `test -f '../Globals.cpp' || echo '$(srcdir)/'`../Globals.cpp + +libgba_a-Globals.obj: ../Globals.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Globals.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Globals.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Globals.obj `if test -f '../Globals.cpp'; then $(CYGPATH_W) '../Globals.cpp'; else $(CYGPATH_W) '$(srcdir)/../Globals.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Globals.Tpo" "$(DEPDIR)/libgba_a-Globals.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Globals.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Globals.cpp' object='libgba_a-Globals.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Globals.Po' tmpdepfile='$(DEPDIR)/libgba_a-Globals.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Globals.obj `if test -f '../Globals.cpp'; then $(CYGPATH_W) '../Globals.cpp'; else $(CYGPATH_W) '$(srcdir)/../Globals.cpp'; fi` + +libgba_a-Mode0.o: ../Mode0.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode0.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode0.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode0.o `test -f '../Mode0.cpp' || echo '$(srcdir)/'`../Mode0.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode0.Tpo" "$(DEPDIR)/libgba_a-Mode0.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode0.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode0.cpp' object='libgba_a-Mode0.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode0.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode0.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode0.o `test -f '../Mode0.cpp' || echo '$(srcdir)/'`../Mode0.cpp + +libgba_a-Mode0.obj: ../Mode0.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode0.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode0.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode0.obj `if test -f '../Mode0.cpp'; then $(CYGPATH_W) '../Mode0.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode0.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode0.Tpo" "$(DEPDIR)/libgba_a-Mode0.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode0.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode0.cpp' object='libgba_a-Mode0.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode0.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode0.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode0.obj `if test -f '../Mode0.cpp'; then $(CYGPATH_W) '../Mode0.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode0.cpp'; fi` + +libgba_a-Mode1.o: ../Mode1.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode1.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode1.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode1.o `test -f '../Mode1.cpp' || echo '$(srcdir)/'`../Mode1.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode1.Tpo" "$(DEPDIR)/libgba_a-Mode1.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode1.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode1.cpp' object='libgba_a-Mode1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode1.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode1.o `test -f '../Mode1.cpp' || echo '$(srcdir)/'`../Mode1.cpp + +libgba_a-Mode1.obj: ../Mode1.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode1.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode1.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode1.obj `if test -f '../Mode1.cpp'; then $(CYGPATH_W) '../Mode1.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode1.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode1.Tpo" "$(DEPDIR)/libgba_a-Mode1.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode1.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode1.cpp' object='libgba_a-Mode1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode1.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode1.obj `if test -f '../Mode1.cpp'; then $(CYGPATH_W) '../Mode1.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode1.cpp'; fi` + +libgba_a-Mode2.o: ../Mode2.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode2.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode2.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode2.o `test -f '../Mode2.cpp' || echo '$(srcdir)/'`../Mode2.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode2.Tpo" "$(DEPDIR)/libgba_a-Mode2.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode2.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode2.cpp' object='libgba_a-Mode2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode2.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode2.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode2.o `test -f '../Mode2.cpp' || echo '$(srcdir)/'`../Mode2.cpp + +libgba_a-Mode2.obj: ../Mode2.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode2.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode2.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode2.obj `if test -f '../Mode2.cpp'; then $(CYGPATH_W) '../Mode2.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode2.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode2.Tpo" "$(DEPDIR)/libgba_a-Mode2.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode2.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode2.cpp' object='libgba_a-Mode2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode2.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode2.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode2.obj `if test -f '../Mode2.cpp'; then $(CYGPATH_W) '../Mode2.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode2.cpp'; fi` + +libgba_a-Mode3.o: ../Mode3.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode3.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode3.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode3.o `test -f '../Mode3.cpp' || echo '$(srcdir)/'`../Mode3.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode3.Tpo" "$(DEPDIR)/libgba_a-Mode3.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode3.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode3.cpp' object='libgba_a-Mode3.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode3.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode3.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode3.o `test -f '../Mode3.cpp' || echo '$(srcdir)/'`../Mode3.cpp + +libgba_a-Mode3.obj: ../Mode3.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode3.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode3.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode3.obj `if test -f '../Mode3.cpp'; then $(CYGPATH_W) '../Mode3.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode3.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode3.Tpo" "$(DEPDIR)/libgba_a-Mode3.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode3.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode3.cpp' object='libgba_a-Mode3.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode3.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode3.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode3.obj `if test -f '../Mode3.cpp'; then $(CYGPATH_W) '../Mode3.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode3.cpp'; fi` + +libgba_a-Mode4.o: ../Mode4.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode4.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode4.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode4.o `test -f '../Mode4.cpp' || echo '$(srcdir)/'`../Mode4.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode4.Tpo" "$(DEPDIR)/libgba_a-Mode4.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode4.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode4.cpp' object='libgba_a-Mode4.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode4.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode4.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode4.o `test -f '../Mode4.cpp' || echo '$(srcdir)/'`../Mode4.cpp + +libgba_a-Mode4.obj: ../Mode4.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode4.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode4.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode4.obj `if test -f '../Mode4.cpp'; then $(CYGPATH_W) '../Mode4.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode4.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode4.Tpo" "$(DEPDIR)/libgba_a-Mode4.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode4.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode4.cpp' object='libgba_a-Mode4.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode4.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode4.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode4.obj `if test -f '../Mode4.cpp'; then $(CYGPATH_W) '../Mode4.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode4.cpp'; fi` + +libgba_a-Mode5.o: ../Mode5.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode5.o -MD -MP -MF "$(DEPDIR)/libgba_a-Mode5.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode5.o `test -f '../Mode5.cpp' || echo '$(srcdir)/'`../Mode5.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode5.Tpo" "$(DEPDIR)/libgba_a-Mode5.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode5.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode5.cpp' object='libgba_a-Mode5.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode5.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode5.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode5.o `test -f '../Mode5.cpp' || echo '$(srcdir)/'`../Mode5.cpp + +libgba_a-Mode5.obj: ../Mode5.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Mode5.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Mode5.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Mode5.obj `if test -f '../Mode5.cpp'; then $(CYGPATH_W) '../Mode5.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode5.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Mode5.Tpo" "$(DEPDIR)/libgba_a-Mode5.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Mode5.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode5.cpp' object='libgba_a-Mode5.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Mode5.Po' tmpdepfile='$(DEPDIR)/libgba_a-Mode5.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Mode5.obj `if test -f '../Mode5.cpp'; then $(CYGPATH_W) '../Mode5.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode5.cpp'; fi` + +libgba_a-RTC.o: ../RTC.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-RTC.o -MD -MP -MF "$(DEPDIR)/libgba_a-RTC.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-RTC.o `test -f '../RTC.cpp' || echo '$(srcdir)/'`../RTC.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-RTC.Tpo" "$(DEPDIR)/libgba_a-RTC.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-RTC.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../RTC.cpp' object='libgba_a-RTC.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-RTC.Po' tmpdepfile='$(DEPDIR)/libgba_a-RTC.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-RTC.o `test -f '../RTC.cpp' || echo '$(srcdir)/'`../RTC.cpp + +libgba_a-RTC.obj: ../RTC.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-RTC.obj -MD -MP -MF "$(DEPDIR)/libgba_a-RTC.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-RTC.obj `if test -f '../RTC.cpp'; then $(CYGPATH_W) '../RTC.cpp'; else $(CYGPATH_W) '$(srcdir)/../RTC.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-RTC.Tpo" "$(DEPDIR)/libgba_a-RTC.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-RTC.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../RTC.cpp' object='libgba_a-RTC.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-RTC.Po' tmpdepfile='$(DEPDIR)/libgba_a-RTC.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-RTC.obj `if test -f '../RTC.cpp'; then $(CYGPATH_W) '../RTC.cpp'; else $(CYGPATH_W) '$(srcdir)/../RTC.cpp'; fi` + +libgba_a-Sound.o: ../Sound.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Sound.o -MD -MP -MF "$(DEPDIR)/libgba_a-Sound.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Sound.o `test -f '../Sound.cpp' || echo '$(srcdir)/'`../Sound.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Sound.Tpo" "$(DEPDIR)/libgba_a-Sound.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Sound.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sound.cpp' object='libgba_a-Sound.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Sound.Po' tmpdepfile='$(DEPDIR)/libgba_a-Sound.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Sound.o `test -f '../Sound.cpp' || echo '$(srcdir)/'`../Sound.cpp + +libgba_a-Sound.obj: ../Sound.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Sound.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Sound.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Sound.obj `if test -f '../Sound.cpp'; then $(CYGPATH_W) '../Sound.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sound.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Sound.Tpo" "$(DEPDIR)/libgba_a-Sound.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Sound.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sound.cpp' object='libgba_a-Sound.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Sound.Po' tmpdepfile='$(DEPDIR)/libgba_a-Sound.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Sound.obj `if test -f '../Sound.cpp'; then $(CYGPATH_W) '../Sound.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sound.cpp'; fi` + +libgba_a-Sram.o: ../Sram.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Sram.o -MD -MP -MF "$(DEPDIR)/libgba_a-Sram.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Sram.o `test -f '../Sram.cpp' || echo '$(srcdir)/'`../Sram.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Sram.Tpo" "$(DEPDIR)/libgba_a-Sram.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Sram.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sram.cpp' object='libgba_a-Sram.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Sram.Po' tmpdepfile='$(DEPDIR)/libgba_a-Sram.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Sram.o `test -f '../Sram.cpp' || echo '$(srcdir)/'`../Sram.cpp + +libgba_a-Sram.obj: ../Sram.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Sram.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Sram.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Sram.obj `if test -f '../Sram.cpp'; then $(CYGPATH_W) '../Sram.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sram.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Sram.Tpo" "$(DEPDIR)/libgba_a-Sram.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Sram.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sram.cpp' object='libgba_a-Sram.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Sram.Po' tmpdepfile='$(DEPDIR)/libgba_a-Sram.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Sram.obj `if test -f '../Sram.cpp'; then $(CYGPATH_W) '../Sram.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sram.cpp'; fi` + +libgba_a-Text.o: ../Text.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Text.o -MD -MP -MF "$(DEPDIR)/libgba_a-Text.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Text.o `test -f '../Text.cpp' || echo '$(srcdir)/'`../Text.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Text.Tpo" "$(DEPDIR)/libgba_a-Text.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Text.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Text.cpp' object='libgba_a-Text.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Text.Po' tmpdepfile='$(DEPDIR)/libgba_a-Text.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Text.o `test -f '../Text.cpp' || echo '$(srcdir)/'`../Text.cpp + +libgba_a-Text.obj: ../Text.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Text.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Text.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Text.obj `if test -f '../Text.cpp'; then $(CYGPATH_W) '../Text.cpp'; else $(CYGPATH_W) '$(srcdir)/../Text.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Text.Tpo" "$(DEPDIR)/libgba_a-Text.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Text.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Text.cpp' object='libgba_a-Text.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Text.Po' tmpdepfile='$(DEPDIR)/libgba_a-Text.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Text.obj `if test -f '../Text.cpp'; then $(CYGPATH_W) '../Text.cpp'; else $(CYGPATH_W) '$(srcdir)/../Text.cpp'; fi` + +libgba_a-Util.o: ../Util.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Util.o -MD -MP -MF "$(DEPDIR)/libgba_a-Util.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Util.o `test -f '../Util.cpp' || echo '$(srcdir)/'`../Util.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Util.Tpo" "$(DEPDIR)/libgba_a-Util.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Util.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Util.cpp' object='libgba_a-Util.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Util.Po' tmpdepfile='$(DEPDIR)/libgba_a-Util.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Util.o `test -f '../Util.cpp' || echo '$(srcdir)/'`../Util.cpp + +libgba_a-Util.obj: ../Util.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-Util.obj -MD -MP -MF "$(DEPDIR)/libgba_a-Util.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-Util.obj `if test -f '../Util.cpp'; then $(CYGPATH_W) '../Util.cpp'; else $(CYGPATH_W) '$(srcdir)/../Util.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-Util.Tpo" "$(DEPDIR)/libgba_a-Util.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-Util.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Util.cpp' object='libgba_a-Util.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-Util.Po' tmpdepfile='$(DEPDIR)/libgba_a-Util.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-Util.obj `if test -f '../Util.cpp'; then $(CYGPATH_W) '../Util.cpp'; else $(CYGPATH_W) '$(srcdir)/../Util.cpp'; fi` + +libgba_a-admame.o: ../admame.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-admame.o -MD -MP -MF "$(DEPDIR)/libgba_a-admame.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-admame.o `test -f '../admame.cpp' || echo '$(srcdir)/'`../admame.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-admame.Tpo" "$(DEPDIR)/libgba_a-admame.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-admame.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../admame.cpp' object='libgba_a-admame.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-admame.Po' tmpdepfile='$(DEPDIR)/libgba_a-admame.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-admame.o `test -f '../admame.cpp' || echo '$(srcdir)/'`../admame.cpp + +libgba_a-admame.obj: ../admame.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-admame.obj -MD -MP -MF "$(DEPDIR)/libgba_a-admame.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-admame.obj `if test -f '../admame.cpp'; then $(CYGPATH_W) '../admame.cpp'; else $(CYGPATH_W) '$(srcdir)/../admame.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-admame.Tpo" "$(DEPDIR)/libgba_a-admame.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-admame.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../admame.cpp' object='libgba_a-admame.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-admame.Po' tmpdepfile='$(DEPDIR)/libgba_a-admame.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-admame.obj `if test -f '../admame.cpp'; then $(CYGPATH_W) '../admame.cpp'; else $(CYGPATH_W) '$(srcdir)/../admame.cpp'; fi` + +libgba_a-agbprint.o: ../agbprint.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-agbprint.o -MD -MP -MF "$(DEPDIR)/libgba_a-agbprint.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-agbprint.o `test -f '../agbprint.cpp' || echo '$(srcdir)/'`../agbprint.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-agbprint.Tpo" "$(DEPDIR)/libgba_a-agbprint.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-agbprint.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../agbprint.cpp' object='libgba_a-agbprint.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-agbprint.Po' tmpdepfile='$(DEPDIR)/libgba_a-agbprint.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-agbprint.o `test -f '../agbprint.cpp' || echo '$(srcdir)/'`../agbprint.cpp + +libgba_a-agbprint.obj: ../agbprint.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-agbprint.obj -MD -MP -MF "$(DEPDIR)/libgba_a-agbprint.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-agbprint.obj `if test -f '../agbprint.cpp'; then $(CYGPATH_W) '../agbprint.cpp'; else $(CYGPATH_W) '$(srcdir)/../agbprint.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-agbprint.Tpo" "$(DEPDIR)/libgba_a-agbprint.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-agbprint.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../agbprint.cpp' object='libgba_a-agbprint.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-agbprint.Po' tmpdepfile='$(DEPDIR)/libgba_a-agbprint.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-agbprint.obj `if test -f '../agbprint.cpp'; then $(CYGPATH_W) '../agbprint.cpp'; else $(CYGPATH_W) '$(srcdir)/../agbprint.cpp'; fi` + +libgba_a-armdis.o: ../armdis.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-armdis.o -MD -MP -MF "$(DEPDIR)/libgba_a-armdis.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-armdis.o `test -f '../armdis.cpp' || echo '$(srcdir)/'`../armdis.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-armdis.Tpo" "$(DEPDIR)/libgba_a-armdis.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-armdis.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../armdis.cpp' object='libgba_a-armdis.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-armdis.Po' tmpdepfile='$(DEPDIR)/libgba_a-armdis.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-armdis.o `test -f '../armdis.cpp' || echo '$(srcdir)/'`../armdis.cpp + +libgba_a-armdis.obj: ../armdis.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-armdis.obj -MD -MP -MF "$(DEPDIR)/libgba_a-armdis.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-armdis.obj `if test -f '../armdis.cpp'; then $(CYGPATH_W) '../armdis.cpp'; else $(CYGPATH_W) '$(srcdir)/../armdis.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-armdis.Tpo" "$(DEPDIR)/libgba_a-armdis.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-armdis.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../armdis.cpp' object='libgba_a-armdis.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-armdis.Po' tmpdepfile='$(DEPDIR)/libgba_a-armdis.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-armdis.obj `if test -f '../armdis.cpp'; then $(CYGPATH_W) '../armdis.cpp'; else $(CYGPATH_W) '$(srcdir)/../armdis.cpp'; fi` + +libgba_a-bilinear.o: ../bilinear.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-bilinear.o -MD -MP -MF "$(DEPDIR)/libgba_a-bilinear.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-bilinear.o `test -f '../bilinear.cpp' || echo '$(srcdir)/'`../bilinear.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-bilinear.Tpo" "$(DEPDIR)/libgba_a-bilinear.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-bilinear.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bilinear.cpp' object='libgba_a-bilinear.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-bilinear.Po' tmpdepfile='$(DEPDIR)/libgba_a-bilinear.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-bilinear.o `test -f '../bilinear.cpp' || echo '$(srcdir)/'`../bilinear.cpp + +libgba_a-bilinear.obj: ../bilinear.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-bilinear.obj -MD -MP -MF "$(DEPDIR)/libgba_a-bilinear.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-bilinear.obj `if test -f '../bilinear.cpp'; then $(CYGPATH_W) '../bilinear.cpp'; else $(CYGPATH_W) '$(srcdir)/../bilinear.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-bilinear.Tpo" "$(DEPDIR)/libgba_a-bilinear.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-bilinear.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bilinear.cpp' object='libgba_a-bilinear.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-bilinear.Po' tmpdepfile='$(DEPDIR)/libgba_a-bilinear.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-bilinear.obj `if test -f '../bilinear.cpp'; then $(CYGPATH_W) '../bilinear.cpp'; else $(CYGPATH_W) '$(srcdir)/../bilinear.cpp'; fi` + +libgba_a-bios.o: ../bios.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-bios.o -MD -MP -MF "$(DEPDIR)/libgba_a-bios.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-bios.o `test -f '../bios.cpp' || echo '$(srcdir)/'`../bios.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-bios.Tpo" "$(DEPDIR)/libgba_a-bios.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-bios.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bios.cpp' object='libgba_a-bios.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-bios.Po' tmpdepfile='$(DEPDIR)/libgba_a-bios.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-bios.o `test -f '../bios.cpp' || echo '$(srcdir)/'`../bios.cpp + +libgba_a-bios.obj: ../bios.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-bios.obj -MD -MP -MF "$(DEPDIR)/libgba_a-bios.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-bios.obj `if test -f '../bios.cpp'; then $(CYGPATH_W) '../bios.cpp'; else $(CYGPATH_W) '$(srcdir)/../bios.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-bios.Tpo" "$(DEPDIR)/libgba_a-bios.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-bios.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bios.cpp' object='libgba_a-bios.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-bios.Po' tmpdepfile='$(DEPDIR)/libgba_a-bios.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-bios.obj `if test -f '../bios.cpp'; then $(CYGPATH_W) '../bios.cpp'; else $(CYGPATH_W) '$(srcdir)/../bios.cpp'; fi` + +libgba_a-elf.o: ../elf.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-elf.o -MD -MP -MF "$(DEPDIR)/libgba_a-elf.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-elf.o `test -f '../elf.cpp' || echo '$(srcdir)/'`../elf.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-elf.Tpo" "$(DEPDIR)/libgba_a-elf.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-elf.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../elf.cpp' object='libgba_a-elf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-elf.Po' tmpdepfile='$(DEPDIR)/libgba_a-elf.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-elf.o `test -f '../elf.cpp' || echo '$(srcdir)/'`../elf.cpp + +libgba_a-elf.obj: ../elf.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-elf.obj -MD -MP -MF "$(DEPDIR)/libgba_a-elf.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-elf.obj `if test -f '../elf.cpp'; then $(CYGPATH_W) '../elf.cpp'; else $(CYGPATH_W) '$(srcdir)/../elf.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-elf.Tpo" "$(DEPDIR)/libgba_a-elf.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-elf.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../elf.cpp' object='libgba_a-elf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-elf.Po' tmpdepfile='$(DEPDIR)/libgba_a-elf.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-elf.obj `if test -f '../elf.cpp'; then $(CYGPATH_W) '../elf.cpp'; else $(CYGPATH_W) '$(srcdir)/../elf.cpp'; fi` + +libgba_a-hq2x.o: ../hq2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-hq2x.o -MD -MP -MF "$(DEPDIR)/libgba_a-hq2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-hq2x.o `test -f '../hq2x.cpp' || echo '$(srcdir)/'`../hq2x.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-hq2x.Tpo" "$(DEPDIR)/libgba_a-hq2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-hq2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../hq2x.cpp' object='libgba_a-hq2x.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-hq2x.Po' tmpdepfile='$(DEPDIR)/libgba_a-hq2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-hq2x.o `test -f '../hq2x.cpp' || echo '$(srcdir)/'`../hq2x.cpp + +libgba_a-hq2x.obj: ../hq2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-hq2x.obj -MD -MP -MF "$(DEPDIR)/libgba_a-hq2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-hq2x.obj `if test -f '../hq2x.cpp'; then $(CYGPATH_W) '../hq2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../hq2x.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-hq2x.Tpo" "$(DEPDIR)/libgba_a-hq2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-hq2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../hq2x.cpp' object='libgba_a-hq2x.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-hq2x.Po' tmpdepfile='$(DEPDIR)/libgba_a-hq2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-hq2x.obj `if test -f '../hq2x.cpp'; then $(CYGPATH_W) '../hq2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../hq2x.cpp'; fi` + +libgba_a-interframe.o: ../interframe.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-interframe.o -MD -MP -MF "$(DEPDIR)/libgba_a-interframe.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-interframe.o `test -f '../interframe.cpp' || echo '$(srcdir)/'`../interframe.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-interframe.Tpo" "$(DEPDIR)/libgba_a-interframe.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-interframe.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../interframe.cpp' object='libgba_a-interframe.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-interframe.Po' tmpdepfile='$(DEPDIR)/libgba_a-interframe.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-interframe.o `test -f '../interframe.cpp' || echo '$(srcdir)/'`../interframe.cpp + +libgba_a-interframe.obj: ../interframe.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-interframe.obj -MD -MP -MF "$(DEPDIR)/libgba_a-interframe.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-interframe.obj `if test -f '../interframe.cpp'; then $(CYGPATH_W) '../interframe.cpp'; else $(CYGPATH_W) '$(srcdir)/../interframe.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-interframe.Tpo" "$(DEPDIR)/libgba_a-interframe.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-interframe.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../interframe.cpp' object='libgba_a-interframe.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-interframe.Po' tmpdepfile='$(DEPDIR)/libgba_a-interframe.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-interframe.obj `if test -f '../interframe.cpp'; then $(CYGPATH_W) '../interframe.cpp'; else $(CYGPATH_W) '$(srcdir)/../interframe.cpp'; fi` + +libgba_a-motionblur.o: ../motionblur.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-motionblur.o -MD -MP -MF "$(DEPDIR)/libgba_a-motionblur.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-motionblur.o `test -f '../motionblur.cpp' || echo '$(srcdir)/'`../motionblur.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-motionblur.Tpo" "$(DEPDIR)/libgba_a-motionblur.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-motionblur.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../motionblur.cpp' object='libgba_a-motionblur.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-motionblur.Po' tmpdepfile='$(DEPDIR)/libgba_a-motionblur.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-motionblur.o `test -f '../motionblur.cpp' || echo '$(srcdir)/'`../motionblur.cpp + +libgba_a-motionblur.obj: ../motionblur.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-motionblur.obj -MD -MP -MF "$(DEPDIR)/libgba_a-motionblur.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-motionblur.obj `if test -f '../motionblur.cpp'; then $(CYGPATH_W) '../motionblur.cpp'; else $(CYGPATH_W) '$(srcdir)/../motionblur.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-motionblur.Tpo" "$(DEPDIR)/libgba_a-motionblur.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-motionblur.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../motionblur.cpp' object='libgba_a-motionblur.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-motionblur.Po' tmpdepfile='$(DEPDIR)/libgba_a-motionblur.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-motionblur.obj `if test -f '../motionblur.cpp'; then $(CYGPATH_W) '../motionblur.cpp'; else $(CYGPATH_W) '$(srcdir)/../motionblur.cpp'; fi` + +libgba_a-pixel.o: ../pixel.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-pixel.o -MD -MP -MF "$(DEPDIR)/libgba_a-pixel.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-pixel.o `test -f '../pixel.cpp' || echo '$(srcdir)/'`../pixel.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-pixel.Tpo" "$(DEPDIR)/libgba_a-pixel.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-pixel.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../pixel.cpp' object='libgba_a-pixel.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-pixel.Po' tmpdepfile='$(DEPDIR)/libgba_a-pixel.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-pixel.o `test -f '../pixel.cpp' || echo '$(srcdir)/'`../pixel.cpp + +libgba_a-pixel.obj: ../pixel.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-pixel.obj -MD -MP -MF "$(DEPDIR)/libgba_a-pixel.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-pixel.obj `if test -f '../pixel.cpp'; then $(CYGPATH_W) '../pixel.cpp'; else $(CYGPATH_W) '$(srcdir)/../pixel.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-pixel.Tpo" "$(DEPDIR)/libgba_a-pixel.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-pixel.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../pixel.cpp' object='libgba_a-pixel.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-pixel.Po' tmpdepfile='$(DEPDIR)/libgba_a-pixel.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-pixel.obj `if test -f '../pixel.cpp'; then $(CYGPATH_W) '../pixel.cpp'; else $(CYGPATH_W) '$(srcdir)/../pixel.cpp'; fi` + +libgba_a-remote.o: ../remote.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-remote.o -MD -MP -MF "$(DEPDIR)/libgba_a-remote.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-remote.o `test -f '../remote.cpp' || echo '$(srcdir)/'`../remote.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-remote.Tpo" "$(DEPDIR)/libgba_a-remote.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-remote.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../remote.cpp' object='libgba_a-remote.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-remote.Po' tmpdepfile='$(DEPDIR)/libgba_a-remote.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-remote.o `test -f '../remote.cpp' || echo '$(srcdir)/'`../remote.cpp + +libgba_a-remote.obj: ../remote.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-remote.obj -MD -MP -MF "$(DEPDIR)/libgba_a-remote.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-remote.obj `if test -f '../remote.cpp'; then $(CYGPATH_W) '../remote.cpp'; else $(CYGPATH_W) '$(srcdir)/../remote.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-remote.Tpo" "$(DEPDIR)/libgba_a-remote.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-remote.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../remote.cpp' object='libgba_a-remote.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-remote.Po' tmpdepfile='$(DEPDIR)/libgba_a-remote.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-remote.obj `if test -f '../remote.cpp'; then $(CYGPATH_W) '../remote.cpp'; else $(CYGPATH_W) '$(srcdir)/../remote.cpp'; fi` + +libgba_a-scanline.o: ../scanline.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-scanline.o -MD -MP -MF "$(DEPDIR)/libgba_a-scanline.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-scanline.o `test -f '../scanline.cpp' || echo '$(srcdir)/'`../scanline.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-scanline.Tpo" "$(DEPDIR)/libgba_a-scanline.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-scanline.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../scanline.cpp' object='libgba_a-scanline.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-scanline.Po' tmpdepfile='$(DEPDIR)/libgba_a-scanline.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-scanline.o `test -f '../scanline.cpp' || echo '$(srcdir)/'`../scanline.cpp + +libgba_a-scanline.obj: ../scanline.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-scanline.obj -MD -MP -MF "$(DEPDIR)/libgba_a-scanline.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-scanline.obj `if test -f '../scanline.cpp'; then $(CYGPATH_W) '../scanline.cpp'; else $(CYGPATH_W) '$(srcdir)/../scanline.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-scanline.Tpo" "$(DEPDIR)/libgba_a-scanline.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-scanline.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../scanline.cpp' object='libgba_a-scanline.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-scanline.Po' tmpdepfile='$(DEPDIR)/libgba_a-scanline.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-scanline.obj `if test -f '../scanline.cpp'; then $(CYGPATH_W) '../scanline.cpp'; else $(CYGPATH_W) '$(srcdir)/../scanline.cpp'; fi` + +libgba_a-simple2x.o: ../simple2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-simple2x.o -MD -MP -MF "$(DEPDIR)/libgba_a-simple2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-simple2x.o `test -f '../simple2x.cpp' || echo '$(srcdir)/'`../simple2x.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-simple2x.Tpo" "$(DEPDIR)/libgba_a-simple2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-simple2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../simple2x.cpp' object='libgba_a-simple2x.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-simple2x.Po' tmpdepfile='$(DEPDIR)/libgba_a-simple2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-simple2x.o `test -f '../simple2x.cpp' || echo '$(srcdir)/'`../simple2x.cpp + +libgba_a-simple2x.obj: ../simple2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-simple2x.obj -MD -MP -MF "$(DEPDIR)/libgba_a-simple2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-simple2x.obj `if test -f '../simple2x.cpp'; then $(CYGPATH_W) '../simple2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../simple2x.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-simple2x.Tpo" "$(DEPDIR)/libgba_a-simple2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-simple2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../simple2x.cpp' object='libgba_a-simple2x.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-simple2x.Po' tmpdepfile='$(DEPDIR)/libgba_a-simple2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-simple2x.obj `if test -f '../simple2x.cpp'; then $(CYGPATH_W) '../simple2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../simple2x.cpp'; fi` + +libgba_a-unzip.o: ../unzip.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-unzip.o -MD -MP -MF "$(DEPDIR)/libgba_a-unzip.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-unzip.o `test -f '../unzip.cpp' || echo '$(srcdir)/'`../unzip.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-unzip.Tpo" "$(DEPDIR)/libgba_a-unzip.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-unzip.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../unzip.cpp' object='libgba_a-unzip.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-unzip.Po' tmpdepfile='$(DEPDIR)/libgba_a-unzip.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-unzip.o `test -f '../unzip.cpp' || echo '$(srcdir)/'`../unzip.cpp + +libgba_a-unzip.obj: ../unzip.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -MT libgba_a-unzip.obj -MD -MP -MF "$(DEPDIR)/libgba_a-unzip.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o libgba_a-unzip.obj `if test -f '../unzip.cpp'; then $(CYGPATH_W) '../unzip.cpp'; else $(CYGPATH_W) '$(srcdir)/../unzip.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgba_a-unzip.Tpo" "$(DEPDIR)/libgba_a-unzip.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/libgba_a-unzip.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../unzip.cpp' object='libgba_a-unzip.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/libgba_a-unzip.Po' tmpdepfile='$(DEPDIR)/libgba_a-unzip.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgba_a_CPPFLAGS) $(CPPFLAGS) $(libgba_a_CXXFLAGS) $(CXXFLAGS) -c -o libgba_a-unzip.obj `if test -f '../unzip.cpp'; then $(CYGPATH_W) '../unzip.cpp'; else $(CYGPATH_W) '$(srcdir)/../unzip.cpp'; fi` + +gvba-configfile.o: configfile.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-configfile.o -MD -MP -MF "$(DEPDIR)/gvba-configfile.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-configfile.o `test -f 'configfile.cpp' || echo '$(srcdir)/'`configfile.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-configfile.Tpo" "$(DEPDIR)/gvba-configfile.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-configfile.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='configfile.cpp' object='gvba-configfile.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-configfile.Po' tmpdepfile='$(DEPDIR)/gvba-configfile.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-configfile.o `test -f 'configfile.cpp' || echo '$(srcdir)/'`configfile.cpp + +gvba-configfile.obj: configfile.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-configfile.obj -MD -MP -MF "$(DEPDIR)/gvba-configfile.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-configfile.obj `if test -f 'configfile.cpp'; then $(CYGPATH_W) 'configfile.cpp'; else $(CYGPATH_W) '$(srcdir)/configfile.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-configfile.Tpo" "$(DEPDIR)/gvba-configfile.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-configfile.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='configfile.cpp' object='gvba-configfile.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-configfile.Po' tmpdepfile='$(DEPDIR)/gvba-configfile.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-configfile.obj `if test -f 'configfile.cpp'; then $(CYGPATH_W) 'configfile.cpp'; else $(CYGPATH_W) '$(srcdir)/configfile.cpp'; fi` + +gvba-filters.o: filters.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-filters.o -MD -MP -MF "$(DEPDIR)/gvba-filters.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-filters.o `test -f 'filters.cpp' || echo '$(srcdir)/'`filters.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-filters.Tpo" "$(DEPDIR)/gvba-filters.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-filters.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='filters.cpp' object='gvba-filters.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-filters.Po' tmpdepfile='$(DEPDIR)/gvba-filters.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-filters.o `test -f 'filters.cpp' || echo '$(srcdir)/'`filters.cpp + +gvba-filters.obj: filters.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-filters.obj -MD -MP -MF "$(DEPDIR)/gvba-filters.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-filters.obj `if test -f 'filters.cpp'; then $(CYGPATH_W) 'filters.cpp'; else $(CYGPATH_W) '$(srcdir)/filters.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-filters.Tpo" "$(DEPDIR)/gvba-filters.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-filters.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='filters.cpp' object='gvba-filters.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-filters.Po' tmpdepfile='$(DEPDIR)/gvba-filters.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-filters.obj `if test -f 'filters.cpp'; then $(CYGPATH_W) 'filters.cpp'; else $(CYGPATH_W) '$(srcdir)/filters.cpp'; fi` + +gvba-input.o: input.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-input.o -MD -MP -MF "$(DEPDIR)/gvba-input.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-input.o `test -f 'input.cpp' || echo '$(srcdir)/'`input.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-input.Tpo" "$(DEPDIR)/gvba-input.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-input.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='input.cpp' object='gvba-input.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-input.Po' tmpdepfile='$(DEPDIR)/gvba-input.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-input.o `test -f 'input.cpp' || echo '$(srcdir)/'`input.cpp + +gvba-input.obj: input.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-input.obj -MD -MP -MF "$(DEPDIR)/gvba-input.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-input.obj `if test -f 'input.cpp'; then $(CYGPATH_W) 'input.cpp'; else $(CYGPATH_W) '$(srcdir)/input.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-input.Tpo" "$(DEPDIR)/gvba-input.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-input.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='input.cpp' object='gvba-input.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-input.Po' tmpdepfile='$(DEPDIR)/gvba-input.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-input.obj `if test -f 'input.cpp'; then $(CYGPATH_W) 'input.cpp'; else $(CYGPATH_W) '$(srcdir)/input.cpp'; fi` + +gvba-joypadconfig.o: joypadconfig.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-joypadconfig.o -MD -MP -MF "$(DEPDIR)/gvba-joypadconfig.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-joypadconfig.o `test -f 'joypadconfig.cpp' || echo '$(srcdir)/'`joypadconfig.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-joypadconfig.Tpo" "$(DEPDIR)/gvba-joypadconfig.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-joypadconfig.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='joypadconfig.cpp' object='gvba-joypadconfig.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-joypadconfig.Po' tmpdepfile='$(DEPDIR)/gvba-joypadconfig.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-joypadconfig.o `test -f 'joypadconfig.cpp' || echo '$(srcdir)/'`joypadconfig.cpp + +gvba-joypadconfig.obj: joypadconfig.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-joypadconfig.obj -MD -MP -MF "$(DEPDIR)/gvba-joypadconfig.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-joypadconfig.obj `if test -f 'joypadconfig.cpp'; then $(CYGPATH_W) 'joypadconfig.cpp'; else $(CYGPATH_W) '$(srcdir)/joypadconfig.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-joypadconfig.Tpo" "$(DEPDIR)/gvba-joypadconfig.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-joypadconfig.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='joypadconfig.cpp' object='gvba-joypadconfig.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-joypadconfig.Po' tmpdepfile='$(DEPDIR)/gvba-joypadconfig.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-joypadconfig.obj `if test -f 'joypadconfig.cpp'; then $(CYGPATH_W) 'joypadconfig.cpp'; else $(CYGPATH_W) '$(srcdir)/joypadconfig.cpp'; fi` + +gvba-main.o: main.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-main.o -MD -MP -MF "$(DEPDIR)/gvba-main.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-main.Tpo" "$(DEPDIR)/gvba-main.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-main.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cpp' object='gvba-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-main.Po' tmpdepfile='$(DEPDIR)/gvba-main.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp + +gvba-main.obj: main.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-main.obj -MD -MP -MF "$(DEPDIR)/gvba-main.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-main.Tpo" "$(DEPDIR)/gvba-main.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-main.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='main.cpp' object='gvba-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-main.Po' tmpdepfile='$(DEPDIR)/gvba-main.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi` + +gvba-screenarea.o: screenarea.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-screenarea.o -MD -MP -MF "$(DEPDIR)/gvba-screenarea.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-screenarea.o `test -f 'screenarea.cpp' || echo '$(srcdir)/'`screenarea.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-screenarea.Tpo" "$(DEPDIR)/gvba-screenarea.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-screenarea.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='screenarea.cpp' object='gvba-screenarea.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-screenarea.Po' tmpdepfile='$(DEPDIR)/gvba-screenarea.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-screenarea.o `test -f 'screenarea.cpp' || echo '$(srcdir)/'`screenarea.cpp + +gvba-screenarea.obj: screenarea.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-screenarea.obj -MD -MP -MF "$(DEPDIR)/gvba-screenarea.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-screenarea.obj `if test -f 'screenarea.cpp'; then $(CYGPATH_W) 'screenarea.cpp'; else $(CYGPATH_W) '$(srcdir)/screenarea.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-screenarea.Tpo" "$(DEPDIR)/gvba-screenarea.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-screenarea.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='screenarea.cpp' object='gvba-screenarea.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-screenarea.Po' tmpdepfile='$(DEPDIR)/gvba-screenarea.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-screenarea.obj `if test -f 'screenarea.cpp'; then $(CYGPATH_W) 'screenarea.cpp'; else $(CYGPATH_W) '$(srcdir)/screenarea.cpp'; fi` + +gvba-system.o: system.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-system.o -MD -MP -MF "$(DEPDIR)/gvba-system.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-system.o `test -f 'system.cpp' || echo '$(srcdir)/'`system.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-system.Tpo" "$(DEPDIR)/gvba-system.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-system.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='system.cpp' object='gvba-system.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-system.Po' tmpdepfile='$(DEPDIR)/gvba-system.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-system.o `test -f 'system.cpp' || echo '$(srcdir)/'`system.cpp + +gvba-system.obj: system.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-system.obj -MD -MP -MF "$(DEPDIR)/gvba-system.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-system.obj `if test -f 'system.cpp'; then $(CYGPATH_W) 'system.cpp'; else $(CYGPATH_W) '$(srcdir)/system.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-system.Tpo" "$(DEPDIR)/gvba-system.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-system.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='system.cpp' object='gvba-system.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-system.Po' tmpdepfile='$(DEPDIR)/gvba-system.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-system.obj `if test -f 'system.cpp'; then $(CYGPATH_W) 'system.cpp'; else $(CYGPATH_W) '$(srcdir)/system.cpp'; fi` + +gvba-tools.o: tools.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-tools.o -MD -MP -MF "$(DEPDIR)/gvba-tools.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-tools.o `test -f 'tools.cpp' || echo '$(srcdir)/'`tools.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-tools.Tpo" "$(DEPDIR)/gvba-tools.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-tools.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tools.cpp' object='gvba-tools.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-tools.Po' tmpdepfile='$(DEPDIR)/gvba-tools.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-tools.o `test -f 'tools.cpp' || echo '$(srcdir)/'`tools.cpp + +gvba-tools.obj: tools.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-tools.obj -MD -MP -MF "$(DEPDIR)/gvba-tools.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-tools.obj `if test -f 'tools.cpp'; then $(CYGPATH_W) 'tools.cpp'; else $(CYGPATH_W) '$(srcdir)/tools.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-tools.Tpo" "$(DEPDIR)/gvba-tools.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-tools.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='tools.cpp' object='gvba-tools.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-tools.Po' tmpdepfile='$(DEPDIR)/gvba-tools.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-tools.obj `if test -f 'tools.cpp'; then $(CYGPATH_W) 'tools.cpp'; else $(CYGPATH_W) '$(srcdir)/tools.cpp'; fi` + +gvba-windowcallbacks.o: windowcallbacks.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-windowcallbacks.o -MD -MP -MF "$(DEPDIR)/gvba-windowcallbacks.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-windowcallbacks.o `test -f 'windowcallbacks.cpp' || echo '$(srcdir)/'`windowcallbacks.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-windowcallbacks.Tpo" "$(DEPDIR)/gvba-windowcallbacks.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-windowcallbacks.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='windowcallbacks.cpp' object='gvba-windowcallbacks.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-windowcallbacks.Po' tmpdepfile='$(DEPDIR)/gvba-windowcallbacks.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-windowcallbacks.o `test -f 'windowcallbacks.cpp' || echo '$(srcdir)/'`windowcallbacks.cpp + +gvba-windowcallbacks.obj: windowcallbacks.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-windowcallbacks.obj -MD -MP -MF "$(DEPDIR)/gvba-windowcallbacks.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-windowcallbacks.obj `if test -f 'windowcallbacks.cpp'; then $(CYGPATH_W) 'windowcallbacks.cpp'; else $(CYGPATH_W) '$(srcdir)/windowcallbacks.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-windowcallbacks.Tpo" "$(DEPDIR)/gvba-windowcallbacks.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-windowcallbacks.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='windowcallbacks.cpp' object='gvba-windowcallbacks.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-windowcallbacks.Po' tmpdepfile='$(DEPDIR)/gvba-windowcallbacks.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-windowcallbacks.obj `if test -f 'windowcallbacks.cpp'; then $(CYGPATH_W) 'windowcallbacks.cpp'; else $(CYGPATH_W) '$(srcdir)/windowcallbacks.cpp'; fi` + +gvba-window.o: window.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-window.o -MD -MP -MF "$(DEPDIR)/gvba-window.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-window.Tpo" "$(DEPDIR)/gvba-window.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-window.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='gvba-window.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-window.Po' tmpdepfile='$(DEPDIR)/gvba-window.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp + +gvba-window.obj: window.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -MT gvba-window.obj -MD -MP -MF "$(DEPDIR)/gvba-window.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o gvba-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gvba-window.Tpo" "$(DEPDIR)/gvba-window.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/gvba-window.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='gvba-window.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/gvba-window.Po' tmpdepfile='$(DEPDIR)/gvba-window.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(gvba_CPPFLAGS) $(CPPFLAGS) $(gvba_CXXFLAGS) $(CXXFLAGS) -c -o gvba-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi` +uninstall-info-am: +dist_pkgdataDATA_INSTALL = $(INSTALL_DATA) +install-dist_pkgdataDATA: $(dist_pkgdata_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +uninstall-dist_pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if (etags --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + else \ + include_option=--include; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(DATA) +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: install-dist_pkgdataDATA + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-dist_pkgdataDATA \ + uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ + clean-recursive ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-binPROGRAMS \ + install-data install-data-am install-data-recursive \ + install-dist_pkgdataDATA install-exec install-exec-am \ + install-exec-recursive install-info install-info-am \ + install-info-recursive install-man install-recursive \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am installdirs-recursive maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-recursive \ + pdf pdf-am pdf-recursive ps ps-am ps-recursive tags \ + tags-recursive uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-dist_pkgdataDATA uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/gtk/configfile.cpp b/src/gtk/configfile.cpp new file mode 100644 index 0000000..3b50457 --- /dev/null +++ b/src/gtk/configfile.cpp @@ -0,0 +1,262 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "configfile.h" + +#include +#include + +#include +#include + +namespace VBA +{ +namespace Config +{ + +using std::string; +using Glib::IOChannel; + +Line::Line(const string & _rsKey, const string & _rsValue) : + m_sKey(_rsKey), + m_sValue(_rsValue) +{ +} + +Section::Section(const string & _rsName) : + m_sName(_rsName) +{ +} + +bool Section::bKeyExists(const string & _rsKey) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + return true; + } + } + return false; +} + +void Section::vSetKey(const string & _rsKey, const string & _rsValue) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + it->m_sValue = _rsValue; + return; + } + } + push_back(Line(_rsKey, _rsValue)); +} + +string Section::sGetKey(const string & _rsKey) const +{ + for (const_iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + return it->m_sValue; + } + } + throw KeyNotFound(m_sName, _rsKey); +} + +void Section::vRemoveKey(const string & _rsKey) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + erase(it); + return; + } + } +} + +File::File() +{ +} + +File::File(const string & _rsFile) +{ + vLoad(_rsFile); +} + +File::~File() +{ +} + +bool File::bSectionExists(const string & _rsName) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->sGetName() == _rsName) + { + return true; + } + } + return false; +} + +Section * File::poAddSection(const string & _rsName) +{ + Section * poSection = NULL; + for (iterator it = begin(); it != end(); it++) + { + if (it->sGetName() == _rsName) + { + poSection = &(*it); + } + } + if (poSection == NULL) + { + push_back(Section(_rsName)); + poSection = &back(); + } + return poSection; +} + +Section * File::poGetSection(const string & _rsName) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->sGetName() == _rsName) + { + return &(*it); + } + } + throw SectionNotFound(_rsName); +} + +void File::vRemoveSection(const string & _rsName) +{ + for (iterator it = begin(); it != end(); it++) + { + if (it->sGetName() == _rsName) + { + erase(it); + return; + } + } +} + +void File::vLoad(const string & _rsFile, + bool _bAddSection, + bool _bAddKey) +{ + string sBuffer = Glib::file_get_contents(_rsFile); + Section * poSection = NULL; + char ** lines = g_strsplit(sBuffer.c_str(), "\n", 0); + char * tmp; + int i = 0; + while (lines[i]) + { + if (lines[i][0] == '[') + { + if ((tmp = strchr(lines[i], ']'))) + { + *tmp = '\0'; + if (_bAddSection) + { + poSection = poAddSection(&lines[i][1]); + } + else + { + try + { + poSection = poGetSection(&lines[i][1]); + } + catch (...) + { + poSection = NULL; + } + } + } + } + else if (lines[i][0] != '#' && poSection != NULL) + { + if ((tmp = strchr(lines[i], '='))) + { + *tmp = '\0'; + tmp++; + if (_bAddKey || poSection->bKeyExists(lines[i])) + { + poSection->vSetKey(lines[i], tmp); + } + } + } + i++; + } + g_strfreev(lines); +} + +void File::vSave(const string & _rsFile) +{ + Glib::RefPtr poFile = IOChannel::create_from_file(_rsFile, "w"); + poFile->set_encoding(""); + + for (const_iterator poSection = begin(); + poSection != end(); + poSection++) + { + string sName = "[" + poSection->sGetName() + "]\n"; + poFile->write(sName); + + for (Section::const_iterator poLine = poSection->begin(); + poLine != poSection->end(); + poLine++) + { + string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n"; + poFile->write(sLine); + } + poFile->write("\n"); + } +} + +void File::vClear() +{ + clear(); +} + +std::ostream & operator<<(std::ostream & _roOut, const File & _roFile) +{ + for (File::const_iterator poSection = _roFile.begin(); + poSection != _roFile.end(); + poSection++) + { + string sName = "[" + poSection->sGetName() + "]\n"; + _roOut << sName; + + for (Section::const_iterator poLine = poSection->begin(); + poLine != poSection->end(); + poLine++) + { + string sLine = poLine->m_sKey + "=" + poLine->m_sValue + "\n"; + _roOut << sLine; + } + _roOut << "\n"; + } + return _roOut; +} + +} // namespace Config +} // namespace VBA diff --git a/src/gtk/configfile.h b/src/gtk/configfile.h new file mode 100644 index 0000000..15b9dfc --- /dev/null +++ b/src/gtk/configfile.h @@ -0,0 +1,204 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_CONFIGFILE_H__ +#define __VBA_CONFIGFILE_H__ + +#include +#include +#include +#include + +namespace VBA +{ +namespace Config +{ + +class NotFound +{ +public: + virtual ~NotFound() {} + +protected: + NotFound() {} +}; + +class SectionNotFound : public NotFound +{ +public: + SectionNotFound(const std::string & _rsName) : + m_sName(_rsName) + { + } + virtual ~SectionNotFound() {} + + inline std::string sGetName() const { return m_sName; } + +private: + std::string m_sName; +}; + +class KeyNotFound : public NotFound +{ +public: + KeyNotFound(const std::string & _rsSection, const std::string & _rsKey) : + m_sSection(_rsSection), + m_sKey(_rsKey) + { + } + virtual ~KeyNotFound() {} + + inline std::string sGetSection() const { return m_sSection; } + inline std::string sGetKey() const { return m_sKey; } + +private: + std::string m_sSection; + std::string m_sKey; +}; + +class Line +{ +public: + Line(const std::string & _rsKey, const std::string & _rsValue); + + std::string m_sKey; + std::string m_sValue; +}; + +class Section : private std::list +{ +public: + explicit Section(const std::string & _rsName); + + inline std::string sGetName() const { return m_sName; } + + bool bKeyExists(const std::string & _rsKey); + void vSetKey(const std::string & _rsKey, const std::string & _rsValue); + std::string sGetKey(const std::string & _rsKey) const; + void vRemoveKey(const std::string & _rsKey); + + template + void vSetKey(const std::string & _rsKey, const T & _rValue); + + template + T oGetKey(const std::string & _rsKey) const; + + // read only + typedef std::list::const_iterator const_iterator; + inline const_iterator begin() const + { + return std::list::begin(); + } + inline const_iterator end() const + { + return std::list::end(); + } + +private: + inline iterator begin() + { + return std::list::begin(); + } + inline iterator end() + { + return std::list::end(); + } + + std::string m_sName; +}; + +class File : private std::list
+{ +public: + File(); + File(const std::string & _rsFile); + virtual ~File(); + + bool bSectionExists(const std::string & _rsName); + Section * poAddSection(const std::string & _rsName); + Section * poGetSection(const std::string & _rsName); + void vRemoveSection(const std::string & _rsName); + void vLoad(const std::string & _rsFile, + bool _bAddSection = true, + bool _bAddKey = true); + void vSave(const std::string & _rsFile); + void vClear(); + + // read only + typedef std::list
::const_iterator const_iterator; + inline const_iterator begin() const + { + return std::list
::begin(); + } + inline const_iterator end() const + { + return std::list
::end(); + } + +private: + inline iterator begin() + { + return std::list
::begin(); + } + inline iterator end() + { + return std::list
::end(); + } +}; + +// debug +std::ostream & operator<<(std::ostream & _roOut, const File & _roConfig); + +template +void Section::vSetKey(const std::string & _rsKey, const T & _rValue) +{ + std::ostringstream oOut; + oOut << _rValue; + for (iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + it->m_sValue = oOut.str(); + return; + } + } + push_back(Line(_rsKey, oOut.str())); +} + +template +T Section::oGetKey(const std::string & _rsKey) const +{ + T oValue; + for (const_iterator it = begin(); it != end(); it++) + { + if (it->m_sKey == _rsKey) + { + std::istringstream oIn(it->m_sValue); + oIn >> oValue; + return oValue; + } + } + throw KeyNotFound(m_sName, _rsKey); +} + +} // namespace Config +} // namespace VBA + + +#endif // __VBA_CONFIGFILE_H__ diff --git a/src/gtk/filters.cpp b/src/gtk/filters.cpp new file mode 100644 index 0000000..50f31bf --- /dev/null +++ b/src/gtk/filters.cpp @@ -0,0 +1,59 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "filters.h" + +namespace VBA +{ + +static const Filter2x apvFilters2x[][2] = +{ + { NULL, NULL }, + { _2xSaI, _2xSaI32 }, + { Super2xSaI, Super2xSaI32 }, + { SuperEagle, SuperEagle32 }, + { Pixelate, Pixelate32 }, + { MotionBlur, MotionBlur32 }, + { AdMame2x, AdMame2x32 }, + { Simple2x, Simple2x32 }, + { Bilinear, Bilinear32 }, + { BilinearPlus, BilinearPlus32 }, + { Scanlines, Scanlines32 }, + { ScanlinesTV, ScanlinesTV32 }, + { hq2x, hq2x32 }, + { lq2x, lq2x32 } +}; + +static const FilterIB apvFiltersIB[][2] = +{ + { NULL, NULL }, + { SmartIB, SmartIB32 }, + { MotionBlurIB, MotionBlurIB32 } +}; + +Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth) +{ + return apvFilters2x[_eFilter2x][_eDepth]; +} + +FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth) +{ + return apvFiltersIB[_eFilterIB][_eDepth]; +} + +} // namespace VBA diff --git a/src/gtk/filters.h b/src/gtk/filters.h new file mode 100644 index 0000000..a058f80 --- /dev/null +++ b/src/gtk/filters.h @@ -0,0 +1,106 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_FILTERS_H__ +#define __VBA_FILTERS_H__ + +#include "../System.h" + +int Init_2xSaI(u32); + +void _2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int); +void _2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void Super2xSaI (u8 *, u32, u8 *, u8 *, u32, int, int); +void Super2xSaI32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void SuperEagle (u8 *, u32, u8 *, u8 *, u32, int, int); +void SuperEagle32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void Pixelate (u8 *, u32, u8 *, u8 *, u32, int, int); +void Pixelate32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void MotionBlur (u8 *, u32, u8 *, u8 *, u32, int, int); +void MotionBlur32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void AdMame2x (u8 *, u32, u8 *, u8 *, u32, int, int); +void AdMame2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void Simple2x (u8 *, u32, u8 *, u8 *, u32, int, int); +void Simple2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void Bilinear (u8 *, u32, u8 *, u8 *, u32, int, int); +void Bilinear32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void BilinearPlus (u8 *, u32, u8 *, u8 *, u32, int, int); +void BilinearPlus32(u8 *, u32, u8 *, u8 *, u32, int, int); +void Scanlines (u8 *, u32, u8 *, u8 *, u32, int, int); +void Scanlines32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void ScanlinesTV (u8 *, u32, u8 *, u8 *, u32, int, int); +void ScanlinesTV32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void hq2x (u8 *, u32, u8 *, u8 *, u32, int, int); +void hq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); +void lq2x (u8 *, u32, u8 *, u8 *, u32, int, int); +void lq2x32 (u8 *, u32, u8 *, u8 *, u32, int, int); + +void SmartIB (u8 *, u32, int, int); +void SmartIB32 (u8 *, u32, int, int); +void MotionBlurIB (u8 *, u32, int, int); +void MotionBlurIB32(u8 *, u32, int, int); + +namespace VBA +{ + +typedef void (*Filter2x)(u8 *, u32, u8 *, u8 *, u32, int, int); +typedef void (*FilterIB)(u8 *, u32, int, int); + +enum EFilter2x +{ + FirstFilter, + FilterNone = FirstFilter, + Filter2xSaI, + FilterSuper2xSaI, + FilterSuperEagle, + FilterPixelate, + FilterMotionBlur, + FilterAdMame2x, + FilterSimple2x, + FilterBilinear, + FilterBilinearPlus, + FilterScanlines, + FilterScanlinesTV, + FilterHq2x, + FilterLq2x, + LastFilter = FilterLq2x +}; + +enum EFilterIB +{ + FirstFilterIB, + FilterIBNone = FirstFilterIB, + FilterIBSmart, + FilterIBMotionBlur, + LastFilterIB = FilterIBMotionBlur +}; + +enum EFilterDepth +{ + FilterDepth16, + FilterDepth32 +}; + +Filter2x pvGetFilter2x(EFilter2x _eFilter2x, EFilterDepth _eDepth); +FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth); + +} // namespace VBA + + +#endif // __VBA_FILTERS_H__ diff --git a/src/gtk/images/Makefile.am b/src/gtk/images/Makefile.am new file mode 100644 index 0000000..7b6d942 --- /dev/null +++ b/src/gtk/images/Makefile.am @@ -0,0 +1,22 @@ +VBA_WM_IMAGES = \ + stock-vba-wm-16.png \ + stock-vba-wm-32.png \ + stock-vba-wm-48.png \ + stock-vba-wm-64.png + +VBA_WM_VARIABLES = \ + stock_vba_wm_16 $(srcdir)/stock-vba-wm-16.png \ + stock_vba_wm_32 $(srcdir)/stock-vba-wm-32.png \ + stock_vba_wm_48 $(srcdir)/stock-vba-wm-48.png \ + stock_vba_wm_64 $(srcdir)/stock-vba-wm-64.png + +EXTRA_DIST = $(VBA_WM_IMAGES) + +noinst_DATA = vba-wm-pixbufs.h + +dist_pkgdata_DATA = vba-64.png + +CLEANFILES = $(noinst_DATA) + +$(srcdir)/vba-wm-pixbufs.h: $(VBA_WM_IMAGES) Makefile.am + gdk-pixbuf-csource --raw --build-list $(VBA_WM_VARIABLES) > $(@F) diff --git a/src/gtk/images/Makefile.in b/src/gtk/images/Makefile.in new file mode 100644 index 0000000..a698130 --- /dev/null +++ b/src/gtk/images/Makefile.in @@ -0,0 +1,339 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +VBA_WM_IMAGES = \ + stock-vba-wm-16.png \ + stock-vba-wm-32.png \ + stock-vba-wm-48.png \ + stock-vba-wm-64.png + + +VBA_WM_VARIABLES = \ + stock_vba_wm_16 $(srcdir)/stock-vba-wm-16.png \ + stock_vba_wm_32 $(srcdir)/stock-vba-wm-32.png \ + stock_vba_wm_48 $(srcdir)/stock-vba-wm-48.png \ + stock_vba_wm_64 $(srcdir)/stock-vba-wm-64.png + + +EXTRA_DIST = $(VBA_WM_IMAGES) + +noinst_DATA = vba-wm-pixbufs.h + +dist_pkgdata_DATA = vba-64.png + +CLEANFILES = $(noinst_DATA) +subdir = src/gtk/images +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DATA = $(dist_pkgdata_DATA) $(noinst_DATA) + +DIST_COMMON = $(dist_pkgdata_DATA) $(srcdir)/Makefile.in Makefile.am +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/gtk/images/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: +dist_pkgdataDATA_INSTALL = $(INSTALL_DATA) +install-dist_pkgdataDATA: $(dist_pkgdata_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \ + $(dist_pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \ + done + +uninstall-dist_pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkgdata_DATA)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \ + rm -f $(DESTDIR)$(pkgdatadir)/$$f; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: install-dist_pkgdataDATA + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_pkgdataDATA uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am \ + install-dist_pkgdataDATA install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am \ + uninstall-dist_pkgdataDATA uninstall-info-am + + +$(srcdir)/vba-wm-pixbufs.h: $(VBA_WM_IMAGES) Makefile.am + gdk-pixbuf-csource --raw --build-list $(VBA_WM_VARIABLES) > $(@F) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/gtk/images/stock-vba-wm-16.png b/src/gtk/images/stock-vba-wm-16.png new file mode 100644 index 0000000..bee56f7 Binary files /dev/null and b/src/gtk/images/stock-vba-wm-16.png differ diff --git a/src/gtk/images/stock-vba-wm-32.png b/src/gtk/images/stock-vba-wm-32.png new file mode 100644 index 0000000..9eb6f01 Binary files /dev/null and b/src/gtk/images/stock-vba-wm-32.png differ diff --git a/src/gtk/images/stock-vba-wm-48.png b/src/gtk/images/stock-vba-wm-48.png new file mode 100644 index 0000000..7c322fe Binary files /dev/null and b/src/gtk/images/stock-vba-wm-48.png differ diff --git a/src/gtk/images/stock-vba-wm-64.png b/src/gtk/images/stock-vba-wm-64.png new file mode 100644 index 0000000..beaa290 Binary files /dev/null and b/src/gtk/images/stock-vba-wm-64.png differ diff --git a/src/gtk/images/vba-64.png b/src/gtk/images/vba-64.png new file mode 100644 index 0000000..beaa290 Binary files /dev/null and b/src/gtk/images/vba-64.png differ diff --git a/src/gtk/input.cpp b/src/gtk/input.cpp new file mode 100644 index 0000000..5eecbf1 --- /dev/null +++ b/src/gtk/input.cpp @@ -0,0 +1,53 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "input.h" + +#include + +namespace VBA +{ + +Keymap::Keymap() +{ + m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal); + if (m_pstTable == NULL) + { + throw std::bad_alloc(); + } +} + +Keymap::~Keymap() +{ + g_hash_table_destroy(m_pstTable); +} + +void Keymap::vRegister(guint _uiVal, EKey _eKey) +{ + g_hash_table_insert(m_pstTable, + GUINT_TO_POINTER(_uiVal), + GUINT_TO_POINTER(_eKey)); +} + +void Keymap::vClear() +{ + g_hash_table_destroy(m_pstTable); + m_pstTable = g_hash_table_new(g_direct_hash, g_direct_equal); +} + +} // namespace VBA diff --git a/src/gtk/input.h b/src/gtk/input.h new file mode 100644 index 0000000..5b2b21e --- /dev/null +++ b/src/gtk/input.h @@ -0,0 +1,92 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_INPUT_H__ +#define __VBA_INPUT_H__ + +#include + +namespace VBA +{ + +enum EKey +{ + KeyNone, + // GBA keys + KeyA, + KeyB, + KeySelect, + KeyStart, + KeyRight, + KeyLeft, + KeyUp, + KeyDown, + KeyR, + KeyL, + // VBA extension + KeySpeed, + KeyCapture +}; + +enum EKeyFlag +{ + // GBA keys + KeyFlagA = 1 << 0, + KeyFlagB = 1 << 1, + KeyFlagSelect = 1 << 2, + KeyFlagStart = 1 << 3, + KeyFlagRight = 1 << 4, + KeyFlagLeft = 1 << 5, + KeyFlagUp = 1 << 6, + KeyFlagDown = 1 << 7, + KeyFlagR = 1 << 8, + KeyFlagL = 1 << 9, + // VBA extension + KeyFlagSpeed = 1 << 10, + KeyFlagCapture = 1 << 11, +}; + +class Keymap +{ + public: + Keymap(); + ~Keymap(); + + void vRegister(guint _uiVal, EKey _eKey); + void vClear(); + inline EKey eGetKey(guint _uiVal); + + private: + GHashTable * m_pstTable; + + // noncopyable + Keymap(const Keymap &); + Keymap & operator=(const Keymap &); +}; + +inline EKey Keymap::eGetKey(guint _uiVal) +{ + return (EKey)GPOINTER_TO_UINT(g_hash_table_lookup(m_pstTable, + GUINT_TO_POINTER(_uiVal))); +} + +} // namespace VBA + + +#endif // __VBA_INPUT_H__ diff --git a/src/gtk/intl.h b/src/gtk/intl.h new file mode 100644 index 0000000..f40f779 --- /dev/null +++ b/src/gtk/intl.h @@ -0,0 +1,42 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_INTL_H__ +#define __VBA_INTL_H__ + +#ifndef GETTEXT_PACKAGE +# error "GETTEXT_PACKAGE must be defined" +#endif + +#ifdef ENABLE_NLS +# include +# define _(String) gettext(String) +# define N_(String) (String) +#else +# define _(String) (String) +# define N_(String) (String) +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,String) (String) +# define dcgettext(Domain,String,Type) (String) +# define bindtextdomain(Domain,Directory) (Domain) +#endif + + +#endif // __VBA_INTL_H__ diff --git a/src/gtk/joypadconfig.cpp b/src/gtk/joypadconfig.cpp new file mode 100644 index 0000000..17be83b --- /dev/null +++ b/src/gtk/joypadconfig.cpp @@ -0,0 +1,276 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "joypadconfig.h" + +#include + +#include "intl.h" + +namespace VBA +{ + +guint * JoypadConfig::puiAt(int _iIndex) +{ + guint * puiMember; + + switch (_iIndex) + { + case 0: + puiMember = &m_uiUp; + break; + case 1: + puiMember = &m_uiDown; + break; + case 2: + puiMember = &m_uiLeft; + break; + case 3: + puiMember = &m_uiRight; + break; + case 4: + puiMember = &m_uiA; + break; + case 5: + puiMember = &m_uiB; + break; + case 6: + puiMember = &m_uiL; + break; + case 7: + puiMember = &m_uiR; + break; + case 8: + puiMember = &m_uiSelect; + break; + case 9: + puiMember = &m_uiStart; + break; + case 10: + puiMember = &m_uiSpeed; + break; + case 11: + puiMember = &m_uiCapture; + break; + default: + puiMember = NULL; + } + + return puiMember; +} + +int JoypadConfig::iFind(guint _uiKeycode) +{ + for (guint i = 0; i < 12; i++) + { + if (*puiAt(i) == _uiKeycode) + { + return i; + } + } + + return -1; +} + +void JoypadConfig::vSetDefault() +{ + guint auiKeyval[] = + { + GDK_Up, GDK_Down, GDK_Left, GDK_Right, + GDK_z, GDK_x, GDK_a, GDK_s, + GDK_BackSpace, GDK_Return, + GDK_space, GDK_F12 + }; + + for (guint i = 0; i < G_N_ELEMENTS(auiKeyval); i++) + { + GdkKeymapKey * pstKeys; + int iKeys; + + if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), + auiKeyval[i], + &pstKeys, + &iKeys)) + { + *puiAt(i) = pstKeys[0].keycode; + g_free(pstKeys); + } + else + { + *puiAt(i) = 0; + } + } +} + +Keymap * JoypadConfig::poCreateKeymap() const +{ + Keymap * poKeymap = new Keymap(); + + poKeymap->vRegister(m_uiUp, KeyUp ); + poKeymap->vRegister(m_uiDown, KeyDown ); + poKeymap->vRegister(m_uiLeft, KeyLeft ); + poKeymap->vRegister(m_uiRight, KeyRight ); + poKeymap->vRegister(m_uiA, KeyA ); + poKeymap->vRegister(m_uiB, KeyB ); + poKeymap->vRegister(m_uiL, KeyL ); + poKeymap->vRegister(m_uiR, KeyR ); + poKeymap->vRegister(m_uiSelect, KeySelect ); + poKeymap->vRegister(m_uiStart, KeyStart ); + poKeymap->vRegister(m_uiSpeed, KeySpeed ); + poKeymap->vRegister(m_uiCapture, KeyCapture ); + + return poKeymap; +} + +JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog, + const Glib::RefPtr & _poXml) : + Gtk::Dialog(_pstDialog) +{ + m_puiCurrentKeyCode = NULL; + + memset(&m_oConfig, 0, sizeof(m_oConfig)); + + m_poOkButton = dynamic_cast(_poXml->get_widget("JoypadOkButton")); + + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadUpEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadDownEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadLeftEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadRightEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadAEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadBEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadLEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadREntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadSelectEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadStartEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadSpeedEntry"))); + m_oEntries.push_back(dynamic_cast(_poXml->get_widget("JoypadCaptureEntry"))); + + for (guint i = 0; i < m_oEntries.size(); i++) + { + Gtk::Entry * poEntry = m_oEntries[i]; + + poEntry->signal_focus_in_event().connect(SigC::bind( + SigC::slot(*this, &JoypadConfigDialog::bOnEntryFocusIn), + i)); + poEntry->signal_focus_out_event().connect(SigC::slot(*this, &JoypadConfigDialog::bOnEntryFocusOut)); + } + + vUpdateEntries(); +} + +JoypadConfigDialog::~JoypadConfigDialog() +{ +} + +void JoypadConfigDialog::vSetConfig(const JoypadConfig & _roConfig) +{ + m_oConfig = _roConfig; + vUpdateEntries(); +} + +void JoypadConfigDialog::vUpdateEntries() +{ + for (guint i = 0; i < m_oEntries.size(); i++) + { + guint uiKeyval = 0; + gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(), + *m_oConfig.puiAt(i), + (GdkModifierType)0, + 0, + &uiKeyval, + NULL, + NULL, + NULL); + const char * csName = gdk_keyval_name(uiKeyval); + if (csName == NULL) + { + m_oEntries[i]->set_text(_("")); + } + else + { + m_oEntries[i]->set_text(csName); + } + } +} + +bool JoypadConfigDialog::bOnEntryFocusIn(GdkEventFocus * _pstEvent, + guint _uiEntry) +{ + m_uiCurrentEntry = _uiEntry; + m_puiCurrentKeyCode = m_oConfig.puiAt(_uiEntry); + + return false; +} + +bool JoypadConfigDialog::bOnEntryFocusOut(GdkEventFocus * _pstEvent) +{ + m_puiCurrentKeyCode = NULL; + + return false; +} + +bool JoypadConfigDialog::on_key_press_event(GdkEventKey * _pstEvent) +{ + if (m_puiCurrentKeyCode == NULL) + { + return Gtk::Dialog::on_key_press_event(_pstEvent); + } + + *m_puiCurrentKeyCode = 0; + int iFound = m_oConfig.iFind(_pstEvent->hardware_keycode); + if (iFound >= 0) + { + *m_oConfig.puiAt(iFound) = 0; + m_oEntries[iFound]->set_text(_("")); + } + + *m_puiCurrentKeyCode = _pstEvent->hardware_keycode; + + guint uiKeyval = 0; + gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(), + _pstEvent->hardware_keycode, + (GdkModifierType)0, + 0, + &uiKeyval, + NULL, + NULL, + NULL); + + const char * csName = gdk_keyval_name(uiKeyval); + if (csName == NULL) + { + m_oEntries[m_uiCurrentEntry]->set_text(_("")); + } + else + { + m_oEntries[m_uiCurrentEntry]->set_text(csName); + } + + if (m_uiCurrentEntry + 1 < m_oEntries.size()) + { + m_oEntries[m_uiCurrentEntry + 1]->grab_focus(); + } + else + { + m_poOkButton->grab_focus(); + } + + return true; +} + +} // namespace VBA diff --git a/src/gtk/joypadconfig.h b/src/gtk/joypadconfig.h new file mode 100644 index 0000000..0af7f3a --- /dev/null +++ b/src/gtk/joypadconfig.h @@ -0,0 +1,88 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_JOYPADCONFIG_H__ +#define __VBA_JOYPADCONFIG_H__ + +#include + +#include +#include + +#ifndef GTKMM20 +# include "sigccompat.h" +#endif // ! GTKMM20 + +#include "input.h" + +namespace VBA +{ + +class JoypadConfig +{ +public: + guint m_uiUp; + guint m_uiDown; + guint m_uiLeft; + guint m_uiRight; + guint m_uiA; + guint m_uiB; + guint m_uiL; + guint m_uiR; + guint m_uiSelect; + guint m_uiStart; + guint m_uiSpeed; + guint m_uiCapture; + + guint * puiAt(int _iIndex); + int iFind(guint _uiKeycode); + void vSetDefault(); + Keymap * poCreateKeymap() const; +}; + +class JoypadConfigDialog : public Gtk::Dialog +{ +public: + JoypadConfigDialog(GtkDialog * _pstDialog, + const Glib::RefPtr & _poXml); + virtual ~JoypadConfigDialog(); + + void vSetConfig(const JoypadConfig & _roConfig); + inline JoypadConfig stGetConfig() const { return m_oConfig; } + +protected: + bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry); + bool bOnEntryFocusOut(GdkEventFocus * _pstEvent); + + bool on_key_press_event(GdkEventKey * _pstEvent); + +private: + JoypadConfig m_oConfig; + Gtk::Button * m_poOkButton; + std::vector m_oEntries; + guint * m_puiCurrentKeyCode; + guint m_uiCurrentEntry; + + void vUpdateEntries(); +}; + +} // namespace VBA + + +#endif // __VBA_JOYPADCONFIG_H__ diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp new file mode 100644 index 0000000..a783bd2 --- /dev/null +++ b/src/gtk/main.cpp @@ -0,0 +1,177 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include "../getopt.h" + +#include + +#include +#include +#include +#include + +#include "images/vba-wm-pixbufs.h" + +#include "window.h" +#include "intl.h" + +using Gnome::Glade::Xml; + +static const char * csProgramName; + +static int iShowHelp; +static int iShowVersion; + +// Non-characters used for long options that have no equivalent short option +enum +{ + IGNORED_OPTION = CHAR_MAX + 1 +}; + +static const char csShortOptions[] = "V"; + +static const struct option astLongOptions[] = +{ + { "help", no_argument, &iShowHelp, IGNORED_OPTION }, + { "version", no_argument, NULL, 'V' }, + { 0, 0, 0, 0 } +}; + +static void vUsage(int iStatus) +{ + if (iStatus != 0) + { + g_printerr(_("Try `%s --help' for more information.\n"), csProgramName); + } + else + { + g_print(_("Usage: %s [option ...] [file]\n"), csProgramName); + g_print(_("\ +\n\ +Options:\n\ + --help Output this help.\n\ + -V, --version Output version information.\n\ +")); + } + + exit(iStatus); +} + +static void vSetDefaultWindowIcon() +{ + const guint8 * apuiInlinePixbuf[] = + { + stock_vba_wm_16, + stock_vba_wm_32, + stock_vba_wm_48, + stock_vba_wm_64 + }; + + std::list > listPixbuf; + for (guint i = 0; i < G_N_ELEMENTS(apuiInlinePixbuf); i++) + { + listPixbuf.push_back( + Gdk::Pixbuf::create_from_inline(-1, apuiInlinePixbuf[i])); + } + + Gtk::Window::set_default_icon_list(listPixbuf); +} + +int main(int argc, char * argv[]) +{ + csProgramName = argv[0]; + +#ifdef ENABLE_NLS + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + textdomain(GETTEXT_PACKAGE); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); +#endif // ENABLE_NLS + + Gtk::Main oKit(argc, argv); + + int iOpt; + while ((iOpt = getopt_long(argc, argv, csShortOptions, astLongOptions, NULL)) + != -1) + { + switch (iOpt) + { + case 'V': + iShowVersion = 1; + break; + case 0: + // Long options + break; + default: + vUsage(1); + break; + } + } + + if (iShowVersion) + { + g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION); + exit(0); + } + + if (iShowHelp) + { + vUsage(0); + } + + vSetDefaultWindowIcon(); + + Glib::RefPtr poXml; + try + { + poXml = Xml::create(PKGDATADIR "/vba.glade", "MainWindow"); + } + catch (const Xml::Error & e) + { + Gtk::MessageDialog oDialog(e.what(), +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_ERROR, + Gtk::BUTTONS_OK); + oDialog.run(); + return 1; + } + + VBA::Window * poWindow = NULL; + poXml->get_widget_derived("MainWindow", poWindow); + + if (optind < argc) + { + // Display the window before loading the file + poWindow->show(); + while (Gtk::Main::events_pending()) + { + Gtk::Main::iteration(); + } + + poWindow->bLoadROM(argv[optind]); + } + + Gtk::Main::run(*poWindow); + delete poWindow; + + return 0; +} diff --git a/src/gtk/menuitem.h b/src/gtk/menuitem.h new file mode 100644 index 0000000..d846458 --- /dev/null +++ b/src/gtk/menuitem.h @@ -0,0 +1,80 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_MENUITEM_H__ +#define __VBA_MENUITEM_H__ + +#include +#include + +#ifdef GTKMM20 +namespace Gtk { typedef Gtk::Menu_Helpers::AccelKey AccelKey; } +#endif // GTKMM20 + +namespace VBA +{ + +class MenuItem : public Gtk::MenuItem +{ +public: + MenuItem() + {} + + MenuItem(Gtk::Widget & _roWidget) : + Gtk::MenuItem(_roWidget) + {} + + MenuItem(const Glib::ustring & _rsLabel, bool _bMnemonic = false) : + Gtk::MenuItem(_rsLabel, _bMnemonic) + {} + + inline void set_accel_key(const Gtk::AccelKey & _roAccelKey) + { + Gtk::MenuItem::set_accel_key(_roAccelKey); + } +}; + +class ImageMenuItem : public Gtk::ImageMenuItem +{ +public: + ImageMenuItem() + {} + + ImageMenuItem(Widget & _roImage, const Glib::ustring & _rsLabel, bool _bMnemonic = false) : + Gtk::ImageMenuItem(_roImage, _rsLabel, _bMnemonic) + {} + + ImageMenuItem(const Glib::ustring & _rsLabel, bool _bMnemonic = false) : + Gtk::ImageMenuItem(_rsLabel, _bMnemonic) + {} + + ImageMenuItem(const Gtk::StockID & _roId) : + Gtk::ImageMenuItem(_roId) + {} + + inline void set_accel_key(const Gtk::AccelKey & _roAccelKey) + { + Gtk::MenuItem::set_accel_key(_roAccelKey); + } +}; + +} // namespace VBA + + +#endif // __VBA_MENUITEM_H__ diff --git a/src/gtk/screenarea.cpp b/src/gtk/screenarea.cpp new file mode 100644 index 0000000..b6d2969 --- /dev/null +++ b/src/gtk/screenarea.cpp @@ -0,0 +1,293 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "screenarea.h" + +#include + +namespace VBA +{ + +ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) : + m_puiPixels(NULL), + m_puiDelta(NULL), + m_vFilter2x(NULL), + m_vFilterIB(NULL), + m_bShowCursor(true) +{ + g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); + + m_iWidth = _iWidth; + m_iHeight = _iHeight; + m_iScale = _iScale; + vUpdateSize(); + + set_events(Gdk::EXPOSURE_MASK + | Gdk::POINTER_MOTION_MASK + | Gdk::ENTER_NOTIFY_MASK + | Gdk::LEAVE_NOTIFY_MASK); + + char aiEmptyData[8]; + memset(aiEmptyData, 0, sizeof(aiEmptyData)); + Glib::RefPtr poSource = Gdk::Bitmap::create(aiEmptyData, 8, 8); + Glib::RefPtr poMask = Gdk::Bitmap::create(aiEmptyData, 8, 8); + Gdk::Color oFg; + Gdk::Color oBg; + oFg.set_rgb(0, 0, 0); + oBg.set_rgb(0, 0, 0); + + m_poEmptyCursor = new Gdk::Cursor(poSource, poMask, oFg, oBg, 0, 0); +} + +ScreenArea::~ScreenArea() +{ + if (m_puiPixels != NULL) + { + delete[] m_puiPixels; + } + + if (m_puiDelta != NULL) + { + delete[] m_puiDelta; + } + + if (m_poEmptyCursor != NULL) + { + delete m_poEmptyCursor; + } +} + +void ScreenArea::vSetSize(int _iWidth, int _iHeight) +{ + g_return_if_fail(_iWidth >= 1 && _iHeight >= 1); + + if (_iWidth != m_iWidth || _iHeight != m_iHeight) + { + m_iWidth = _iWidth; + m_iHeight = _iHeight; + vUpdateSize(); + } +} + +void ScreenArea::vSetScale(int _iScale) +{ + g_return_if_fail(_iScale >= 1); + + if (_iScale != m_iScale) + { + m_iScale = _iScale; + vUpdateSize(); + } +} + +void ScreenArea::vSetFilter2x(EFilter2x _eFilter2x) +{ + m_vFilter2x = pvGetFilter2x(_eFilter2x, FilterDepth32); +} + +void ScreenArea::vSetFilterIB(EFilterIB _eFilterIB) +{ + m_vFilterIB = pvGetFilterIB(_eFilterIB, FilterDepth32); +} + +void ScreenArea::vDrawPixels(u8 * _puiData) +{ + if (m_vFilterIB != NULL) + { + m_vFilterIB(_puiData + m_iAreaWidth * 2 + 4, + m_iAreaWidth * 2 + 4, + m_iWidth, + m_iHeight); + } + + if (m_iScale == 1) + { + u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1; + u32 * puiPixel = m_puiPixels; + for (int y = 0; y < m_iHeight; y++) + { + for (int x = 0; x < m_iWidth; x++) + { + *puiPixel++ = *puiSrc++; + } + puiSrc++; + } + } + else if (m_iScale == 2 && m_vFilter2x != NULL) + { + m_vFilter2x(_puiData + m_iAreaWidth * 2 + 4, + m_iAreaWidth * 2 + 4, + m_puiDelta, + (u8 *)m_puiPixels, + m_iRowStride, + m_iWidth, + m_iHeight); + } + else + { + u32 * puiSrc = (u32 *)_puiData + m_iWidth + 1; + u32 * puiSrc2; + u32 * puiPixel = m_puiPixels; + for (int y = 0; y < m_iHeight; y++) + { + for (int j = 0; j < m_iScale; j++) + { + puiSrc2 = puiSrc; + for (int x = 0; x < m_iWidth; x++) + { + for (int i = 0; i < m_iScale; i++) + { + *puiPixel++ = *puiSrc2; + } + puiSrc2++; + } + } + puiSrc = puiSrc2 + 1; + } + } + + queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight); +} + +void ScreenArea::vDrawColor(u32 _uiColor) +{ + _uiColor = GUINT32_TO_BE(_uiColor) << 8; + + u32 * puiPixel = m_puiPixels; + u32 * puiEnd = m_puiPixels + m_iAreaWidth * m_iAreaHeight; + while (puiPixel != puiEnd) + { + *puiPixel++ = _uiColor; + } + + queue_draw_area(0, 0, m_iAreaWidth, m_iAreaHeight); +} + +void ScreenArea::vUpdateSize() +{ + if (m_puiPixels != NULL) + { + delete[] m_puiPixels; + } + + if (m_puiDelta != NULL) + { + delete[] m_puiDelta; + } + + m_iAreaWidth = m_iScale * m_iWidth; + m_iAreaHeight = m_iScale * m_iHeight; + m_iRowStride = m_iAreaWidth * 4; + + m_puiPixels = new u32[m_iAreaWidth * m_iAreaHeight]; + + m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * 4]; + memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * 4); + + set_size_request(m_iAreaWidth, m_iAreaHeight); +} + +void ScreenArea::vStartCursorTimeout() +{ + m_oCursorSig.disconnect(); + m_oCursorSig = Glib::signal_timeout().connect( + SigC::slot(*this, &ScreenArea::bOnCursorTimeout), + 2000); +} + +void ScreenArea::vStopCursorTimeout() +{ + m_oCursorSig.disconnect(); +} + +void ScreenArea::vHideCursor() +{ + get_window()->set_cursor(*m_poEmptyCursor); + m_bShowCursor = false; +} + +void ScreenArea::vShowCursor() +{ + get_window()->set_cursor(); + m_bShowCursor = true; +} + +bool ScreenArea::on_expose_event(GdkEventExpose * _pstEvent) +{ + if (_pstEvent->area.x + _pstEvent->area.width > m_iAreaWidth + || _pstEvent->area.y + _pstEvent->area.height > m_iAreaHeight) + { + return false; + } + + guchar * puiAreaPixels = (guchar *)m_puiPixels; + + if (_pstEvent->area.x != 0) + { + puiAreaPixels += _pstEvent->area.x << 2; + } + + if (_pstEvent->area.y != 0) + { + puiAreaPixels += _pstEvent->area.y * m_iRowStride; + } + + get_window()->draw_rgb_32_image(get_style()->get_fg_gc(get_state()), + _pstEvent->area.x, + _pstEvent->area.y, + _pstEvent->area.width, + _pstEvent->area.height, + Gdk::RGB_DITHER_MAX, + puiAreaPixels, + m_iRowStride); + return true; +} + +bool ScreenArea::on_motion_notify_event(GdkEventMotion * _pstEvent) +{ + if (! m_bShowCursor) + { + vShowCursor(); + } + vStartCursorTimeout(); + return false; +} + +bool ScreenArea::on_enter_notify_event(GdkEventCrossing * _pstEvent) +{ + vStartCursorTimeout(); + return false; +} + +bool ScreenArea::on_leave_notify_event(GdkEventCrossing * _pstEvent) +{ + vStopCursorTimeout(); + if (! m_bShowCursor) + { + vShowCursor(); + } + return false; +} + +bool ScreenArea::bOnCursorTimeout() +{ + vHideCursor(); + return false; +} + +} // namespace VBA diff --git a/src/gtk/screenarea.h b/src/gtk/screenarea.h new file mode 100644 index 0000000..41662c7 --- /dev/null +++ b/src/gtk/screenarea.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_SCREENAREA_H__ +#define __VBA_SCREENAREA_H__ + +#include +#include + +#ifndef GTKMM20 +# include "sigccompat.h" +#endif // ! GTKMM20 + +#include "filters.h" + +namespace VBA +{ + +class ScreenArea : public Gtk::DrawingArea +{ +public: + ScreenArea(int _iWidth, int _iHeight, int _iScale = 1); + virtual ~ScreenArea(); + + void vSetSize(int _iWidth, int _iHeight); + void vSetScale(int _iScale); + void vSetFilter2x(EFilter2x _eFilter2x); + void vSetFilterIB(EFilterIB _eFilterIB); + void vDrawPixels(u8 * _puiData); + void vDrawColor(u32 _uiColor); // 0xRRGGBB + +protected: + virtual bool on_expose_event(GdkEventExpose * _pstEvent); + virtual bool on_motion_notify_event(GdkEventMotion * _pstEvent); + virtual bool on_enter_notify_event(GdkEventCrossing * _pstEvent); + virtual bool on_leave_notify_event(GdkEventCrossing * _pstEvent); + virtual bool bOnCursorTimeout(); + +private: + int m_iWidth; + int m_iHeight; + int m_iScale; + int m_iAreaWidth; + int m_iAreaHeight; + int m_iRowStride; + u32 * m_puiPixels; + u8 * m_puiDelta; + Filter2x m_vFilter2x; + FilterIB m_vFilterIB; + + bool m_bShowCursor; + Gdk::Cursor * m_poEmptyCursor; + SigC::Connection m_oCursorSig; + + void vUpdateSize(); + void vStartCursorTimeout(); + void vStopCursorTimeout(); + void vHideCursor(); + void vShowCursor(); +}; + +} // namespace VBA + + +#endif // __VBA_SCREENAREA_H__ diff --git a/src/gtk/sigccompat.h b/src/gtk/sigccompat.h new file mode 100644 index 0000000..d640d1d --- /dev/null +++ b/src/gtk/sigccompat.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_SIGCCOMPAT_H__ +#define __VBA_SIGCCOMPAT_H__ + +#undef LIBSIGC_DISABLE_DEPRECATED +#include +#include + +#include +#include +#include + +namespace SigC +{ + +template +inline Slot0 +slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)() ) +{ return ::sigc::bound_mem_functor0 + (dynamic_cast< T_obj1&>(_A_obj), _A_func); } + +template +inline Slot1 +slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)(T_arg1) ) +{ return ::sigc::bound_mem_functor1 + (dynamic_cast< T_obj1&>(_A_obj), _A_func); } + +template +inline Slot2 +slot( T_obj1& _A_obj, T_return (T_obj2::*_A_func)(T_arg1,T_arg2) ) +{ return ::sigc::bound_mem_functor2 + (dynamic_cast< T_obj1&>(_A_obj), _A_func); } + +} // namespace SigC + + +#endif // __VBA_SIGCCOMPAT_H__ diff --git a/src/gtk/system.cpp b/src/gtk/system.cpp new file mode 100644 index 0000000..888eaf3 --- /dev/null +++ b/src/gtk/system.cpp @@ -0,0 +1,343 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#include +#include + +#include "../GBA.h" +#include "../gb/GB.h" +#include "../gb/gbGlobals.h" +#include "../Util.h" +#include "../Sound.h" + +#include "window.h" +#include "intl.h" + +// Required vars, used by the emulator core +// +int systemRedShift; +int systemGreenShift; +int systemBlueShift; +int systemColorDepth; +int systemDebug; +int systemVerbose; +int systemSaveUpdateCounter; +int systemFrameSkip; +u32 systemColorMap32[0x10000]; +u16 systemColorMap16[0x10000]; +u16 systemGbPalette[24]; +bool systemSoundOn; + +int emulating; +bool debugger; +int RGB_LOW_BITS_MASK; + +// Extra vars, only used for the GUI +// +int systemRenderedFrames; +int systemFPS; + +// Sound stuff +// +const int iSoundSamples = 2048; +const int iSoundTotalLen = iSoundSamples * 4; +static u8 auiSoundBuffer[iSoundTotalLen]; +static int iSoundLen; +static SDL_cond * pstSoundCond; +static SDL_mutex * pstSoundMutex; + +inline VBA::Window * GUI() +{ + return VBA::Window::poGetInstance(); +} + +void systemMessage(int _iId, const char * _csFormat, ...) +{ + va_list args; + va_start(args, _csFormat); + + GUI()->vPopupErrorV(_(_csFormat), args); + + va_end(args); +} + +void systemDrawScreen() +{ + GUI()->vDrawScreen(); + systemRenderedFrames++; +} + +bool systemReadJoypads() +{ + return true; +} + +u32 systemReadJoypad(int,bool) +{ + return GUI()->uiReadJoypad(); +} + +void systemShowSpeed(int _iSpeed) +{ + systemFPS = systemRenderedFrames; + systemRenderedFrames = 0; + + GUI()->vShowSpeed(_iSpeed); +} + +void system10Frames(int _iRate) +{ + GUI()->vComputeFrameskip(_iRate); +} + +void systemFrame() +{ +} + +void systemSetTitle(const char * _csTitle) +{ + GUI()->set_title(_csTitle); +} + +void systemScreenCapture(int _iNum) +{ + GUI()->vCaptureScreen(_iNum); +} + +void systemWriteDataToSoundBuffer() +{ + if (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING) + { + SDL_PauseAudio(0); + } + + bool bWait = true; + while (bWait && ! speedup && GUI()->iGetThrottle() == 0) + { + SDL_mutexP(pstSoundMutex); + if (iSoundLen < iSoundTotalLen) + { + bWait = false; + } + SDL_mutexV(pstSoundMutex); + } + + int iLen = soundBufferLen; + int iCopied = 0; + if (iSoundLen + iLen >= iSoundTotalLen) + { + iCopied = iSoundTotalLen - iSoundLen; + memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, iCopied); + + iSoundLen = iSoundTotalLen; + SDL_CondSignal(pstSoundCond); + + bWait = true; + if (! speedup && GUI()->iGetThrottle() == 0) + { + while(bWait) + { + SDL_mutexP(pstSoundMutex); + if (iSoundLen < iSoundTotalLen) + { + bWait = false; + } + SDL_mutexV(pstSoundMutex); + } + + memcpy(auiSoundBuffer, ((u8 *)soundFinalWave) + iCopied, + soundBufferLen - iCopied); + + iSoundLen = soundBufferLen - iCopied; + } + else + { + memcpy(auiSoundBuffer, ((u8 *)soundFinalWave) + iCopied, + soundBufferLen); + } + } + else + { + memcpy(&auiSoundBuffer[iSoundLen], soundFinalWave, soundBufferLen); + iSoundLen += soundBufferLen; + } +} + +static void vSoundCallback(void * _pvUserData, u8 * _puiStream, int _iLen) +{ + if (! emulating) + { + return; + } + + SDL_mutexP(pstSoundMutex); + if (! speedup && GUI()->iGetThrottle() == 0) + { + while (iSoundLen < iSoundTotalLen && emulating) + { + SDL_CondWait(pstSoundCond, pstSoundMutex); + } + } + if (emulating) + { + memcpy(_puiStream, auiSoundBuffer, _iLen); + } + iSoundLen = 0; + SDL_mutexV(pstSoundMutex); +} + +bool systemSoundInit() +{ + SDL_AudioSpec stAudio; + + switch (soundQuality) + { + case 1: + stAudio.freq = 44100; + soundBufferLen = 1470 * 2; + break; + case 2: + stAudio.freq = 22050; + soundBufferLen = 736 * 2; + break; + case 4: + stAudio.freq = 11025; + soundBufferLen = 368 * 2; + break; + } + + stAudio.format = AUDIO_S16SYS; + stAudio.channels = 2; + stAudio.samples = iSoundSamples; + stAudio.callback = vSoundCallback; + stAudio.userdata = NULL; + + if (SDL_OpenAudio(&stAudio, NULL) < 0) + { + fprintf(stderr, "Failed to open audio: %s\n", SDL_GetError()); + return false; + } + + pstSoundCond = SDL_CreateCond(); + pstSoundMutex = SDL_CreateMutex(); + + soundBufferTotalLen = soundBufferLen * 10; + iSoundLen = 0; + systemSoundOn = true; + + return true; +} + +void systemSoundShutdown() +{ + SDL_mutexP(pstSoundMutex); + int iSave = emulating; + emulating = 0; + SDL_CondSignal(pstSoundCond); + SDL_mutexV(pstSoundMutex); + + SDL_DestroyCond(pstSoundCond); + pstSoundCond = NULL; + + SDL_DestroyMutex(pstSoundMutex); + pstSoundMutex = NULL; + + SDL_CloseAudio(); + + emulating = iSave; + systemSoundOn = false; +} + +void systemSoundPause() +{ + SDL_PauseAudio(1); +} + +void systemSoundResume() +{ + SDL_PauseAudio(0); +} + +void systemSoundReset() +{ +} + +u32 systemGetClock() +{ + return SDL_GetTicks(); +} + +void systemUpdateMotionSensor() +{ +} + +int systemGetSensorX() +{ + return 0; +} + +int systemGetSensorY() +{ + return 0; +} + +void systemGbPrint(u8 * _puiData, + int _iPages, + int _iFeed, + int _iPalette, + int _iContrast) +{ +} + +void systemScreenMessage(const char * _csMsg, int slot, int duration, const char *colorList) +{ +} + +bool systemCanChangeSoundQuality() +{ + return true; +} + +bool systemPauseOnFrame() +{ + return false; +} + +void systemGbBorderOn() +{ +} + +void debuggerMain() +{ +} + +void debuggerSignal(int, int) +{ +} + +void debuggerOutput(char *, u32) +{ +} + +void (*dbgMain)() = debuggerMain; +void (*dbgSignal)(int, int) = debuggerSignal; +void (*dbgOutput)(char *, u32) = debuggerOutput; diff --git a/src/gtk/tools.cpp b/src/gtk/tools.cpp new file mode 100644 index 0000000..6e1a065 --- /dev/null +++ b/src/gtk/tools.cpp @@ -0,0 +1,65 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "tools.h" + +namespace VBA +{ + +std::string sCutSuffix(const std::string & _rsString, + const std::string & _rsSep) +{ + return _rsString.substr(0, _rsString.find_last_of(_rsSep)); +} + +Glib::ustring sCutSuffix(const Glib::ustring & _rsString, + const Glib::ustring & _rsSep) +{ + return _rsString.substr(0, _rsString.find_last_of(_rsSep)); +} + +bool bHasSuffix(const Glib::ustring & _rsString, + const Glib::ustring & _rsSuffix, + bool _bCaseSensitive) +{ + if (_rsSuffix.size() > _rsString.size()) + { + return false; + } + + Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size()); + + if (_bCaseSensitive) + { + if (_rsSuffix == sEnd) + { + return true; + } + } + else + { + if (_rsSuffix.lowercase() == sEnd.lowercase()) + { + return true; + } + } + + return false; +} + +} // namespace VBA diff --git a/src/gtk/tools.h b/src/gtk/tools.h new file mode 100644 index 0000000..6dca228 --- /dev/null +++ b/src/gtk/tools.h @@ -0,0 +1,42 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_TOOLS_H__ +#define __VBA_TOOLS_H__ + +#include +#include + +namespace VBA +{ + +std::string sCutSuffix(const std::string & _rsString, + const std::string & _rsSep = "."); + +Glib::ustring sCutSuffix(const Glib::ustring & _rsString, + const Glib::ustring & _rsSep = "."); + +bool bHasSuffix(const Glib::ustring & _rsString, + const Glib::ustring & _rsSuffix, + bool _bCaseSensitive = true); + +} + + +#endif // __VBA_TOOLS_H__ diff --git a/src/gtk/vba.glade b/src/gtk/vba.glade new file mode 100644 index 0000000..ca1cc8a --- /dev/null +++ b/src/gtk/vba.glade @@ -0,0 +1,3597 @@ + + + + + + + VBA + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + + + + True + False + 0 + + + + True + GTK_SHADOW_OUT + GTK_POS_LEFT + GTK_POS_TOP + + + + True + + + + True + _File + True + + + + + + + True + _Open... + True + + + + + True + gtk-open + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + + + + + + True + _Load... + True + + + + + + + True + _Save... + True + + + + + + + True + Loa_d game + True + + + + + + + True + Most recent + True + + + + + + True + Auto load most recent + True + False + + + + + + True + + + + + + True + Slot1 + True + + + + + + + True + Slot2 + True + + + + + + + True + Slot3 + True + + + + + + + True + Slot4 + True + + + + + + + True + Slot5 + True + + + + + + + True + Slot6 + True + + + + + + + True + Slot7 + True + + + + + + + True + Slot8 + True + + + + + + + True + Slot9 + True + + + + + + + True + Slot10 + True + + + + + + + + + + + True + S_ave game + True + + + + + + + True + Oldest slot + True + + + + + + True + + + + + + True + Slot1 + True + + + + + + + True + Slot2 + True + + + + + + + True + Slot3 + True + + + + + + + True + Slot4 + True + + + + + + + True + Slot5 + True + + + + + + + True + Slot6 + True + + + + + + + True + Slot7 + True + + + + + + + True + Slot8 + True + + + + + + + True + Slot9 + True + + + + + + + True + Slot10 + True + + + + + + + + + + + True + + + + + + True + _Pause + True + False + + + + + + + True + _Reset + True + + + + + + + True + + + + + + True + Rece_nt + True + + + + + + + True + _Reset + True + + + + + + True + _Freeze + True + False + + + + + + True + + + + + + + + + + True + + + + + + True + _Import + True + + + + + + + True + _Battery file... + True + + + + + + + + + + True + E_xport + True + + + + + + + True + _Battery file... + True + + + + + + + + + + True + + + + + + True + Screen capt_ure... + True + + + + + + True + + + + + + True + _Close + True + + + + True + gtk-close + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + _Exit + True + + + + + True + gtk-quit + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + + + + + True + _Options + True + + + + + + + True + _Frameskip + True + + + + + + + True + _Throttle + True + + + + + + + True + _No throttle + True + True + + + + + + True + 25% + True + False + ThrottleNoThrottle + + + + + + True + 50% + True + False + ThrottleNoThrottle + + + + + + True + 100% + True + False + ThrottleNoThrottle + + + + + + True + 150% + True + False + ThrottleNoThrottle + + + + + + True + 200% + True + False + ThrottleNoThrottle + + + + + + True + _Other... + True + False + ThrottleNoThrottle + + + + + + + + + + True + + + + + + True + _Automatic + True + True + + + + + + True + _0 + True + False + FrameskipAutomatic + + + + + + True + _1 + True + False + FrameskipAutomatic + + + + + + True + _2 + True + False + FrameskipAutomatic + + + + + + True + _3 + True + False + FrameskipAutomatic + + + + + + True + _4 + True + False + FrameskipAutomatic + + + + + + True + _5 + True + False + FrameskipAutomatic + + + + + + True + _6 + True + False + FrameskipAutomatic + + + + + + True + _7 + True + False + FrameskipAutomatic + + + + + + True + _8 + True + False + FrameskipAutomatic + + + + + + True + _9 + True + False + FrameskipAutomatic + + + + + + + + + + True + _Video + True + + + + + + + True + _1x + True + True + + + + + + True + _2x + True + False + Video1x + + + + + + True + _3x + True + False + Video1x + + + + + + True + _4x + True + False + Video1x + + + + + + True + _5x + True + False + Video1x + + + + + + True + _6x + True + False + Video1x + + + + + + True + + + + + + True + _Layers + True + + + + + + + True + BG0 + True + False + + + + + + + True + BG1 + True + False + + + + + + + True + BG2 + True + False + + + + + + + True + BG3 + True + False + + + + + + + True + OBJ + True + False + + + + + + + True + WIN0 + True + False + + + + + + + True + WIN1 + True + False + + + + + + + True + OBJWIN + True + False + + + + + + + + + + + + + + + True + _Emulator + True + + + + + + + True + Directories... + True + + + + + + True + Pause when inactive window + True + False + + + + + + True + Show speed + True + + + + + + + True + None + True + True + + + + + + True + Percentage + True + False + ShowSpeedNone + + + + + + True + Detailed + True + False + ShowSpeedNone + + + + + + + + + + True + Save type + True + + + + + + + True + _Automatic + True + True + + + + + + True + EEPROM + True + False + SaveTypeAutomatic + + + + + + True + SRAM + True + False + SaveTypeAutomatic + + + + + + True + Flash + True + False + SaveTypeAutomatic + + + + + + True + EEPROM+Sensor + True + False + SaveTypeAutomatic + + + + + + True + None + True + False + SaveTypeAutomatic + + + + + + True + + + + + + True + Flash 64K + True + True + + + + + + True + Flash 128K + True + False + SaveTypeFlash64K + + + + + + + + + + True + + + + + + True + _Select BIOS file... + True + + + + + + True + _Use BIOS file + True + False + + + + + + True + + + + + + True + Screenshot format + True + + + + + + + True + _PNG + True + True + + + + + + True + _BMP + True + False + ScreenshotFormatPNG + + + + + + + + + + + + + + True + _Sound + True + + + + + + + True + O_ff + True + True + + + + + + True + _Mute + True + False + SoundOff + + + + + + True + _On + True + False + SoundOff + + + + + + True + + + + + + True + Echo + True + False + + + + + + True + Low pass filter + True + False + + + + + + True + Reverse stereo + True + False + + + + + + True + + + + + + True + Channel _1 + True + False + + + + + + True + Channel _2 + True + False + + + + + + True + Channel _3 + True + False + + + + + + True + Channel _4 + True + False + + + + + + True + Channel _A + True + False + + + + + + True + Channel _B + True + False + + + + + + True + + + + + + True + 11 _Khz + True + True + + + + + + True + 22 K_hz + True + False + Sound11Khz + + + + + + True + 44 Kh_z + True + False + Sound11Khz + + + + + + True + + + + + + True + _Volume + True + + + + + + + True + 25% + True + True + + + + + + True + 50% + True + False + Volume25 + + + + + + True + 100% + True + False + Volume25 + + + + + + True + 200% + True + False + Volume25 + + + + + + True + 300% + True + False + Volume25 + + + + + + True + 400% + True + False + Volume25 + + + + + + + + + + + + + + True + _Gameboy + True + + + + + + + True + _Border + True + False + + + + + + True + _Printer + True + False + + + + + + True + + + + + + True + _Automatic + True + True + + + + + + True + _GBA + True + False + GameboyAutomatic + + + + + + True + _CGB/GBC + True + False + GameboyAutomatic + + + + + + True + _SGB + True + False + GameboyAutomatic + + + + + + True + SGB_2 + True + False + GameboyAutomatic + + + + + + True + G_B + True + False + GameboyAutomatic + + + + + + + + + + True + F_ilter + True + + + + + + + True + Interframe _blending + True + + + + + + + True + _None + True + True + + + + + + True + _Smart + True + False + IFBNone + + + + + + True + _Motion Blur + True + False + IFBNone + + + + + + + + + + True + + + + + + True + _None + True + True + + + + + + True + _TV Mode + True + False + FilterNone + + + + + + True + _2xSaI + True + False + FilterNone + + + + + + True + _Super 2xSaI + True + False + FilterNone + + + + + + True + Super _Eagle + True + False + FilterNone + + + + + + True + _Pixelate + True + False + FilterNone + + + + + + True + _Motion Blur + True + False + FilterNone + + + + + + True + _AdvanceMAME 2x + True + False + FilterNone + + + + + + True + S_imple 2x + True + False + FilterNone + + + + + + True + Bilinea_r + True + False + FilterNone + + + + + + True + Bilinear Pl_us + True + False + FilterNone + + + + + + True + S_canlines + True + False + FilterNone + + + + + + True + h_q2x + True + False + FilterNone + + + + + + True + _lq2x + True + False + FilterNone + + + + + + True + + + + + + True + _Disable MMX + True + False + + + + + + + + + + True + _Joypad + True + + + + + + + True + _Configure + True + + + + + + + True + _1... + True + + + + + + True + _2... + True + + + + + + True + _3... + True + + + + + + True + _4... + True + + + + + + + + + + True + + + + + + True + _1 + True + True + + + + + + True + _2 + True + False + Joypad1 + + + + + + True + _3 + True + False + Joypad1 + + + + + + True + _4 + True + False + Joypad1 + + + + + + True + + + + + + True + _Autofire + True + + + + + + + True + _A + True + False + + + + + + + True + _B + True + False + + + + + + + True + _L + True + False + + + + + + + True + _R + True + False + + + + + + + + + + + + + + + + + + + True + _Tools + True + + + + + + + True + _GDB + True + + + + + + + True + _Wait connection... + True + + + + + + True + _Load and wait... + True + + + + + + True + _Break + True + + + + + + True + _Disconnect + True + + + + + + + + + + + + + + True + _Help + True + + + + + + + True + _About + True + + + + + + + + + + + 0 + False + True + + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + + + 0 + True + True + + + + + + + + About VBA + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + + + 0 + True + True + + + + + + True + True + + False + True + GTK_JUSTIFY_CENTER + False + True + 0.5 + 0.5 + 5 + 5 + + + 0 + True + False + + + + + + True + True + An emulator for Gameboy(TM) and GameboyAdvance(TM). + False + False + GTK_JUSTIFY_CENTER + True + True + 0.5 + 0.5 + 5 + 5 + + + 0 + True + False + + + + + + True + True + <i>Special thanks to Yann Parmentier aka "kohai" for the icons.</i> + False + True + GTK_JUSTIFY_LEFT + False + True + 0.5 + 0.5 + 5 + 5 + + + 0 + True + False + + + + + + True + True + <small>Copyright (C) 2004 Forgotten and the VBA development team</small> + False + True + GTK_JUSTIFY_CENTER + True + True + 0.5 + 0.5 + 5 + 5 + + + 0 + True + False + + + + + + + + Throttle + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 0 + + + + True + Throttle : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + True + True + 100 5 1000 1 25 25 + + + 0 + True + True + + + + + + True + % + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + + + Directories + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 5 + 4 + False + 0 + 0 + + + + True + GBA roms : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + expand + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 0 + 1 + fill + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 3 + 4 + 0 + 1 + fill + expand + + + + + + True + GB roms : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 3 + 4 + 1 + 2 + fill + expand + + + + + + True + Batteries : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + expand + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 3 + 4 + 2 + 3 + fill + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 2 + 3 + fill + expand + + + + + + True + Saves : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + expand + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 3 + 4 + fill + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 3 + 4 + 3 + 4 + fill + expand + + + + + + True + Captures : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + expand + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 4 + 5 + fill + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 3 + 4 + 4 + 5 + fill + expand + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + expand + + + + + + True + True + GTK_RELIEF_NONE + + + + True + gtk-cancel + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 1 + 2 + fill + expand + + + + + 0 + True + True + + + + + + + + Joypad config + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 0.5 + 0.5 + 0 + 1 + + + + True + 12 + 2 + False + 5 + 0 + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + fill + expand + + + + + + True + Down : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + expand + + + + + + True + Left : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + expand + + + + + + True + Right : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + expand + + + + + + True + Button A : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + expand + + + + + + True + Button B : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + expand + + + + + + True + Button L : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 6 + 7 + fill + expand + + + + + + True + Button R : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 7 + 8 + fill + expand + + + + + + True + Select : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 8 + 9 + fill + expand + + + + + + True + Start : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 9 + 10 + fill + expand + + + + + + True + Speed : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 10 + 11 + fill + expand + + + + + + True + Capture : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 11 + 12 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 5 + 6 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 6 + 7 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 7 + 8 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 8 + 9 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 9 + 10 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 10 + 11 + fill + expand + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 11 + 12 + fill + expand + + + + + + True + Up : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + expand + + + + + + + 0 + True + True + + + + + + + + TCP port + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 0 + + + + True + Port : + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + True + True + 55555 1 65535 1 100 100 + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + + diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp new file mode 100644 index 0000000..9fa2b24 --- /dev/null +++ b/src/gtk/window.cpp @@ -0,0 +1,1942 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "window.h" + +#include + +#include +#include + +#include + +#include "../GBA.h" +#include "../gb/GB.h" +#include "../gb/gbGlobals.h" +#include "../gb/gbPrinter.h" +#include "../Sound.h" +#include "../Util.h" + +#include "menuitem.h" +#include "tools.h" +#include "intl.h" + +extern int systemRenderedFrames; +extern int systemFPS; +extern bool debugger; +extern int RGB_LOW_BITS_MASK; +extern void (*dbgMain)(); +extern void (*dbgSignal)(int, int); +extern void (*dbgOutput)(char *, u32); +extern void remoteInit(); +extern void remoteCleanUp(); +extern void remoteStubMain(); +extern void remoteStubSignal(int, int); +extern void remoteOutput(char *, u32); +extern void remoteSetProtocol(int); +extern void remoteSetPort(int); + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif // MMX + +namespace VBA +{ + +using Gnome::Glade::Xml; + +Window * Window::m_poInstance = NULL; + +Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : + Gtk::Window (_pstWindow), + m_iGBScreenWidth (160), + m_iGBScreenHeight (144), + m_iSGBScreenWidth (256), + m_iSGBScreenHeight(224), + m_iGBAScreenWidth (240), + m_iGBAScreenHeight(160), + m_iFrameskipMin (0), + m_iFrameskipMax (9), + m_iThrottleMin (5), + m_iThrottleMax (1000), + m_iScaleMin (1), + m_iScaleMax (6), + m_iShowSpeedMin (ShowNone), + m_iShowSpeedMax (ShowDetailed), + m_iSaveTypeMin (SaveAuto), + m_iSaveTypeMax (SaveNone), + m_iSoundQualityMin(Sound44K), + m_iSoundQualityMax(Sound11K), + m_iSoundVolumeMin (Sound100), + m_iSoundVolumeMax (Sound50), + m_iEmulatorTypeMin(EmulatorAuto), + m_iEmulatorTypeMax(EmulatorSGB2), + m_iFilter2xMin (FirstFilter), + m_iFilter2xMax (LastFilter), + m_iFilterIBMin (FirstFilterIB), + m_iFilterIBMax (LastFilterIB), + m_iJoypadMin (1), + m_iJoypadMax (4) +{ + m_poXml = _poXml; + m_poFileOpenDialog = NULL; + m_iScreenWidth = m_iGBAScreenWidth; + m_iScreenHeight = m_iGBAScreenHeight; + m_eCartridge = CartridgeNone; + m_uiJoypadState = 0; + + vInitSystem(); + vInitSDL(); + + Gtk::Container * poC; + poC = dynamic_cast(_poXml->get_widget("ScreenContainer")); + m_poScreenArea = Gtk::manage(new ScreenArea(m_iScreenWidth, m_iScreenHeight)); + poC->add(*m_poScreenArea); + vDrawDefaultScreen(); + m_poScreenArea->show(); + + // Get config + // + vInitConfig(); + + m_sUserDataDir = Glib::get_home_dir() + "/.gvba"; + m_sConfigFile = m_sUserDataDir + "/config"; + + if (! Glib::file_test(m_sUserDataDir, Glib::FILE_TEST_EXISTS)) + { + mkdir(m_sUserDataDir.c_str(), 0777); + } + if (Glib::file_test(m_sConfigFile, Glib::FILE_TEST_EXISTS)) + { + vLoadConfig(m_sConfigFile); + vCheckConfig(); + } + else + { + vSaveConfig(m_sConfigFile); + } + + vCreateFileOpenDialog(); + vLoadHistoryFromConfig(); + vLoadJoypadsFromConfig(); + + Gtk::MenuItem * poMI; + Gtk::CheckMenuItem * poCMI; + + // File menu + // + poMI = dynamic_cast(_poXml->get_widget("FileOpen")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileOpen)); + + poMI = dynamic_cast(_poXml->get_widget("FileLoad")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileLoad)); + m_listSensitiveWhenPlaying.push_back(poMI); + + poMI = dynamic_cast(_poXml->get_widget("FileSave")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileSave)); + m_listSensitiveWhenPlaying.push_back(poMI); + + for (int i = 0; i < 10; i++) + { + char csName[20]; + snprintf(csName, 20, "LoadGameSlot%d", i + 1); + m_apoLoadGameItem[i] = dynamic_cast(_poXml->get_widget(csName)); + snprintf(csName, 20, "SaveGameSlot%d", i + 1); + m_apoSaveGameItem[i] = dynamic_cast(_poXml->get_widget(csName)); + + m_apoLoadGameItem[i]->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnLoadGame), + i + 1)); + m_apoSaveGameItem[i]->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSaveGame), + i + 1)); + } + vUpdateGameSlots(); + + poMI = dynamic_cast(_poXml->get_widget("LoadGameMostRecent")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnLoadGameMostRecent)); + m_listSensitiveWhenPlaying.push_back(poMI); + + poCMI = dynamic_cast(_poXml->get_widget("LoadGameAuto")); + poCMI->set_active(m_poCoreConfig->oGetKey("load_game_auto")); + vOnLoadGameAutoToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnLoadGameAutoToggled), + poCMI)); + + poMI = dynamic_cast(_poXml->get_widget("SaveGameOldest")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnSaveGameOldest)); + m_listSensitiveWhenPlaying.push_back(poMI); + + m_poFilePauseItem = dynamic_cast(_poXml->get_widget("FilePause")); + m_poFilePauseItem->set_active(false); + vOnFilePauseToggled(m_poFilePauseItem); + m_poFilePauseItem->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnFilePauseToggled), + m_poFilePauseItem)); + m_listSensitiveWhenPlaying.push_back(m_poFilePauseItem); + + poMI = dynamic_cast(_poXml->get_widget("FileReset")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileReset)); + m_listSensitiveWhenPlaying.push_back(poMI); + + poMI = dynamic_cast(_poXml->get_widget("FileScreenCapture")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileScreenCapture)); + m_listSensitiveWhenPlaying.push_back(poMI); + + poMI = dynamic_cast(_poXml->get_widget("FileClose")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileClose)); + m_listSensitiveWhenPlaying.push_back(poMI); + + poMI = dynamic_cast(_poXml->get_widget("FileExit")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnFileExit)); + + // Recent menu + // + m_poRecentMenu = dynamic_cast(_poXml->get_widget("RecentMenu_menu")); + vUpdateHistoryMenu(); + + m_poRecentResetItem = dynamic_cast(_poXml->get_widget("RecentReset")); + m_poRecentResetItem->signal_activate().connect(SigC::slot(*this, &Window::vOnRecentReset)); + + poCMI = dynamic_cast(_poXml->get_widget("RecentFreeze")); + poCMI->set_active(m_poHistoryConfig->oGetKey("freeze")); + vOnRecentFreezeToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnRecentFreezeToggled), + poCMI)); + + // Import menu + // + poMI = dynamic_cast(_poXml->get_widget("ImportBatteryFile")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnImportBatteryFile)); + m_listSensitiveWhenPlaying.push_back(poMI); + + // Export menu + // + poMI = dynamic_cast(_poXml->get_widget("ExportBatteryFile")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnExportBatteryFile)); + m_listSensitiveWhenPlaying.push_back(poMI); + + // Frameskip menu + // + struct + { + const char * m_csName; + const int m_iFrameskip; + } + astFrameskip[] = + { + { "FrameskipAutomatic", -1 }, + { "Frameskip0", 0 }, + { "Frameskip1", 1 }, + { "Frameskip2", 2 }, + { "Frameskip3", 3 }, + { "Frameskip4", 4 }, + { "Frameskip5", 5 }, + { "Frameskip6", 6 }, + { "Frameskip7", 7 }, + { "Frameskip8", 8 }, + { "Frameskip9", 9 } + }; + int iDefaultFrameskip; + if (m_poCoreConfig->sGetKey("frameskip") == "auto") + { + iDefaultFrameskip = -1; + } + else + { + iDefaultFrameskip = m_poCoreConfig->oGetKey("frameskip"); + } + for (guint i = 0; i < G_N_ELEMENTS(astFrameskip); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astFrameskip[i].m_csName)); + if (astFrameskip[i].m_iFrameskip == iDefaultFrameskip) + { + poCMI->set_active(); + vOnFrameskipToggled(poCMI, iDefaultFrameskip); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnFrameskipToggled), + poCMI, astFrameskip[i].m_iFrameskip)); + } + + // Throttle menu + // + struct + { + const char * m_csName; + const int m_iThrottle; + } + astThrottle[] = + { + { "ThrottleNoThrottle", 0 }, + { "Throttle25", 25 }, + { "Throttle50", 50 }, + { "Throttle100", 100 }, + { "Throttle150", 150 }, + { "Throttle200", 200 } + }; + poCMI = dynamic_cast(_poXml->get_widget("ThrottleOther")); + poCMI->set_active(); + poCMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnThrottleOther), + poCMI)); + + int iDefaultThrottle = m_poCoreConfig->oGetKey("throttle"); + for (guint i = 0; i < G_N_ELEMENTS(astThrottle); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astThrottle[i].m_csName)); + if (astThrottle[i].m_iThrottle == iDefaultThrottle) + { + poCMI->set_active(); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnThrottleToggled), + poCMI, astThrottle[i].m_iThrottle)); + } + vSetThrottle(iDefaultThrottle); + + // Video menu + // + struct + { + const char * m_csName; + const int m_iScale; + } + astVideoScale[] = + { + { "Video1x", 1 }, + { "Video2x", 2 }, + { "Video3x", 3 }, + { "Video4x", 4 }, + { "Video5x", 5 }, + { "Video6x", 6 } + }; + int iDefaultScale = m_poDisplayConfig->oGetKey("scale"); + for (guint i = 0; i < G_N_ELEMENTS(astVideoScale); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astVideoScale[i].m_csName)); + if (astVideoScale[i].m_iScale == iDefaultScale) + { + poCMI->set_active(); + vOnVideoScaleToggled(poCMI, iDefaultScale); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnVideoScaleToggled), + poCMI, astVideoScale[i].m_iScale)); + } + + // Layers menu + // + struct + { + const char * m_csName; + const char * m_csKey; + const int m_iLayer; + } + astLayer[] = + { + { "LayersBg0", "layer_bg0", 0 }, + { "LayersBg1", "layer_bg1", 1 }, + { "LayersBg2", "layer_bg2", 2 }, + { "LayersBg3", "layer_bg3", 3 }, + { "LayersObj", "layer_obj", 4 }, + { "LayersWin0", "layer_win0", 5 }, + { "LayersWin1", "layer_win1", 6 }, + { "LayersObjWin", "layer_objwin", 7 } + }; + for (guint i = 0; i < G_N_ELEMENTS(astLayer); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astLayer[i].m_csName)); + poCMI->set_active(m_poCoreConfig->oGetKey(astLayer[i].m_csKey)); + vOnLayerToggled(poCMI, astLayer[i].m_iLayer); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnLayerToggled), + poCMI, astLayer[i].m_iLayer)); + } + + // Emulator menu + // + poMI = dynamic_cast(_poXml->get_widget("EmulatorDirectories")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnDirectories)); + + poCMI = dynamic_cast(_poXml->get_widget("EmulatorPauseWhenInactive")); + poCMI->set_active(m_poDisplayConfig->oGetKey("pause_when_inactive")); + vOnPauseWhenInactiveToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnPauseWhenInactiveToggled), + poCMI)); + + m_poUseBiosItem = dynamic_cast(_poXml->get_widget("EmulatorUseBios")); + m_poUseBiosItem->set_active(m_poCoreConfig->oGetKey("use_bios_file")); + if (m_poCoreConfig->sGetKey("bios_file") == "") + { + m_poUseBiosItem->set_sensitive(false); + } + m_poUseBiosItem->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnUseBiosToggled), + m_poUseBiosItem)); + + poMI = dynamic_cast(_poXml->get_widget("EmulatorSelectBios")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnSelectBios)); + + // Show speed menu + // + struct + { + const char * m_csName; + const EShowSpeed m_eShowSpeed; + } + astShowSpeed[] = + { + { "ShowSpeedNone", ShowNone }, + { "ShowSpeedPercentage", ShowPercentage }, + { "ShowSpeedDetailed", ShowDetailed } + }; + EShowSpeed eDefaultShowSpeed = (EShowSpeed)m_poDisplayConfig->oGetKey("show_speed"); + for (guint i = 0; i < G_N_ELEMENTS(astShowSpeed); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astShowSpeed[i].m_csName)); + if (astShowSpeed[i].m_eShowSpeed == eDefaultShowSpeed) + { + poCMI->set_active(); + vOnShowSpeedToggled(poCMI, eDefaultShowSpeed); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnShowSpeedToggled), + poCMI, astShowSpeed[i].m_eShowSpeed)); + } + + // Save type menu + // + struct + { + const char * m_csName; + const ESaveType m_eSaveType; + } + astSaveType[] = + { + { "SaveTypeAutomatic", SaveAuto }, + { "SaveTypeEeprom", SaveEEPROM }, + { "SaveTypeSram", SaveSRAM }, + { "SaveTypeFlash", SaveFlash }, + { "SaveTypeEepromSensor", SaveEEPROMSensor }, + { "SaveTypeNone", SaveNone } + }; + ESaveType eDefaultSaveType = (ESaveType)m_poCoreConfig->oGetKey("save_type"); + for (guint i = 0; i < G_N_ELEMENTS(astSaveType); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astSaveType[i].m_csName)); + if (astSaveType[i].m_eSaveType == eDefaultSaveType) + { + poCMI->set_active(); + vOnSaveTypeToggled(poCMI, eDefaultSaveType); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSaveTypeToggled), + poCMI, astSaveType[i].m_eSaveType)); + } + + // Flash size menu + // + struct + { + const char * m_csName; + const int m_iFlashSize; + } + astFlashSize[] = + { + { "SaveTypeFlash64K", 64 }, + { "SaveTypeFlash128K", 128 } + }; + int iDefaultFlashSize = m_poCoreConfig->oGetKey("flash_size"); + for (guint i = 0; i < G_N_ELEMENTS(astFlashSize); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astFlashSize[i].m_csName)); + if (astFlashSize[i].m_iFlashSize == iDefaultFlashSize) + { + poCMI->set_active(); + vOnFlashSizeToggled(poCMI, iDefaultFlashSize); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnFlashSizeToggled), + poCMI, astFlashSize[i].m_iFlashSize)); + } + + // Screenshot format menu + // + struct + { + const char * m_csName; + const char * m_csScreenshotFormat; + } + astScreenshotFormat[] = + { + { "ScreenshotFormatPNG", "png" }, + { "ScreenshotFormatBMP", "bmp" } + }; + std::string sDefaultScreenshotFormat = m_poCoreConfig->sGetKey("screenshot_format"); + for (guint i = 0; i < G_N_ELEMENTS(astScreenshotFormat); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astScreenshotFormat[i].m_csName)); + if (astScreenshotFormat[i].m_csScreenshotFormat == sDefaultScreenshotFormat) + { + poCMI->set_active(); + vOnScreenshotFormatToggled(poCMI, sDefaultScreenshotFormat); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnScreenshotFormatToggled), + poCMI, std::string(astScreenshotFormat[i].m_csScreenshotFormat))); + } + + // Sound menu + // + std::string sDefaultSoundStatus = m_poSoundConfig->sGetKey("status"); + + poCMI = dynamic_cast(_poXml->get_widget("SoundOff")); + if (sDefaultSoundStatus == "off") + { + poCMI->set_active(); + vOnSoundStatusToggled(poCMI, SoundOff); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundStatusToggled), + poCMI, SoundOff)); + m_poSoundOffItem = poCMI; + + poCMI = dynamic_cast(_poXml->get_widget("SoundMute")); + if (sDefaultSoundStatus == "mute") + { + poCMI->set_active(); + vOnSoundStatusToggled(poCMI, SoundMute); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundStatusToggled), + poCMI, SoundMute)); + + poCMI = dynamic_cast(_poXml->get_widget("SoundOn")); + if (sDefaultSoundStatus == "on") + { + poCMI->set_active(); + vOnSoundStatusToggled(poCMI, SoundOn); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundStatusToggled), + poCMI, SoundOn)); + + poCMI = dynamic_cast(_poXml->get_widget("SoundEcho")); + poCMI->set_active(m_poSoundConfig->oGetKey("echo")); + vOnSoundEchoToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundEchoToggled), + poCMI)); + + poCMI = dynamic_cast(_poXml->get_widget("SoundLowPass")); + poCMI->set_active(m_poSoundConfig->oGetKey("low_pass")); + vOnSoundLowPassToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundLowPassToggled), + poCMI)); + + poCMI = dynamic_cast(_poXml->get_widget("SoundReverseStereo")); + poCMI->set_active(m_poSoundConfig->oGetKey("reverse_stereo")); + vOnSoundReverseToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundReverseToggled), + poCMI)); + + struct + { + const char * m_csName; + const char * m_csKey; + const int m_iSoundChannel; + } + astSoundChannel[] = + { + { "SoundChannel1", "channel_1", 0 }, + { "SoundChannel2", "channel_2", 1 }, + { "SoundChannel3", "channel_3", 2 }, + { "SoundChannel4", "channel_4", 3 }, + { "SoundChannelA", "channel_A", 4 }, + { "SoundChannelB", "channel_B", 5 } + }; + for (guint i = 0; i < G_N_ELEMENTS(astSoundChannel); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astSoundChannel[i].m_csName)); + poCMI->set_active(m_poSoundConfig->oGetKey(astSoundChannel[i].m_csKey)); + vOnSoundChannelToggled(poCMI, astSoundChannel[i].m_iSoundChannel); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundChannelToggled), + poCMI, astSoundChannel[i].m_iSoundChannel)); + } + + struct + { + const char * m_csName; + const ESoundQuality m_eSoundQuality; + } + astSoundQuality[] = + { + { "Sound11Khz", Sound11K }, + { "Sound22Khz", Sound22K }, + { "Sound44Khz", Sound44K } + }; + ESoundQuality eDefaultSoundQuality = (ESoundQuality)m_poSoundConfig->oGetKey("quality"); + for (guint i = 0; i < G_N_ELEMENTS(astSoundQuality); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astSoundQuality[i].m_csName)); + if (astSoundQuality[i].m_eSoundQuality == eDefaultSoundQuality) + { + poCMI->set_active(); + vOnSoundQualityToggled(poCMI, eDefaultSoundQuality); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundQualityToggled), + poCMI, astSoundQuality[i].m_eSoundQuality)); + } + + // Volume menu + // + struct + { + const char * m_csName; + const ESoundVolume m_eSoundVolume; + } + astSoundVolume[] = + { + { "Volume25", Sound25 }, + { "Volume50", Sound50 }, + { "Volume100", Sound100 }, + { "Volume200", Sound200 }, + { "Volume300", Sound300 }, + { "Volume400", Sound400 } + }; + ESoundVolume eDefaultSoundVolume = (ESoundVolume)m_poSoundConfig->oGetKey("volume"); + for (guint i = 0; i < G_N_ELEMENTS(astSoundVolume); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astSoundVolume[i].m_csName)); + if (astSoundVolume[i].m_eSoundVolume == eDefaultSoundVolume) + { + poCMI->set_active(); + vOnSoundVolumeToggled(poCMI, eDefaultSoundVolume); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnSoundVolumeToggled), + poCMI, astSoundVolume[i].m_eSoundVolume)); + } + + // Gameboy menu + // + poCMI = dynamic_cast(_poXml->get_widget("GameboyBorder")); + poCMI->set_active(m_poCoreConfig->oGetKey("gb_border")); + vOnGBBorderToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnGBBorderToggled), + poCMI)); + + poCMI = dynamic_cast(_poXml->get_widget("GameboyPrinter")); + poCMI->set_active(m_poCoreConfig->oGetKey("gb_printer")); + vOnGBPrinterToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnGBPrinterToggled), + poCMI)); + + struct + { + const char * m_csName; + const EEmulatorType m_eEmulatorType; + } + astEmulatorType[] = + { + { "GameboyAutomatic", EmulatorAuto }, + { "GameboyGba", EmulatorGBA }, + { "GameboyCgb", EmulatorCGB }, + { "GameboySgb", EmulatorSGB }, + { "GameboySgb2", EmulatorSGB2 }, + { "GameboyGb", EmulatorGB } + }; + EEmulatorType eDefaultEmulatorType = (EEmulatorType)m_poCoreConfig->oGetKey("emulator_type"); + for (guint i = 0; i < G_N_ELEMENTS(astEmulatorType); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astEmulatorType[i].m_csName)); + if (astEmulatorType[i].m_eEmulatorType == eDefaultEmulatorType) + { + poCMI->set_active(); + vOnEmulatorTypeToggled(poCMI, eDefaultEmulatorType); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnEmulatorTypeToggled), + poCMI, astEmulatorType[i].m_eEmulatorType)); + } + + // Filter menu + // + struct + { + const char * m_csName; + const EFilter2x m_eFilter2x; + } + astFilter2x[] = + { + { "FilterNone", FilterNone }, + { "FilterTVMode", FilterScanlinesTV }, + { "Filter2xSaI", Filter2xSaI }, + { "FilterSuper2xSaI", FilterSuper2xSaI }, + { "FilterSuperEagle", FilterSuperEagle }, + { "FilterPixelate", FilterPixelate }, + { "FilterMotionBlur", FilterMotionBlur }, + { "FilterAdvanceMame2x", FilterAdMame2x }, + { "FilterSimple2x", FilterSimple2x }, + { "FilterBilinear", FilterBilinear }, + { "FilterBilinearPlus", FilterBilinearPlus }, + { "FilterScanlines", FilterScanlines }, + { "FilterHq2x", FilterHq2x }, + { "FilterLq2x", FilterLq2x } + }; + EFilter2x eDefaultFilter2x = (EFilter2x)m_poDisplayConfig->oGetKey("filter2x"); + for (guint i = 0; i < G_N_ELEMENTS(astFilter2x); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astFilter2x[i].m_csName)); + if (astFilter2x[i].m_eFilter2x == eDefaultFilter2x) + { + poCMI->set_active(); + vOnFilter2xToggled(poCMI, eDefaultFilter2x); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnFilter2xToggled), + poCMI, astFilter2x[i].m_eFilter2x)); + } + + poCMI = dynamic_cast(_poXml->get_widget("FilterDisableMmx")); +#ifdef MMX + poCMI->set_active(m_poDisplayConfig->oGetKey("filter_disable_mmx")); + vOnDisableMMXToggled(poCMI); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnDisableMMXToggled), + poCMI)); +#else // ! MMX + poCMI->set_active(); + poCMI->set_sensitive(false); +#endif // ! MMX + + // Interframe blending menu + // + struct + { + const char * m_csName; + const EFilterIB m_eFilterIB; + } + astFilterIB[] = + { + { "IFBNone", FilterIBNone }, + { "IFBSmart", FilterIBSmart }, + { "IFBMotionBlur", FilterIBMotionBlur } + }; + EFilterIB eDefaultFilterIB = (EFilterIB)m_poDisplayConfig->oGetKey("filterIB"); + for (guint i = 0; i < G_N_ELEMENTS(astFilterIB); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astFilterIB[i].m_csName)); + if (astFilterIB[i].m_eFilterIB == eDefaultFilterIB) + { + poCMI->set_active(); + vOnFilterIBToggled(poCMI, eDefaultFilterIB); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnFilterIBToggled), + poCMI, astFilterIB[i].m_eFilterIB)); + } + + // Joypad menu + // + poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure1")); + poMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnJoypadConfigure), 1)); + + poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure2")); + poMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnJoypadConfigure), 2)); + + poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure3")); + poMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnJoypadConfigure), 3)); + + poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure4")); + poMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnJoypadConfigure), 4)); + + int iDefaultJoypad = m_poInputConfig->oGetKey("active_joypad"); + for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) + { + char csName[20]; + snprintf(csName, sizeof(csName), "Joypad%d", i); + + poCMI = dynamic_cast(_poXml->get_widget(csName)); + if (i == iDefaultJoypad) + { + poCMI->set_active(); + vOnJoypadToggled(poCMI, iDefaultJoypad); + } + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnJoypadToggled), + poCMI, i)); + } + + // Autofire menu + // + struct + { + const char * m_csName; + const char * m_csKey; + const EKeyFlag m_eKeyFlag; + } + astAutofire[] = + { + { "AutofireA", "autofire_A", KeyFlagA }, + { "AutofireB", "autofire_B", KeyFlagB }, + { "AutofireL", "autofire_L", KeyFlagL }, + { "AutofireR", "autofire_R", KeyFlagR } + }; + for (guint i = 0; i < G_N_ELEMENTS(astAutofire); i++) + { + poCMI = dynamic_cast(_poXml->get_widget(astAutofire[i].m_csName)); + poCMI->set_active(m_poInputConfig->oGetKey(astAutofire[i].m_csKey)); + vOnAutofireToggled(poCMI, astAutofire[i].m_eKeyFlag); + poCMI->signal_toggled().connect(SigC::bind( + SigC::slot(*this, &Window::vOnAutofireToggled), + poCMI, astAutofire[i].m_eKeyFlag)); + } + + // GDB menu + // + poMI = dynamic_cast(_poXml->get_widget("GdbWait")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBWait)); + + poMI = dynamic_cast(_poXml->get_widget("GdbLoadAndWait")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBLoadAndWait)); + + poMI = dynamic_cast(_poXml->get_widget("GdbBreak")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBBreak)); + + poMI = dynamic_cast(_poXml->get_widget("GdbDisconnect")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnGDBDisconnect)); + + // Help menu + // + poMI = dynamic_cast(_poXml->get_widget("HelpAbout")); + poMI->signal_activate().connect(SigC::slot(*this, &Window::vOnHelpAbout)); + + // Init widgets sensitivity + for (std::list::iterator it = m_listSensitiveWhenPlaying.begin(); + it != m_listSensitiveWhenPlaying.end(); + it++) + { + (*it)->set_sensitive(false); + } + + if (m_poInstance == NULL) + { + m_poInstance = this; + } + else + { + abort(); + } +} + +Window::~Window() +{ + vOnFileClose(); + vSaveHistoryToConfig(); + vSaveJoypadsToConfig(); + vSaveConfig(m_sConfigFile); + + if (m_poFileOpenDialog != NULL) + { + delete m_poFileOpenDialog; + } + + if (m_poKeymap != NULL) + { + delete m_poKeymap; + } + + m_poInstance = NULL; +} + +void Window::vInitSystem() +{ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + systemRedShift = 3; + systemGreenShift = 11; + systemBlueShift = 19; + RGB_LOW_BITS_MASK = 0x00010101; +#else + systemRedShift = 27; + systemGreenShift = 19; + systemBlueShift = 11; + RGB_LOW_BITS_MASK = 0x01010100; +#endif + + systemColorDepth = 32; + systemDebug = 0; + systemVerbose = 0; + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + systemFrameSkip = 0; + systemSoundOn = false; + soundOffFlag = true; + + systemRenderedFrames = 0; + systemFPS = 0; + + emulating = 0; + debugger = false; + + for (int i = 0; i < 0x10000; i++) + { +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + systemColorMap32[i] = (((i & 0x1f) << systemRedShift) + | (((i & 0x3e0) >> 5) << systemGreenShift) + | (((i & 0x7c00) >> 10) << systemBlueShift)); +#else + systemColorMap32[i] = (((i & 0x1f) << systemRedShift) + | (((i & 0x3e0) >> 5) << systemGreenShift) + | (((i & 0x7c00) >> 10) << systemBlueShift)); +#endif + } + + gbFrameSkip = 0; + + for (int i = 0; i < 24; ) + { + systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); + systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + systemGbPalette[i++] = 0; + } + + Init_2xSaI(32); +} + +void Window::vInitSDL() +{ + static bool bDone = false; + + if (bDone) + return; + + int iFlags = (SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE); + + if (SDL_Init(iFlags) < 0) + { + fprintf(stderr, "Failed to init SDL: %s", SDL_GetError()); + abort(); + } + + bDone = true; +} + +void Window::vInitConfig() +{ + m_oConfig.vClear(); + + // History section + // + m_poHistoryConfig = m_oConfig.poAddSection("History"); + m_poHistoryConfig->vSetKey("freeze", false ); + m_poHistoryConfig->vSetKey("0", "" ); + m_poHistoryConfig->vSetKey("1", "" ); + m_poHistoryConfig->vSetKey("2", "" ); + m_poHistoryConfig->vSetKey("3", "" ); + m_poHistoryConfig->vSetKey("4", "" ); + m_poHistoryConfig->vSetKey("5", "" ); + m_poHistoryConfig->vSetKey("6", "" ); + m_poHistoryConfig->vSetKey("7", "" ); + m_poHistoryConfig->vSetKey("8", "" ); + m_poHistoryConfig->vSetKey("9", "" ); + + // Directories section + // + m_poDirConfig = m_oConfig.poAddSection("Directories"); + m_poDirConfig->vSetKey("gb_roms", "" ); + m_poDirConfig->vSetKey("gba_roms", "" ); + m_poDirConfig->vSetKey("batteries", "" ); + m_poDirConfig->vSetKey("saves", "" ); + m_poDirConfig->vSetKey("captures", "" ); + + // Core section + // + m_poCoreConfig = m_oConfig.poAddSection("Core"); + m_poCoreConfig->vSetKey("load_game_auto", false ); + m_poCoreConfig->vSetKey("frameskip", "auto" ); + m_poCoreConfig->vSetKey("throttle", 0 ); + m_poCoreConfig->vSetKey("layer_bg0", true ); + m_poCoreConfig->vSetKey("layer_bg1", true ); + m_poCoreConfig->vSetKey("layer_bg2", true ); + m_poCoreConfig->vSetKey("layer_bg3", true ); + m_poCoreConfig->vSetKey("layer_obj", true ); + m_poCoreConfig->vSetKey("layer_win0", true ); + m_poCoreConfig->vSetKey("layer_win1", true ); + m_poCoreConfig->vSetKey("layer_objwin", true ); + m_poCoreConfig->vSetKey("use_bios_file", false ); + m_poCoreConfig->vSetKey("bios_file", "" ); + m_poCoreConfig->vSetKey("save_type", SaveAuto ); + m_poCoreConfig->vSetKey("flash_size", 64 ); + m_poCoreConfig->vSetKey("gb_border", true ); + m_poCoreConfig->vSetKey("gb_printer", false ); + m_poCoreConfig->vSetKey("emulator_type", EmulatorAuto ); + m_poCoreConfig->vSetKey("screenshot_format", "png" ); + + // Display section + // + m_poDisplayConfig = m_oConfig.poAddSection("Display"); + m_poDisplayConfig->vSetKey("scale", 1 ); + m_poDisplayConfig->vSetKey("show_speed", ShowPercentage ); + m_poDisplayConfig->vSetKey("pause_when_inactive", true ); + m_poDisplayConfig->vSetKey("filter2x", FilterNone ); + m_poDisplayConfig->vSetKey("filterIB", FilterIBNone ); +#ifdef MMX + m_poDisplayConfig->vSetKey("filter_disable_mmx", false ); +#endif // MMX + + // Sound section + // + m_poSoundConfig = m_oConfig.poAddSection("Sound"); + m_poSoundConfig->vSetKey("status", "on" ); + m_poSoundConfig->vSetKey("echo", false ); + m_poSoundConfig->vSetKey("low_pass", false ); + m_poSoundConfig->vSetKey("reverse_stereo", false ); + m_poSoundConfig->vSetKey("channel_1", true ); + m_poSoundConfig->vSetKey("channel_2", true ); + m_poSoundConfig->vSetKey("channel_3", true ); + m_poSoundConfig->vSetKey("channel_4", true ); + m_poSoundConfig->vSetKey("channel_A", true ); + m_poSoundConfig->vSetKey("channel_B", true ); + m_poSoundConfig->vSetKey("quality", Sound22K ); + m_poSoundConfig->vSetKey("volume", Sound100 ); + + // Input section + // + JoypadConfig oJoypadConfig; + oJoypadConfig.vSetDefault(); + m_poInputConfig = m_oConfig.poAddSection("Input"); + m_poInputConfig->vSetKey("active_joypad", m_iJoypadMin ); + for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) + { + char csPrefix[20]; + snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i); + std::string sPrefix(csPrefix); + m_poInputConfig->vSetKey(sPrefix + "up", oJoypadConfig.m_uiUp ); + m_poInputConfig->vSetKey(sPrefix + "down", oJoypadConfig.m_uiDown ); + m_poInputConfig->vSetKey(sPrefix + "left", oJoypadConfig.m_uiLeft ); + m_poInputConfig->vSetKey(sPrefix + "right", oJoypadConfig.m_uiRight ); + m_poInputConfig->vSetKey(sPrefix + "A", oJoypadConfig.m_uiA ); + m_poInputConfig->vSetKey(sPrefix + "B", oJoypadConfig.m_uiB ); + m_poInputConfig->vSetKey(sPrefix + "L", oJoypadConfig.m_uiL ); + m_poInputConfig->vSetKey(sPrefix + "R", oJoypadConfig.m_uiR ); + m_poInputConfig->vSetKey(sPrefix + "select", oJoypadConfig.m_uiSelect ); + m_poInputConfig->vSetKey(sPrefix + "start", oJoypadConfig.m_uiStart ); + m_poInputConfig->vSetKey(sPrefix + "speed", oJoypadConfig.m_uiSpeed ); + m_poInputConfig->vSetKey(sPrefix + "capture", oJoypadConfig.m_uiCapture ); + } + m_poInputConfig->vSetKey("autofire_A", false ); + m_poInputConfig->vSetKey("autofire_B", false ); + m_poInputConfig->vSetKey("autofire_L", false ); + m_poInputConfig->vSetKey("autofire_R", false ); +} + +void Window::vCheckConfig() +{ + int iValue; + int iAdjusted; + std::string sValue; + + // Directories section + // + sValue = m_poDirConfig->sGetKey("gb_roms"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("gb_roms", ""); + } + sValue = m_poDirConfig->sGetKey("gba_roms"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("gba_roms", ""); + } + sValue = m_poDirConfig->sGetKey("batteries"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("batteries", ""); + } + sValue = m_poDirConfig->sGetKey("saves"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("saves", ""); + } + sValue = m_poDirConfig->sGetKey("captures"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_DIR)) + { + m_poDirConfig->vSetKey("captures", ""); + } + + // Core section + // + if (m_poCoreConfig->sGetKey("frameskip") != "auto") + { + iValue = m_poCoreConfig->oGetKey("frameskip"); + iAdjusted = CLAMP(iValue, m_iFrameskipMin, m_iFrameskipMax); + if (iValue != iAdjusted) + { + m_poCoreConfig->vSetKey("frameskip", iAdjusted); + } + } + + iValue = m_poCoreConfig->oGetKey("throttle"); + if (iValue != 0) + { + iAdjusted = CLAMP(iValue, m_iThrottleMin, m_iThrottleMax); + if (iValue != iAdjusted) + { + m_poCoreConfig->vSetKey("throttle", iAdjusted); + } + } + + sValue = m_poCoreConfig->sGetKey("bios_file"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_REGULAR)) + { + m_poCoreConfig->vSetKey("bios_file", ""); + } + if (m_poCoreConfig->sGetKey("bios_file") == "") + { + m_poCoreConfig->vSetKey("use_bios_file", false); + } + + iValue = m_poCoreConfig->oGetKey("save_type"); + if (iValue != 0) + { + iAdjusted = CLAMP(iValue, m_iSaveTypeMin, m_iSaveTypeMax); + if (iValue != iAdjusted) + { + m_poCoreConfig->vSetKey("save_type", iAdjusted); + } + } + + iValue = m_poCoreConfig->oGetKey("flash_size"); + if (iValue != 64 && iValue != 128) + { + m_poCoreConfig->vSetKey("flash_size", 64); + } + + iValue = m_poCoreConfig->oGetKey("emulator_type"); + iAdjusted = CLAMP(iValue, m_iEmulatorTypeMin, m_iEmulatorTypeMax); + if (iValue != iAdjusted) + { + m_poCoreConfig->vSetKey("emulator_type", iAdjusted); + } + + sValue = m_poCoreConfig->sGetKey("screenshot_format"); + if (sValue != "png" && sValue != "bmp") + { + sValue = "png"; + } + + // Display section + // + iValue = m_poDisplayConfig->oGetKey("scale"); + iAdjusted = CLAMP(iValue, m_iScaleMin, m_iScaleMax); + if (iValue != iAdjusted) + { + m_poDisplayConfig->vSetKey("scale", iAdjusted); + } + + iValue = m_poDisplayConfig->oGetKey("show_speed"); + iAdjusted = CLAMP(iValue, m_iShowSpeedMin, m_iShowSpeedMax); + if (iValue != iAdjusted) + { + m_poDisplayConfig->vSetKey("show_speed", iAdjusted); + } + + iValue = m_poDisplayConfig->oGetKey("filter2x"); + iAdjusted = CLAMP(iValue, m_iFilter2xMin, m_iFilter2xMax); + if (iValue != iAdjusted) + { + m_poDisplayConfig->vSetKey("filter2x", iAdjusted); + } + + iValue = m_poDisplayConfig->oGetKey("filterIB"); + iAdjusted = CLAMP(iValue, m_iFilterIBMin, m_iFilterIBMax); + if (iValue != iAdjusted) + { + m_poDisplayConfig->vSetKey("filterIB", iAdjusted); + } + + // Sound section + // + sValue = m_poSoundConfig->sGetKey("status"); + if (sValue != "off" && sValue != "on" && sValue != "mute") + { + m_poSoundConfig->vSetKey("status", "on"); + } + + iValue = m_poSoundConfig->oGetKey("quality"); + iAdjusted = CLAMP(iValue, m_iSoundQualityMin, m_iSoundQualityMax); + if (iValue != iAdjusted) + { + m_poSoundConfig->vSetKey("quality", iAdjusted); + } + + iValue = m_poSoundConfig->oGetKey("volume"); + iAdjusted = CLAMP(iValue, m_iSoundVolumeMin, m_iSoundVolumeMax); + if (iValue != iAdjusted) + { + m_poSoundConfig->vSetKey("volume", iAdjusted); + } + + // Input section + // + iValue = m_poInputConfig->oGetKey("active_joypad"); + iAdjusted = CLAMP(iValue, m_iJoypadMin, m_iJoypadMax); + if (iValue != iAdjusted) + { + m_poInputConfig->vSetKey("active_joypad", iAdjusted); + } +} + +void Window::vLoadConfig(const std::string & _rsFile) +{ + try + { + m_oConfig.vLoad(_rsFile, false, false); + } + catch (const Glib::Error & e) + { + vPopupError(e.what().c_str()); + } +} + +void Window::vSaveConfig(const std::string & _rsFile) +{ + try + { + m_oConfig.vSave(_rsFile); + } + catch (const Glib::Error & e) + { + vPopupError(e.what().c_str()); + } +} + +void Window::vLoadHistoryFromConfig() +{ + char csKey[] = "0"; + for (int i = 0; i < 10; i++, csKey[0]++) + { + std::string sFile = m_poHistoryConfig->sGetKey(csKey); + if (sFile == "") + { + break; + } + m_listHistory.push_back(sFile); + } +} + +void Window::vSaveHistoryToConfig() +{ + char csKey[] = "0"; + for (std::list::const_iterator it = m_listHistory.begin(); + it != m_listHistory.end(); + it++, csKey[0]++) + { + m_poHistoryConfig->vSetKey(csKey, *it); + } +} + +void Window::vHistoryAdd(const std::string & _rsFile) +{ + if (m_poHistoryConfig->oGetKey("freeze")) + { + return; + } + + m_listHistory.remove(_rsFile); + m_listHistory.push_front(_rsFile); + if (m_listHistory.size() > 10) + { + m_listHistory.pop_back(); + } + + vUpdateHistoryMenu(); +} + +void Window::vClearHistoryMenu() +{ + Gtk::Menu_Helpers::MenuList::iterator it = m_poRecentMenu->items().begin(); + for (int i = 0; i < 3; i++, it++) + ; + + m_poRecentMenu->items().erase(it, m_poRecentMenu->items().end()); +} + +void Window::vUpdateHistoryMenu() +{ + vClearHistoryMenu(); + + guint uiAccelKey = GDK_F1; + for (std::list::const_iterator it = m_listHistory.begin(); + it != m_listHistory.end(); + it++, uiAccelKey++) + { + Gtk::Image * poImage = Gtk::manage(new Gtk::Image(Gtk::Stock::OPEN, Gtk::ICON_SIZE_MENU)); + Glib::ustring sLabel = Glib::path_get_basename(*it); + VBA::ImageMenuItem * poIMI = Gtk::manage(new VBA::ImageMenuItem(*poImage, sLabel)); + + m_oTooltips.set_tip(*poIMI, *it); + + poIMI->signal_activate().connect(SigC::bind( + SigC::slot(*this, &Window::vOnRecentFile), + *it)); + + poIMI->set_accel_key(Gtk::AccelKey(uiAccelKey, Gdk::CONTROL_MASK)); + poIMI->accelerate(*this); + + poIMI->show(); + m_poRecentMenu->items().push_back(*poIMI); + } +} + +void Window::vLoadJoypadsFromConfig() +{ + m_oJoypads.clear(); + + for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) + { + char csPrefix[20]; + snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i); + std::string sPrefix(csPrefix); + + JoypadConfig oJoypadConfig; + oJoypadConfig.m_uiUp = m_poInputConfig->oGetKey(sPrefix + "up"); + oJoypadConfig.m_uiDown = m_poInputConfig->oGetKey(sPrefix + "down"); + oJoypadConfig.m_uiLeft = m_poInputConfig->oGetKey(sPrefix + "left"); + oJoypadConfig.m_uiRight = m_poInputConfig->oGetKey(sPrefix + "right"); + oJoypadConfig.m_uiA = m_poInputConfig->oGetKey(sPrefix + "A"); + oJoypadConfig.m_uiB = m_poInputConfig->oGetKey(sPrefix + "B"); + oJoypadConfig.m_uiL = m_poInputConfig->oGetKey(sPrefix + "L"); + oJoypadConfig.m_uiR = m_poInputConfig->oGetKey(sPrefix + "R"); + oJoypadConfig.m_uiSelect = m_poInputConfig->oGetKey(sPrefix + "select"); + oJoypadConfig.m_uiStart = m_poInputConfig->oGetKey(sPrefix + "start"); + oJoypadConfig.m_uiSpeed = m_poInputConfig->oGetKey(sPrefix + "speed"); + oJoypadConfig.m_uiCapture = m_poInputConfig->oGetKey(sPrefix + "capture"); + + m_oJoypads.push_back(oJoypadConfig); + } +} + +void Window::vSaveJoypadsToConfig() +{ + for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) + { + char csPrefix[20]; + snprintf(csPrefix, sizeof(csPrefix), "joypad%d_", i); + std::string sPrefix(csPrefix); + + m_poInputConfig->vSetKey(sPrefix + "up", m_oJoypads[i - 1].m_uiUp ); + m_poInputConfig->vSetKey(sPrefix + "down", m_oJoypads[i - 1].m_uiDown ); + m_poInputConfig->vSetKey(sPrefix + "left", m_oJoypads[i - 1].m_uiLeft ); + m_poInputConfig->vSetKey(sPrefix + "right", m_oJoypads[i - 1].m_uiRight ); + m_poInputConfig->vSetKey(sPrefix + "A", m_oJoypads[i - 1].m_uiA ); + m_poInputConfig->vSetKey(sPrefix + "B", m_oJoypads[i - 1].m_uiB ); + m_poInputConfig->vSetKey(sPrefix + "L", m_oJoypads[i - 1].m_uiL ); + m_poInputConfig->vSetKey(sPrefix + "R", m_oJoypads[i - 1].m_uiR ); + m_poInputConfig->vSetKey(sPrefix + "select", m_oJoypads[i - 1].m_uiSelect ); + m_poInputConfig->vSetKey(sPrefix + "start", m_oJoypads[i - 1].m_uiStart ); + m_poInputConfig->vSetKey(sPrefix + "speed", m_oJoypads[i - 1].m_uiSpeed ); + m_poInputConfig->vSetKey(sPrefix + "capture", m_oJoypads[i - 1].m_uiCapture ); + } +} + +void Window::vUpdateScreen() +{ + if (m_eCartridge == CartridgeGB) + { + if (gbBorderOn) + { + m_iScreenWidth = m_iSGBScreenWidth; + m_iScreenHeight = m_iSGBScreenHeight; + gbBorderLineSkip = m_iSGBScreenWidth; + gbBorderColumnSkip = (m_iSGBScreenWidth - m_iGBScreenWidth) / 2; + gbBorderRowSkip = (m_iSGBScreenHeight - m_iGBScreenHeight) / 2; + } + else + { + m_iScreenWidth = m_iGBScreenWidth; + m_iScreenHeight = m_iGBScreenHeight; + gbBorderLineSkip = m_iGBScreenWidth; + gbBorderColumnSkip = 0; + gbBorderRowSkip = 0; + } + } + else if (m_eCartridge == CartridgeGBA) + { + m_iScreenWidth = m_iGBAScreenWidth; + m_iScreenHeight = m_iGBAScreenHeight; + } + + g_return_if_fail(m_iScreenWidth >= 1 && m_iScreenHeight >= 1); + + m_poScreenArea->vSetSize(m_iScreenWidth, m_iScreenHeight); + m_poScreenArea->vSetScale(m_poDisplayConfig->oGetKey("scale")); + + resize(1, 1); + + if (emulating) + { + vDrawScreen(); + } + else + { + vDrawDefaultScreen(); + } +} + +bool Window::bLoadROM(const std::string & _rsFile) +{ + vOnFileClose(); + + m_sRomFile = _rsFile; + const char * csFile = _rsFile.c_str(); + + IMAGE_TYPE eType = utilFindType(csFile); + if (eType == IMAGE_UNKNOWN) + { + vPopupError(_("Unknown file type %s"), csFile); + return false; + } + + bool bLoaded = false; + if (eType == IMAGE_GB) + { + bLoaded = gbLoadRom(csFile); + if (bLoaded) + { + m_eCartridge = CartridgeGB; + m_stEmulator = GBSystem; + } + } + else if (eType == IMAGE_GBA) + { + int iSize = CPULoadRom(csFile); + bLoaded = (iSize > 0); + if (bLoaded) + { + m_eCartridge = CartridgeGBA; + m_stEmulator = GBASystem; + + useBios = m_poCoreConfig->oGetKey("use_bios_file"); + CPUInit(m_poCoreConfig->sGetKey("bios_file").c_str(), useBios); + CPUReset(); + + // If the bios file was rejected by CPUInit + if (m_poCoreConfig->oGetKey("use_bios_file") && ! useBios) + { + m_poUseBiosItem->set_active(false); + m_poUseBiosItem->set_sensitive(false); + m_poCoreConfig->vSetKey("bios_file", ""); + } + } + } + + if (! bLoaded) + { + return false; + } + + vLoadBattery(); + vUpdateScreen(); + + debugger = false; // May cause conflicts + emulating = 1; + m_bWasEmulating = false; + m_uiThrottleDelay = 0; + + if (m_eCartridge == CartridgeGBA) + { + soundSetQuality(m_eSoundQuality); + } + else + { + gbSoundSetQuality(m_eSoundQuality); + } + + vUpdateGameSlots(); + vHistoryAdd(_rsFile); + + for (std::list::iterator it = m_listSensitiveWhenPlaying.begin(); + it != m_listSensitiveWhenPlaying.end(); + it++) + { + (*it)->set_sensitive(); + } + + if (m_poCoreConfig->oGetKey("load_game_auto")) + { + vOnLoadGameMostRecent(); + } + + vStartEmu(); + + return true; +} + +void Window::vPopupError(const char * _csFormat, ...) +{ + va_list args; + va_start(args, _csFormat); + char * csMsg = g_strdup_vprintf(_csFormat, args); + va_end(args); + + Gtk::MessageDialog oDialog(*this, + csMsg, +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_ERROR, + Gtk::BUTTONS_OK); + oDialog.run(); + g_free(csMsg); +} + +void Window::vPopupErrorV(const char * _csFormat, va_list _args) +{ + char * csMsg = g_strdup_vprintf(_csFormat, _args); + + Gtk::MessageDialog oDialog(*this, + csMsg, +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_ERROR, + Gtk::BUTTONS_OK); + oDialog.run(); + g_free(csMsg); +} + +void Window::vDrawScreen() +{ + m_poScreenArea->vDrawPixels(pix); +} + +void Window::vDrawDefaultScreen() +{ + m_poScreenArea->vDrawColor(0x000000); // Black +} + +void Window::vSetDefaultTitle() +{ + set_title("VBA"); +} + +void Window::vShowSpeed(int _iSpeed) +{ + char csTitle[50]; + + if (m_eShowSpeed == ShowPercentage) + { + snprintf(csTitle, 50, "VBA - %d%%", _iSpeed); + set_title(csTitle); + } + else if (m_eShowSpeed == ShowDetailed) + { + snprintf(csTitle, 50, "VBA - %d%% (%d, %d fps)", + _iSpeed, systemFrameSkip, systemFPS); + set_title(csTitle); + } +} + +void Window::vComputeFrameskip(int _iRate) +{ + static u32 uiLastTime = 0; + static int iFrameskipAdjust = 0; + + u32 uiTime = SDL_GetTicks(); + + if (m_bWasEmulating) + { + int iWantedSpeed = 100; + + if (m_iThrottle > 0) + { + if (! speedup) + { + u32 uiDiff = uiTime - m_uiThrottleLastTime; + int iTarget = 1000000 / (_iRate * m_iThrottle); + int iDelay = iTarget - uiDiff; + if (iDelay > 0) + { + m_uiThrottleDelay = iDelay; + } + } + iWantedSpeed = m_iThrottle; + } + + if (m_bAutoFrameskip) + { + u32 uiDiff = uiTime - uiLastTime; + int iSpeed = iWantedSpeed; + + if (uiDiff != 0) + { + iSpeed = (1000000 / _iRate) / uiDiff; + } + + if (iSpeed >= iWantedSpeed - 2) + { + iFrameskipAdjust++; + if (iFrameskipAdjust >= 3) + { + iFrameskipAdjust = 0; + if (systemFrameSkip > 0) + { + systemFrameSkip--; + } + } + } + else + { + if (iSpeed < iWantedSpeed - 20) + { + iFrameskipAdjust -= ((iWantedSpeed - 10) - iSpeed) / 5; + } + else if (systemFrameSkip < 9) + { + iFrameskipAdjust--; + } + + if (iFrameskipAdjust <= -2) + { + iFrameskipAdjust += 2; + if (systemFrameSkip < 9) + { + systemFrameSkip++; + } + } + } + } + } + else + { + m_bWasEmulating = true; + } + + uiLastTime = uiTime; + m_uiThrottleLastTime = uiTime; +} + +void Window::vCaptureScreen(int _iNum) +{ + std::string sBaseName; + std::string sCaptureDir = m_poDirConfig->sGetKey("captures"); + if (sCaptureDir == "") + { + sBaseName = sCutSuffix(m_sRomFile); + } + else + { + sBaseName = sCaptureDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)); + } + std::string sFormat = m_poCoreConfig->sGetKey("screenshot_format"); + + char * csFile = g_strdup_printf("%s_%02d.%s", + sBaseName.c_str(), + _iNum, + sFormat.c_str()); + if (sFormat == "png") + { + m_stEmulator.emuWritePNG(csFile); + } + else + { + m_stEmulator.emuWriteBMP(csFile); + } + g_free(csFile); +} + +u32 Window::uiReadJoypad() +{ + u32 uiJoypad = m_uiJoypadState; + + if (m_uiAutofireState != 0) + { + uiJoypad &= ~m_uiAutofireState; + if (m_bAutofireToggle) + { + uiJoypad |= m_uiAutofireState; + } + m_bAutofireToggle = ! m_bAutofireToggle; + } + + return uiJoypad; +} + +void Window::vCreateFileOpenDialog() +{ + if (m_poFileOpenDialog != NULL) + { + return; + } + + std::string sGBDir = m_poDirConfig->sGetKey("gb_roms"); + std::string sGBADir = m_poDirConfig->sGetKey("gba_roms"); + +#ifdef GTKMM20 + + Gtk::FileSelection * poDialog = new Gtk::FileSelection(_("Open")); + poDialog->set_transient_for(*this); + + if (sGBADir != "") + { + poDialog->set_filename(sGBADir + "/"); + } + else if (sGBDir != "") + { + poDialog->set_filename(sGBDir + "/"); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog * poDialog = new Gtk::FileChooserDialog(*this, _("Open")); + poDialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + poDialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + if (sGBDir != "") + { + poDialog->add_shortcut_folder(sGBDir); + poDialog->set_current_folder(sGBDir); + } + + if (sGBADir != "" && sGBADir != sGBDir) + { + poDialog->add_shortcut_folder(sGBADir); + poDialog->set_current_folder(sGBADir); + } + + const char * acsPattern[] = + { + // GBA + "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]", + // GB + "*.[gG][bB]", "*.[sS][gG][bB]", "*.[cC][gG][bB]", "*.[gG][bB][cC]", + // Both + "*.[mM][bB]", "*.[eE][lL][fF]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]" + }; + + Gtk::FileFilter oAllGBAFilter; + oAllGBAFilter.set_name(_("All Gameboy Advance files")); + for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) + { + oAllGBAFilter.add_pattern(acsPattern[i]); + } + + Gtk::FileFilter oGBAFilter; + oGBAFilter.set_name(_("Gameboy Advance files")); + for (int i = 0; i < 3; i++) + { + oGBAFilter.add_pattern(acsPattern[i]); + } + + Gtk::FileFilter oGBFilter; + oGBFilter.set_name(_("Gameboy files")); + for (int i = 3; i < 7; i++) + { + oGBFilter.add_pattern(acsPattern[i]); + } + + poDialog->add_filter(oAllGBAFilter); + poDialog->add_filter(oGBAFilter); + poDialog->add_filter(oGBFilter); + +#endif // ! GTKMM20 + + m_poFileOpenDialog = poDialog; +} + +void Window::vLoadBattery() +{ + std::string sBattery; + std::string sDir = m_poDirConfig->sGetKey("batteries"); + if (sDir == "") + { + sBattery = sCutSuffix(m_sRomFile) + ".sav"; + } + else + { + sBattery = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sav"; + } + + if (m_stEmulator.emuReadBattery(sBattery.c_str())) + { + systemScreenMessage(_("Loaded battery")); + } +} + +void Window::vSaveBattery() +{ + std::string sBattery; + std::string sDir = m_poDirConfig->sGetKey("batteries"); + if (sDir == "") + { + sBattery = sCutSuffix(m_sRomFile) + ".sav"; + } + else + { + sBattery = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)) + ".sav"; + } + + if (m_stEmulator.emuWriteBattery(sBattery.c_str())) + { + systemScreenMessage(_("Saved battery")); + } +} + +void Window::vStartEmu() +{ + if (m_oEmuSig.connected()) + { + return; + } + + m_oEmuSig = Glib::signal_idle().connect(SigC::slot(*this, &Window::bOnEmuIdle), + Glib::PRIORITY_DEFAULT_IDLE); +} + +void Window::vStopEmu() +{ + m_oEmuSig.disconnect(); + m_bWasEmulating = false; +} + +void Window::vSetThrottle(int _iPercent) +{ + m_iThrottle = _iPercent; + m_poCoreConfig->vSetKey("throttle", _iPercent); +} + +void Window::vSelectBestThrottleItem() +{ + struct + { + const char * m_csName; + const int m_iThrottle; + } + astThrottle[] = + { + { "ThrottleNoThrottle", 0 }, + { "Throttle25", 25 }, + { "Throttle50", 50 }, + { "Throttle100", 100 }, + { "Throttle150", 150 }, + { "Throttle200", 200 } + }; + for (guint i = 0; i < G_N_ELEMENTS(astThrottle); i++) + { + Gtk::CheckMenuItem * poCMI; + poCMI = dynamic_cast(m_poXml->get_widget(astThrottle[i].m_csName)); + if (astThrottle[i].m_iThrottle == m_iThrottle) + { + poCMI->set_active(); + } + } +} + +void Window::vUpdateGameSlots() +{ + if (m_eCartridge == CartridgeNone) + { + std::string sDateTime = _("----/--/-- --:--:--"); + + for (int i = 0; i < 10; i++) + { + char csPrefix[10]; + snprintf(csPrefix, sizeof(csPrefix), "%2d ", i + 1); + + Gtk::Label * poLabel; + poLabel = dynamic_cast(m_apoLoadGameItem[i]->get_child()); + poLabel->set_text(csPrefix + sDateTime); + m_apoLoadGameItem[i]->set_sensitive(false); + + poLabel = dynamic_cast(m_apoSaveGameItem[i]->get_child()); + poLabel->set_text(csPrefix + sDateTime); + m_apoSaveGameItem[i]->set_sensitive(false); + + m_astGameSlot[i].m_bEmpty = true; + } + } + else + { + std::string sFileBase; + std::string sDir = m_poDirConfig->sGetKey("saves"); + if (sDir == "") + { + sFileBase = sCutSuffix(m_sRomFile); + } + else + { + sFileBase = sDir + "/" + sCutSuffix(Glib::path_get_basename(m_sRomFile)); + } + + const char * csDateFormat = _("%Y/%m/%d %H:%M:%S"); + + for (int i = 0; i < 10; i++) + { + char csPrefix[10]; + snprintf(csPrefix, sizeof(csPrefix), "%2d ", i + 1); + + char csSlot[10]; + snprintf(csSlot, sizeof(csSlot), "%d", i + 1); + m_astGameSlot[i].m_sFile = sFileBase + csSlot + ".sgm"; + + std::string sDateTime; + struct stat stStat; + if (stat(m_astGameSlot[i].m_sFile.c_str(), &stStat) == -1) + { + sDateTime = _("----/--/-- --:--:--"); + m_astGameSlot[i].m_bEmpty = true; + } + else + { + char csDateTime[30]; + strftime(csDateTime, sizeof(csDateTime), csDateFormat, + localtime(&stStat.st_mtime)); + sDateTime = csDateTime; + m_astGameSlot[i].m_bEmpty = false; + m_astGameSlot[i].m_uiTime = stStat.st_mtime; + } + + Gtk::Label * poLabel; + poLabel = dynamic_cast(m_apoLoadGameItem[i]->get_child()); + poLabel->set_text(csPrefix + sDateTime); + m_apoLoadGameItem[i]->set_sensitive(! m_astGameSlot[i].m_bEmpty); + + poLabel = dynamic_cast(m_apoSaveGameItem[i]->get_child()); + poLabel->set_text(csPrefix + sDateTime); + m_apoSaveGameItem[i]->set_sensitive(); + } + } +} + +} // VBA namespace diff --git a/src/gtk/window.h b/src/gtk/window.h new file mode 100644 index 0000000..dee8e9e --- /dev/null +++ b/src/gtk/window.h @@ -0,0 +1,322 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VBA_WINDOW_H__ +#define __VBA_WINDOW_H__ + +#include +#include + +#include +#include + +#ifndef GTKMM20 +# include "sigccompat.h" +#endif // ! GTKMM20 + +#include +#include +#include + +#include "../System.h" + +#include "configfile.h" +#include "screenarea.h" +#include "filters.h" +#include "input.h" +#include "joypadconfig.h" + +namespace VBA +{ + +class Window : public Gtk::Window +{ + friend class Gnome::Glade::Xml; + +public: + virtual ~Window(); + + inline static Window * poGetInstance() { return m_poInstance; } + + enum ECartridge + { + CartridgeNone, + CartridgeGB, + CartridgeGBA + }; + + // GB/GBA screen sizes + const int m_iGBScreenWidth; + const int m_iGBScreenHeight; + const int m_iSGBScreenWidth; + const int m_iSGBScreenHeight; + const int m_iGBAScreenWidth; + const int m_iGBAScreenHeight; + + bool bLoadROM(const std::string & _rsFile); + void vPopupError(const char * _csFormat, ...); + void vPopupErrorV(const char * _csFormat, va_list _args); + void vDrawScreen(); + void vComputeFrameskip(int _iRate); + void vShowSpeed(int _iSpeed); + void vCaptureScreen(int _iNum); + u32 uiReadJoypad(); + + inline ECartridge eGetCartridge() const { return m_eCartridge; } + inline int iGetThrottle() const { return m_iThrottle; } + +protected: + Window(GtkWindow * _pstWindow, + const Glib::RefPtr & _poXml); + + enum EShowSpeed + { + ShowNone, + ShowPercentage, + ShowDetailed + }; + + enum ESaveType + { + SaveAuto, + SaveEEPROM, + SaveSRAM, + SaveFlash, + SaveEEPROMSensor, + SaveNone + }; + + enum ESoundStatus + { + SoundOff, + SoundMute, + SoundOn + }; + + enum ESoundQuality + { + Sound44K = 1, + Sound22K = 2, + Sound11K = 4 + }; + + enum ESoundVolume + { + Sound100, + Sound200, + Sound300, + Sound400, + Sound25, + Sound50 + }; + + enum EEmulatorType + { + EmulatorAuto, + EmulatorCGB, + EmulatorSGB, + EmulatorGB, + EmulatorGBA, + EmulatorSGB2 + }; + + virtual void vOnFileOpen(); + virtual void vOnFileLoad(); + virtual void vOnFileSave(); + virtual void vOnLoadGameMostRecent(); + virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnLoadGame(int _iSlot); + virtual void vOnSaveGameOldest(); + virtual void vOnSaveGame(int _iSlot); + virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnFileReset(); + virtual void vOnRecentReset(); + virtual void vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnRecentFile(std::string _sFile); + virtual void vOnImportBatteryFile(); + virtual void vOnExportBatteryFile(); + virtual void vOnFileScreenCapture(); + virtual void vOnFileClose(); + virtual void vOnFileExit(); + virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue); + virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); + virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); + virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); + virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); + virtual void vOnDirectories(); + virtual void vOnDirectoryReset(Gtk::Entry * _poEntry); + virtual void vOnDirectorySelect(Gtk::Entry * _poEntry); + virtual void vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnSelectBios(); + virtual void vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed); + virtual void vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType); + virtual void vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize); + virtual void vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat); + virtual void vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus); + virtual void vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel); + virtual void vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality); + virtual void vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume); + virtual void vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI); + virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType); + virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); + virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); +#ifdef MMX + virtual void vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI); +#endif // MMX + virtual void vOnJoypadConfigure(int _iJoypad); + virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad); + virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag); + virtual void vOnGDBWait(); + virtual void vOnGDBLoadAndWait(); + virtual void vOnGDBBreak(); + virtual void vOnGDBDisconnect(); + virtual void vOnHelpAbout(); + virtual bool bOnEmuIdle(); + + virtual bool on_focus_in_event(GdkEventFocus * _pstEvent); + virtual bool on_focus_out_event(GdkEventFocus * _pstEvent); + virtual bool on_key_press_event(GdkEventKey * _pstEvent); + virtual bool on_key_release_event(GdkEventKey * _pstEvent); + +private: + // Config limits + const int m_iFrameskipMin; + const int m_iFrameskipMax; + const int m_iThrottleMin; + const int m_iThrottleMax; + const int m_iScaleMin; + const int m_iScaleMax; + const int m_iShowSpeedMin; + const int m_iShowSpeedMax; + const int m_iSaveTypeMin; + const int m_iSaveTypeMax; + const int m_iSoundQualityMin; + const int m_iSoundQualityMax; + const int m_iSoundVolumeMin; + const int m_iSoundVolumeMax; + const int m_iEmulatorTypeMin; + const int m_iEmulatorTypeMax; + const int m_iFilter2xMin; + const int m_iFilter2xMax; + const int m_iFilterIBMin; + const int m_iFilterIBMax; + const int m_iJoypadMin; + const int m_iJoypadMax; + + static Window * m_poInstance; + + Glib::RefPtr m_poXml; + + std::string m_sUserDataDir; + std::string m_sConfigFile; + Config::File m_oConfig; + Config::Section * m_poHistoryConfig; + Config::Section * m_poDirConfig; + Config::Section * m_poCoreConfig; + Config::Section * m_poDisplayConfig; + Config::Section * m_poSoundConfig; + Config::Section * m_poInputConfig; + +#ifdef GTKMM20 + Gtk::FileSelection * m_poFileOpenDialog; +#else // ! GTKMM20 + Gtk::FileChooserDialog * m_poFileOpenDialog; +#endif // ! GTKMM20 + ScreenArea * m_poScreenArea; + Gtk::Menu * m_poRecentMenu; + Gtk::MenuItem * m_poRecentResetItem; + Gtk::CheckMenuItem * m_poFilePauseItem; + Gtk::CheckMenuItem * m_poUseBiosItem; + Gtk::CheckMenuItem * m_poSoundOffItem; + + struct SGameSlot + { + bool m_bEmpty; + std::string m_sFile; + time_t m_uiTime; + }; + + Gtk::MenuItem * m_apoLoadGameItem[10]; + Gtk::MenuItem * m_apoSaveGameItem[10]; + SGameSlot m_astGameSlot[10]; + + std::list m_listHistory; + + std::list m_listSensitiveWhenPlaying; + + Gtk::Tooltips m_oTooltips; + + SigC::Connection m_oEmuSig; + + std::vector m_oJoypads; + Keymap * m_poKeymap; + + int m_iScreenWidth; + int m_iScreenHeight; + + std::string m_sRomFile; + ECartridge m_eCartridge; + EmulatedSystem m_stEmulator; + u32 m_uiJoypadState; + u32 m_uiAutofireState; + bool m_bAutofireToggle; + bool m_bPaused; + bool m_bWasEmulating; + bool m_bAutoFrameskip; + int m_iThrottle; + u32 m_uiThrottleLastTime; + u32 m_uiThrottleDelay; + EShowSpeed m_eShowSpeed; + ESoundQuality m_eSoundQuality; + + void vInitSystem(); + void vInitSDL(); + void vInitConfig(); + void vCheckConfig(); + void vLoadConfig(const std::string & _rsFile); + void vSaveConfig(const std::string & _rsFile); + void vLoadHistoryFromConfig(); + void vSaveHistoryToConfig(); + void vHistoryAdd(const std::string & _rsFile); + void vClearHistoryMenu(); + void vUpdateHistoryMenu(); + void vLoadJoypadsFromConfig(); + void vSaveJoypadsToConfig(); + void vUpdateScreen(); + void vDrawDefaultScreen(); + void vSetDefaultTitle(); + void vCreateFileOpenDialog(); + void vLoadBattery(); + void vSaveBattery(); + void vStartEmu(); + void vStopEmu(); + void vSetThrottle(int _iPercent); + void vSelectBestThrottleItem(); + void vUpdateGameSlots(); +}; + +} // namespace VBA + + +#endif // __VBA_WINDOW_H__ diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp new file mode 100644 index 0000000..3d5dc91 --- /dev/null +++ b/src/gtk/windowcallbacks.cpp @@ -0,0 +1,1579 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "window.h" + +#include + +#include +#include + +#include + +#include "../GBA.h" +#include "../gb/GB.h" +#include "../gb/gbGlobals.h" +#include "../gb/gbPrinter.h" +#include "../Sound.h" +#include "../Util.h" + +#include "tools.h" +#include "intl.h" + +extern int systemRenderedFrames; +extern int systemFPS; +extern bool debugger; +extern int RGB_LOW_BITS_MASK; +extern void (*dbgMain)(); +extern void (*dbgSignal)(int, int); +extern void (*dbgOutput)(char *, u32); +extern void remoteInit(); +extern void remoteCleanUp(); +extern void remoteStubMain(); +extern void remoteStubSignal(int, int); +extern void remoteOutput(char *, u32); +extern void remoteSetProtocol(int); +extern void remoteSetPort(int); + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif // MMX + +namespace VBA +{ + +using Gnome::Glade::Xml; + +void Window::vOnFileOpen() +{ + while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) + { + if (bLoadROM(m_poFileOpenDialog->get_filename())) + { + break; + } + } + m_poFileOpenDialog->hide(); +} + +void Window::vOnFileLoad() +{ + std::string sSaveDir = m_poDirConfig->sGetKey("saves"); + +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Load game")); + oDialog.set_transient_for(*this); + + if (sSaveDir == "") + { + oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/"); + } + else + { + oDialog.set_filename(sSaveDir + "/"); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Load game")); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + if (sSaveDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(sSaveDir); + oDialog.add_shortcut_folder(sSaveDir); + } + + Gtk::FileFilter oSaveFilter; + oSaveFilter.set_name(_("VisualBoyAdvance save game")); + oSaveFilter.add_pattern("*.[sS][gG][mM]"); + + oDialog.add_filter(oSaveFilter); + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + if (m_stEmulator.emuReadState(oDialog.get_filename().c_str())) + { + break; + } + } +} + +void Window::vOnFileSave() +{ + Glib::ustring sSaveDir = m_poDirConfig->sGetKey("saves"); + +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Save game")); + oDialog.set_transient_for(*this); + + if (sSaveDir == "") + { + oDialog.set_filename(sCutSuffix(m_sRomFile)); + } + else + { + oDialog.set_filename(sSaveDir + "/" + + sCutSuffix(Glib::path_get_basename(m_sRomFile))); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Save game"), + Gtk::FILE_CHOOSER_ACTION_SAVE); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + + if (sSaveDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(sSaveDir); + oDialog.add_shortcut_folder(sSaveDir); + } + oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); + + Gtk::FileFilter oSaveFilter; + oSaveFilter.set_name(_("VisualBoyAdvance save game")); + oSaveFilter.add_pattern("*.[sS][gG][mM]"); + + oDialog.add_filter(oSaveFilter); + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + Glib::ustring sFile = oDialog.get_filename(); + if (! bHasSuffix(sFile, ".sgm", false)) + { + sFile += ".sgm"; + } + + if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) + { + Gtk::MessageDialog oConfirmDialog(*this, + _("File already exists. Overwrite it?"), +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + if (oConfirmDialog.run() != Gtk::RESPONSE_YES) + { + continue; + } + } + + if (m_stEmulator.emuWriteState(sFile.c_str())) + { + break; + } + } +} + +void Window::vOnLoadGameMostRecent() +{ + int iMostRecent = -1; + time_t uiTimeMax; + + for (int i = 0; i < 10; i++) + { + if (! m_astGameSlot[i].m_bEmpty + && (iMostRecent < 0 || m_astGameSlot[i].m_uiTime > uiTimeMax)) + { + iMostRecent = i; + uiTimeMax = m_astGameSlot[i].m_uiTime; + } + } + + if (iMostRecent >= 0) + { + vOnLoadGame(iMostRecent + 1); + } +} + +void Window::vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI) +{ + m_poCoreConfig->vSetKey("load_game_auto", _poCMI->get_active()); +} + +void Window::vOnLoadGame(int _iSlot) +{ + int i = _iSlot - 1; + if (! m_astGameSlot[i].m_bEmpty) + { + m_stEmulator.emuReadState(m_astGameSlot[i].m_sFile.c_str()); + m_poFilePauseItem->set_active(false); + } +} + +void Window::vOnSaveGameOldest() +{ + int iOldest = -1; + time_t uiTimeMin; + + for (int i = 0; i < 10; i++) + { + if (! m_astGameSlot[i].m_bEmpty + && (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)) + { + iOldest = i; + uiTimeMin = m_astGameSlot[i].m_uiTime; + } + } + + if (iOldest >= 0) + { + vOnSaveGame(iOldest + 1); + } + else + { + vOnSaveGame(1); + } +} + +void Window::vOnSaveGame(int _iSlot) +{ + int i = _iSlot - 1; + m_stEmulator.emuWriteState(m_astGameSlot[i].m_sFile.c_str()); + vUpdateGameSlots(); +} + +void Window::vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI) +{ + m_bPaused = _poCMI->get_active(); + if (emulating) + { + if (m_bPaused) + { + vStopEmu(); + soundPause(); + } + else + { + vStartEmu(); + soundResume(); + } + } +} + +void Window::vOnFileReset() +{ + if (emulating) + { + m_stEmulator.emuReset(); + m_poFilePauseItem->set_active(false); + } +} + +void Window::vOnRecentReset() +{ + m_listHistory.clear(); + vClearHistoryMenu(); +} + +void Window::vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI) +{ + m_poRecentResetItem->set_sensitive(! _poCMI->get_active()); + m_poHistoryConfig->vSetKey("freeze", _poCMI->get_active()); +} + +void Window::vOnRecentFile(std::string _sFile) +{ + bLoadROM(_sFile); +} + +void Window::vOnImportBatteryFile() +{ + std::string BatteryDir = m_poDirConfig->sGetKey("batteries"); + +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Import battery file")); + oDialog.set_transient_for(*this); + + if (BatteryDir == "") + { + oDialog.set_filename(Glib::path_get_dirname(m_sRomFile) + "/"); + } + else + { + oDialog.set_filename(BatteryDir + "/"); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Import battery file")); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + if (BatteryDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(BatteryDir); + oDialog.add_shortcut_folder(BatteryDir); + } + + Gtk::FileFilter oBatteryFilter; + oBatteryFilter.set_name(_("Battery file")); + oBatteryFilter.add_pattern("*.[sS][aA][vV]"); + + Gtk::FileFilter oFlashFilter; + oFlashFilter.set_name(_("Flash save")); + oFlashFilter.add_pattern("*.[dD][aA][tT]"); + + oDialog.add_filter(oBatteryFilter); + oDialog.add_filter(oFlashFilter); + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + Gtk::MessageDialog oConfirmDialog(*this, + _("Importing a battery file will erase any saved games and reset the emulator. Do you want to continue?"), +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + if (oConfirmDialog.run() != Gtk::RESPONSE_YES) + { + continue; + } + + if (m_stEmulator.emuReadBattery(oDialog.get_filename().c_str())) + { + m_stEmulator.emuReset(); + break; + } + else + { + vPopupError(_("Failed to import battery file %s."), + oDialog.get_filename().c_str()); + } + } +} + +void Window::vOnExportBatteryFile() +{ + std::string sBatteryDir = m_poDirConfig->sGetKey("batteries"); + +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Export battery file")); + oDialog.set_transient_for(*this); + + if (sBatteryDir == "") + { + oDialog.set_filename(sCutSuffix(m_sRomFile)); + } + else + { + oDialog.set_filename(sBatteryDir + "/" + + sCutSuffix(Glib::path_get_basename(m_sRomFile))); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Export battery file"), + Gtk::FILE_CHOOSER_ACTION_SAVE); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + + if (sBatteryDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(sBatteryDir); + oDialog.add_shortcut_folder(sBatteryDir); + } + oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); + + Gtk::FileFilter oBatteryFilter; + oBatteryFilter.set_name(_("Battery file")); + oBatteryFilter.add_pattern("*.[sS][aA][vV]"); + + Gtk::FileFilter oFlashFilter; + oFlashFilter.set_name(_("Flash save")); + oFlashFilter.add_pattern("*.[dD][aA][tT]"); + + oDialog.add_filter(oBatteryFilter); + oDialog.add_filter(oFlashFilter); + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + Glib::ustring sFile = oDialog.get_filename(); + Glib::ustring sExt; + +#ifdef GTKMM20 + + sExt = ".sav"; + +#else // ! GTKMM20 + + if (oDialog.get_filter() == &oBatteryFilter) + { + sExt = ".sav"; + } + else + { + sExt = ".dat"; + } + +#endif // ! GTKMM20 + + if (! bHasSuffix(sFile, sExt, false)) + { + sFile += sExt; + } + + if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) + { + Gtk::MessageDialog oConfirmDialog(*this, + _("File already exists. Overwrite it?"), +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + if (oConfirmDialog.run() != Gtk::RESPONSE_YES) + { + continue; + } + } + + bool bResult; + if (m_eCartridge == CartridgeGB) + { + bResult = gbWriteBatteryFile(sFile.c_str(), false); + } + else + { + bResult = m_stEmulator.emuWriteBattery(sFile.c_str()); + } + + if (bResult) + { + break; + } + else + { + vPopupError(_("Failed to export battery file %s."), + sFile.c_str()); + } + } +} + +void Window::vOnFileScreenCapture() +{ + std::string sCaptureDir = m_poDirConfig->sGetKey("captures"); + +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Save screenshot")); + oDialog.set_transient_for(*this); + + if (sCaptureDir == "") + { + oDialog.set_filename(sCutSuffix(m_sRomFile)); + } + else + { + oDialog.set_filename(sCaptureDir + "/" + + sCutSuffix(Glib::path_get_basename(m_sRomFile))); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Save screenshot"), + Gtk::FILE_CHOOSER_ACTION_SAVE); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + + if (sCaptureDir == "") + { + oDialog.set_current_folder(Glib::path_get_dirname(m_sRomFile)); + } + else + { + oDialog.set_current_folder(sCaptureDir); + oDialog.add_shortcut_folder(sCaptureDir); + } + oDialog.set_current_name(sCutSuffix(Glib::path_get_basename(m_sRomFile))); + + Gtk::FileFilter oPngFilter; + oPngFilter.set_name(_("PNG image")); + oPngFilter.add_pattern("*.[pP][nN][gG]"); + + Gtk::FileFilter oBmpFilter; + oBmpFilter.set_name(_("BMP image")); + oBmpFilter.add_pattern("*.[bB][mM][pP]"); + + oDialog.add_filter(oPngFilter); + oDialog.add_filter(oBmpFilter); + + if (m_poCoreConfig->sGetKey("screenshot_format") == "bmp") + { + oDialog.set_filter(oBmpFilter); + } + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + Glib::ustring sFile = oDialog.get_filename(); + Glib::ustring sExt; + +#ifdef GTKMM20 + + sExt = "." + m_poCoreConfig->sGetKey("screenshot_format"); + +#else // ! GTKMM20 + + if (oDialog.get_filter() == &oPngFilter) + { + sExt = ".png"; + } + else + { + sExt = ".bmp"; + } + +#endif // ! GTKMM20 + + if (! bHasSuffix(sFile, sExt, false)) + { + sFile += sExt; + } + + if (Glib::file_test(sFile, Glib::FILE_TEST_EXISTS)) + { + Gtk::MessageDialog oConfirmDialog(*this, + _("File already exists. Overwrite it?"), +#ifndef GTKMM20 + false, +#endif // ! GTKMM20 + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + if (oConfirmDialog.run() != Gtk::RESPONSE_YES) + { + continue; + } + } + + bool bResult; + if (sExt == ".png") + { + bResult = m_stEmulator.emuWritePNG(sFile.c_str()); + } + else + { + bResult = m_stEmulator.emuWriteBMP(sFile.c_str()); + } + + if (bResult) + { + break; + } + } +} + +void Window::vOnFileClose() +{ + if (m_eCartridge != CartridgeNone) + { + soundPause(); + vStopEmu(); + vSetDefaultTitle(); + vDrawDefaultScreen(); + vSaveBattery(); + m_stEmulator.emuCleanUp(); + m_eCartridge = CartridgeNone; + emulating = 0; + + vUpdateGameSlots(); + + for (std::list::iterator it = m_listSensitiveWhenPlaying.begin(); + it != m_listSensitiveWhenPlaying.end(); + it++) + { + (*it)->set_sensitive(false); + } + + m_poFilePauseItem->set_active(false); + } +} + +void Window::vOnFileExit() +{ + hide(); +} + +void Window::vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue) +{ + if (! _poCMI->get_active()) + { + return; + } + + if (_iValue >= 0 && _iValue <= 9) + { + m_poCoreConfig->vSetKey("frameskip", _iValue); + gbFrameSkip = _iValue; + systemFrameSkip = _iValue; + m_bAutoFrameskip = false; + } + else + { + m_poCoreConfig->vSetKey("frameskip", "auto"); + gbFrameSkip = 0; + systemFrameSkip = 0; + m_bAutoFrameskip = true; + } +} + +void Window::vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent) +{ + if (! _poCMI->get_active()) + { + return; + } + + vSetThrottle(_iPercent); + + // Initialize the frameskip adjustment each time throttle is changed + if (m_bAutoFrameskip) + { + systemFrameSkip = 0; + } +} + +void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI) +{ + if (! _poCMI->get_active()) + { + return; + } + + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "ThrottleDialog"); + + Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("ThrottleDialog")); + Gtk::SpinButton * poSpin = dynamic_cast(poXml->get_widget("ThrottleSpin")); + + poDialog->set_transient_for(*this); + + if (m_iThrottle != 0) + { + poSpin->set_value(m_iThrottle); + } + else + { + poSpin->set_value(100); + } + + if (poDialog->run() == Gtk::RESPONSE_OK) + { + vSetThrottle(poSpin->get_value_as_int()); + } + + delete poDialog; + vSelectBestThrottleItem(); +} + +void Window::vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_poDisplayConfig->vSetKey("scale", _iScale); + vUpdateScreen(); +} + +void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer) +{ + int iMask = (0x0100 << _iLayer); + if (_poCMI->get_active()) + { + layerSettings |= iMask; + } + else + { + layerSettings &= ~iMask; + } + layerEnable = DISPCNT & layerSettings; + + const char * acsLayers[] = + { + "layer_bg0", + "layer_bg1", + "layer_bg2", + "layer_bg3", + "layer_obj", + "layer_win0", + "layer_win1", + "layer_objwin" + }; + m_poCoreConfig->vSetKey(acsLayers[_iLayer], _poCMI->get_active()); +} + +void Window::vOnDirectories() +{ + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "DirectoriesDialog"); + + struct + { + const char * m_csKey; + const char * m_csEntry; + const char * m_csResetButton; + const char * m_csSelectButton; + } + astRow[] = + { + { "gba_roms", "GBARomsDirEntry", "GBARomsDirResetButton", "GBARomsDirSelectButton" }, + { "gb_roms", "GBRomsDirEntry", "GBRomsDirResetButton", "GBRomsDirSelectButton" }, + { "batteries", "BatteriesDirEntry", "BatteriesDirResetButton", "BatteriesDirSelectButton" }, + { "saves", "SavesDirEntry", "SavesDirResetButton", "SavesDirSelectButton" }, + { "captures", "CapturesDirEntry", "CapturesDirResetButton", "CapturesDirSelectButton" } + }; + + for (guint i = 0; i < G_N_ELEMENTS(astRow); i++) + { + Gtk::Entry * poEntry = dynamic_cast(poXml->get_widget(astRow[i].m_csEntry)); + Gtk::Button * poReset = dynamic_cast(poXml->get_widget(astRow[i].m_csResetButton)); + Gtk::Button * poSelect = dynamic_cast(poXml->get_widget(astRow[i].m_csSelectButton)); + + poEntry->set_text(m_poDirConfig->sGetKey(astRow[i].m_csKey)); + + poReset->signal_clicked().connect(SigC::bind( + SigC::slot(*this, &Window::vOnDirectoryReset), + poEntry)); + poSelect->signal_clicked().connect(SigC::bind( + SigC::slot(*this, &Window::vOnDirectorySelect), + poEntry)); + } + + Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("DirectoriesDialog")); + poDialog->set_transient_for(*this); + + if (poDialog->run() == Gtk::RESPONSE_OK) + { + for (guint i = 0; i < G_N_ELEMENTS(astRow); i++) + { + Gtk::Entry * poEntry = dynamic_cast(poXml->get_widget(astRow[i].m_csEntry)); + Glib::ustring sDir = poEntry->get_text(); + if (! Glib::file_test(sDir, Glib::FILE_TEST_IS_DIR)) + { + sDir = ""; + } + m_poDirConfig->vSetKey(astRow[i].m_csKey, sDir); + } + + // Needed if saves dir changed + vUpdateGameSlots(); + } + + delete poDialog; +} + +void Window::vOnDirectoryReset(Gtk::Entry * _poEntry) +{ + _poEntry->set_text(""); +} + +void Window::vOnDirectorySelect(Gtk::Entry * _poEntry) +{ +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Select directory")); + oDialog.set_transient_for(*this); + + if (_poEntry->get_text() != "") + { + oDialog.set_filename(_poEntry->get_text() + "/"); + } + + if (oDialog.run() == Gtk::RESPONSE_OK) + { + std::string sFile = oDialog.get_filename(); + if (! Glib::file_test(sFile, Glib::FILE_TEST_IS_DIR)) + { + sFile = Glib::path_get_dirname(sFile); + } + _poEntry->set_text(sFile); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Select directory"), + Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); + + if (_poEntry->get_text() != "") + { + oDialog.add_shortcut_folder(_poEntry->get_text()); + oDialog.set_current_folder(_poEntry->get_text()); + } + + if (oDialog.run() == Gtk::RESPONSE_OK) + { + _poEntry->set_text(oDialog.get_filename()); + } + +#endif // ! GTKMM20 +} + +void Window::vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI) +{ + m_poDisplayConfig->vSetKey("pause_when_inactive", _poCMI->get_active()); +} + +void Window::vOnSelectBios() +{ +#ifdef GTKMM20 + + Gtk::FileSelection oDialog(_("Select BIOS file")); + oDialog.set_transient_for(*this); + + if (m_poCoreConfig->sGetKey("bios_file") != "") + { + oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file")); + } + +#else // ! GTKMM20 + + Gtk::FileChooserDialog oDialog(*this, _("Select BIOS file")); + oDialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + oDialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + if (m_poCoreConfig->sGetKey("bios_file") != "") + { + oDialog.set_filename(m_poCoreConfig->sGetKey("bios_file")); + } + + const char * acsPattern[] = + { + "*.[bB][iI][nN]", "*.[aA][gG][bB]", "*.[gG][bB][aA]", + "*.[bB][iI][oO][sS]", "*.[zZ][iI][pP]", "*.[zZ]", "*.[gG][zZ]" + }; + + Gtk::FileFilter oAllFilter; + oAllFilter.set_name(_("All files")); + oAllFilter.add_pattern("*"); + + Gtk::FileFilter oBiosFilter; + oBiosFilter.set_name(_("Gameboy Advance BIOS")); + for (guint i = 0; i < G_N_ELEMENTS(acsPattern); i++) + { + oBiosFilter.add_pattern(acsPattern[i]); + } + + oDialog.add_filter(oAllFilter); + oDialog.add_filter(oBiosFilter); + + oDialog.set_filter(oBiosFilter); + +#endif // ! GTKMM20 + + while (oDialog.run() == Gtk::RESPONSE_OK) + { + if (Glib::file_test(oDialog.get_filename(), Glib::FILE_TEST_IS_REGULAR)) + { + m_poCoreConfig->vSetKey("bios_file", oDialog.get_filename()); + m_poUseBiosItem->set_sensitive(); + break; + } + } +} + +void Window::vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI) +{ + m_poCoreConfig->vSetKey("use_bios_file", _poCMI->get_active()); +} + +void Window::vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_eShowSpeed = (EShowSpeed)_iShowSpeed; + if (m_eShowSpeed == ShowNone) + { + vSetDefaultTitle(); + } + m_poDisplayConfig->vSetKey("show_speed", _iShowSpeed); +} + +void Window::vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType) +{ + if (! _poCMI->get_active()) + { + return; + } + + cpuSaveType = _iSaveType; + m_poCoreConfig->vSetKey("save_type", _iSaveType); +} + +void Window::vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize) +{ + if (! _poCMI->get_active()) + { + return; + } + + if (_iFlashSize == 64) + { + flashSetSize(0x10000); + } + else + { + flashSetSize(0x20000); + } + m_poCoreConfig->vSetKey("flash_size", _iFlashSize); +} + +void Window::vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_poCoreConfig->vSetKey("screenshot_format", _sFormat); +} + +void Window::vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus) +{ + if (! _poCMI->get_active()) + { + return; + } + + std::string sSoundStatus; + switch (_iSoundStatus) + { + case SoundOff: + soundOffFlag = true; + if (systemSoundOn) + { + soundShutdown(); + } + sSoundStatus = "off"; + break; + case SoundMute: + soundDisable(0x30f); + sSoundStatus = "mute"; + break; + case SoundOn: + if (soundOffFlag) + { + soundOffFlag = false; + if (! soundInit()) + { + m_poSoundOffItem->set_active(); + return; + } + } + soundEnable(0x30f); + sSoundStatus = "on"; + break; + } + m_poSoundConfig->vSetKey("status", sSoundStatus); +} + +void Window::vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI) +{ + soundEcho = _poCMI->get_active(); + m_poSoundConfig->vSetKey("echo", soundEcho); +} + +void Window::vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI) +{ + soundLowPass = _poCMI->get_active(); + m_poSoundConfig->vSetKey("low_pass", soundLowPass); +} + +void Window::vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI) +{ + soundReverse = _poCMI->get_active(); + m_poSoundConfig->vSetKey("reverse_stereo", soundReverse); +} + +void Window::vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel) +{ + int iShift = _iSoundChannel; + if (_iSoundChannel > 3) + { + iShift += 4; + } + int iFlag = 1 << iShift; + int iActive = soundGetEnable() & 0x30f; + if (_poCMI->get_active()) + { + iActive |= iFlag; + } + else + { + iActive &= ~iFlag; + } + soundEnable(iActive); + soundDisable(~iActive & 0x30f); + + const char * acsChannels[] = + { + "channel_1", + "channel_2", + "channel_3", + "channel_4", + "channel_A", + "channel_B" + }; + m_poSoundConfig->vSetKey(acsChannels[_iSoundChannel], _poCMI->get_active()); +} + +void Window::vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_eSoundQuality = (ESoundQuality)_iSoundQuality; + if (m_eCartridge == CartridgeGBA) + { + soundSetQuality(_iSoundQuality); + } + else if (m_eCartridge == CartridgeGB) + { + gbSoundSetQuality(_iSoundQuality); + } + m_poSoundConfig->vSetKey("quality", _iSoundQuality); +} + +void Window::vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume) +{ + if (! _poCMI->get_active()) + { + return; + } + + soundVolume = _iSoundVolume; + m_poSoundConfig->vSetKey("volume", _iSoundVolume); +} + +void Window::vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI) +{ + gbBorderOn = _poCMI->get_active(); + if (emulating && m_eCartridge == CartridgeGB && _poCMI->get_active()) + { + gbSgbRenderBorder(); + } + vUpdateScreen(); + m_poCoreConfig->vSetKey("gb_border", _poCMI->get_active()); +} + +void Window::vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI) +{ + if (_poCMI->get_active()) + { + gbSerialFunction = gbPrinterSend; + } + else + { + gbSerialFunction = NULL; + } + m_poCoreConfig->vSetKey("gb_printer", _poCMI->get_active()); +} + +void Window::vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType) +{ + gbEmulatorType = _iEmulatorType; + m_poCoreConfig->vSetKey("emulator_type", _iEmulatorType); +} + +void Window::vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_poScreenArea->vSetFilter2x((EFilter2x)_iFilter2x); + if (emulating) + { + vDrawScreen(); + } + m_poDisplayConfig->vSetKey("filter2x", _iFilter2x); +} + +void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB) +{ + if (! _poCMI->get_active()) + { + return; + } + + m_poScreenArea->vSetFilterIB((EFilterIB)_iFilterIB); + if (emulating) + { + vDrawScreen(); + } + m_poDisplayConfig->vSetKey("filterIB", _iFilterIB); +} + +#ifdef MMX +void Window::vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI) +{ + cpu_mmx = ! _poCMI->get_active(); + m_poDisplayConfig->vSetKey("filter_disable_mmx", _poCMI->get_active()); +} +#endif // MMX + +void Window::vOnJoypadConfigure(int _iJoypad) +{ + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "JoypadConfigDialog"); + + JoypadConfigDialog * poDialog = NULL; + poXml->get_widget_derived("JoypadConfigDialog", poDialog); + poDialog->set_transient_for(*this); + poDialog->vSetConfig(m_oJoypads[_iJoypad - 1]); + + if (poDialog->run() == Gtk::RESPONSE_OK) + { + m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig(); + if (_iJoypad == m_poInputConfig->oGetKey("active_joypad")) + { + if (m_poKeymap != NULL) + { + delete m_poKeymap; + } + m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap(); + } + } + + delete poDialog; +} + +void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad) +{ + if (! _poCMI->get_active()) + { + return; + } + + if (m_poKeymap != NULL) + { + delete m_poKeymap; + } + m_poKeymap = m_oJoypads[_iJoypad - 1].poCreateKeymap(); + + m_poInputConfig->vSetKey("active_joypad", _iJoypad); +} + +void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag) +{ + if (_poCMI->get_active()) + { + m_uiAutofireState |= _uiKeyFlag; + } + else + { + m_uiAutofireState &= ~_uiKeyFlag; + } + + std::string sKey; + if (_uiKeyFlag == KeyFlagA) + { + sKey = "autofire_A"; + } + else if (_uiKeyFlag == KeyFlagB) + { + sKey = "autofire_B"; + } + else if (_uiKeyFlag == KeyFlagL) + { + sKey = "autofire_L"; + } + else if (_uiKeyFlag == KeyFlagR) + { + sKey = "autofire_R"; + } + m_poInputConfig->vSetKey(sKey, _poCMI->get_active()); +} + +void Window::vOnGDBWait() +{ + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog"); + + Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("TcpPortDialog")); + Gtk::SpinButton * poSpin = dynamic_cast(poXml->get_widget("TcpPortSpin")); + + poDialog->set_transient_for(*this); + + int iPort = 55555; + poSpin->set_value(iPort); + + bool bOk = false; + if (poDialog->run() == Gtk::RESPONSE_OK) + { + bOk = true; + iPort = poSpin->get_value_as_int(); + } + delete poDialog; + + if (! bOk) + { + return; + } + + m_eCartridge = CartridgeGBA; + m_sRomFile = "gnu_stub"; + m_stEmulator = GBASystem; + + rom = (u8 *) malloc(0x2000000); + workRAM = (u8 *) calloc(1, 0x40000); + bios = (u8 *) calloc(1, 0x4000); + internalRAM = (u8 *) calloc(1, 0x8000); + paletteRAM = (u8 *) calloc(1, 0x400); + vram = (u8 *) calloc(1, 0x20000); + oam = (u8 *) calloc(1, 0x400); + pix = (u8 *) calloc(1, 4 * m_iGBAScreenWidth * m_iGBAScreenHeight); + ioMem = (u8 *) calloc(1, 0x400); + + useBios = m_poCoreConfig->oGetKey("use_bios_file"); + CPUInit(m_poCoreConfig->sGetKey("bios_file").c_str(), useBios); + CPUReset(); + + for (std::list::iterator it = m_listSensitiveWhenPlaying.begin(); + it != m_listSensitiveWhenPlaying.end(); + it++) + { + (*it)->set_sensitive(); + } + + if (m_poCoreConfig->oGetKey("load_game_auto")) + { + vOnLoadGameMostRecent(); + } + + vStartEmu(); + + emulating = 1; + + dbgMain = remoteStubMain; + dbgSignal = remoteStubSignal; + dbgOutput = remoteOutput; + debugger = true; + + remoteSetProtocol(0); + remoteSetPort(iPort); + remoteInit(); +} + +void Window::vOnGDBLoadAndWait() +{ + bool bLoaded = false; + + while (m_poFileOpenDialog->run() == Gtk::RESPONSE_OK) + { + if (bLoadROM(m_poFileOpenDialog->get_filename())) + { + bLoaded = true; + break; + } + } + m_poFileOpenDialog->hide(); + + if (! bLoaded) + { + return; + } + + if (m_eCartridge != CartridgeGBA) + { + vPopupError(_("Only GBA images are supported.")); + vOnFileClose(); + return; + } + + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "TcpPortDialog"); + + Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("TcpPortDialog")); + Gtk::SpinButton * poSpin = dynamic_cast(poXml->get_widget("TcpPortSpin")); + + poDialog->set_transient_for(*this); + + int iPort = 55555; + poSpin->set_value(iPort); + + bool bOk = false; + if (poDialog->run() == Gtk::RESPONSE_OK) + { + bOk = true; + iPort = poSpin->get_value_as_int(); + } + delete poDialog; + + if (! bOk) + { + return; + } + + dbgMain = remoteStubMain; + dbgSignal = remoteStubSignal; + dbgOutput = remoteOutput; + debugger = true; + + remoteSetProtocol(0); + remoteSetPort(iPort); + remoteInit(); +} + +void Window::vOnGDBBreak() +{ + if (armState) + { + armNextPC -= 4; + reg[15].I -= 4; + } + else + { + armNextPC -= 2; + reg[15].I -= 2; + } + + debugger = true; +} + +void Window::vOnGDBDisconnect() +{ + remoteCleanUp(); + debugger = false; +} + +void Window::vOnHelpAbout() +{ + Glib::RefPtr poXml; + poXml = Xml::create(PKGDATADIR "/vba.glade", "AboutDialog"); + + Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("AboutDialog")); + poDialog->set_transient_for(*this); + + Gtk::Image oIcon(PKGDATADIR "/vba-64.png"); + oIcon.show(); + Gtk::Container * poIconContainer = dynamic_cast(poXml->get_widget("AboutIconContainer")); + poIconContainer->add(oIcon); + + Gtk::Label * poLabel = dynamic_cast(poXml->get_widget("VersionLabel")); + poLabel->set_markup("" PACKAGE " " VERSION ""); + + poDialog->run(); + delete poDialog; +} + +bool Window::bOnEmuIdle() +{ + if (debugger && m_stEmulator.emuHasDebugger) + { + dbgMain(); + return true; + } + + if (m_uiThrottleDelay != 0) + { + u32 uiTime = SDL_GetTicks(); + if (uiTime - m_uiThrottleLastTime >= m_uiThrottleDelay) + { + m_uiThrottleDelay = 0; + m_uiThrottleLastTime = uiTime; + } + else + { + return true; + } + } + + m_stEmulator.emuMain(m_stEmulator.emuCount); + return true; +} + +bool Window::on_focus_in_event(GdkEventFocus * _pstEvent) +{ + if (emulating + && ! m_bPaused + && m_poDisplayConfig->oGetKey("pause_when_inactive")) + { + vStartEmu(); + soundResume(); + } + return false; +} + +bool Window::on_focus_out_event(GdkEventFocus * _pstEvent) +{ + if (emulating + && ! m_bPaused + && m_poDisplayConfig->oGetKey("pause_when_inactive")) + { + vStopEmu(); + soundPause(); + } + return false; +} + +bool Window::on_key_press_event(GdkEventKey * _pstEvent) +{ + EKey eKey; + + if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask()) + || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone) + { + return Gtk::Window::on_key_press_event(_pstEvent); + } + + switch (eKey) + { + case KeyA: + m_uiJoypadState |= KeyFlagA; + break; + case KeyB: + m_uiJoypadState |= KeyFlagB; + break; + case KeySelect: + m_uiJoypadState |= KeyFlagSelect; + break; + case KeyStart: + m_uiJoypadState |= KeyFlagStart; + break; + case KeyRight: + m_uiJoypadState |= KeyFlagRight; + m_uiJoypadState &= ~KeyFlagLeft; + break; + case KeyLeft: + m_uiJoypadState |= KeyFlagLeft; + m_uiJoypadState &= ~KeyFlagRight; + break; + case KeyUp: + m_uiJoypadState |= KeyFlagUp; + m_uiJoypadState &= ~KeyFlagDown; + break; + case KeyDown: + m_uiJoypadState |= KeyFlagDown; + m_uiJoypadState &= ~KeyFlagUp; + break; + case KeyR: + m_uiJoypadState |= KeyFlagR; + break; + case KeyL: + m_uiJoypadState |= KeyFlagL; + break; + case KeySpeed: + m_uiJoypadState |= KeyFlagSpeed; + break; + case KeyCapture: + m_uiJoypadState |= KeyFlagCapture; + break; + case KeyNone: + break; + } + return true; +} + +bool Window::on_key_release_event(GdkEventKey * _pstEvent) +{ + EKey eKey; + + if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask()) + || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone) + { + return Gtk::Window::on_key_release_event(_pstEvent); + } + + switch (eKey) + { + case KeyA: + m_uiJoypadState &= ~KeyFlagA; + break; + case KeyB: + m_uiJoypadState &= ~KeyFlagB; + break; + case KeySelect: + m_uiJoypadState &= ~KeyFlagSelect; + break; + case KeyStart: + m_uiJoypadState &= ~KeyFlagStart; + break; + case KeyRight: + m_uiJoypadState &= ~KeyFlagRight; + break; + case KeyLeft: + m_uiJoypadState &= ~KeyFlagLeft; + break; + case KeyUp: + m_uiJoypadState &= ~KeyFlagUp; + break; + case KeyDown: + m_uiJoypadState &= ~KeyFlagDown; + break; + case KeyR: + m_uiJoypadState &= ~KeyFlagR; + break; + case KeyL: + m_uiJoypadState &= ~KeyFlagL; + break; + case KeySpeed: + m_uiJoypadState &= ~KeyFlagSpeed; + break; + case KeyCapture: + m_uiJoypadState &= ~KeyFlagCapture; + break; + case KeyNone: + break; + } + return true; +} + +} // namespace VBA diff --git a/src/hq2x.cpp b/src/hq2x.cpp new file mode 100644 index 0000000..39293f9 --- /dev/null +++ b/src/hq2x.cpp @@ -0,0 +1,920 @@ +/* + * This file is part of the Advance project. + * + * Copyright (C) 2003 Andrea Mazzoleni + * + * 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. + * + * In addition, as a special exception, Andrea Mazzoleni + * gives permission to link the code of this program with + * the MAME library (or with modified versions of MAME that use the + * same license as MAME), and distribute linked combinations including + * the two. You must obey the GNU General Public License in all + * respects for all of the code used other than MAME. If you modify + * this file, you may extend this exception to your version of the + * file, but you are not obligated to do so. If you do not wish to + * do so, delete this exception statement from your version. + */ +#include "System.h" +#include "interp.h" + +unsigned interp_mask[2]; +unsigned interp_bits_per_pixel; + +/***************************************************************************/ +/* HQ2x C implementation */ + +/* + * This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin + */ + +static void hq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count) +{ + unsigned i; + + for(i=0;i0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i> 3; + r = (int)((c[j] & 0xF800)) >> 8; + } else { + b = (int)((c[j] & 0x1F)) << 3; + g = (int)((c[j] & 0x3E0)) >> 2; + r = (int)((c[j] & 0x7C00)) >> 7; + } + const int bright = r+r+r + g+g+g + b+b; + if(bright > maxBright) maxBright = bright; + if(bright < minBright) minBright = bright; + + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if(diffBright > 7) + { + #define ABS(x) ((x) < 0 ? -(x) : (x)) + + const int centerBright = brightArray[4]; + if(ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if(ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if(ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if(ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if(ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if(ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if(ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if(ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } + +#define P0 dst0[0] +#define P1 dst0[1] +#define P2 dst1[0] +#define P3 dst1[1] +#define MUR false//(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right +#define MDR false//(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right +#define MDL false//(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left +#define MUL false//(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left +#define IC(p0) c[p0] +#define I11(p0,p1) interp_16_11(c[p0], c[p1]) +#define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2]) +#define I31(p0,p1) interp_16_31(c[p0], c[p1]) +#define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2]) +#define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2]) +#define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2]) +#define I53(p0,p1) interp_16_53(c[p0], c[p1]) +#define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2]) +#define I71(p0,p1) interp_16_71(c[p0], c[p1]) +#define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2]) +#define I97(p0,p1) interp_16_97(c[p0], c[p1]) +#define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2]) +#define I151(p0,p1) interp_16_151(c[p0], c[p1]) + + switch (mask) { +#include "hq2x.h" + } + +#undef P0 +#undef P1 +#undef P2 +#undef P3 +#undef MUR +#undef MDR +#undef MDL +#undef MUL +#undef IC +#undef I11 +#undef I211 +#undef I31 +#undef I332 +#undef I431 +#undef I521 +#undef I53 +#undef I611 +#undef I71 +#undef I772 +#undef I97 +#undef I1411 +#undef I151 + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } +} + +static void hq2xS_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count) +{ + unsigned i; + + for(i=0;i> 8; + const int r = (int)((c[j] & 0xF80000)) >> 16; + const int bright = r+r+r + g+g+g + b+b; + if(bright > maxBright) maxBright = bright; + if(bright < minBright) minBright = bright; + + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if(diffBright > 7) + { + #define ABS(x) ((x) < 0 ? -(x) : (x)) + + const int centerBright = brightArray[4]; + if(ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if(ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if(ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if(ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if(ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if(ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if(ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if(ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } + +#define P0 dst0[0] +#define P1 dst0[1] +#define P2 dst1[0] +#define P3 dst1[1] +#define MUR false//(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right +#define MDR false//(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right +#define MDL false//(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left +#define MUL false//(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left +#define IC(p0) c[p0] +#define I11(p0,p1) interp_32_11(c[p0], c[p1]) +#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2]) +#define I31(p0,p1) interp_32_31(c[p0], c[p1]) +#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2]) +#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2]) +#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2]) +#define I53(p0,p1) interp_32_53(c[p0], c[p1]) +#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2]) +#define I71(p0,p1) interp_32_71(c[p0], c[p1]) +#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2]) +#define I97(p0,p1) interp_32_97(c[p0], c[p1]) +#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2]) +#define I151(p0,p1) interp_32_151(c[p0], c[p1]) + + switch (mask) { +#include "hq2x.h" + } + +#undef P0 +#undef P1 +#undef P2 +#undef P3 +#undef MUR +#undef MDR +#undef MDL +#undef MUL +#undef IC +#undef I11 +#undef I211 +#undef I31 +#undef I332 +#undef I431 +#undef I521 +#undef I53 +#undef I611 +#undef I71 +#undef I772 +#undef I97 +#undef I1411 +#undef I151 + + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } +} + +/***************************************************************************/ +/* LQ2x C implementation */ + +/* + * This effect is derived from the hq2x effect made by Maxim Stepin + */ + +static void lq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count) +{ + unsigned i; + + for(i=0;i0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } + + if (i> 1); + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = src0 + (srcPitch >> 1); + u16 *src2 = src1 + (srcPitch >> 1); + + hq2x_16_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch; + dst1 += dstPitch; + hq2x_16_def(dst0, dst1, src0, src1, src1, width); +} + +void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dst0 = (u32 *)dstPtr; + u32 *dst1 = dst0 + (dstPitch >> 2); + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = src0 + (srcPitch >> 2); + u32 *src2 = src1 + (srcPitch >> 2); + hq2x_32_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src1, width); +} + +void hq2xS(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u16 *dst0 = (u16 *)dstPtr; + u16 *dst1 = dst0 + (dstPitch >> 1); + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = src0 + (srcPitch >> 1); + u16 *src2 = src1 + (srcPitch >> 1); + + hq2xS_16_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2xS_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch; + dst1 += dstPitch; + hq2xS_16_def(dst0, dst1, src0, src1, src1, width); +} + +void hq2xS32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dst0 = (u32 *)dstPtr; + u32 *dst1 = dst0 + (dstPitch >> 2); + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = src0 + (srcPitch >> 2); + u32 *src2 = src1 + (srcPitch >> 2); + hq2xS_32_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2xS_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2xS_32_def(dst0, dst1, src0, src1, src1, width); +} + +void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u16 *dst0 = (u16 *)dstPtr; + u16 *dst1 = dst0 + (dstPitch >> 1); + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = src0 + (srcPitch >> 1); + u16 *src2 = src1 + (srcPitch >> 1); + + lq2x_16_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch; + dst1 += dstPitch; + lq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } + dst0 += dstPitch; + dst1 += dstPitch; + lq2x_16_def(dst0, dst1, src0, src1, src1, width); +} + +void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u32 *dst0 = (u32 *)dstPtr; + u32 *dst1 = dst0 + (dstPitch >> 2); + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = src0 + (srcPitch >> 2); + u32 *src2 = src1 + (srcPitch >> 2); + lq2x_32_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while(count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + lq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + lq2x_32_def(dst0, dst1, src0, src1, src1, width); +} + +void hq2x_init(unsigned bits_per_pixel) +{ + interp_set(bits_per_pixel); +} diff --git a/src/hq2x.h b/src/hq2x.h new file mode 100644 index 0000000..64c5778 --- /dev/null +++ b/src/hq2x.h @@ -0,0 +1,1824 @@ +case 0 : +case 1 : +case 4 : +case 5 : +case 32 : +case 33 : +case 36 : +case 37 : +case 128 : +case 129 : +case 132 : +case 133 : +case 160 : +case 161 : +case 164 : +case 165 : +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 2 : +case 34 : +case 130 : +case 162 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 3 : +case 35 : +case 131 : +case 163 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 6 : +case 38 : +case 134 : +case 166 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 7 : +case 39 : +case 135 : +case 167 : +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 8 : +case 12 : +case 136 : +case 140 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); +} break; +case 9 : +case 13 : +case 137 : +case 141 : +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); +} break; +case 10 : +case 138 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 11 : +case 139 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 14 : +case 142 : +{ + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 15 : +case 143 : +{ + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 16 : +case 17 : +case 48 : +case 49 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); +} break; +case 18 : +case 50 : +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 19 : +case 51 : +{ + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = I31(4, 2); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 20 : +case 21 : +case 52 : +case 53 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); +} break; +case 22 : +case 54 : +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 23 : +case 55 : +{ + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 24 : +case 66 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 25 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 26 : +case 31 : +case 95 : +{ + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 27 : +case 75 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 28 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 29 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 30 : +case 86 : +{ + P0 = I31(4, 0); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 40 : +case 44 : +case 168 : +case 172 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); +} break; +case 41 : +case 45 : +case 169 : +case 173 : +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); +} break; +case 42 : +case 170 : +{ + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 43 : +case 171 : +{ + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 46 : +case 174 : +{ + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 47 : +case 175 : +{ + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 56 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 57 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 58 : +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 59 : +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 60 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 61 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 62 : +{ + P0 = I31(4, 0); + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 63 : +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 64 : +case 65 : +case 68 : +case 69 : +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 67 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 70 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 71 : +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 72 : +case 76 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 73 : +case 77 : +{ + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = I31(4, 6); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 74 : +case 107 : +case 123 : +{ + P1 = I31(4, 2); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 78 : +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 79 : +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 80 : +case 81 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 82 : +case 214 : +case 222 : +{ + P0 = I31(4, 0); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 83 : +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 84 : +case 85 : +{ + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = I31(4, 8); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 87 : +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 88 : +case 248 : +case 250 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 89 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 90 : +{ + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 91 : +{ + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 92 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 93 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 94 : +{ + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 96 : +case 97 : +case 100 : +case 101 : +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 98 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 99 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 102 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 103 : +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 104 : +case 108 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 105 : +case 109 : +{ + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 106 : +case 120 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 110 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 111 : +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 112 : +case 113 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = I31(4, 8); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 114 : +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 115 : +{ + P0 = I31(4, 3); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 116 : +case 117 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 118 : +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 119 : +{ + P2 = I31(4, 3); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 121 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 122 : +{ + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 124 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 125 : +{ + P1 = I31(4, 1); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 126 : +{ + P0 = I31(4, 0); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 127 : +{ + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 144 : +case 145 : +case 176 : +case 177 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 146 : +case 178 : +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (MUR) { + P1 = I31(4, 2); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 147 : +case 179 : +{ + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 148 : +case 149 : +case 180 : +case 181 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 150 : +case 182 : +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 151 : +case 183 : +{ + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 152 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 153 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 154 : +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 155 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 156 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 157 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 158 : +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 159 : +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 184 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 185 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 186 : +{ + P2 = I31(4, 7); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 187 : +{ + P1 = I31(4, 2); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 188 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 189 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 190 : +{ + P0 = I31(4, 0); + P2 = I31(4, 7); + if (MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 191 : +{ + P2 = I31(4, 7); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 192 : +case 193 : +case 196 : +case 197 : +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 194 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 195 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 198 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 199 : +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 200 : +case 204 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (MDL) { + P2 = I31(4, 6); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 201 : +case 205 : +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } +} break; +case 202 : +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 203 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 206 : +{ + P1 = I31(4, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 207 : +{ + P2 = I31(4, 6); + P3 = I31(4, 5); + if (MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 208 : +case 209 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 210 : +case 216 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 211 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 212 : +case 213 : +{ + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 215 : +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 217 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 218 : +{ + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 219 : +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 220 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 221 : +{ + P0 = I31(4, 1); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 223 : +{ + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 224 : +case 225 : +case 228 : +case 229 : +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 226 : +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 227 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 230 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 231 : +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 232 : +case 236 : +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 233 : +case 237 : +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } +} break; +case 234 : +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 235 : +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 238 : +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + if (MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 239 : +{ + P1 = I31(4, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 240 : +case 241 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 242 : +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 243 : +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 244 : +case 245 : +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 246 : +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 247 : +{ + P0 = I31(4, 3); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 249 : +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 251 : +{ + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 252 : +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 253 : +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 254 : +{ + P0 = I31(4, 0); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 255 : +{ + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; diff --git a/src/hq3x32.cpp b/src/hq3x32.cpp new file mode 100644 index 0000000..993bbbf --- /dev/null +++ b/src/hq3x32.cpp @@ -0,0 +1,462 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2005 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "hq_shared32.h" +#include "System.h" +#include "interp.h" + +#define SIZE_PIXEL 2 // 16bit = 2 bytes +#define PIXELTYPE unsigned short +#define Interp1 Interp1_16 +#define Interp2 Interp2_16 +#define Interp3 Interp3_16 +#define Interp4 Interp4_16 +#define Interp5 Interp5_16 + +void hq3x(unsigned char * pIn, unsigned int srcPitch, + unsigned char *, + unsigned char * pOut, unsigned int dstPitch, + int Xres, int Yres) +{ + int i, j; + unsigned int line; + PIXELTYPE c[10]; + + // +----+----+----+ + // | | | | + // | c1 | c2 | c3 | + // +----+----+----+ + // | | | | + // | c4 | c5 | c6 | + // +----+----+----+ + // | | | | + // | c7 | c8 | c9 | + // +----+----+----+ + + for (j=0; j0) || (j0) + { + c[1] = *((PIXELTYPE*)(pIn - line - SIZE_PIXEL)); + c[4] = *((PIXELTYPE*)(pIn - SIZE_PIXEL)); + c[7] = *((PIXELTYPE*)(pIn + line - SIZE_PIXEL)); + } + else + { + c[1] = c[2]; + c[4] = c[5]; + c[7] = c[8]; + } + + if (i> 3; + r = (int)((c[j] & 0xF800)) >> 8; + } else { + b = (int)((c[j] & 0x1F)) << 3; + g = (int)((c[j] & 0x3E0)) >> 2; + r = (int)((c[j] & 0x7C00)) >> 7; + } + const int bright = r+r+r + g+g+g + b+b; + if(bright > maxBright) maxBright = bright; + if(bright < minBright) minBright = bright; + + brightArray[j] = bright; + } + const int diffBright = ((maxBright - minBright) * 7) >> 4; + if(diffBright > 7) + { + #define ABS(x) ((x) < 0 ? -(x) : (x)) + + const int centerBright = brightArray[5]; + if(ABS(brightArray[1] - centerBright) > diffBright) + pattern |= 1 << 0; + if(ABS(brightArray[2] - centerBright) > diffBright) + pattern |= 1 << 1; + if(ABS(brightArray[3] - centerBright) > diffBright) + pattern |= 1 << 2; + if(ABS(brightArray[4] - centerBright) > diffBright) + pattern |= 1 << 3; + if(ABS(brightArray[6] - centerBright) > diffBright) + pattern |= 1 << 4; + if(ABS(brightArray[7] - centerBright) > diffBright) + pattern |= 1 << 5; + if(ABS(brightArray[8] - centerBright) > diffBright) + pattern |= 1 << 6; + if(ABS(brightArray[9] - centerBright) > diffBright) + pattern |= 1 << 7; + } + +#define Diff(x,y) false//(ABS((x) - (y)) > diffBright) +#undef cget +#define cget(x) brightArray[x] +#include "hq3x32.h" +#undef cget +#undef Diff + pIn+=SIZE_PIXEL; + pOut+=3<<1; + } + pIn+=srcPitch-(Xres<<1); + pOut+=dstPitch-(3*Xres<<1); + pOut+=dstPitch<<1; + // pIn+=SIZE_PIXEL; + // pOut+=3*SIZE_PIXEL; + //} + //pIn+=srcPitch-(4*Xres); + //pOut+=dstPitch-(3*Xres*SIZE_PIXEL); + //pOut+=2*dstPitch; + } +} + +#undef Interp1 +#undef Interp2 +#undef Interp3 +#undef Interp4 +#undef Interp5 +#undef SIZE_PIXEL +#undef PIXELTYPE +#define SIZE_PIXEL 4 // 32bit = 4 bytes +#define PIXELTYPE unsigned int + +void hq3x32(unsigned char * pIn, unsigned int srcPitch, + unsigned char *, + unsigned char * pOut, unsigned int dstPitch, + int Xres, int Yres) +{ + unsigned int YUV1, YUV2; + int i, j, k; + unsigned int line; + PIXELTYPE c[10]; + + // +----+----+----+ + // | | | | + // | c1 | c2 | c3 | + // +----+----+----+ + // | | | | + // | c4 | c5 | c6 | + // +----+----+----+ + // | | | | + // | c7 | c8 | c9 | + // +----+----+----+ + + for (j=0; j0) && (j0) + { + c[1] = *((PIXELTYPE*)(pIn - line - SIZE_PIXEL)); + c[4] = *((PIXELTYPE*)(pIn - SIZE_PIXEL)); + c[7] = *((PIXELTYPE*)(pIn + line - SIZE_PIXEL)); + } + else + { + c[1] = c[2]; + c[4] = c[5]; + c[7] = c[8]; + } + + if (i trY ) || + ( abs32((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || + ( abs32((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) + ) + pattern |= flag; + } + flag <<= 1; + } + +#include "hq3x32.h" + pIn+=SIZE_PIXEL; + pOut+=3<<2; + } + pIn+=srcPitch-(Xres<<2); + pOut+=dstPitch-(3*Xres<<2); + pOut+=dstPitch<<1; + // pIn+=SIZE_PIXEL; + // pOut+=3*SIZE_PIXEL; + //} + //pIn+=srcPitch-(4*Xres); + //pOut+=dstPitch-(3*Xres*SIZE_PIXEL); + //pOut+=2*dstPitch; + } +} + + +void hq3xS32(unsigned char * pIn, unsigned int srcPitch, + unsigned char *, + unsigned char * pOut, unsigned int dstPitch, + int Xres, int Yres) +{ + int i, j; + unsigned int line; + PIXELTYPE c[10]; + + // +----+----+----+ + // | | | | + // | c1 | c2 | c3 | + // +----+----+----+ + // | | | | + // | c4 | c5 | c6 | + // +----+----+----+ + // | | | | + // | c7 | c8 | c9 | + // +----+----+----+ + + for (j=0; j0) && (j0) + { + c[1] = *((PIXELTYPE*)(pIn - line - SIZE_PIXEL)); + c[4] = *((PIXELTYPE*)(pIn - SIZE_PIXEL)); + c[7] = *((PIXELTYPE*)(pIn + line - SIZE_PIXEL)); + } + else + { + c[1] = c[2]; + c[4] = c[5]; + c[7] = c[8]; + } + + if (i> 8; + const int r = (int)((c[j] & 0xF80000)) >> 16; + const int bright = r+r+r + g+g+g + b+b; + if(bright > maxBright) maxBright = bright; + if(bright < minBright) minBright = bright; + + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if(diffBright > 7) + { + #define ABS(x) ((x) < 0 ? -(x) : (x)) + + const int centerBright = brightArray[5]; + if(ABS(brightArray[1] - centerBright) > diffBright) + pattern |= 1 << 0; + if(ABS(brightArray[2] - centerBright) > diffBright) + pattern |= 1 << 1; + if(ABS(brightArray[3] - centerBright) > diffBright) + pattern |= 1 << 2; + if(ABS(brightArray[4] - centerBright) > diffBright) + pattern |= 1 << 3; + if(ABS(brightArray[6] - centerBright) > diffBright) + pattern |= 1 << 4; + if(ABS(brightArray[7] - centerBright) > diffBright) + pattern |= 1 << 5; + if(ABS(brightArray[8] - centerBright) > diffBright) + pattern |= 1 << 6; + if(ABS(brightArray[9] - centerBright) > diffBright) + pattern |= 1 << 7; + } + +#define Diff(x,y) false//(ABS((x) - (y)) > diffBright) +#undef cget +#define cget(x) brightArray[x] +#include "hq3x32.h" +#undef cget +#undef Diff + pIn+=SIZE_PIXEL; + pOut+=3<<2; + } + pIn+=srcPitch-(Xres<<2); + pOut+=dstPitch-(3*Xres<<2); + pOut+=dstPitch<<1; + // pIn+=SIZE_PIXEL; + // pOut+=3*SIZE_PIXEL; + //} + //pIn+=srcPitch-(4*Xres); + //pOut+=dstPitch-(3*Xres*SIZE_PIXEL); + //pOut+=2*dstPitch; + } +} \ No newline at end of file diff --git a/src/hq3x32.h b/src/hq3x32.h new file mode 100644 index 0000000..d8a6874 --- /dev/null +++ b/src/hq3x32.h @@ -0,0 +1,3692 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2005 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#define PIXEL00_1M Interp1( pOut, c[5], c[1] ); +#define PIXEL00_1U Interp1( pOut, c[5], c[2] ); +#define PIXEL00_1L Interp1( pOut, c[5], c[4] ); +#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] ); +#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] ); +#define PIXEL00_5 Interp5( pOut, c[4], c[2] ); +#define PIXEL00_C *((PIXELTYPE*)(pOut)) = c[5]; + +#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] ); +#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] ); +#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] ); +#define PIXEL01_C *((PIXELTYPE*)(pOut+SIZE_PIXEL)) = c[5]; + +#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] ); +#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] ); +#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); +#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] ); +#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] ); +#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] ); +#define PIXEL02_C *((PIXELTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; + +#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] ); +#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] ); +#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] ); +#define PIXEL10_C *((PIXELTYPE*)(pOut+dstPitch)) = c[5]; + +#define PIXEL11 *((PIXELTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5]; + +#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); +#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); +#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] ); +#define PIXEL12_C *((PIXELTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; + +#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] ); +#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] ); +#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] ); +#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] ); +#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] ); +#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] ); +#define PIXEL20_C *((PIXELTYPE*)(pOut+dstPitch+dstPitch)) = c[5]; + +#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] ); +#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] ); +#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] ); +#define PIXEL21_C *((PIXELTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5]; + +#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] ); +#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] ); +#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); +#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] ); +#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] ); +#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] ); +#define PIXEL22_C *((PIXELTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; + +#ifndef cget +#define cget(x) c[x] +#endif + + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 18: + case 50: + { + PIXEL00_1M + + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_1M + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 80: + case 81: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_1M + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 72: + case 76: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_1M + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 10: + case 138: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 66: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 24: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; + } + case 22: + case 54: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 208: + case 209: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 104: + case 108: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 11: + case 139: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 19: + case 51: + { + if (Diff(cget(2), cget(6))) + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL12_C + } + else + { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 146: + case 178: + { + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_1M + PIXEL12_C + PIXEL22_1D + } + else + { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + break; + } + case 84: + case 85: + { + if (Diff(cget(6), cget(8))) + { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_1M + } + else + { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL10_1 + PIXEL11 + PIXEL20_1M + break; + } + case 112: + case 113: + { + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + } + else + { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; + } + case 200: + case 204: + { + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + } + else + { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + break; + } + case 73: + case 77: + { + if (Diff(cget(8), cget(4))) + { + PIXEL00_1U + PIXEL10_C + PIXEL20_1M + PIXEL21_C + } + else + { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + PIXEL22_1M + break; + } + case 42: + case 170: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } + else + { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL21_1 + PIXEL22_2 + break; + } + case 14: + case 142: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } + else + { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 67: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 70: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 28: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 152: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 194: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 98: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 56: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 25: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 26: + case 31: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 82: + case 214: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + } + else + { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 88: + case 248: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + } + else + { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL22_4 + } + break; + } + case 74: + case 107: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + } + else + { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 27: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 86: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 216: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 106: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 30: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 210: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 120: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 75: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 29: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; + } + case 198: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 184: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 99: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 57: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 71: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 156: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 226: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 60: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 195: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 102: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 153: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 58: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 83: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 92: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 202: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 78: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1M + break; + } + case 154: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 114: + { + PIXEL00_1M + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 89: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 90: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 55: + case 23: + { + if (Diff(cget(2), cget(6))) + { + PIXEL00_1L + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; + } + case 182: + case 150: + { + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + PIXEL22_1D + } + else + { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + break; + } + case 213: + case 212: + { + if (Diff(cget(6), cget(8))) + { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL10_1 + PIXEL11 + PIXEL20_1M + break; + } + case 241: + case 240: + { + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; + } + case 236: + case 232: + { + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + PIXEL22_1R + } + else + { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + break; + } + case 109: + case 105: + { + if (Diff(cget(8), cget(4))) + { + PIXEL00_1U + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + PIXEL22_1M + break; + } + case 171: + case 43: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } + else + { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL21_1 + PIXEL22_2 + break; + } + case 143: + case 15: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } + else + { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; + } + case 124: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 203: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 62: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 211: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 118: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 217: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 110: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 155: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 188: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 185: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 61: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 157: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 103: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 227: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 230: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 199: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 220: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 158: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 234: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1M + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1R + break; + } + case 242: + { + PIXEL00_1M + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 59: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 121: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 87: + { + PIXEL00_1L + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1M + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 79: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1R + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1M + break; + } + case 122: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 94: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 218: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 91: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 229: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 167: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; + } + case 173: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; + } + case 181: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; + } + case 186: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 115: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 93: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 206: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 205: + case 201: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_1M + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 174: + case 46: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_1M + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; + } + case 179: + case 147: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_1M + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; + } + case 117: + case 116: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_1M + } + else + { + PIXEL22_2 + } + break; + } + case 189: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 231: + { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; + } + case 126: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 219: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 125: + { + if (Diff(cget(8), cget(4))) + { + PIXEL00_1U + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + PIXEL22_1M + break; + } + case 221: + { + if (Diff(cget(6), cget(8))) + { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_1U + PIXEL01_1 + PIXEL10_C + PIXEL11 + PIXEL20_1M + break; + } + case 207: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } + else + { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; + } + case 238: + { + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + PIXEL22_1R + } + else + { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL11 + PIXEL12_1 + break; + } + case 190: + { + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + PIXEL22_1D + } + else + { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + break; + } + case 187: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } + else + { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL21_1 + PIXEL22_1D + break; + } + case 243: + { + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; + } + case 119: + { + if (Diff(cget(2), cget(6))) + { + PIXEL00_1L + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; + } + case 237: + case 233: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 175: + case 47: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; + } + case 183: + case 151: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; + } + case 245: + case 244: + { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + case 250: + { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + } + else + { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL22_4 + } + break; + } + case 123: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + } + else + { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 95: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; + } + case 222: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + } + else + { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 252: + { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + } + else + { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + case 249: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL22_4 + } + break; + } + case 235: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + } + else + { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 111: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 63: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; + } + case 159: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; + } + case 215: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 246: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + } + else + { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + case 254: + { + PIXEL00_1M + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + } + else + { + PIXEL01_3 + PIXEL02_4 + } + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + } + else + { + PIXEL10_3 + PIXEL20_4 + } + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL21_3 + PIXEL22_2 + } + break; + } + case 253: + { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + case 251: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + } + else + { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL10_3 + PIXEL20_2 + PIXEL21_3 + } + if (Diff(cget(6), cget(8))) + { + PIXEL12_C + PIXEL22_C + } + else + { + PIXEL12_3 + PIXEL22_4 + } + break; + } + case 239: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; + } + case 127: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } + else + { + PIXEL00_2 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + PIXEL21_C + } + else + { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; + } + case 191: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; + } + case 223: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + PIXEL10_C + } + else + { + PIXEL00_4 + PIXEL10_3 + } + if (Diff(cget(2), cget(6))) + { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } + else + { + PIXEL01_3 + PIXEL02_2 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + if (Diff(cget(6), cget(8))) + { + PIXEL21_C + PIXEL22_C + } + else + { + PIXEL21_3 + PIXEL22_4 + } + break; + } + case 247: + { + PIXEL00_1L + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + case 255: + { + if (Diff(cget(4), cget(2))) + { + PIXEL00_C + } + else + { + PIXEL00_2 + } + PIXEL01_C + if (Diff(cget(2), cget(6))) + { + PIXEL02_C + } + else + { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(cget(8), cget(4))) + { + PIXEL20_C + } + else + { + PIXEL20_2 + } + PIXEL21_C + if (Diff(cget(6), cget(8))) + { + PIXEL22_C + } + else + { + PIXEL22_2 + } + break; + } + } diff --git a/src/hq_shared32.cpp b/src/hq_shared32.cpp new file mode 100644 index 0000000..cca2127 --- /dev/null +++ b/src/hq_shared32.cpp @@ -0,0 +1,414 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2005 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "hq_shared32.h" + +const unsigned __int64 reg_blank = 0x0000000000000000; +const unsigned __int64 const7 = 0x0000000700070007; +const unsigned __int64 treshold = 0x0000000000300706; + +void Interp1(unsigned char * pc, unsigned int c1, unsigned int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + +#ifdef MMX + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movq mm0, mm1 + pslld mm0, 2 + psubd mm0, mm1 + paddd mm0, mm2 + psrld mm0, 2 + movd [eax], mm0 + EMMS + } +#else + __asm + { + mov eax, pc + mov edx, c1 + shl edx, 2 + add edx, c2 + sub edx, c1 + shr edx, 2 + mov [eax], edx + } +#endif +} + +void Interp2(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3) +{ + //*((int*)pc) = (c1*2+c2+c3)/4; + +#ifdef MMX + __asm + { + mov eax, pc + movd mm0, c1 + movd mm1, c2 + movd mm2, c3 + pslld mm0, 1 + paddd mm0, mm1 + paddd mm0, mm2 + psrad mm0, 2 + movd [eax], mm0 + EMMS + } +#else + __asm + { + mov eax, pc + mov edx, c1 + shl edx, 1 + add edx, c2 + add edx, c3 + shr edx, 2 + mov [eax], edx + } +#endif +} + +void Interp3(unsigned char * pc, unsigned int c1, unsigned int c2) +{ + //*((int*)pc) = (c1*7+c2)/8; + //*((int*)pc) = ((((c1 & 0x00FF00)*7 + (c2 & 0x00FF00) ) & 0x0007F800) + + // (((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3; + +#ifdef MMX + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + pmullw mm1, const7 + paddw mm1, mm2 + psrlw mm1, 3 + packuswb mm1, reg_blank + movd [eax], mm1 + EMMS + } +#else + __asm + { + mov eax, c1 + mov ebx, c2 + mov ecx, eax + shl ecx, 3 + sub ecx, eax + add ecx, ebx + shr ecx, 3 + mov eax, pc + mov [eax], ecx + } +#endif +} + +void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3) +{ + //*((int*)pc) = (c1*2+(c2+c3)*7)/16; + //*((int*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*7 ) & 0x000FF000) + + // (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4; + +#ifdef MMX + __asm + { + mov eax, pc + movd mm1, c1 + movd mm2, c2 + movd mm3, c3 + punpcklbw mm1, reg_blank + punpcklbw mm2, reg_blank + punpcklbw mm3, reg_blank + psllw mm1, 1 + paddw mm2, mm3 + pmullw mm2, const7 + paddw mm1, mm2 + psrlw mm1, 4 + packuswb mm1, reg_blank + movd [eax], mm1 + EMMS + } +#else + + __asm + { + mov eax, [c1] + and eax, 0FF00h + shl eax, 1 + mov ecx, [c2] + and ecx, 0FF00h + mov edx, [c3] + and edx, 0FF00h + add ecx, edx + imul ecx, ecx,7 + add eax, ecx + and eax, 0FF000h + + mov ebx, [c1] + and ebx, 0FF00FFh + shl ebx, 1 + mov ecx, [c2] + and ecx, 0FF00FFh + mov edx, [c3] + and edx, 0FF00FFh + add ecx, edx + imul ecx, ecx,7 + add ebx, ecx + and ebx, 0FF00FF0h + + add eax, ebx + shr eax, 4 + + mov ebx, pc + mov [ebx], eax + } +#endif +} + +void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2) +{ + //*((int*)pc) = (c1+c2)/2; + +#ifdef MMX + __asm + { + mov eax, pc + movd mm0, c1 + movd mm1, c2 + paddd mm0, mm1 + psrad mm0, 1 + movd [eax], mm0 + EMMS + } +#else + __asm + { + mov eax, pc + mov edx, c1 + add edx, c2 + shr edx, 1 + mov [eax], edx + } +#endif +} + + +#include "System.h" +#include "interp.h" + +void Interp1_16(unsigned char * pc, unsigned short c1, unsigned short c2) +{ + *((unsigned short*)pc) = interp_16_31(c1, c2); + //*((int*)pc) = (c1*3+c2)/4; +} + +void Interp2_16(unsigned char * pc, unsigned short c1, unsigned short c2, unsigned short c3) +{ + *((unsigned short*)pc) = interp_16_211(c1, c2, c3); + //*((int*)pc) = (c1*2+c2+c3)/4; +} + +void Interp3_16(unsigned char * pc, unsigned short c1, unsigned short c2) +{ + *((unsigned short*)pc) = interp_16_71(c1, c2); +// *((unsigned short*)pc) = (c1*7+c2)/8; +// *((unsigned short*)pc) = ((((c1 & 0x00FF00)*7 + (c2 & 0x00FF00) ) & 0x0007F800) + +// (((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3; +} + +void Interp4_16(unsigned char * pc, unsigned short c1, unsigned short c2, unsigned short c3) +{ + *((unsigned short*)pc) = interp_16_772(c2, c3, c1); +// *((unsigned short*)pc) = (c1*2+(c2+c3)*7)/16; +// *((unsigned short*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*7 ) & 0x000FF000) + +// (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4; +} + +void Interp5_16(unsigned char * pc, unsigned short c1, unsigned short c2) +{ + *((unsigned short*)pc) = interp_16_11(c1, c2); +} + + + + +bool Diff(unsigned int c1, unsigned int c2) +{ + unsigned int + YUV1 = RGBtoYUV(c1), + YUV2 = RGBtoYUV(c2); + + if (YUV1 == YUV2) return false; // Save some processing power + +#ifdef MMX + unsigned int retval; + __asm + { + mov eax, 0x7FFFFFFF + movd mm7, eax ;mm7 = ABS_MASK = 0x7FFFFFFF + + ; Copy source colors in first reg + movd mm0, YUV1 + movd mm1, YUV2 + + mov eax, 0x00FF0000 + movd mm6, eax ;mm6 = Ymask = 0x00FF0000 + + ; Calculate color Y difference + movq mm2, mm0 + movq mm3, mm1 + pand mm2, mm6 + pand mm3, mm6 + psubd mm2, mm3 + pand mm2, mm7 + + mov eax, 0x0000FF00 + movd mm6, eax ;mm6 = Umask = 0x0000FF00 + + ; Calculate color U difference + movq mm3, mm0 + movq mm4, mm1 + pand mm3, mm6 + pand mm4, mm6 + psubd mm3, mm4 + pand mm3, mm7 + + mov eax, 0x000000FF + movd mm6, eax ;mm6 = Vmask = 0x000000FF + + ; Calculate color V difference + movq mm4, mm0 + movq mm5, mm1 + pand mm4, mm6 + pand mm5, mm6 + psubd mm4, mm5 + pand mm4, mm7 + + mov eax, 0x00300000 + movd mm5, eax ;mm5 = trY = 0x00300000 + mov eax, 0x00000700 + movd mm6, eax ;mm6 = trU = 0x00000700 + mov eax, 0x00000006 + movd mm7, eax ;mm7 = trV = 0x00000006 + + ; Compare the results + pcmpgtd mm2, trY + pcmpgtd mm3, trU + pcmpgtd mm4, trV + por mm2, mm3 + por mm2, mm4 + + movd retval, mm2 + + EMMS + } + return (retval != 0); +#else + return + ( abs32((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || + ( abs32((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || + ( abs32((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ); +#endif +} + + +unsigned int RGBtoYUV(unsigned int c) +{ // Division through 3 slows down the emulation about 10% !!! +#ifdef MMX + unsigned int retval; + __asm + { + movd mm0, c + movq mm1, mm0 + movq mm2, mm0 ;mm0=mm1=mm2=c + + mov eax, 0x000000FF + movd mm5, eax ;mm5 = REDMASK = 0x000000FF + mov eax, 0x0000FF00 + movd mm6, eax ;mm6 = GREENMASK = 0x0000FF00 + mov eax, 0x00FF0000 + movd mm7, eax ;mm7 = BLUEMASK = 0x00FF0000 + + + pand mm0, mm5 + pand mm1, mm6 + pand mm2, mm7 ;mm0=R mm1=G mm2=B + + movq mm3, mm0 + paddd mm3, mm1 + paddd mm3, mm2 +; psrld mm3, 2 ;mm3=Y +; pslld mm3, 16 + pslld mm3, 14 ;mm3=Y<<16 + + mov eax, 512 + movd mm7, eax ;mm7 = 128 << 2 = 512 + + movq mm4, mm0 + psubd mm4, mm2 +; psrld mm4, 2 +; paddd mm4, mm7 ;mm4=U +; pslld mm4, 8 ;mm4=U<<8 + paddd mm4, mm7 + pslld mm4, 6 + + mov eax, 128 + movd mm7, eax ;mm7 = 128 + + movq mm5, mm1 + pslld mm5, 1 + psubd mm5, mm0 + psubd mm5, mm2 + psrld mm5, 3 + paddd mm5, mm7 ;mm5=V + + paddd mm5, mm4 + paddd mm5, mm3 + + movd retval, mm5 + + EMMS + } + return retval; +#else + unsigned char r, g, b, Y, u, v; + r = (c & 0x000000FF); + g = (c & 0x0000FF00) >> 8; + b = (c & 0x00FF0000) >> 16; + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2*g -b)>>3); + return (Y<<16) + (u<<8) + v; + + // Extremely High Quality Code + //unsigned char r, g, b; + //r = c & 0xFF; + //g = (c >> 8) & 0xFF; + //b = (c >> 16) & 0xFF; + //unsigned char y, u, v; + //y = (0.256788 * r + 0.504129 * g + 0.097906 * b) + 16; + //u = (-0.148223 * r - 0.290993 * g + 0.439216 * b) + 128; + //v = (0.439216 * r - 0.367788 * g - 0.071427 * b) + 128; + //return (y << 16) + (u << 8) + v; +#endif +} \ No newline at end of file diff --git a/src/hq_shared32.h b/src/hq_shared32.h new file mode 100644 index 0000000..2fb46e0 --- /dev/null +++ b/src/hq_shared32.h @@ -0,0 +1,41 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2005 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#define abs32(value) (value & 0x7FFFFFFF) +#define abs16(value) (value & 0x7FFF) + +const int Ymask = 0x00FF0000; +const int Umask = 0x0000FF00; +const int Vmask = 0x000000FF; +const int trY = 0x00300000; +const int trU = 0x00000700; +const int trV = 0x00000006; + +void Interp1(unsigned char * pc, unsigned int c1, unsigned int c2); +void Interp2(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3); +void Interp3(unsigned char * pc, unsigned int c1, unsigned int c2); +void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3); +void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2); +void Interp1_16(unsigned char * pc, unsigned short c1, unsigned short c2); +void Interp2_16(unsigned char * pc, unsigned short c1, unsigned short c2, unsigned short c3); +void Interp3_16(unsigned char * pc, unsigned short c1, unsigned short c2); +void Interp4_16(unsigned char * pc, unsigned short c1, unsigned short c2, unsigned short c3); +void Interp5_16(unsigned char * pc, unsigned short c1, unsigned short c2); +bool Diff(unsigned int c1, unsigned int c2); +unsigned int RGBtoYUV(unsigned int c); \ No newline at end of file diff --git a/src/i386/2xSaImmx.asm b/src/i386/2xSaImmx.asm new file mode 100644 index 0000000..6bef810 --- /dev/null +++ b/src/i386/2xSaImmx.asm @@ -0,0 +1,2109 @@ +;/*---------------------------------------------------------------------* +; * The following (piece of) code, (part of) the 2xSaI engine, * +; * copyright (c) 1999 - 2001 by Derek Liauw Kie Fa. * +; * Non-Commercial use of this software is allowed and is encouraged, * +; * provided that appropriate credit be given. * +; * You may freely modify this code, but I request * +; * that any improvements to the engine be submitted to me, so * +; * that I can implement these improvements in newer versions of * +; * the software. * +; * If you need more information, have any comments or suggestions, * +; * you can e-mail me. My e-mail: derek-liauw@usa.net. * +; *---------------------------------------------------------------------*/ + +;---------------------- +; 2xSaI version 0.59 WIP, soon to become version 0.60 +;---------------------- + +;%define FAR_POINTER + + + + BITS 32 +%ifdef __DJGPP__ + GLOBAL __2xSaILine + GLOBAL __2xSaISuperEagleLine + GLOBAL __2xSaISuper2xSaILine + GLOBAL _Init_2xSaIMMX +%else + GLOBAL _2xSaILine + GLOBAL _2xSaISuperEagleLine + GLOBAL _2xSaISuper2xSaILine + GLOBAL Init_2xSaIMMX +%endif + SECTION .text ALIGN = 32 + +%ifdef FAR_POINTER +;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width, +; uint8 *dstPtr, uint32 dstPitch, uint16 dstSegment); +%else +;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width, +; uint8 *dstPtr, uint32 dstPitch); +%endif + +srcPtr equ 8 +deltaPtr equ 12 +srcPitch equ 16 +width equ 20 +dstOffset equ 24 +dstPitch equ 28 +dstSegment equ 32 + + + + +colorB0 equ -2 +colorB1 equ 0 +colorB2 equ 2 +colorB3 equ 4 + +color7 equ -2 +color8 equ 0 +color9 equ 2 + +color4 equ -2 +color5 equ 0 +color6 equ 2 +colorS2 equ 4 + +color1 equ -2 +color2 equ 0 +color3 equ 2 +colorS1 equ 4 + +colorA0 equ -2 +colorA1 equ 0 +colorA2 equ 2 +colorA3 equ 4 + + + + +%ifdef __DJGPP__ +__2xSaISuper2xSaILine: +%else +_2xSaISuper2xSaILine: +%endif +; Store some stuff + push ebp + mov ebp, esp + pushad + +; Prepare the destination +%ifdef FAR_POINTER + ; Set the selector + mov eax, [ebp+dstSegment] + mov fs, ax +%endif + mov edx, [ebp+dstOffset] ; edx points to the screen +; Prepare the source + ; eax points to colorA + mov eax, [ebp+srcPtr] ;eax points to colorA + mov ebx, [ebp+srcPitch] ;ebx contains the source pitch + mov ecx, [ebp+width] ;ecx contains the number of pixels to process + ; eax now points to colorB1 + sub eax, ebx ;eax points to B1 which is the base + +; Main Loop +.Loop: push ecx + + ;-----Check Delta------------------ + mov ecx, [ebp+deltaPtr] + + + ;load source img + movq mm0, [eax+colorB0] + movq mm1, [eax+colorB3] + movq mm2, [eax+ebx+color4] + movq mm3, [eax+ebx+colorS2] + movq mm4, [eax+ebx+ebx+color1] + movq mm5, [eax+ebx+ebx+colorS1] + push eax + add eax, ebx + movq mm6, [eax+ebx+ebx+colorA0] + movq mm7, [eax+ebx+ebx+colorA3] + pop eax + + ;compare to delta + pcmpeqw mm0, [ecx+2+colorB0] + pcmpeqw mm1, [ecx+2+colorB3] + pcmpeqw mm2, [ecx+ebx+2+color4] + pcmpeqw mm3, [ecx+ebx+2+colorS2] + pcmpeqw mm4, [ecx+ebx+ebx+2+color1] + pcmpeqw mm5, [ecx+ebx+ebx+2+colorS1] + add ecx, ebx + pcmpeqw mm6, [ecx+ebx+ebx+2+colorA0] + pcmpeqw mm7, [ecx+ebx+ebx+2+colorA3] + sub ecx, ebx + + + ;compose results + pand mm0, mm1 + pand mm2, mm3 + pand mm4, mm5 + pand mm6, mm7 + pand mm0, mm2 + pand mm4, mm6 + pxor mm7, mm7 + pand mm0, mm4 + movq mm6, [eax+colorB0] + pcmpeqw mm7, mm0 ;did any compare give us a zero ? + + movq [ecx+2+colorB0], mm6 + + packsswb mm7, mm7 + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_PROCESS ;no, so we can skip + + ;End Delta + + ;--------------------------------- + movq mm0, [eax+ebx+color5] + movq mm1, [eax+ebx+color6] + movq mm2, mm0 + movq mm3, mm1 + movq mm4, mm0 + movq mm5, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + movq [I56Pixel], mm0 + movq mm7, mm0 + + ;------------------- + movq mm0, mm7 + movq mm1, mm4 ;5,5,5,6 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + movq [I5556Pixel], mm0 + ;-------------------- + + movq mm0, mm7 + movq mm1, mm5 ;6,6,6,5 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [I5666Pixel], mm0 + + ;------------------------- + ;------------------------- + movq mm0, [eax+ebx+ebx+color2] + movq mm1, [eax+ebx+ebx+color3] + movq mm2, mm0 + movq mm3, mm1 + movq mm4, mm0 + movq mm5, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [I23Pixel], mm0 + movq mm7, mm0 + + ;--------------------- + movq mm0, mm7 + movq mm1, mm4 ;2,2,2,3 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [I2223Pixel], mm0 + + ;---------------------- + movq mm0, mm7 + movq mm1, mm5 ;3,3,3,2 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [I2333Pixel], mm0 + + + ;-------------------- +;//////////////////////////////// +; Decide which "branch" to take +;-------------------------------- + movq mm0, [eax+ebx+color5] + movq mm1, [eax+ebx+color6] + movq mm6, mm0 + movq mm7, mm1 + pcmpeqw mm0, [eax+ebx+ebx+color3] + pcmpeqw mm1, [eax+ebx+ebx+color2] + pcmpeqw mm6, mm7 + + movq mm2, mm0 + movq mm3, mm0 + + pand mm0, mm1 ;colorA == colorD && colorB == colorC + pxor mm7, mm7 + + pcmpeqw mm2, mm7 + pand mm6, mm0 + pand mm2, mm1 ;colorA != colorD && colorB == colorC + + pcmpeqw mm1, mm7 + + pand mm1, mm3 ;colorA == colorD && colorB != colorC + pxor mm0, mm6 + por mm1, mm6 + movq mm7, mm0 + movq [Mask26], mm2 + packsswb mm7, mm7 + movq [Mask35], mm1 + + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_GUESS + +;--------------------------------------------- + movq mm6, mm0 + movq mm4, [eax+ebx+colorA] + movq mm5, [eax+ebx+colorB] + pxor mm7, mm7 + pand mm6, [ONE] + + movq mm0, [eax+colorE] + movq mm1, [eax+ebx+colorG] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+colorF] + movq mm1, [eax+ebx+colorK] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + push eax + add eax, ebx + movq mm0, [eax+ebx+colorH] + movq mm1, [eax+ebx+ebx+colorN] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+ebx+colorL] + movq mm1, [eax+ebx+ebx+colorO] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + pop eax + movq mm1, mm7 + pxor mm0, mm0 + pcmpgtw mm7, mm0 + pcmpgtw mm0, mm1 + + por mm7, [Mask35] + por mm0, [Mask26] + movq [Mask35], mm7 + movq [Mask26], mm0 + +.SKIP_GUESS: + + ;Start the ASSEMBLY !!! eh... compose all the results together to form the final image... + + + movq mm0, [eax+ebx+color5] + movq mm1, [eax+ebx+ebx+color2] + movq mm2, mm0 + movq mm3, mm1 + movq mm4, mm0 + movq mm5, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + ;--------------------------- + + + +%ifdef dfhsdfhsdahdsfhdsfh + + if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2) + product2a = INTERPOLATE (color2, color5); + else + if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0) + product2a = INTERPOLATE(color2, color5); + else + product2a = color2; + + if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2) + product1a = INTERPOLATE (color2, color5); + else + if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0) + product1a = INTERPOLATE(color2, color5); + else + product1a = color5; + +%endif + + + movq mm7, [Mask26] + movq mm6, [eax+colorB2] + movq mm5, [eax+ebx+ebx+color2] + movq mm4, [eax+ebx+ebx+color1] + pcmpeqw mm4, mm5 + pcmpeqw mm6, mm5 + pxor mm5, mm5 + pand mm7, mm4 + pcmpeqw mm6, mm5 + pand mm7, mm6 + + + + movq mm6, [eax+ebx+ebx+color3] + movq mm5, [eax+ebx+ebx+color2] + movq mm4, [eax+ebx+ebx+color1] + movq mm2, [eax+ebx+color5] + movq mm1, [eax+ebx+color4] + movq mm3, [eax+colorB0] + + pcmpeqw mm2, mm4 + pcmpeqw mm6, mm5 + pcmpeqw mm1, mm5 + pcmpeqw mm3, mm5 + pxor mm5, mm5 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm6, mm1 + pand mm2, mm3 + pand mm6, mm2 + por mm7, mm6 + + + movq mm6, mm7 + pcmpeqw mm6, mm5 + pand mm7, mm0 + + movq mm1, [eax+ebx+color5] + pand mm6, mm1 + por mm7, mm6 + movq [final1a], mm7 ;finished 1a + + + + ;-------------------------------- + + movq mm7, [Mask35] + push eax + add eax, ebx + movq mm6, [eax+ebx+ebx+colorA2] + pop eax + movq mm5, [eax+ebx+color5] + movq mm4, [eax+ebx+color4] + pcmpeqw mm4, mm5 + pcmpeqw mm6, mm5 + pxor mm5, mm5 + pand mm7, mm4 + pcmpeqw mm6, mm5 + pand mm7, mm6 + + + + movq mm6, [eax+ebx+color6] + movq mm5, [eax+ebx+color5] + movq mm4, [eax+ebx+color4] + movq mm2, [eax+ebx+ebx+color2] + movq mm1, [eax+ebx+ebx+color1] + push eax + add eax, ebx + movq mm3, [eax+ebx+ebx+colorA0] + pop eax + + pcmpeqw mm2, mm4 + pcmpeqw mm6, mm5 + pcmpeqw mm1, mm5 + pcmpeqw mm3, mm5 + pxor mm5, mm5 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm6, mm1 + pand mm2, mm3 + pand mm6, mm2 + por mm7, mm6 + + + movq mm6, mm7 + pcmpeqw mm6, mm5 + pand mm7, mm0 + + movq mm1, [eax+ebx+ebx+color2] + pand mm6, mm1 + por mm7, mm6 + movq [final2a], mm7 ;finished 2a + + + ;-------------------------------------------- + + +%ifdef dfhsdfhsdahdsfhdsfh + if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) + product2b = Q_INTERPOLATE (color3, color3, color3, color2); + else + if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3) + product2b = Q_INTERPOLATE (color2, color2, color2, color3); + else + product2b = INTERPOLATE (color2, color3); + + if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0) + product1b = Q_INTERPOLATE (color6, color6, color6, color5); + else + if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3) + product1b = Q_INTERPOLATE (color6, color5, color5, color5); + else + product1b = INTERPOLATE (color5, color6); +%endif + + push eax + add eax, ebx + pxor mm7, mm7 + movq mm0, [eax+ebx+ebx+colorA0] + movq mm1, [eax+ebx+ebx+colorA1] + movq mm2, [eax+ebx+ebx+colorA2] + movq mm3, [eax+ebx+ebx+colorA3] + pop eax + movq mm4, [eax+ebx+ebx+color2] + movq mm5, [eax+ebx+ebx+color3] + movq mm6, [eax+ebx+color6] + + pcmpeqw mm6, mm5 + pcmpeqw mm1, mm5 + pcmpeqw mm4, mm2 + pcmpeqw mm0, mm5 + pcmpeqw mm4, mm7 + pcmpeqw mm0, mm7 + pand mm0, mm4 + pand mm6, mm1 + pand mm0, mm6 + + + push eax + add eax, ebx + movq mm1, [eax+ebx+ebx+colorA1] + pop eax + movq mm4, [eax+ebx+ebx+color2] + movq mm5, [eax+ebx+color5] + movq mm6, [eax+ebx+ebx+color3] + + pcmpeqw mm5, mm4 + pcmpeqw mm2, mm4 + pcmpeqw mm1, mm6 + pcmpeqw mm3, mm4 + pcmpeqw mm1, mm7 + pcmpeqw mm3, mm7 + pand mm2, mm5 + pand mm1, mm3 + pand mm1, mm2 + + + movq mm7, mm0 + por mm7, mm1 + + movq mm4, [Mask35] + movq mm3, [Mask26] + + movq mm6, mm4 + pand mm6, mm7 + pxor mm4, mm6 + + movq mm6, mm3 + pand mm6, mm7 + pxor mm3, mm6 + + movq mm2, mm0 + movq mm7, [I2333Pixel] + movq mm6, [I2223Pixel] + movq mm5, [I23Pixel] + + + por mm2, mm4 + pand mm4, [eax+ebx+ebx+color3] + por mm2, mm3 + pand mm3, [eax+ebx+ebx+color2] + por mm2, mm1 + pand mm0, mm7 + pand mm1, mm6 + pxor mm7, mm7 + pcmpeqw mm2, mm7 + por mm0, mm1 + por mm3, mm4 + pand mm2, mm5 + por mm0, mm3 + por mm0, mm2 + movq [final2b], mm0 + + ;----------------------------------- + + + pxor mm7, mm7 + movq mm0, [eax+colorB0] + movq mm1, [eax+colorB1] + movq mm2, [eax+colorB2] + movq mm3, [eax+colorB3] + movq mm4, [eax+ebx+color5] + movq mm5, [eax+ebx+color6] + movq mm6, [eax+ebx+ebx+color3] + + pcmpeqw mm6, mm5 + pcmpeqw mm1, mm5 + pcmpeqw mm4, mm2 + pcmpeqw mm0, mm5 + pcmpeqw mm4, mm7 + pcmpeqw mm0, mm7 + pand mm0, mm4 + pand mm6, mm1 + pand mm0, mm6 + + movq mm1, [eax+colorB1] + movq mm4, [eax+ebx+color5] + movq mm5, [eax+ebx+ebx+color2] + movq mm6, [eax+ebx+color6] + + pcmpeqw mm5, mm4 + pcmpeqw mm2, mm4 + pcmpeqw mm1, mm6 + pcmpeqw mm3, mm4 + pcmpeqw mm1, mm7 + pcmpeqw mm3, mm7 + pand mm2, mm5 + pand mm1, mm3 + pand mm1, mm2 + + + movq mm7, mm0 + por mm7, mm1 + + movq mm4, [Mask35] + movq mm3, [Mask26] + + movq mm6, mm4 + pand mm6, mm7 + pxor mm4, mm6 + + movq mm6, mm3 + pand mm6, mm7 + pxor mm3, mm6 + + movq mm2, mm0 + movq mm7, [I5666Pixel] + movq mm6, [I5556Pixel] + movq mm5, [I56Pixel] + + + por mm2, mm4 + pand mm4, [eax+ebx+color5] + por mm2, mm3 + pand mm3, [eax+ebx+color6] + por mm2, mm1 + pand mm0, mm7 + pand mm1, mm6 + pxor mm7, mm7 + pcmpeqw mm2, mm7 + por mm0, mm1 + por mm3, mm4 + pand mm2, mm5 + por mm0, mm3 + por mm0, mm2 + movq [final1b], mm0 + + ;--------- + + movq mm0, [final1a] + movq mm4, [final2a] + movq mm2, [final1b] + movq mm6, [final2b] + + + movq mm1, mm0 + movq mm5, mm4 + + + punpcklwd mm0, mm2 + punpckhwd mm1, mm2 + + punpcklwd mm4, mm6 + punpckhwd mm5, mm6 + + +%ifdef FAR_POINTER + movq [fs:edx], mm0 + movq [fs:edx+8], mm1 + push edx + add edx, [ebp+dstPitch] + movq [fs:edx], mm4 + movq [fs:edx+8], mm5 + pop edx +%else + movq [edx], mm0 + movq [edx+8], mm1 + push edx + add edx, [ebp+dstPitch] + movq [edx], mm4 + movq [edx+8], mm5 + pop edx +%endif +.SKIP_PROCESS: + mov ecx, [ebp+deltaPtr] + add ecx, 8 + mov [ebp+deltaPtr], ecx + add edx, 16 + add eax, 8 + + pop ecx + sub ecx, 4 + cmp ecx, 0 + jg near .Loop + +; Restore some stuff + popad + mov esp, ebp + pop ebp + emms + ret + + +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- + + + +%ifdef __DJGPP__ +__2xSaISuperEagleLine: +%else +_2xSaISuperEagleLine: +%endif +; Store some stuff + push ebp + mov ebp, esp + pushad + +; Prepare the destination +%ifdef FAR_POINTER + ; Set the selector + mov eax, [ebp+dstSegment] + mov fs, ax +%endif + mov edx, [ebp+dstOffset] ; edx points to the screen +; Prepare the source + ; eax points to colorA + mov eax, [ebp+srcPtr] + mov ebx, [ebp+srcPitch] + mov ecx, [ebp+width] + ; eax now points to colorB1 + sub eax, ebx + +; Main Loop +.Loop: push ecx + + ;-----Check Delta------------------ + mov ecx, [ebp+deltaPtr] + + movq mm0, [eax+colorB0] + movq mm1, [eax+colorB3] + movq mm2, [eax+ebx+color4] + movq mm3, [eax+ebx+colorS2] + movq mm4, [eax+ebx+ebx+color1] + movq mm5, [eax+ebx+ebx+colorS1] + push eax + add eax, ebx + movq mm6, [eax+ebx+ebx+colorA0] + movq mm7, [eax+ebx+ebx+colorA3] + pop eax + + pcmpeqw mm0, [ecx+2+colorB0] + pcmpeqw mm1, [ecx+2+colorB3] + pcmpeqw mm2, [ecx+ebx+2+color4] + pcmpeqw mm3, [ecx+ebx+2+colorS2] + pcmpeqw mm4, [ecx+ebx+ebx+2+color1] + pcmpeqw mm5, [ecx+ebx+ebx+2+colorS1] + add ecx, ebx + pcmpeqw mm6, [ecx+ebx+ebx+2+colorA0] + pcmpeqw mm7, [ecx+ebx+ebx+2+colorA3] + sub ecx, ebx + + + pand mm0, mm1 + pand mm2, mm3 + pand mm4, mm5 + pand mm6, mm7 + pand mm0, mm2 + pand mm4, mm6 + pxor mm7, mm7 + pand mm0, mm4 + movq mm6, [eax+colorB0] + pcmpeqw mm7, mm0 + + movq [ecx+2+colorB0], mm6 + + packsswb mm7, mm7 + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_PROCESS + + ;End Delta + + ;--------------------------------- + movq mm0, [eax+ebx+color5] + movq mm1, [eax+ebx+color6] + movq mm2, mm0 + movq mm3, mm1 + movq mm4, mm0 + movq mm5, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + movq [I56Pixel], mm0 + movq mm7, mm0 + + ;------------------- + movq mm0, mm7 + movq mm1, mm4 ;5,5,5,6 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + movq [product1a], mm0 + ;-------------------- + + movq mm0, mm7 + movq mm1, mm5 ;6,6,6,5 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [product1b], mm0 + + ;------------------------- + ;------------------------- + movq mm0, [eax+ebx+ebx+color2] + movq mm1, [eax+ebx+ebx+color3] + movq mm2, mm0 + movq mm3, mm1 + movq mm4, mm0 + movq mm5, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [I23Pixel], mm0 + movq mm7, mm0 + + ;--------------------- + movq mm0, mm7 + movq mm1, mm4 ;2,2,2,3 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [product2a], mm0 + + ;---------------------- + movq mm0, mm7 + movq mm1, mm5 ;3,3,3,2 + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 + movq [product2b], mm0 + + + ;//////////////////////////////// + ; Decide which "branch" to take + ;-------------------------------- + movq mm4, [eax+ebx+color5] + movq mm5, [eax+ebx+color6] + movq mm6, [eax+ebx+ebx+color3] + movq mm7, [eax+ebx+ebx+color2] + + pxor mm3, mm3 + movq mm0, mm4 + movq mm1, mm5 + + pcmpeqw mm0, mm6 + pcmpeqw mm1, mm7 + pcmpeqw mm1, mm3 + pand mm0, mm1 + movq [Mask35], mm0 + + movq mm0, [eax+ebx+ebx+colorS1] + movq mm1, [eax+ebx+color4] + push eax + add eax, ebx + movq mm2, [eax+ebx+ebx+colorA2] + pop eax + movq mm3, [eax+colorB1] + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm4 + pcmpeqw mm3, mm4 + pand mm0, mm1 + pand mm2, mm3 + por mm0, mm2 + pand mm0, [Mask35] + movq [Mask35b], mm0 + + ;----------- + pxor mm3, mm3 + movq mm0, mm4 + movq mm1, mm5 + + pcmpeqw mm0, mm6 + pcmpeqw mm1, mm7 + pcmpeqw mm0, mm3 + pand mm0, mm1 + movq [Mask26], mm0 + + movq mm0, [eax+ebx+ebx+color1] + movq mm1, [eax+ebx+colorS2] + push eax + add eax, ebx + movq mm2, [eax+ebx+ebx+colorA1] + pop eax + movq mm3, [eax+colorB2] + pcmpeqw mm0, mm5 + pcmpeqw mm1, mm5 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm1 + pand mm2, mm3 + por mm0, mm2 + pand mm0, [Mask26] + movq [Mask26b], mm0 + + ;-------------------- + movq mm0, mm4 + movq mm1, mm5 + movq mm2, mm0 + + pcmpeqw mm2, mm1 + pcmpeqw mm0, mm6 + pcmpeqw mm1, mm7 + pand mm0, mm1 + pand mm2, mm0 + pxor mm0, mm2 + movq mm7, mm0 + + ;------------------ + packsswb mm7, mm7 + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_GUESS + +;--------------------------------------------- +; Map of the pixels: I|E F|J +; G|A B|K +; H|C D|L +; M|N O|P + movq mm6, mm0 + movq mm4, [eax+ebx+color5] + movq mm5, [eax+ebx+color6] + pxor mm7, mm7 + pand mm6, [ONE] + + movq mm0, [eax+colorB1] + movq mm1, [eax+ebx+color4] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+colorB2] + movq mm1, [eax+ebx+colorS2] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + push eax + add eax, ebx + movq mm0, [eax+ebx+color1] + movq mm1, [eax+ebx+ebx+colorA1] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+ebx+colorS1] + movq mm1, [eax+ebx+ebx+colorA2] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + pop eax + movq mm1, mm7 + pxor mm0, mm0 + pcmpgtw mm7, mm0 + pcmpgtw mm0, mm1 + + por mm7, [Mask35] + por mm0, [Mask26] + movq [Mask35], mm7 + movq [Mask26], mm0 + +.SKIP_GUESS: + ;Start the ASSEMBLY !!! + + movq mm4, [Mask35] + movq mm5, [Mask26] + movq mm6, [Mask35b] + movq mm7, [Mask26b] + + movq mm0, [eax+ebx+color5] + movq mm1, [eax+ebx+color6] + movq mm2, [eax+ebx+ebx+color2] + movq mm3, [eax+ebx+ebx+color3] + pcmpeqw mm0, mm2 + pcmpeqw mm1, mm3 + movq mm2, mm4 + movq mm3, mm5 + por mm0, mm1 + por mm2, mm3 + pand mm2, mm0 + pxor mm0, mm2 + movq mm3, mm0 + + movq mm2, mm0 + pxor mm0, mm0 + por mm2, mm4 + pxor mm4, mm6 + por mm2, mm5 + pxor mm5, mm7 + pcmpeqw mm2, mm0 + ;---------------- + + movq mm0, [eax+ebx+color5] + movq mm1, mm3 + por mm1, mm4 + por mm1, mm6 + pand mm0, mm1 + movq mm1, mm5 + pand mm1, [I56Pixel] + por mm0, mm1 + movq mm1, mm7 + pand mm1, [product1b] + por mm0, mm1 + movq mm1, mm2 + pand mm1, [product1a] + por mm0, mm1 + movq [final1a], mm0 + + movq mm0, [eax+ebx+color6] + movq mm1, mm3 + por mm1, mm5 + por mm1, mm7 + pand mm0, mm1 + movq mm1, mm4 + pand mm1, [I56Pixel] + por mm0, mm1 + movq mm1, mm6 + pand mm1, [product1a] + por mm0, mm1 + movq mm1, mm2 + pand mm1, [product1b] + por mm0, mm1 + movq [final1b], mm0 + + movq mm0, [eax+ebx+ebx+color2] + movq mm1, mm3 + por mm1, mm5 + por mm1, mm7 + pand mm0, mm1 + movq mm1, mm4 + pand mm1, [I23Pixel] + por mm0, mm1 + movq mm1, mm6 + pand mm1, [product2b] + por mm0, mm1 + movq mm1, mm2 + pand mm1, [product2a] + por mm0, mm1 + movq [final2a], mm0 + + movq mm0, [eax+ebx+ebx+color3] + movq mm1, mm3 + por mm1, mm4 + por mm1, mm6 + pand mm0, mm1 + movq mm1, mm5 + pand mm1, [I23Pixel] + por mm0, mm1 + movq mm1, mm7 + pand mm1, [product2a] + por mm0, mm1 + movq mm1, mm2 + pand mm1, [product2b] + por mm0, mm1 + movq [final2b], mm0 + + + movq mm0, [final1a] + movq mm2, [final1b] + movq mm1, mm0 + movq mm4, [final2a] + movq mm6, [final2b] + movq mm5, mm4 + punpcklwd mm0, mm2 + punpckhwd mm1, mm2 + punpcklwd mm4, mm6 + punpckhwd mm5, mm6 + + + + +%ifdef FAR_POINTER + movq [fs:edx], mm0 + movq [fs:edx+8], mm1 + push edx + add edx, [ebp+dstPitch] + movq [fs:edx], mm4 + movq [fs:edx+8], mm5 + pop edx +%else + movq [edx], mm0 + movq [edx+8], mm1 + push edx + add edx, [ebp+dstPitch] + movq [edx], mm4 + movq [edx+8], mm5 + pop edx +%endif +.SKIP_PROCESS: + mov ecx, [ebp+deltaPtr] + add ecx, 8 + mov [ebp+deltaPtr], ecx + add edx, 16 + add eax, 8 + + pop ecx + sub ecx, 4 + cmp ecx, 0 + jg near .Loop + +; Restore some stuff + popad + mov esp, ebp + pop ebp + emms + ret + + +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- + + +;This is version 0.50 +colorI equ -2 +colorE equ 0 +colorF equ 2 +colorJ equ 4 + +colorG equ -2 +colorA equ 0 +colorB equ 2 +colorK equ 4 + +colorH equ -2 +colorC equ 0 +colorD equ 2 +colorL equ 4 + +colorM equ -2 +colorN equ 0 +colorO equ 2 +colorP equ 4 + +%ifdef __DJGPP__ +__2xSaILine: +%else +_2xSaILine: +%endif +; Store some stuff + push ebp + mov ebp, esp + pushad + +; Prepare the destination +%ifdef FAR_POINTER + ; Set the selector + mov eax, [ebp+dstSegment] + mov fs, ax +%endif + mov edx, [ebp+dstOffset] ; edx points to the screen +; Prepare the source + ; eax points to colorA + mov eax, [ebp+srcPtr] + mov ebx, [ebp+srcPitch] + mov ecx, [ebp+width] + ; eax now points to colorE + sub eax, ebx + + +; Main Loop +.Loop: push ecx + + ;-----Check Delta------------------ + mov ecx, [ebp+deltaPtr] + + movq mm0, [eax+colorI] + movq mm1, [eax+colorJ] + movq mm2, [eax+ebx+colorG] + movq mm3, [eax+ebx+colorK] + movq mm4, [eax+ebx+ebx+colorH] + movq mm5, [eax+ebx+ebx+colorL] + push eax + add eax, ebx + movq mm6, [eax+ebx+ebx+colorM] + movq mm7, [eax+ebx+ebx+colorP] + pop eax + + pcmpeqw mm0, [ecx+2+colorI] + pcmpeqw mm1, [ecx+2+colorK] + pcmpeqw mm2, [ecx+ebx+2+colorG] + pcmpeqw mm3, [ecx+ebx+2+colorK] + pcmpeqw mm4, [ecx+ebx+ebx+2+colorH] + pcmpeqw mm5, [ecx+ebx+ebx+2+colorL] + add ecx, ebx + pcmpeqw mm6, [ecx+ebx+ebx+2+colorM] + pcmpeqw mm7, [ecx+ebx+ebx+2+colorP] + sub ecx, ebx + + + pand mm0, mm1 + pand mm2, mm3 + pand mm4, mm5 + pand mm6, mm7 + pand mm0, mm2 + pand mm4, mm6 + pxor mm7, mm7 + pand mm0, mm4 + movq mm6, [eax+colorI] + pcmpeqw mm7, mm0 + + movq [ecx+2+colorI], mm6 + + packsswb mm7, mm7 + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_PROCESS + + ;End Delta + + ;--------------------------------- + + +;1 + ;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorE) && (colorB == colorL) + movq mm0, [eax+ebx+colorA] ;mm0 and mm1 contain colorA + movq mm2, [eax+ebx+colorB] ;mm2 and mm3 contain colorB + + movq mm1, mm0 + movq mm3, mm2 + + pcmpeqw mm0, [eax+ebx+ebx+colorD] + pcmpeqw mm1, [eax+colorE] + pcmpeqw mm2, [eax+ebx+ebx+colorL] + pcmpeqw mm3, [eax+ebx+ebx+colorC] + + pand mm0, mm1 + pxor mm1, mm1 + pand mm0, mm2 + pcmpeqw mm3, mm1 + pand mm0, mm3 ;result in mm0 + + ;if ((colorA == colorC) && (colorB != colorE) && (colorA == colorF) && (colorB == colorJ) + movq mm4, [eax+ebx+colorA] ;mm4 and mm5 contain colorA + movq mm6, [eax+ebx+colorB] ;mm6 and mm7 contain colorB + movq mm5, mm4 + movq mm7, mm6 + + pcmpeqw mm4, [eax+ebx+ebx+colorC] + pcmpeqw mm5, [eax+colorF] + pcmpeqw mm6, [eax+colorJ] + pcmpeqw mm7, [eax+colorE] + + pand mm4, mm5 + pxor mm5, mm5 + pand mm4, mm6 + pcmpeqw mm7, mm5 + pand mm4, mm7 ;result in mm4 + + por mm0, mm4 ;combine the masks + movq [Mask1], mm0 + + ;-------------------------------------------- + +;2 + ;if ((colorB == colorC) && (colorA != colorD) && (colorB == colorF) && (colorA == colorH) + movq mm0, [eax+ebx+colorB] ;mm0 and mm1 contain colorB + movq mm2, [eax+ebx+colorA] ;mm2 and mm3 contain colorA + movq mm1, mm0 + movq mm3, mm2 + + pcmpeqw mm0, [eax+ebx+ebx+colorC] + pcmpeqw mm1, [eax+colorF] + pcmpeqw mm2, [eax+ebx+ebx+colorH] + pcmpeqw mm3, [eax+ebx+ebx+colorD] + + pand mm0, mm1 + pxor mm1, mm1 + pand mm0, mm2 + pcmpeqw mm3, mm1 + pand mm0, mm3 ;result in mm0 + + ;if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI) + movq mm4, [eax+ebx+colorB] ;mm4 and mm5 contain colorB + movq mm6, [eax+ebx+colorA] ;mm6 and mm7 contain colorA + movq mm5, mm4 + movq mm7, mm6 + + pcmpeqw mm4, [eax+ebx+ebx+colorD] + pcmpeqw mm5, [eax+colorE] + pcmpeqw mm6, [eax+colorI] + pcmpeqw mm7, [eax+colorF] + + pand mm4, mm5 + pxor mm5, mm5 + pand mm4, mm6 + pcmpeqw mm7, mm5 + pand mm4, mm7 ;result in mm4 + + por mm0, mm4 ;combine the masks + movq [Mask2], mm0 + + +;interpolate colorA and colorB + movq mm0, [eax+ebx+colorA] + movq mm1, [eax+ebx+colorB] + + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + + ;assemble the pixels + movq mm1, [eax+ebx+colorA] + movq mm2, [eax+ebx+colorB] + + movq mm3, [Mask1] + movq mm5, mm1 + movq mm4, [Mask2] + movq mm6, mm1 + + pand mm1, mm3 + por mm3, mm4 + pxor mm7, mm7 + pand mm2, mm4 + + pcmpeqw mm3, mm7 + por mm1, mm2 + pand mm0, mm3 + + por mm0, mm1 + + punpcklwd mm5, mm0 + punpckhwd mm6, mm0 + +%ifdef FAR_POINTER + movq [fs:edx], mm5 + movq [fs:edx+8], mm6 +%else + movq [edx], mm5 + movq [edx+8], mm6 +%endif + +;------------------------------------------------ +; Create the Nextline +;------------------------------------------------ +;3 ;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorG) && (colorC == colorO) + movq mm0, [eax+ebx+colorA] ;mm0 and mm1 contain colorA + movq mm2, [eax+ebx+ebx+colorC] ;mm2 and mm3 contain colorC + movq mm1, mm0 + movq mm3, mm2 + + push eax + add eax, ebx + pcmpeqw mm0, [eax+ebx+colorD] + pcmpeqw mm1, [eax+colorG] + pcmpeqw mm2, [eax+ebx+ebx+colorO] + pcmpeqw mm3, [eax+colorB] + pop eax + + pand mm0, mm1 + pxor mm1, mm1 + pand mm0, mm2 + pcmpeqw mm3, mm1 + pand mm0, mm3 ;result in mm0 + + ;if ((colorA == colorB) && (colorG != colorC) && (colorA == colorH) && (colorC == colorM) + movq mm4, [eax+ebx+colorA] ;mm4 and mm5 contain colorA + movq mm6, [eax+ebx+ebx+colorC] ;mm6 and mm7 contain colorC + movq mm5, mm4 + movq mm7, mm6 + + push eax + add eax, ebx + pcmpeqw mm4, [eax+ebx+colorH] + pcmpeqw mm5, [eax+colorB] + pcmpeqw mm6, [eax+ebx+ebx+colorM] + pcmpeqw mm7, [eax+colorG] + pop eax + + pand mm4, mm5 + pxor mm5, mm5 + pand mm4, mm6 + pcmpeqw mm7, mm5 + pand mm4, mm7 ;result in mm4 + + por mm0, mm4 ;combine the masks + movq [Mask1], mm0 + ;-------------------------------------------- + +;4 + ;if ((colorB == colorC) && (colorA != colorD) && (colorC == colorH) && (colorA == colorF) + movq mm0, [eax+ebx+ebx+colorC] ;mm0 and mm1 contain colorC + movq mm2, [eax+ebx+colorA] ;mm2 and mm3 contain colorA + movq mm1, mm0 + movq mm3, mm2 + + pcmpeqw mm0, [eax+ebx+colorB] + pcmpeqw mm1, [eax+ebx+ebx+colorH] + pcmpeqw mm2, [eax+colorF] + pcmpeqw mm3, [eax+ebx+ebx+colorD] + + pand mm0, mm1 + pxor mm1, mm1 + pand mm0, mm2 + pcmpeqw mm3, mm1 + pand mm0, mm3 ;result in mm0 + + ;if ((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI) + movq mm4, [eax+ebx+ebx+colorC] ;mm4 and mm5 contain colorC + movq mm6, [eax+ebx+colorA] ;mm6 and mm7 contain colorA + movq mm5, mm4 + movq mm7, mm6 + + pcmpeqw mm4, [eax+ebx+ebx+colorD] + pcmpeqw mm5, [eax+ebx+colorG] + pcmpeqw mm6, [eax+colorI] + pcmpeqw mm7, [eax+ebx+ebx+colorH] + + pand mm4, mm5 + pxor mm5, mm5 + pand mm4, mm6 + pcmpeqw mm7, mm5 + pand mm4, mm7 ;result in mm4 + + por mm0, mm4 ;combine the masks + movq [Mask2], mm0 + ;---------------------------------------------- + +;interpolate colorA and colorC + movq mm0, [eax+ebx+colorA] + movq mm1, [eax+ebx+ebx+colorC] + + movq mm2, mm0 + movq mm3, mm1 + + pand mm0, [colorMask] + pand mm1, [colorMask] + + psrlw mm0, 1 + psrlw mm1, 1 + + pand mm3, [lowPixelMask] + paddw mm0, mm1 + + pand mm3, mm2 + paddw mm0, mm3 ;mm0 contains the interpolated values + ;------------- + + ;assemble the pixels + movq mm1, [eax+ebx+colorA] + movq mm2, [eax+ebx+ebx+colorC] + + movq mm3, [Mask1] + movq mm4, [Mask2] + + pand mm1, mm3 + pand mm2, mm4 + + por mm3, mm4 + pxor mm7, mm7 + por mm1, mm2 + + pcmpeqw mm3, mm7 + pand mm0, mm3 + por mm0, mm1 + movq [ACPixel], mm0 + +;//////////////////////////////// +; Decide which "branch" to take +;-------------------------------- + movq mm0, [eax+ebx+colorA] + movq mm1, [eax+ebx+colorB] + movq mm6, mm0 + movq mm7, mm1 + pcmpeqw mm0, [eax+ebx+ebx+colorD] + pcmpeqw mm1, [eax+ebx+ebx+colorC] + pcmpeqw mm6, mm7 + + movq mm2, mm0 + movq mm3, mm0 + + pand mm0, mm1 ;colorA == colorD && colorB == colorC + pxor mm7, mm7 + + pcmpeqw mm2, mm7 + pand mm6, mm0 + pand mm2, mm1 ;colorA != colorD && colorB == colorC + + pcmpeqw mm1, mm7 + + pand mm1, mm3 ;colorA == colorD && colorB != colorC + pxor mm0, mm6 + por mm1, mm6 + movq mm7, mm0 + movq [Mask2], mm2 + packsswb mm7, mm7 + movq [Mask1], mm1 + + movd ecx, mm7 + test ecx, ecx + jz near .SKIP_GUESS + +;--------------------------------------------- +; Map of the pixels: I|E F|J +; G|A B|K +; H|C D|L +; M|N O|P + movq mm6, mm0 + movq mm4, [eax+ebx+colorA] + movq mm5, [eax+ebx+colorB] + pxor mm7, mm7 + pand mm6, [ONE] + + movq mm0, [eax+colorE] + movq mm1, [eax+ebx+colorG] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+colorF] + movq mm1, [eax+ebx+colorK] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + push eax + add eax, ebx + movq mm0, [eax+ebx+colorH] + movq mm1, [eax+ebx+ebx+colorN] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + movq mm0, [eax+ebx+colorL] + movq mm1, [eax+ebx+ebx+colorO] + movq mm2, mm0 + movq mm3, mm1 + pcmpeqw mm0, mm4 + pcmpeqw mm1, mm4 + pcmpeqw mm2, mm5 + pcmpeqw mm3, mm5 + pand mm0, mm6 + pand mm1, mm6 + pand mm2, mm6 + pand mm3, mm6 + paddw mm0, mm1 + paddw mm2, mm3 + + pxor mm3, mm3 + pcmpgtw mm0, mm6 + pcmpgtw mm2, mm6 + pcmpeqw mm0, mm3 + pcmpeqw mm2, mm3 + pand mm0, mm6 + pand mm2, mm6 + paddw mm7, mm0 + psubw mm7, mm2 + + pop eax + movq mm1, mm7 + pxor mm0, mm0 + pcmpgtw mm7, mm0 + pcmpgtw mm0, mm1 + + por mm7, [Mask1] + por mm0, [Mask2] + movq [Mask1], mm7 + movq [Mask2], mm0 + +.SKIP_GUESS: + ;---------------------------- + ;interpolate A, B, C and D + movq mm0, [eax+ebx+colorA] + movq mm1, [eax+ebx+colorB] + movq mm4, mm0 + movq mm2, [eax+ebx+ebx+colorC] + movq mm5, mm1 + movq mm3, [qcolorMask] + movq mm6, mm2 + movq mm7, [qlowpixelMask] + + pand mm0, mm3 + pand mm1, mm3 + pand mm2, mm3 + pand mm3, [eax+ebx+ebx+colorD] + + psrlw mm0, 2 + pand mm4, mm7 + psrlw mm1, 2 + pand mm5, mm7 + psrlw mm2, 2 + pand mm6, mm7 + psrlw mm3, 2 + pand mm7, [eax+ebx+ebx+colorD] + + paddw mm0, mm1 + paddw mm2, mm3 + + paddw mm4, mm5 + paddw mm6, mm7 + + paddw mm4, mm6 + paddw mm0, mm2 + psrlw mm4, 2 + pand mm4, [qlowpixelMask] + paddw mm0, mm4 ;mm0 contains the interpolated value of A, B, C and D + +;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + ;assemble the pixels + movq mm1, [Mask1] + movq mm2, [Mask2] + movq mm4, [eax+ebx+colorA] + movq mm5, [eax+ebx+colorB] + pand mm4, mm1 + pand mm5, mm2 + + pxor mm7, mm7 + por mm1, mm2 + por mm4, mm5 + pcmpeqw mm1, mm7 + pand mm0, mm1 + por mm4, mm0 ;mm4 contains the diagonal pixels + + movq mm0, [ACPixel] + movq mm1, mm0 + punpcklwd mm0, mm4 + punpckhwd mm1, mm4 + + push edx + add edx, [ebp+dstPitch] + +%ifdef FAR_POINTER + movq [fs:edx], mm0 + movq [fs:edx+8], mm1 +%else + movq [edx], mm0 + movq [edx+8], mm1 +%endif + pop edx + +.SKIP_PROCESS: + mov ecx, [ebp+deltaPtr] + add ecx, 8 + mov [ebp+deltaPtr], ecx + add edx, 16 + add eax, 8 + + pop ecx + sub ecx, 4 + cmp ecx, 0 + jg near .Loop + +; Restore some stuff + popad + mov esp, ebp + pop ebp + emms + ret + +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- + +%ifdef __DJGPP__ +_Init_2xSaIMMX: +%else +Init_2xSaIMMX: +%endif +; Store some stuff + push ebp + mov ebp, esp + push edx + + +;Damn thing doesn't work +; mov eax,1 +; cpuid +; test edx, 0x00800000 ;test bit 23 +; jz end2 ;bit not set => no MMX detected + + mov eax, [ebp+8] ;PixelFormat + cmp eax, 555 + jz Bits555 + cmp eax, 565 + jz Bits565 +end2: + mov eax, 1 + jmp end3 +Bits555: + mov edx, 0x7BDE7BDE + mov eax, colorMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0x04210421 + mov eax, lowPixelMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0x739C739C + mov eax, qcolorMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0x0C630C63 + mov eax, qlowpixelMask + mov [eax], edx + mov [eax+4], edx + mov eax, 0 + jmp end3 +Bits565: + mov edx, 0xF7DEF7DE + mov eax, colorMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0x08210821 + mov eax, lowPixelMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0xE79CE79C + mov eax, qcolorMask + mov [eax], edx + mov [eax+4], edx + mov edx, 0x18631863 + mov eax, qlowpixelMask + mov [eax], edx + mov [eax+4], edx + mov eax, 0 + jmp end3 +end3: + pop edx + mov esp, ebp + pop ebp + ret + + +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- +;------------------------------------------------------------------------- + + SECTION .data ALIGN = 32 +;Some constants +colorMask dd 0xF7DEF7DE,0xF7DEF7DE +lowPixelMask dd 0x08210821,0x08210821 + +qcolorMask dd 0xE79CE79C,0xE79CE79C +qlowpixelMask dd 0x18631863,0x18631863 + +darkenMask dd 0xC718C718,0xC718C718 +GreenMask dd 0x07E007E0,0x07E007E0 +RedBlueMask dd 0xF81FF81F,0xF81FF81F + +FALSE dd 0x00000000,0x00000000 +TRUE dd 0xffffffff,0xffffffff +ONE dd 0x00010001,0x00010001 + + + SECTION .bss ALIGN = 32 +ACPixel resb 8 +Mask1 resb 8 +Mask2 resb 8 + +I56Pixel resb 8 +I23Pixel resb 8 +I5556Pixel resb 8 +I2223Pixel resb 8 +I5666Pixel resb 8 +I2333Pixel resb 8 +Mask26 resb 8 +Mask35 resb 8 +Mask26b resb 8 +Mask35b resb 8 +product1a resb 8 +product1b resb 8 +product2a resb 8 +product2b resb 8 +final1a resb 8 +final1b resb 8 +final2a resb 8 +final2b resb 8 diff --git a/src/i386/Makefile.am b/src/i386/Makefile.am new file mode 100644 index 0000000..c82cac3 --- /dev/null +++ b/src/i386/Makefile.am @@ -0,0 +1,8 @@ +SUFFIXES = .asm + +noinst_LIBRARIES = lib386.a + +lib386_a_SOURCES = 2xSaImmx.asm + +.asm.o: + $(NASM) -f elf -o $@ $< diff --git a/src/i386/Makefile.in b/src/i386/Makefile.in new file mode 100644 index 0000000..15cd97f --- /dev/null +++ b/src/i386/Makefile.in @@ -0,0 +1,327 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +SUFFIXES = .asm + +noinst_LIBRARIES = lib386.a + +lib386_a_SOURCES = 2xSaImmx.asm +subdir = src/i386 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + +lib386_a_AR = $(AR) cru +lib386_a_LIBADD = +am_lib386_a_OBJECTS = 2xSaImmx.$(OBJEXT) +lib386_a_OBJECTS = $(am_lib386_a_OBJECTS) + +DEFAULT_INCLUDES = -I. -I$(srcdir) +DIST_SOURCES = $(lib386_a_SOURCES) +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am +SOURCES = $(lib386_a_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .asm .o +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/i386/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + +AR = ar + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +lib386.a: $(lib386_a_OBJECTS) $(lib386_a_DEPENDENCIES) + -rm -f lib386.a + $(lib386_a_AR) lib386.a $(lib386_a_OBJECTS) $(lib386_a_LIBADD) + $(RANLIB) lib386.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES distclean distclean-compile \ + distclean-generic distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + uninstall uninstall-am uninstall-info-am + + +.asm.o: + $(NASM) -f elf -o $@ $< +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/inputGlobal.h b/src/inputGlobal.h new file mode 100644 index 0000000..9a3ad6e --- /dev/null +++ b/src/inputGlobal.h @@ -0,0 +1,39 @@ +#ifndef _INCLUDED_INPUT_GLOBAL_ + +# define _INCLUDED_INPUT_GLOBAL_ + + enum { + KEY_LEFT, KEY_RIGHT, + KEY_UP, KEY_DOWN, + KEY_BUTTON_A, KEY_BUTTON_B, + KEY_BUTTON_START, KEY_BUTTON_SELECT, + KEY_BUTTON_L, KEY_BUTTON_R, + KEY_BUTTON_SPEED, KEY_BUTTON_CAPTURE, + KEY_BUTTON_GS + }; + +# define BUTTON_MASK_A (0x0001) +# define BUTTON_MASK_B (0x0002) +# define BUTTON_MASK_SELECT (0x0004) +# define BUTTON_MASK_START (0x0008) +# define BUTTON_MASK_RIGHT (0x0010) +# define BUTTON_MASK_LEFT (0x0020) +# define BUTTON_MASK_UP (0x0040) +# define BUTTON_MASK_DOWN (0x0080) +# define BUTTON_MASK_R (0x0100) +# define BUTTON_MASK_L (0x0200) +# define BUTTON_REGULAR_MASK (BUTTON_MASK_A|BUTTON_MASK_B|BUTTON_MASK_SELECT|BUTTON_MASK_START|BUTTON_MASK_RIGHT|BUTTON_MASK_LEFT|BUTTON_MASK_UP|BUTTON_MASK_DOWN|BUTTON_MASK_R|BUTTON_MASK_L) +# define BUTTON_MASK_RESET (0x0400) +# define BUTTON_MASK_UNUSED (0x0800) +# define BUTTON_MASK_LEFT_MOTION (0x1000) +# define BUTTON_MASK_RIGHT_MOTION (0x2000) +# define BUTTON_MASK_DOWN_MOTION (0x4000) +# define BUTTON_MASK_UP_MOTION (0x8000) +# define BUTTON_MOTION_MASK (BUTTON_MASK_LEFT_MOTION|BUTTON_MASK_RIGHT_MOTION|BUTTON_MASK_DOWN_MOTION|BUTTON_MASK_UP_MOTION) +# define BUTTON_RECORDINGONLY_MASK (BUTTON_MASK_RESET|BUTTON_MASK_UNUSED|BUTTON_MASK_LEFT_MOTION|BUTTON_MASK_RIGHT_MOTION|BUTTON_MASK_RIGHT_MOTION|BUTTON_MASK_DOWN_MOTION|BUTTON_MASK_UP_MOTION) +# define BUTTON_MASK_SPEED (0x0400) +# define BUTTON_MASK_CAPTURE (0x0800) +# define BUTTON_MASK_GAMESHARK (0x1000) +# define BUTTON_NONRECORDINGONLY_MASK (BUTTON_MASK_SPEED|BUTTON_MASK_CAPTURE|BUTTON_MASK_GAMESHARK) + +#endif \ No newline at end of file diff --git a/src/interframe.cpp b/src/interframe.cpp new file mode 100644 index 0000000..585c0fd --- /dev/null +++ b/src/interframe.cpp @@ -0,0 +1,620 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" +#include +#include + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif + +/* + * Thanks to Kawaks' Mr. K for the code + + Incorporated into vba by Anthony Di Franco +*/ + +static u8 *frm1 = NULL; +static u8 *frm2 = NULL; +static u8 *frm3 = NULL; + +extern int RGB_LOW_BITS_MASK; +extern u32 qRGB_COLOR_MASK[2]; + +static void Init() +{ + frm1 = (u8 *)calloc(322*242,4); + // 1 frame ago + frm2 = (u8 *)calloc(322*242,4); + // 2 frames ago + frm3 = (u8 *)calloc(322*242,4); + // 3 frames ago +} + +void InterframeCleanup() +{ + if(frm1) + free(frm1); + if(frm2) + free(frm2); + if(frm3) + free(frm3); + frm1 = frm2 = frm3 = NULL; +} + +#ifdef MMX +static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = (u16 *)frm1; + u16 *src2 = (u16 *)frm2; + u16 *src3 = (u16 *)frm3; + + int count = width >> 2; + + for(int i = 0; i < height; i++) { +#ifdef __GNUC__ + asm volatile ( + "push %4\n" + "movq 0(%5), %%mm7\n" // colorMask + "0:\n" + "movq 0(%0), %%mm0\n" // src0 + "movq 0(%1), %%mm1\n" // src1 + "movq 0(%2), %%mm2\n" // src2 + "movq 0(%3), %%mm3\n" // src3 + "movq %%mm0, 0(%3)\n" // src3 = src0 + "movq %%mm0, %%mm4\n" + "movq %%mm1, %%mm5\n" + "pcmpeqw %%mm2, %%mm5\n" // src1 == src2 (A) + "pcmpeqw %%mm3, %%mm4\n" // src3 == src0 (B) + "por %%mm5, %%mm4\n" // A | B + "movq %%mm2, %%mm5\n" + "pcmpeqw %%mm0, %%mm5\n" // src0 == src2 (C) + "pcmpeqw %%mm1, %%mm3\n" // src1 == src3 (D) + "por %%mm3, %%mm5\n" // C|D + "pandn %%mm5, %%mm4\n" // (!(A|B))&(C|D) + "movq %%mm0, %%mm2\n" + "pand %%mm7, %%mm2\n" // color & colorMask + "pand %%mm7, %%mm1\n" // src1 & colorMask + "psrlw $1, %%mm2\n" // (color & colorMask) >> 1 (E) + "psrlw $1, %%mm1\n" // (src & colorMask) >> 1 (F) + "paddw %%mm2, %%mm1\n" // E+F + "pand %%mm4, %%mm1\n" // (E+F) & res + "pandn %%mm0, %%mm4\n" // color& !res + + "por %%mm1, %%mm4\n" + "movq %%mm4, 0(%0)\n" // src0 = res + + "addl $8, %0\n" + "addl $8, %1\n" + "addl $8, %2\n" + "addl $8, %3\n" + + "decl %4\n" + "jnz 0b\n" + "pop %4\n" + "emms\n" + : "+r" (src0), "+r" (src1), "+r" (src2), "+r" (src3) + : "r" (count), "r" (qRGB_COLOR_MASK) + ); +#else + __asm { + movq mm7, qword ptr [qRGB_COLOR_MASK]; + mov eax, src0; + mov ebx, src1; + mov ecx, src2; + mov edx, src3; + mov edi, count; + label0: + movq mm0, qword ptr [eax]; // src0 + movq mm1, qword ptr [ebx]; // src1 + movq mm2, qword ptr [ecx]; // src2 + movq mm3, qword ptr [edx]; // src3 + movq qword ptr [edx], mm0; // src3 = src0 + movq mm4, mm0; + movq mm5, mm1; + pcmpeqw mm5, mm2; // src1 == src2 (A) + pcmpeqw mm4, mm3; // src3 == src0 (B) + por mm4, mm5; // A | B + movq mm5, mm2; + pcmpeqw mm5, mm0; // src0 == src2 (C) + pcmpeqw mm3, mm1; // src1 == src3 (D) + por mm5, mm3; // C|D + pandn mm4, mm5; // (!(A|B))&(C|D) + movq mm2, mm0; + pand mm2, mm7; // color & colorMask + pand mm1, mm7; // src1 & colorMask + psrlw mm2, 1; // (color & colorMask) >> 1 (E) + psrlw mm1, 1; // (src & colorMask) >> 1 (F) + paddw mm1, mm2; // E+F + pand mm1, mm4; // (E+F) & res + pandn mm4, mm0; // color & !res + + por mm4, mm1; + movq qword ptr [eax], mm4; // src0 = res + + add eax, 8; + add ebx, 8; + add ecx, 8; + add edx, 8; + + dec edi; + jnz label0; + mov src0, eax; + mov src1, ebx; + mov src2, ecx; + mov src3, edx; + emms; + } +#endif + src0+=2; + src1+=2; + src2+=2; + src3+=2; + } + + /* Swap buffers around */ + u8 *temp = frm1; + frm1 = frm3; + frm3 = frm2; + frm2 = temp; +} +#endif + +void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + if(frm1 == NULL) { + Init(); + } +#ifdef MMX + if(cpu_mmx) { + SmartIB_MMX(srcPtr, srcPitch, width, height); + return; + } +#endif + + u16 colorMask = ~RGB_LOW_BITS_MASK; + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = (u16 *)frm1; + u16 *src2 = (u16 *)frm2; + u16 *src3 = (u16 *)frm3; + + int sPitch = srcPitch >> 1; + + int pos = 0; + for (int j = 0; j < height; j++) + for (int i = 0; i < sPitch; i++) { + u16 color = src0[pos]; + src0[pos] = + (src1[pos] != src2[pos]) && + (src3[pos] != color) && + ((color == src2[pos]) || (src1[pos] == src3[pos])) + ? (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)) : + color; + src3[pos] = color; /* oldest buffer now holds newest frame */ + pos++; + } + + /* Swap buffers around */ + u8 *temp = frm1; + frm1 = frm3; + frm3 = frm2; + frm2 = temp; +} + +#ifdef MMX +static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = (u32 *)frm1; + u32 *src2 = (u32 *)frm2; + u32 *src3 = (u32 *)frm3; + + int count = width >> 1; + + for(int i = 0; i < height; i++) { +#ifdef __GNUC__ + asm volatile ( + "push %4\n" + "movq 0(%5), %%mm7\n" // colorMask + "0:\n" + "movq 0(%0), %%mm0\n" // src0 + "movq 0(%1), %%mm1\n" // src1 + "movq 0(%2), %%mm2\n" // src2 + "movq 0(%3), %%mm3\n" // src3 + "movq %%mm0, 0(%3)\n" // src3 = src0 + "movq %%mm0, %%mm4\n" + "movq %%mm1, %%mm5\n" + "pcmpeqd %%mm2, %%mm5\n" // src1 == src2 (A) + "pcmpeqd %%mm3, %%mm4\n" // src3 == src0 (B) + "por %%mm5, %%mm4\n" // A | B + "movq %%mm2, %%mm5\n" + "pcmpeqd %%mm0, %%mm5\n" // src0 == src2 (C) + "pcmpeqd %%mm1, %%mm3\n" // src1 == src3 (D) + "por %%mm3, %%mm5\n" // C|D + "pandn %%mm5, %%mm4\n" // (!(A|B))&(C|D) + "movq %%mm0, %%mm2\n" + "pand %%mm7, %%mm2\n" // color & colorMask + "pand %%mm7, %%mm1\n" // src1 & colorMask + "psrld $1, %%mm2\n" // (color & colorMask) >> 1 (E) + "psrld $1, %%mm1\n" // (src & colorMask) >> 1 (F) + "paddd %%mm2, %%mm1\n" // E+F + "pand %%mm4, %%mm1\n" // (E+F) & res + "pandn %%mm0, %%mm4\n" // color& !res + + "por %%mm1, %%mm4\n" + "movq %%mm4, 0(%0)\n" // src0 = res + + "addl $8, %0\n" + "addl $8, %1\n" + "addl $8, %2\n" + "addl $8, %3\n" + + "decl %4\n" + "jnz 0b\n" + "pop %4\n" + "emms\n" + : "+r" (src0), "+r" (src1), "+r" (src2), "+r" (src3) + : "r" (count), "r" (qRGB_COLOR_MASK) + ); +#else + __asm { + movq mm7, qword ptr [qRGB_COLOR_MASK]; + mov eax, src0; + mov ebx, src1; + mov ecx, src2; + mov edx, src3; + mov edi, count; + label0: + movq mm0, qword ptr [eax]; // src0 + movq mm1, qword ptr [ebx]; // src1 + movq mm2, qword ptr [ecx]; // src2 + movq mm3, qword ptr [edx]; // src3 + movq qword ptr [edx], mm0; // src3 = src0 + movq mm4, mm0; + movq mm5, mm1; + pcmpeqd mm5, mm2; // src1 == src2 (A) + pcmpeqd mm4, mm3; // src3 == src0 (B) + por mm4, mm5; // A | B + movq mm5, mm2; + pcmpeqd mm5, mm0; // src0 == src2 (C) + pcmpeqd mm3, mm1; // src1 == src3 (D) + por mm5, mm3; // C|D + pandn mm4, mm5; // (!(A|B))&(C|D) + movq mm2, mm0; + pand mm2, mm7; // color & colorMask + pand mm1, mm7; // src1 & colorMask + psrld mm2, 1; // (color & colorMask) >> 1 (E) + psrld mm1, 1; // (src & colorMask) >> 1 (F) + paddd mm1, mm2; // E+F + pand mm1, mm4; // (E+F) & res + pandn mm4, mm0; // color & !res + + por mm4, mm1; + movq qword ptr [eax], mm4; // src0 = res + + add eax, 8; + add ebx, 8; + add ecx, 8; + add edx, 8; + + dec edi; + jnz label0; + mov src0, eax; + mov src1, ebx; + mov src2, ecx; + mov src3, edx; + emms; + } +#endif + + src0++; + src1++; + src2++; + src3++; + } + /* Swap buffers around */ + u8 *temp = frm1; + frm1 = frm3; + frm3 = frm2; + frm2 = temp; +} +#endif + +void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + if(frm1 == NULL) { + Init(); + } +#ifdef MMX + if(cpu_mmx) { + SmartIB32_MMX(srcPtr, srcPitch, width, height); + return; + } +#endif + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = (u32 *)frm1; + u32 *src2 = (u32 *)frm2; + u32 *src3 = (u32 *)frm3; + + u32 colorMask = 0xfefefe; + + int sPitch = srcPitch >> 2; + int pos = 0; + + for (int j = 0; j < height; j++) + for (int i = 0; i < sPitch; i++) { + u32 color = src0[pos]; + src0[pos] = + (src1[pos] != src2[pos]) && + (src3[pos] != color) && + ((color == src2[pos]) || (src1[pos] == src3[pos])) + ? (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)) : + color; + src3[pos] = color; /* oldest buffer now holds newest frame */ + pos++; + } + + /* Swap buffers around */ + u8 *temp = frm1; + frm1 = frm3; + frm3 = frm2; + frm2 = temp; +} + +#ifdef MMX +static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = (u16 *)frm1; + + int count = width >> 2; + + for(int i = 0; i < height; i++) { +#ifdef __GNUC__ + asm volatile ( + "push %2\n" + "movq 0(%3), %%mm7\n" // colorMask + "0:\n" + "movq 0(%0), %%mm0\n" // src0 + "movq 0(%1), %%mm1\n" // src1 + "movq %%mm0, 0(%1)\n" // src1 = src0 + "pand %%mm7, %%mm0\n" // color & colorMask + "pand %%mm7, %%mm1\n" // src1 & colorMask + "psrlw $1, %%mm0\n" // (color & colorMask) >> 1 (E) + "psrlw $1, %%mm1\n" // (src & colorMask) >> 1 (F) + "paddw %%mm1, %%mm0\n" // E+F + + "movq %%mm0, 0(%0)\n" // src0 = res + + "addl $8, %0\n" + "addl $8, %1\n" + + "decl %2\n" + "jnz 0b\n" + "pop %2\n" + "emms\n" + : "+r" (src0), "+r" (src1) + : "r" (count), "r" (qRGB_COLOR_MASK) + ); +#else + __asm { + movq mm7, qword ptr [qRGB_COLOR_MASK]; + mov eax, src0; + mov ebx, src1; + mov edi, count; + label0: + movq mm0, qword ptr [eax]; // src0 + movq mm1, qword ptr [ebx]; // src1 + movq qword ptr [ebx], mm0; // src1 = src0 + pand mm0, mm7; // color & colorMask + pand mm1, mm7; // src1 & colorMask + psrlw mm0, 1; // (color & colorMask) >> 1 (E) + psrlw mm1, 1; // (src & colorMask) >> 1 (F) + paddw mm0, mm1; // E+F + + movq qword ptr [eax], mm0; // src0 = res + + add eax, 8; + add ebx, 8; + + dec edi; + jnz label0; + mov src0, eax; + mov src1, ebx; + emms; + } +#endif + src0+=2; + src1+=2; + } +} +#endif + +void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + if(frm1 == NULL) { + Init(); + } + +#ifdef MMX + if(cpu_mmx) { + MotionBlurIB_MMX(srcPtr, srcPitch, width, height); + return; + } +#endif + + u16 colorMask = ~RGB_LOW_BITS_MASK; + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = (u16 *)frm1; + + int sPitch = srcPitch >> 1; + + int pos = 0; + for (int j = 0; j < height; j++) + for (int i = 0; i < sPitch; i++) { + u16 color = src0[pos]; + src0[pos] = + (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)); + src1[pos] = color; + pos++; + } +} + +#ifdef MMX +static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = (u32 *)frm1; + + int count = width >> 1; + + for(int i = 0; i < height; i++) { +#ifdef __GNUC__ + asm volatile ( + "push %2\n" + "movq 0(%3), %%mm7\n" // colorMask + "0:\n" + "movq 0(%0), %%mm0\n" // src0 + "movq 0(%1), %%mm1\n" // src1 + "movq %%mm0, 0(%1)\n" // src1 = src0 + "pand %%mm7, %%mm0\n" // color & colorMask + "pand %%mm7, %%mm1\n" // src1 & colorMask + "psrld $1, %%mm0\n" // (color & colorMask) >> 1 (E) + "psrld $1, %%mm1\n" // (src & colorMask) >> 1 (F) + "paddd %%mm1, %%mm0\n" // E+F + + "movq %%mm0, 0(%0)\n" // src0 = res + + "addl $8, %0\n" + "addl $8, %1\n" + + "decl %2\n" + "jnz 0b\n" + "pop %2\n" + "emms\n" + : "+r" (src0), "+r" (src1) + : "r" (count), "r" (qRGB_COLOR_MASK) + ); +#else + __asm { + movq mm7, qword ptr [qRGB_COLOR_MASK]; + mov eax, src0; + mov ebx, src1; + mov edi, count; + label0: + movq mm0, qword ptr [eax]; // src0 + movq mm1, qword ptr [ebx]; // src1 + movq qword ptr [ebx], mm0; // src1 = src0 + pand mm0, mm7; // color & colorMask + pand mm1, mm7; // src1 & colorMask + psrld mm0, 1; // (color & colorMask) >> 1 (E) + psrld mm1, 1; // (src & colorMask) >> 1 (F) + paddd mm0, mm1; // E+F + + movq qword ptr [eax], mm0; // src0 = res + + add eax, 8; + add ebx, 8; + + dec edi; + jnz label0; + mov src0, eax; + mov src1, ebx; + emms; + } +#endif + src0++; + src1++; + } +} +#endif + +void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + if(frm1 == NULL) { + Init(); + } + +#ifdef MMX + if(cpu_mmx) { + MotionBlurIB32_MMX(srcPtr, srcPitch, width, height); + return; + } +#endif + + u32 *src0 = (u32 *)srcPtr; + u32 *src1 = (u32 *)frm1; + + u32 colorMask = 0xfefefe; + + int sPitch = srcPitch >> 2; + int pos = 0; + + for (int j = 0; j < height; j++) + for (int i = 0; i < sPitch; i++) { + u32 color = src0[pos]; + src0[pos] = (((color & colorMask) >> 1) + + ((src1[pos] & colorMask) >> 1)); + src1[pos] = color; + pos++; + } +} + +static int count = 0; + +void InterlaceIB(u8 *srcPtr, u32 srcPitch, int width, int height) +{ + if(frm1 == NULL) { + Init(); + } + + u16 colorMask = ~RGB_LOW_BITS_MASK; + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = (u16 *)frm1; + + int sPitch = srcPitch >> 1; + + int pos = 0; + for (int j = 0; j < height; j++) { + bool render = count ? (j & 1) != 0 : (j & 1) == 0; + if(render) { + for (int i = 0; i < sPitch; i++) { + u16 color = src0[pos]; + src0[pos] = + (((color & colorMask) >> 1) + ((((src1[pos] & colorMask) >> 1) & colorMask) >> 1)); + src1[pos] = color; + pos++; + } + } else { + for (int i = 0; i < sPitch; i++) { + u16 color = src0[pos]; + src0[pos] = + (((((color & colorMask) >> 1) & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)); + src1[pos] = color; + pos++; + } + } + } + count = count ^ 1; +} diff --git a/src/interp.h b/src/interp.h new file mode 100644 index 0000000..21d4529 --- /dev/null +++ b/src/interp.h @@ -0,0 +1,351 @@ +/* + * This file is part of the Advance project. + * + * Copyright (C) 2003 Andrea Mazzoleni + * + * 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. + * + * In addition, as a special exception, Andrea Mazzoleni + * gives permission to link the code of this program with + * the MAME library (or with modified versions of MAME that use the + * same license as MAME), and distribute linked combinations including + * the two. You must obey the GNU General Public License in all + * respects for all of the code used other than MAME. If you modify + * this file, you may extend this exception to your version of the + * file, but you are not obligated to do so. If you do not wish to + * do so, delete this exception statement from your version. + */ + +#ifndef __INTERP_H +#define __INTERP_H + +/***************************************************************************/ +/* Basic types */ + +/***************************************************************************/ +/* interpolation */ + +extern unsigned interp_mask[2]; +extern unsigned interp_bits_per_pixel; + +#define INTERP_16_MASK_1(v) (v & interp_mask[0]) +#define INTERP_16_MASK_2(v) (v & interp_mask[1]) + +static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8); +} + +static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8); +} + +static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8); +} + +static inline u16 interp_16_71(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8); +} + +static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4); +} + +static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16) + | INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16); +} + +static inline u16 interp_16_11(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2); +} + +static inline u16 interp_16_31(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4); +} + +static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16); +} + +static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8); +} + +static inline u16 interp_16_53(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8); +} + +static inline u16 interp_16_151(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16); +} + +static inline u16 interp_16_97(u16 p1, u16 p2) +{ + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16) + | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16); +} + +#define INTERP_32_MASK_1(v) (v & 0xFF00FF) +#define INTERP_32_MASK_2(v) (v & 0x00FF00) + +static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8); +} + +static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8); +} + +static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4); +} + +static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8); +} + +static inline u32 interp_32_71(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8); +} + +static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16) + | INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16); +} + +static inline u32 interp_32_11(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2); +} + +static inline u32 interp_32_31(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4); +} + +static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16); +} + +static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8); +} + +static inline u32 interp_32_53(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8); +} + +static inline u32 interp_32_151(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16); +} + +static inline u32 interp_32_97(u32 p1, u32 p2) +{ + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16) + | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16); +} + +/***************************************************************************/ +/* diff */ + +#define INTERP_Y_LIMIT (0x30*4) +#define INTERP_U_LIMIT (0x07*4) +#define INTERP_V_LIMIT (0x06*8) + +static int interp_16_diff(u16 p1, u16 p2) +{ + int r, g, b; + int y, u, v; + + if (p1 == p2) + return 0; + + if (interp_bits_per_pixel == 16) { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3; + r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; + } else { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2; + r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7; + } + + y = r + g + b; + u = r - b; + v = -r + 2*g - b; + + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; + + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; + + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; + +return 0; +} + +static int interp_32_diff(u32 p1, u32 p2) +{ + int r, g, b; + int y, u, v; + + if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) + return 0; + + b = (int)((p1 & 0xFF) - (p2 & 0xFF)); + g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; + r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; + + y = r + g + b; + u = r - b; + v = -r + 2*g - b; + + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; + + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; + + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; + + return 0; +} + + +#define INTERP_LIMIT2 (96000) +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define MIN(x,y) ((x) < (y) ? (x) : (y)) + +static int interp_16_diff2(u16 p1, u16 p2) +{ + int r, g, b; + int y, u, v; + + if ((p1 & 0xF79E) == (p2 & 0xF79E)) + return 0; + + if (interp_bits_per_pixel == 16) { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3; + r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; + } else { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2; + r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7; + } + +// yb = 30*r + 58*g + 12*b; + y = 33*r + 36*g + 31*b; + u = -14*r - 29*g + 44*b; + v = 62*r - 51*g - 10*b; + + if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2) + return 1; + return 0; +} + +static int interp_32_diff2(u32 p1, u32 p2) +{ + int r, g, b; + int y, u, v; + + if ((p1 & 0xF0F0F0) == (p2 & 0xF0F0F0)) + return 0; + + b = (int)((p1 & 0xF8) - (p2 & 0xF8)); + g = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; + r = (int)((p1 & 0xF80000) - (p2 & 0xF80000)) >> 16; + +// y = 30*r + 58*g + 12*b; + y = 33*r + 36*g + 31*b; + u = -14*r - 29*g + 44*b; + v = 62*r - 51*g - 10*b; + + if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2) + return 1; + + return 0; +} + +static void interp_set(unsigned bits_per_pixel) +{ + interp_bits_per_pixel = bits_per_pixel; + + switch (bits_per_pixel) { + case 15 : + interp_mask[0] = 0x7C1F; + interp_mask[1] = 0x03E0; + break; + case 16 : + interp_mask[0] = 0xF81F; + interp_mask[1] = 0x07E0; + break; + case 32 : + interp_mask[0] = 0xFF00FF; + interp_mask[1] = 0x00FF00; + break; + } +} + +#endif diff --git a/src/lq2x.h b/src/lq2x.h new file mode 100644 index 0000000..b005355 --- /dev/null +++ b/src/lq2x.h @@ -0,0 +1,1284 @@ +case 0 : +case 2 : +case 4 : +case 6 : +case 8 : +case 12 : +case 16 : +case 20 : +case 24 : +case 28 : +case 32 : +case 34 : +case 36 : +case 38 : +case 40 : +case 44 : +case 48 : +case 52 : +case 56 : +case 60 : +case 64 : +case 66 : +case 68 : +case 70 : +case 96 : +case 98 : +case 100 : +case 102 : +case 128 : +case 130 : +case 132 : +case 134 : +case 136 : +case 140 : +case 144 : +case 148 : +case 152 : +case 156 : +case 160 : +case 162 : +case 164 : +case 166 : +case 168 : +case 172 : +case 176 : +case 180 : +case 184 : +case 188 : +case 192 : +case 194 : +case 196 : +case 198 : +case 224 : +case 226 : +case 228 : +case 230 : +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); +} break; +case 1 : +case 5 : +case 9 : +case 13 : +case 17 : +case 21 : +case 25 : +case 29 : +case 33 : +case 37 : +case 41 : +case 45 : +case 49 : +case 53 : +case 57 : +case 61 : +case 65 : +case 69 : +case 97 : +case 101 : +case 129 : +case 133 : +case 137 : +case 141 : +case 145 : +case 149 : +case 153 : +case 157 : +case 161 : +case 165 : +case 169 : +case 173 : +case 177 : +case 181 : +case 185 : +case 189 : +case 193 : +case 197 : +case 225 : +case 229 : +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + P3 = IC(1); +} break; +case 3 : +case 35 : +case 67 : +case 99 : +case 131 : +case 163 : +case 195 : +case 227 : +{ + P0 = IC(2); + P1 = IC(2); + P2 = IC(2); + P3 = IC(2); +} break; +case 7 : +case 39 : +case 71 : +case 103 : +case 135 : +case 167 : +case 199 : +case 231 : +{ + P0 = IC(3); + P1 = IC(3); + P2 = IC(3); + P3 = IC(3); +} break; +case 10 : +case 138 : +{ + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } +} break; +case 11 : +case 27 : +case 75 : +case 139 : +case 155 : +case 203 : +{ + P1 = IC(2); + P2 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 14 : +case 142 : +{ + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + P1 = IC(0); + } else { + P0 = I332(1, 3, 0); + P1 = I31(0, 1); + } +} break; +case 15 : +case 143 : +case 207 : +{ + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + P1 = IC(4); + } else { + P0 = I332(1, 3, 4); + P1 = I31(4, 1); + } +} break; +case 18 : +case 22 : +case 30 : +case 50 : +case 54 : +case 62 : +case 86 : +case 118 : +{ + P0 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 19 : +case 51 : +{ + P2 = IC(2); + P3 = IC(2); + if (MUR) { + P0 = IC(2); + P1 = IC(2); + } else { + P0 = I31(2, 1); + P1 = I332(1, 5, 2); + } +} break; +case 23 : +case 55 : +case 119 : +{ + P2 = IC(3); + P3 = IC(3); + if (MUR) { + P0 = IC(3); + P1 = IC(3); + } else { + P0 = I31(3, 1); + P1 = I332(1, 5, 3); + } +} break; +case 26 : +{ + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 31 : +case 95 : +{ + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 42 : +case 170 : +{ + P1 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + P2 = IC(0); + } else { + P0 = I332(1, 3, 0); + P2 = I31(0, 3); + } +} break; +case 43 : +case 171 : +case 187 : +{ + P1 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + P2 = IC(2); + } else { + P0 = I332(1, 3, 2); + P2 = I31(2, 3); + } +} break; +case 46 : +case 174 : +{ + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 47 : +case 175 : +{ + P1 = IC(4); + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 58 : +case 154 : +case 186 : +{ + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 59 : +{ + P2 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 63 : +{ + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 72 : +case 76 : +case 104 : +case 106 : +case 108 : +case 110 : +case 120 : +case 124 : +{ + P0 = IC(0); + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } +} break; +case 73 : +case 77 : +case 105 : +case 109 : +case 125 : +{ + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P0 = IC(1); + P2 = IC(1); + } else { + P0 = I31(1, 3); + P2 = I332(3, 7, 1); + } +} break; +case 74 : +{ + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } +} break; +case 78 : +case 202 : +case 206 : +{ + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 79 : +{ + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 80 : +case 208 : +case 210 : +case 216 : +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 81 : +case 209 : +case 217 : +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I211(1, 5, 7); + } +} break; +case 82 : +case 214 : +case 222 : +{ + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 83 : +case 115 : +{ + P0 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I611(2, 5, 7); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 84 : +case 212 : +{ + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P1 = IC(0); + P3 = IC(0); + } else { + P1 = I31(0, 5); + P3 = I332(5, 7, 0); + } +} break; +case 85 : +case 213 : +case 221 : +{ + P0 = IC(1); + P2 = IC(1); + if (MDR) { + P1 = IC(1); + P3 = IC(1); + } else { + P1 = I31(1, 5); + P3 = I332(5, 7, 1); + } +} break; +case 87 : +{ + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I611(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I211(3, 1, 5); + } +} break; +case 88 : +case 248 : +case 250 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 89 : +case 93 : +{ + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I611(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 90 : +{ + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 91 : +{ + if (MDL) { + P2 = IC(2); + } else { + P2 = I611(2, 3, 7); + } + if (MDR) { + P3 = IC(2); + } else { + P3 = I611(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 92 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } +} break; +case 94 : +{ + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 107 : +case 123 : +{ + P1 = IC(2); + P3 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I211(2, 3, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 111 : +{ + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 112 : +case 240 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDR) { + P2 = IC(0); + P3 = IC(0); + } else { + P2 = I31(0, 7); + P3 = I332(5, 7, 0); + } +} break; +case 113 : +case 241 : +{ + P0 = IC(1); + P1 = IC(1); + if (MDR) { + P2 = IC(1); + P3 = IC(1); + } else { + P2 = I31(1, 7); + P3 = I332(5, 7, 1); + } +} break; +case 114 : +{ + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 116 : +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } +} break; +case 117 : +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 121 : +{ + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I211(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 122 : +{ + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 126 : +{ + P0 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 127 : +{ + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 146 : +case 150 : +case 178 : +case 182 : +case 190 : +{ + P0 = IC(0); + P2 = IC(0); + if (MUR) { + P1 = IC(0); + P3 = IC(0); + } else { + P1 = I332(1, 5, 0); + P3 = I31(0, 5); + } +} break; +case 147 : +case 179 : +{ + P0 = IC(2); + P2 = IC(2); + P3 = IC(2); + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 151 : +case 183 : +{ + P0 = IC(3); + P2 = IC(3); + P3 = IC(3); + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 158 : +{ + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 159 : +{ + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 191 : +{ + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 200 : +case 204 : +case 232 : +case 236 : +case 238 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + P3 = IC(0); + } else { + P2 = I332(3, 7, 0); + P3 = I31(0, 7); + } +} break; +case 201 : +case 205 : +{ + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I611(1, 3, 7); + } +} break; +case 211 : +{ + P0 = IC(2); + P1 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } +} break; +case 215 : +{ + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I211(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 218 : +{ + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 219 : +{ + P1 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 220 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 223 : +{ + P2 = IC(4); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 233 : +case 237 : +{ + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } +} break; +case 234 : +{ + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 235 : +{ + P1 = IC(2); + P3 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I1411(2, 3, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 239 : +{ + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 242 : +{ + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 243 : +{ + P0 = IC(2); + P1 = IC(2); + if (MDR) { + P2 = IC(2); + P3 = IC(2); + } else { + P2 = I31(2, 7); + P3 = I332(5, 7, 2); + } +} break; +case 244 : +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } +} break; +case 245 : +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I1411(1, 5, 7); + } +} break; +case 246 : +{ + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 247 : +{ + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I1411(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 249 : +{ + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I211(1, 5, 7); + } +} break; +case 251 : +{ + P1 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I1411(2, 3, 7); + } + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 252 : +{ + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } +} break; +case 253 : +{ + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I1411(1, 5, 7); + } +} break; +case 254 : +{ + P0 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 255 : +{ + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; diff --git a/src/memgzio.c b/src/memgzio.c new file mode 100644 index 0000000..32f6776 --- /dev/null +++ b/src/memgzio.c @@ -0,0 +1,681 @@ +/* gzio.c -- IO on .gz files + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Compile this file with -DNO_DEFLATE to avoid the compression code. + */ + +/* memgzio.c - IO on .gz files in memory + * Adapted from original gzio.c from zlib library by Forgotten + */ + +/* @(#) $Id: memgzio.c,v 1.3 2004/01/17 23:07:32 kxu Exp $ */ + +#include +#include +#include + +#include "memgzio.h" + +/*struct internal_state {int dummy;};*/ /* for buggy compilers */ + +#ifndef Z_BUFSIZE +# ifdef MAXSEG_64K +# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ +# else +# define Z_BUFSIZE 16384 +# endif +#endif +#ifndef Z_PRINTF_BUFSIZE +# define Z_PRINTF_BUFSIZE 4096 +#endif + +#define ALLOC(size) malloc(size) +#define TRYFREE(p) {if (p) free(p);} + +static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +typedef struct _MemFile { + char *memory; + char *next; + int available; + int error; + char mode; +} MEMFILE; + +typedef struct mem_stream { + z_stream stream; + int z_err; /* error code for last stream operation */ + int z_eof; /* set if end of input file */ + MEMFILE *file; /* memoru file */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ + uLong crc; /* crc32 of uncompressed data */ + char *msg; /* error message */ + int transparent; /* 1 if input file is not a .gz file */ + char mode; /* 'w' or 'r' */ + long startpos; /* start of compressed data in file (header skipped) */ +} mem_stream; + + +local gzFile gz_open OF((char *memory, const int available, const char *mode)); +local int do_flush OF((gzFile file, int flush)); +local int get_byte OF((mem_stream *s)); +local void check_header OF((mem_stream *s)); +local int destroy OF((mem_stream *s)); +local void putLong OF((MEMFILE *file, uLong x)); +local uLong getLong OF((mem_stream *s)); + +local MEMFILE *memOpen(char *memory, int available, char mode) +{ + MEMFILE *f; + + if(available <= 8) + return NULL; + + if(mode != 'w' && mode != 'r') + return NULL; + + f = (MEMFILE *)malloc(sizeof(MEMFILE)); + + f->memory = memory; + f->mode = mode; + f->error = 0; + + if(mode == 'w') { + f->available = available - 8; + f->next = memory + 8; + memory[0] = 'V'; + memory[1] = 'B'; + memory[2] = 'A'; + memory[3] = ' '; + *((int *)(memory+4)) = 0; + } else { + if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' || + memory[3] != ' ') { + free(f); + return NULL; + } + f->available = *((int *)(memory+4)); + f->next = memory+8; + } + + return f; +} + +local size_t memWrite(const void *buffer, size_t size, size_t count, + MEMFILE *file) +{ + size_t total = size*count; + + if(file->mode != 'w') { + file->error = 1; + return 0; + } + + if(total > (size_t)file->available) { + total = file->available; + } + memcpy(file->next, buffer, total); + file->available -= total; + file->next += total; + return total; +} + +local size_t memRead(void *buffer, size_t size, size_t count, + MEMFILE *file) +{ + size_t total = size*count; + + if(file->mode != 'r') { + file->error = 1; + return 0; + } + + if(file->available == 0) + return -1; + + if(total > (size_t)file->available) { + total = file->available; + } + memcpy(buffer, file->next, total); + file->available -= total; + file->next += total; + return total; +} + +local int memPutc(int c, MEMFILE *file) +{ + if(file->mode != 'w') { + file->error = 1; + return -1; + } + + if(file->available >= 1) { + *file->next++ = c; + file->available--; + } else + return -1; + + return c; +} + +local long memTell(MEMFILE *f) +{ + return (f->next - f->memory) - 8; +} + +local int memError(MEMFILE *f) +{ + return f->error; +} + +local int memClose(MEMFILE *f) +{ + if(f->mode == 'w') { + *((int *)(f->memory+4)) = memTell(f); + } + free(f); + return 0; +} + +local int memPrintf(MEMFILE *f, const char *format, ...) +{ + char buffer[80]; + va_list list; + int len; + + va_start(list, format); + len = vsprintf(buffer, format, list); + va_end(list); + + return memWrite(buffer, 1, len, f); +} + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb"). The file is given either by file descriptor + or path name (if fd == -1). + gz_open return NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). +*/ +local gzFile gz_open (memory, available, mode) + char *memory; + const int available; + const char *mode; +{ + int err; + int level = Z_DEFAULT_COMPRESSION; /* compression level */ + int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ + char *p = (char*)mode; + mem_stream *s; + char fmode[80]; /* copy of mode, without the compression level */ + char *m = fmode; + + s = (mem_stream *)ALLOC(sizeof(mem_stream)); + if (!s) return Z_NULL; + + s->stream.zalloc = (alloc_func)0; + s->stream.zfree = (free_func)0; + s->stream.opaque = (voidpf)0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; + s->z_err = Z_OK; + s->z_eof = 0; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + s->file = NULL; + + s->mode = '\0'; + do { + if (*p == 'r') s->mode = 'r'; + if (*p == 'w' || *p == 'a') s->mode = 'w'; + if (*p >= '0' && *p <= '9') { + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + } else { + *m++ = *p; /* copy the mode */ + } + } while (*p++ && m != fmode + sizeof(fmode)); + if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; + + if (s->mode == 'w') { +#ifdef NO_DEFLATE + err = Z_STREAM_ERROR; +#else + err = deflateInit2(&(s->stream), level, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); + /* windowBits is passed < 0 to suppress zlib header */ + + s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); +#endif + if (err != Z_OK || s->outbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } else { + s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); + + err = inflateInit2(&(s->stream), -MAX_WBITS); + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are + * present after the compressed stream. + */ + if (err != Z_OK || s->inbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } + s->stream.avail_out = Z_BUFSIZE; + + errno = 0; + s->file = memOpen(memory, available, s->mode); + + if (s->file == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + + if (s->mode == 'w') { + /* Write a very simple .gz header: + */ + memPrintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + s->startpos = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * startpos anyway in write mode, so this initialization is not + * necessary. + */ + } else { + check_header(s); /* skip the .gz header */ + s->startpos = (memTell(s->file) - s->stream.avail_in); + } + + return (gzFile)s; +} + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. +*/ +gzFile ZEXPORT memgzopen (memory, available, mode) + char *memory; + int available; + const char *mode; +{ + return gz_open (memory, available, mode); +} + +/* =========================================================================== + Read a byte from a mem_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ +local int get_byte(s) + mem_stream *s; +{ + if (s->z_eof) return EOF; + if (s->stream.avail_in == 0) { + errno = 0; + s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (memError(s->file)) s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; +} + +/* =========================================================================== + Check the gzip header of a mem_stream opened for reading. Set the stream + mode to transparent if the gzip magic header is not present; set s->err + to Z_DATA_ERROR if the magic header is present but the rest of the header + is incorrect. + IN assertion: the stream s has already been created sucessfully; + s->stream.avail_in is zero for the first time, but may be non-zero + for concatenated .gz files. +*/ +local void check_header(s) + mem_stream *s; +{ + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; + + /* Check the gzip magic header */ + for (len = 0; len < 2; len++) { + c = get_byte(s); + if (c != gz_magic[len]) { + if (len != 0) s->stream.avail_in++, s->stream.next_in--; + if (c != EOF) { + s->stream.avail_in++, s->stream.next_in--; + s->transparent = 1; + } + s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; + return; + } + } + method = get_byte(s); + flags = get_byte(s); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + s->z_err = Z_DATA_ERROR; + return; + } + + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) (void)get_byte(s); + + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) (void)get_byte(s); + } + s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; +} + + /* =========================================================================== + * Cleanup then free the given mem_stream. Return a zlib error code. + Try freeing in the reverse order of allocations. + */ +local int destroy (s) + mem_stream *s; +{ + int err = Z_OK; + + if (!s) return Z_STREAM_ERROR; + + TRYFREE(s->msg); + + if (s->stream.state != NULL) { + if (s->mode == 'w') { +#ifdef NO_DEFLATE + err = Z_STREAM_ERROR; +#else + err = deflateEnd(&(s->stream)); +#endif + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } + } + if (s->file != NULL && memClose(s->file)) { +#ifdef ESPIPE + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ +#endif + err = Z_ERRNO; + } + if (s->z_err < 0) err = s->z_err; + + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s); + return err; +} + +/* =========================================================================== + Reads the given number of uncompressed bytes from the compressed file. + gzread returns the number of bytes actually read (0 for end of file). +*/ +int ZEXPORT memgzread (file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + mem_stream *s = (mem_stream*)file; + Bytef *start = (Bytef*)buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + + if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; + + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; + if (s->z_err == Z_STREAM_END) return 0; /* EOF */ + + next_out = (Byte*)buf; + s->stream.next_out = (Bytef*)buf; + s->stream.avail_out = len; + + while (s->stream.avail_out != 0) { + + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= memRead(next_out, 1, s->stream.avail_out, + s->file); + } + len -= s->stream.avail_out; + s->stream.total_in += (uLong)len; + s->stream.total_out += (uLong)len; + if (len == 0) s->z_eof = 1; + return (int)len; + } + if (s->stream.avail_in == 0 && !s->z_eof) { + + errno = 0; + s->stream.avail_in = memRead(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (memError(s->file)) { + s->z_err = Z_ERRNO; + break; + } + } + s->stream.next_in = s->inbuf; + } + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; + + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); + /* The uncompressed length returned by above getlong() may + * be different from s->stream.total_out) in case of + * concatenated .gz files. Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + uLong total_in = s->stream.total_in; + uLong total_out = s->stream.total_out; + + inflateReset(&(s->stream)); + s->stream.total_in = total_in; + s->stream.total_out = total_out; + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) break; + } + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + + return (int)(len - s->stream.avail_out); +} + + +#ifndef NO_DEFLATE +/* =========================================================================== + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of bytes actually written (0 in case of error). +*/ +int ZEXPORT memgzwrite (file, buf, len) + gzFile file; + const voidp buf; + unsigned len; +{ + mem_stream *s = (mem_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.next_in = (Bytef*)buf; + s->stream.avail_in = len; + + while (s->stream.avail_in != 0) { + + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (memWrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + break; + } + s->stream.avail_out = Z_BUFSIZE; + } + s->z_err = deflate(&(s->stream), Z_NO_FLUSH); + if (s->z_err != Z_OK) break; + } + s->crc = crc32(s->crc, (const Bytef *)buf, len); + + return (int)(len - s->stream.avail_in); +} +#endif +/* =========================================================================== + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. +*/ +local int do_flush (file, flush) + gzFile file; + int flush; +{ + uInt len; + int done = 0; + mem_stream *s = (mem_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.avail_in = 0; /* should be zero already anyway */ + + for (;;) { + len = Z_BUFSIZE - s->stream.avail_out; + + if (len != 0) { + if ((uInt)memWrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) break; + s->z_err = deflate(&(s->stream), flush); + + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; + + /* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; + } + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} + +/* =========================================================================== + Outputs a long in LSB order to the given file +*/ +local void putLong (file, x) + MEMFILE *file; + uLong x; +{ + int n; + for (n = 0; n < 4; n++) { + memPutc((int)(x & 0xff), file); + x >>= 8; + } +} + +/* =========================================================================== + Reads a long in LSB order from the given mem_stream. Sets z_err in case + of error. +*/ +local uLong getLong (s) + mem_stream *s; +{ + uLong x = (uLong)get_byte(s); + int c; + + x += ((uLong)get_byte(s))<<8; + x += ((uLong)get_byte(s))<<16; + c = get_byte(s); + if (c == EOF) s->z_err = Z_DATA_ERROR; + x += ((uLong)c)<<24; + return x; +} + +/* =========================================================================== + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. +*/ +int ZEXPORT memgzclose (file) + gzFile file; +{ + int err; + mem_stream *s = (mem_stream*)file; + + if (s == NULL) return Z_STREAM_ERROR; + + if (s->mode == 'w') { +#ifdef NO_DEFLATE + return Z_STREAM_ERROR; +#else + err = do_flush (file, Z_FINISH); + if (err != Z_OK) return destroy((mem_stream*)file); + + putLong (s->file, s->crc); + putLong (s->file, s->stream.total_in); +#endif + } + return destroy((mem_stream*)file); +} + +long ZEXPORT memtell(file) + gzFile file; +{ + mem_stream *s = (mem_stream*)file; + + if (s == NULL) return Z_STREAM_ERROR; + + return memTell(s->file); +} diff --git a/src/memgzio.h b/src/memgzio.h new file mode 100644 index 0000000..2ca74cb --- /dev/null +++ b/src/memgzio.h @@ -0,0 +1,21 @@ +/* gzio.c -- IO on .gz files + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Compile this file with -DNO_DEFLATE to avoid the compression code. + */ + +/* memgzio.c - IO on .gz files in memory + * Adapted from original gzio.c from zlib library by Forgotten + */ +#ifndef HAVE_ZUTIL_H +#include "../win32/include/zlib/zutil.h" +#else +#include +#endif + +gzFile ZEXPORT memgzopen(char *memory, int, const char *); +int ZEXPORT memgzread(gzFile, voidp, unsigned); +int ZEXPORT memgzwrite(gzFile, const voidp, unsigned); +int ZEXPORT memgzclose(gzFile); +long ZEXPORT memtell(gzFile); diff --git a/src/motionblur.cpp b/src/motionblur.cpp new file mode 100644 index 0000000..35beb88 --- /dev/null +++ b/src/motionblur.cpp @@ -0,0 +1,192 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" + +extern int RGB_LOW_BITS_MASK; + +void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); + u32 lowPixelMask = RGB_LOW_BITS_MASK; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *xP = (u32 *) deltaPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + u32 currentDelta; + u32 nextDelta; + + finish = (u8 *) bP + ((width+2) << 1); + nextPixel = *bP++; + nextDelta = *xP++; + + do { + currentPixel = nextPixel; + currentDelta = nextDelta; + nextPixel = *bP++; + nextDelta = *xP++; + + if(currentPixel != currentDelta) { + u32 colorA, product, colorB; + + *(xP - 2) = currentPixel; +#ifdef WORDS_BIGENDIAN + colorA = currentPixel >> 16; + colorB = currentDelta >> 16; +#else + colorA = currentPixel & 0xffff; + colorB = currentDelta & 0xffff; +#endif + + product = ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1) + + (colorA & colorB & lowPixelMask))); + + *(dP) = product | product << 16; + *(nL) = product | product << 16; + +#ifdef WORDS_BIGENDIAN + colorA = (currentPixel & 0xffff); + colorB = (currentDelta & 0xffff); +#else + colorA = currentPixel >> 16; + colorB = currentDelta >> 16; +#endif + product = ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1) + + (colorA & colorB & lowPixelMask))); + + *(dP + 1) = product | product << 16; + *(nL + 1) = product | product << 16; + } else { + u32 colorA, product; + + *(xP - 2) = currentPixel; +#ifdef WORDS_BIGENDIAN + colorA = currentPixel >> 16; +#else + colorA = currentPixel & 0xffff; +#endif + + product = colorA; + + *(dP) = product | product << 16; + *(nL) = product | product << 16; +#ifdef WORDS_BIGENDIAN + colorA = (currentPixel & 0xffff); +#else + colorA = currentPixel >> 16; +#endif + product = colorA; + + *(dP + 1) = product | product << 16; + *(nL + 1) = product | product << 16; + } + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + deltaPtr += srcPitch; + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~RGB_LOW_BITS_MASK; + u32 lowPixelMask = RGB_LOW_BITS_MASK; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *xP = (u32 *) deltaPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + u32 currentDelta; + u32 nextDelta; + + finish = (u8 *) bP + ((width+1) << 2); + nextPixel = *bP++; + nextDelta = *xP++; + + do { + currentPixel = nextPixel; + currentDelta = nextDelta; + nextPixel = *bP++; + nextDelta = *xP++; + + u32 colorA, product, colorB; + + *(xP - 2) = currentPixel; + colorA = currentPixel; + colorB = currentDelta; + + product = ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1) + + (colorA & colorB & lowPixelMask))); + + *(dP) = product; + *(dP+1) = product; + *(nL) = product; + *(nL+1) = product; + + *(xP - 1) = nextPixel; + + colorA = nextPixel; + colorB = nextDelta; + + product = ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1) + + (colorA & colorB & lowPixelMask))); + + *(dP + 2) = product; + *(dP + 3) = product; + *(nL + 2) = product; + *(nL + 3) = product; + + nextPixel = *bP++; + nextDelta = *xP++; + + dP += 4; + nL += 4; + } while ((u8 *) bP < finish); + + deltaPtr += srcPitch; + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} diff --git a/src/movie.cpp b/src/movie.cpp new file mode 100644 index 0000000..63aca95 --- /dev/null +++ b/src/movie.cpp @@ -0,0 +1,1409 @@ + +#include +#ifdef HAVE_STRINGS_H +# include +#endif +#include +#include + +#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP) +# include +# include +# include +# include +# define stricmp strcasecmp +# define _MAX_PATH 128 +#endif + +#include + +#ifdef WIN32 +# include +# ifndef W_OK +# define W_OK 2 +# endif +#endif + +#include + +#include "movie.h" + +#if (defined(WIN32) && !defined(SDL)) +# include "win32/stdafx.h" +# include "win32/vba.h" +# include "win32/resource.h" +# include "win32/WinResUtil.h" +# include "win32/MainWnd.h" + +# define theEmulator (theApp.emulator) + +#else + + + extern struct EmulatedSystem emulator; +# define theEmulator (emulator) + +#endif + +#include "GBA.h" +#include "Globals.h" +#include "System.h" +#include "unzip.h" +#include "Util.h" + +#include "inputGlobal.h" +#include "gb/gbGlobals.h" +#include "RTC.h" + +extern int emulating; // from VBA.cpp + +SMovie Movie; +bool loadingMovie = false; + +#if (defined(WIN32) && !defined(SDL)) + extern u32 currentButtons [4]; // from DirectInput.cpp +#else + u32 currentButtons [4]; +#endif +static bool resetSignaled = false; +static bool ignoreNextReset = false; + +static int controllersLeftThisFrame = 0; +static int prevBorder, prevWinBorder, prevBorderAuto; + +static int bytes_per_frame(SMovie & mov) +{ + int num_controllers = 0; + + for(int i = 0 ; i < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS ; i++) + if(mov.header.controllerFlags & MOVIE_CONTROLLER(i)) + num_controllers++; + + return CONTROLLER_DATA_SIZE*num_controllers; +} + + +// little-endian integer read/write functions: +static inline uint32 Read32(const uint8*& ptr) +{ + uint32 v=(ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24)); + ptr += 4; + return v; +} +static inline uint16 Read16(const uint8*& ptr) /* const version */ +{ + uint16 v=(ptr[0] | (ptr[1]<<8)); + ptr += 2; + return v; +} +static inline uint16 Read16(uint8*& ptr) /* non-const version */ +{ + uint16 v=(ptr[0] | (ptr[1]<<8)); + ptr += 2; + return v; +} +#define Read8(ptr) (*(ptr)++) +static void Write32(uint32 v, uint8*& ptr) +{ + ptr[0]=(uint8)(v&0xff); + ptr[1]=(uint8)((v>>8)&0xff); + ptr[2]=(uint8)((v>>16)&0xff); + ptr[3]=(uint8)((v>>24)&0xff); + ptr += 4; +} +static void Write16(uint16 v, uint8*& ptr) +{ + ptr[0]=(uint8)(v&0xff); + ptr[1]=(uint8)((v>>8)&0xff); + ptr += 2; +} +#define Write8(v, ptr) (*ptr++=v) + +static int read_movie_header(FILE * file, SMovie & movie) +{ + assert(file != NULL); + assert(VBM_HEADER_SIZE == sizeof(SMovieFileHeader)); // sanity check on the header type definition + + uint8 headerData [VBM_HEADER_SIZE]; + + if(fread(headerData, 1, VBM_HEADER_SIZE, file) != VBM_HEADER_SIZE) + return WRONG_FORMAT; // if we failed to read in all VBM_HEADER_SIZE bytes of the header + + const uint8* ptr = headerData; + SMovieFileHeader & header = movie.header; + + header.magic = Read32(ptr); + if(header.magic != VBM_MAGIC) + return WRONG_FORMAT; + + header.version = Read32(ptr); + if(header.version != VBM_VERSION) + return WRONG_VERSION; + + header.uid = Read32(ptr); + header.length_frames = Read32(ptr); + header.rerecord_count = Read32(ptr); + + header.startFlags = Read8(ptr); + header.controllerFlags = Read8(ptr); + header.typeFlags = Read8(ptr); + header.optionFlags = Read8(ptr); + + header.saveType = Read32(ptr); + header.flashSize = Read32(ptr); + header.gbEmulatorType = Read32(ptr); + + for(int i = 0 ; i < 12 ; i++) + header.romTitle[i] = Read8(ptr); + + header.reservedByte = Read8(ptr); + + header.romCRC = Read8(ptr); + header.romOrBiosChecksum = Read16(ptr); + header.romGameCode = Read32(ptr); + + header.offset_to_savestate = Read32(ptr); + header.offset_to_controller_data = Read32(ptr); + + return SUCCESS; +} + + +static void write_movie_header(FILE * file, const SMovie & movie) +{ + assert(ftell(file) == 0); // we assume file points to beginning of movie file + + uint8 headerData [VBM_HEADER_SIZE]; + uint8* ptr = headerData; + const SMovieFileHeader & header = movie.header; + + Write32(header.magic, ptr); + Write32(header.version, ptr); + + Write32(header.uid, ptr); + Write32(header.length_frames, ptr); + Write32(header.rerecord_count, ptr); + + Write8(header.startFlags, ptr); + Write8(header.controllerFlags, ptr); + Write8(header.typeFlags, ptr); + Write8(header.optionFlags, ptr); + + Write32(header.saveType, ptr); + Write32(header.flashSize, ptr); + Write32(header.gbEmulatorType, ptr); + + for(int i = 0 ; i < 12 ; i++) + Write8(header.romTitle[i], ptr); + + Write8(header.reservedByte, ptr); + + Write8(header.romCRC, ptr); + Write16(header.romOrBiosChecksum, ptr); + Write32(header.romGameCode, ptr); + + Write32(header.offset_to_savestate, ptr); + Write32(header.offset_to_controller_data, ptr); + + fwrite(headerData, 1, VBM_HEADER_SIZE, file); +} + +static void flush_movie() +{ + if(Movie.state != MOVIE_STATE_RECORD) + return; + + // (over-)write the header + fseek(Movie.file, 0, SEEK_SET); + write_movie_header(Movie.file, Movie); + + // (over-)write the controller data + fseek(Movie.file, Movie.header.offset_to_controller_data, SEEK_SET); + fwrite(Movie.inputBuffer, 1, Movie.bytesPerFrame*(Movie.header.length_frames+1), Movie.file); + + fflush(Movie.file); +} + +static void truncateMovie() +{ + // truncate movie to header.length_frames length + // NOTE: it's certain that the savestate block is never after the + // controller data block, because the VBM format decrees it. + + long truncLen = Movie.header.offset_to_controller_data + Movie.bytesPerFrame*(Movie.header.length_frames+1); + +# if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP) + truncate(Movie.filename, truncLen); +# else +# if (defined(WIN32) && !defined(SDL)) + HANDLE fileHandle = CreateFile(Movie.filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); + if(fileHandle != NULL) + { + SetFilePointer(fileHandle, truncLen, 0, FILE_BEGIN); + SetEndOfFile(fileHandle); + CloseHandle(fileHandle); + } +# endif +# endif +} + +static void change_state(MovieState new_state) +{ + if(new_state == Movie.state) + return; + + flush_movie(); + + Movie.state = new_state; + +#if (defined(WIN32) && !defined(SDL)) + theApp.frameSearching = false; + theApp.frameSearchSkipping = false; +#endif + + if(new_state == MOVIE_STATE_NONE) + { + fclose(Movie.file); + Movie.file = NULL; + Movie.currentFrame = 0; + + truncateMovie(); + +#if (defined(WIN32) && !defined(SDL)) + // undo changes to border settings + { + theApp.winGbBorderOn = prevWinBorder; + gbBorderAutomatic = prevBorderAuto; + } +#endif + extern int gbDMASpeedVersion; + gbDMASpeedVersion = 1; + + if(Movie.inputBuffer) + { + free(Movie.inputBuffer); + Movie.inputBuffer = NULL; + } + } +} + +static void reserve_buffer_space(uint32 space_needed) +{ + if(space_needed > Movie.inputBufferSize) + { + uint32 ptr_offset = Movie.inputBufferPtr - Movie.inputBuffer; + uint32 alloc_chunks = space_needed / BUFFER_GROWTH_SIZE; + Movie.inputBufferSize = BUFFER_GROWTH_SIZE * (alloc_chunks+1); + Movie.inputBuffer = (uint8*)realloc(Movie.inputBuffer, Movie.inputBufferSize); + Movie.inputBufferPtr = Movie.inputBuffer + ptr_offset; + } +} + + +static void read_frame_controller_data(int i) +{ + if(i < 0 || i >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS) + { + assert(0); + return; + } + + // the number of controllers an SGB game checks per frame is not constant throughout the entire game + // so fill in the gaps with blank data when we hit a duplicate check when other controllers remain unchecked + if((controllersLeftThisFrame & MOVIE_CONTROLLER(i)) == 0) + { + if(controllersLeftThisFrame) + { + // already requested, fill in others first + for(int controller = 0 ; controller < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS ; controller++) + if((controllersLeftThisFrame & MOVIE_CONTROLLER(controller)) != 0) + read_frame_controller_data(controller); + } + } + else + controllersLeftThisFrame ^= MOVIE_CONTROLLER(i); + + if(!controllersLeftThisFrame) + controllersLeftThisFrame = Movie.header.controllerFlags; + + + + if(Movie.header.controllerFlags & MOVIE_CONTROLLER(i)) + { + currentButtons[i]=Read16(Movie.inputBufferPtr); + } + else + { + currentButtons[i]=0; // pretend the controller is disconnected + } + + extern bool sensorOn; + if(!sensorOn) + { + // ignore motion sensor input if the current game doesn't support it + if((currentButtons[i] & BUTTON_MOTION_MASK) != 0) + currentButtons[i] &= ~BUTTON_MOTION_MASK; + } + + if(resetSignaled) + currentButtons[i] |= BUTTON_MASK_RESET; + + if(i == 0) + { + if((currentButtons[i] & BUTTON_MASK_RESET) != 0) + { + // 'soft' reset: + theEmulator.emuReset(); + } + + resetSignaled = false; + } +/* // apparently implemented from the other end, in systemReadJoypad +#if (!(defined(WIN32) && !defined(SDL))) + // convert from currentButtons input format + extern void systemWriteJoypad(int which, u32 buttons); + systemWriteJoypad(i, currentButtons[i]); +#endif +*/ +} + +static void write_frame_controller_data(int i) +{ + if(i < 0 || i >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS) + { + assert(0); + return; + } + + + // the number of controllers an SGB game checks per frame is not constant throughout the entire game + // so fill in the gaps with blank data when we hit a duplicate check when other controllers remain unchecked + if((controllersLeftThisFrame & MOVIE_CONTROLLER(i)) == 0) + { + if(controllersLeftThisFrame) + { + // already requested, fill in others first + for(int controller = 0 ; controller < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS ; controller++) + if((controllersLeftThisFrame & MOVIE_CONTROLLER(controller)) != 0) + write_frame_controller_data(controller); + } + } + else + controllersLeftThisFrame ^= MOVIE_CONTROLLER(i); + + if(!controllersLeftThisFrame) + controllersLeftThisFrame = Movie.header.controllerFlags; + + + if(i == 0) + { + reserve_buffer_space((uint32)((Movie.inputBufferPtr+Movie.bytesPerFrame)-Movie.inputBuffer)); + } + + if(Movie.header.controllerFlags & MOVIE_CONTROLLER(i)) + { +/* // apparently implemented from the other end, in systemReadJoypad +#if (!(defined(WIN32) && !defined(SDL))) + // convert to currentButtons input format + currentButtons[i] = systemReadJoypad(i,false); +#endif +*/ + // get the current controller data + uint16 buttonData = (uint16)currentButtons[i]; + + // mask away the irrelevent bits + buttonData &= BUTTON_REGULAR_MASK; + +# if (defined(WIN32) && !defined(SDL)) + // add in the motion sensor bits + extern BOOL checkKey(int key); // from Input.cpp + extern USHORT motion[4]; // from DirectInput.cpp + if(checkKey(motion[KEY_LEFT])) buttonData |= BUTTON_MASK_LEFT_MOTION; + if(checkKey(motion[KEY_RIGHT])) buttonData |= BUTTON_MASK_RIGHT_MOTION; + if(checkKey(motion[KEY_DOWN])) buttonData |= BUTTON_MASK_DOWN_MOTION; + if(checkKey(motion[KEY_UP])) buttonData |= BUTTON_MASK_UP_MOTION; +# else +# ifdef SDL + extern bool sdlCheckJoyKey(int key); // from SDL.cpp + extern u16 motion[4]; // from SDL.cpp + if(sdlCheckJoyKey(motion[KEY_LEFT])) buttonData |= BUTTON_MASK_LEFT_MOTION; + if(sdlCheckJoyKey(motion[KEY_RIGHT])) buttonData |= BUTTON_MASK_RIGHT_MOTION; + if(sdlCheckJoyKey(motion[KEY_DOWN])) buttonData |= BUTTON_MASK_DOWN_MOTION; + if(sdlCheckJoyKey(motion[KEY_UP])) buttonData |= BUTTON_MASK_UP_MOTION; +# endif +# endif + + // soft-reset "button" for 1 frame if the game is reset while recording + if(resetSignaled) + buttonData |= BUTTON_MASK_RESET; + + // write it to file + Write16(buttonData, Movie.inputBufferPtr); + + // and for display + currentButtons[i] = buttonData; + } + else + { + // pretend the controller is disconnected (otherwise input it gives could cause desync since we're not writing it to the movie) + currentButtons[i] = 0; + } + + if(i == 0) + { + resetSignaled = false; + } +} + +void VBAMovieInit () +{ + memset(&Movie, 0, sizeof(Movie)); + Movie.state = MOVIE_STATE_NONE; + Movie.pauseFrame = -1; + for(int i=0; igetDirFromFile(theApp.filename); + + if(((MainWnd *)theApp.m_pMainWnd)->isDriveRoot(saveDir)) + filename.Format("%s%s.sav", saveDir, buffer); + else + filename.Format("%s\\%s.sav", saveDir, buffer); + } + +#else +# ifdef SDL + static void GetBatterySaveName(char * buffer) + { + extern char batteryDir[2048], filename[2048]; // from SDL.cpp + extern char *sdlGetFilename(char *name); // from SDL.cpp + if(batteryDir[0]) + sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename)); + else + sprintf(buffer, "%s.sav", filename); + } +# endif +#endif + +static void SetPlayEmuSettings () +{ + gbEmulatorType = Movie.header.gbEmulatorType; + extern void SetPrefetchHack(bool); +# if (defined(WIN32) && !defined(SDL)) + if(theApp.cartridgeType == 0) // lag disablement applies only to GBA + SetPrefetchHack((Movie.header.optionFlags & MOVIE_SETTING_LAGHACK) != 0); + + ((MainWnd *)theApp.m_pMainWnd)->OnOptionsSound44khz(); // some GB/GBC games depend on the sound rate, so just use the highest one + theApp.useOldGBTiming = false; + theApp.removeIntros = false; + theApp.skipBiosFile = (Movie.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE) != 0; + theApp.useBiosFile = (Movie.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0; + rtcEnable((Movie.header.optionFlags & MOVIE_SETTING_RTCENABLE) != 0); + theApp.winSaveType = Movie.header.saveType; + theApp.winFlashSize = Movie.header.flashSize; + + extern int gbDMASpeedVersion; + if((Movie.header.optionFlags & MOVIE_SETTING_GBCFF55FIX) != 0) + gbDMASpeedVersion = 1; + else + gbDMASpeedVersion = 0; // old CGB HDMA5 timing was used + + prevBorder = gbBorderOn; + prevWinBorder = theApp.winGbBorderOn; + prevBorderAuto = gbBorderAutomatic; + if((gbEmulatorType == 2 || gbEmulatorType == 5) + && !theApp.hideMovieBorder) // games played in SGB mode can have a border + { + gbBorderOn = true; + theApp.winGbBorderOn = true; + gbBorderAutomatic = false; + theApp.updateWindowSize(theApp.videoOption); + } + else + { + gbBorderOn = false; + theApp.winGbBorderOn = false; + gbBorderAutomatic = false; + theApp.updateWindowSize(theApp.videoOption); + if(theApp.hideMovieBorder) + { + theApp.hideMovieBorder = false; + prevBorder = false; // it might be expected behaviour that it stays hidden after the movie + } + } + +# else + extern int saveType, sdlRtcEnable, sdlFlashSize; // from SDL.cpp + extern bool useBios, skipBios, removeIntros; // from SDL.cpp + useBios = (Movie.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0; + skipBios = (Movie.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE) != 0; + removeIntros = (Movie.header.optionFlags & MOVIE_SETTING_REMOVEINTROS) != 0; + sdlRtcEnable = (Movie.header.optionFlags & MOVIE_SETTING_RTCENABLE) != 0; + saveType = Movie.header.saveType; + sdlFlashSize = Movie.header.flashSize; + + extern int cartridgeType; // from SDL.cpp + if(cartridgeType == 0) // lag disablement applies only to GBA + SetPrefetchHack((Movie.header.optionFlags & MOVIE_SETTING_LAGHACK) != 0); +# endif +} + +static void HardResetAndSRAMClear () +{ +# if (defined(WIN32) && !defined(SDL)) + CString filename; + GetBatterySaveName(filename); + remove(filename); // delete the damn SRAM file + theEmulator.emuCleanUp(); // keep it from being resurrected from RAM + ((MainWnd *)theApp.m_pMainWnd)->FileRun(); // start running the game +# else + char fname [1024]; + GetBatterySaveName(fname); + remove(fname); // delete the damn SRAM file + + // Henceforth, emuCleanUp means "clear out SRAM" + theEmulator.emuCleanUp(); // keep it from being resurrected from RAM + + /// FIXME the correct SDL code to call for a full restart isn't in a function yet + theEmulator.emuReset(); +# endif +} + +int VBAMovieOpen (const char* filename, bool8 read_only) +{ + loadingMovie = true; + + FILE* file; + STREAM stream; + int result; + int fn; + + if(filename[0] == '\0') + {loadingMovie = false; return FILE_NOT_FOUND;} + + if(!emulating) + {loadingMovie = false; return UNKNOWN_ERROR;} + + bool alreadyOpen = (Movie.file != NULL && _stricmp(filename, Movie.filename) == 0); + + if(alreadyOpen) + change_state(MOVIE_STATE_NONE); // have to stop current movie before trying to re-open it + + if(filename[0] == '\0' || !(file = fopen(filename, read_only ? "rb" : "rb+"))) + {loadingMovie = false; return FILE_NOT_FOUND;} + else + fclose(file); + + if(!alreadyOpen) + change_state(MOVIE_STATE_NONE); // stop current movie when we're able to open the other one + + file = fopen(filename, read_only ? "rb" : "rb+"); + + // clear out the current movie + VBAMovieInit(); + + // read header + if((result = read_movie_header(file, Movie)) != SUCCESS) + { + fclose(file); + {loadingMovie = false; return result;} + } + + // set emulator settings that make the movie more likely to stay synchronized + SetPlayEmuSettings(); + + // read the metadata / author info from file + fread(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file); + fn = _dup(_fileno(file)); // XXX: why does this fail?? it returns -1 but errno == 0 + fclose(file); + + // apparently this lseek is necessary + _lseek(fn, Movie.header.offset_to_savestate, SEEK_SET); + if(!(stream = utilGzReopen(fn, "rb"))) + if(!(stream = utilGzOpen(filename, "rb"))) + {loadingMovie = false; return FILE_NOT_FOUND;} + else + fn = _dup(_fileno(file)); // in case the above dup failed but opening the file normally doesn't fail + + if(Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT) + { + // load the snapshot + result = theEmulator.emuReadStateFromStream(stream) ? SUCCESS : WRONG_FORMAT; + } + else if(Movie.header.startFlags & MOVIE_START_FROM_SRAM) + { + // 'soft' reset: + theEmulator.emuReset(); + + // load the SRAM + result = theEmulator.emuReadBatteryFromStream(stream) ? SUCCESS : WRONG_FORMAT; + } + else + { + HardResetAndSRAMClear(); + } + + resetSignaled = false; + controllersLeftThisFrame = Movie.header.controllerFlags; + + utilGzClose(stream); + + if(result != SUCCESS) + {loadingMovie = false; return result;} + + if(!(file = fopen(filename, /*read_only ? "rb" :*/ "rb+"))) // want to be able to switch out of read-only later + { + if(!Movie.readOnly || !(file = fopen(filename, "rb"))) // try read-only if failed + return FILE_NOT_FOUND; + } + + // recalculate length of movie from the file size + Movie.bytesPerFrame = bytes_per_frame(Movie); + fseek(file, 0, SEEK_END); + int fileSize = ftell(file); + Movie.header.length_frames = (fileSize - Movie.header.offset_to_controller_data) / Movie.bytesPerFrame - 1; + + if(fseek(file, Movie.header.offset_to_controller_data, SEEK_SET)) + {loadingMovie = false; return WRONG_FORMAT;} + + // read controller data + Movie.file = file; + Movie.inputBufferPtr = Movie.inputBuffer; + uint32 to_read = Movie.bytesPerFrame * (Movie.header.length_frames+1); + reserve_buffer_space(to_read); + fread(Movie.inputBufferPtr, 1, to_read, file); + + // read "baseline" controller data + read_frame_controller_data(0); // correct if we can assume the first controller is active, which we can on all GBx/xGB systems + Movie.currentFrame = 0; + + strncpy(Movie.filename, filename, _MAX_PATH); + Movie.filename[_MAX_PATH-1] = '\0'; + Movie.readOnly = read_only; + change_state(MOVIE_STATE_PLAY); + + if(Movie.readOnly) + systemScreenMessage("Movie replay (read)"); + else + systemScreenMessage("Movie replay (edit)"); + + {loadingMovie = false; return SUCCESS;} +} + +static void CalcROMInfo () +{ +#if (defined(WIN32) && !defined(SDL)) + if(theApp.cartridgeType == 0) // GBA +#else + extern int cartridgeType; // from SDL.cpp + if(cartridgeType == 0) // GBA +#endif + { + extern u8 *bios, *rom; + memcpy(Movie.header.romTitle, (const char *)&rom[0xa0], 12); // GBA TITLE + memcpy(&Movie.header.romGameCode, &rom[0xac], 4); // GBA ROM GAME CODE + + extern u16 checksumBIOS(); + Movie.header.romOrBiosChecksum = checksumBIOS(); // GBA BIOS CHECKSUM + Movie.header.romCRC = rom[0xbd]; // GBA ROM CRC + } + else // non-GBA + { + extern u8 *gbRom; + memcpy(Movie.header.romTitle, (const char *)&gbRom[0x134], 12); // GB TITLE (note this can be 15 but is truncated to 12) + Movie.header.romGameCode = (uint32)gbRom[0x146]; // GB ROM UNIT CODE + + Movie.header.romOrBiosChecksum = (gbRom[0x14e]<<8)|gbRom[0x14f]; // GB ROM CHECKSUM + Movie.header.romCRC = gbRom[0x14d]; // GB ROM CRC + } +} + +static void SetRecordEmuSettings () +{ + Movie.header.optionFlags = 0; +# if (defined(WIN32) && !defined(SDL)) + if(theApp.useBiosFile) Movie.header.optionFlags |= MOVIE_SETTING_USEBIOSFILE; + if(theApp.skipBiosFile) Movie.header.optionFlags |= MOVIE_SETTING_SKIPBIOSFILE; + if(rtcIsEnabled()) Movie.header.optionFlags |= MOVIE_SETTING_RTCENABLE; + Movie.header.saveType = theApp.winSaveType; + Movie.header.flashSize = theApp.winFlashSize; +# else + extern int saveType, sdlRtcEnable, sdlFlashSize; // from SDL.cpp + extern bool useBios, skipBios; // from SDL.cpp + if(useBios) Movie.header.optionFlags |= MOVIE_SETTING_USEBIOSFILE; + if(skipBios) Movie.header.optionFlags |= MOVIE_SETTING_SKIPBIOSFILE; + if(sdlRtcEnable) Movie.header.optionFlags |= MOVIE_SETTING_RTCENABLE; + Movie.header.saveType = saveType; + Movie.header.flashSize = sdlFlashSize; +# endif +#if (defined(WIN32) && !defined(SDL)) + if(GetAsyncKeyState(VK_CONTROL) == 0) +#endif + if(!memLagTempEnabled) Movie.header.optionFlags |= MOVIE_SETTING_LAGHACK; + Movie.header.gbEmulatorType = gbEmulatorType; + + Movie.header.optionFlags |= MOVIE_SETTING_GBCFF55FIX; + extern int gbDMASpeedVersion; + gbDMASpeedVersion = 1; + +# if (defined(WIN32) && !defined(SDL)) + ((MainWnd *)theApp.m_pMainWnd)->OnOptionsSound44khz(); // some GB/GBC games depend on the sound rate, so just use the highest one + theApp.useOldGBTiming = false; + theApp.removeIntros = false; + + prevBorder = gbBorderOn; + prevWinBorder = theApp.winGbBorderOn; + prevBorderAuto = gbBorderAutomatic; + if(gbEmulatorType == 2 || gbEmulatorType == 5) // only games played in SGB mode will have a border + { + gbBorderOn = true; + theApp.winGbBorderOn = true; + gbBorderAutomatic = false; + theApp.updateWindowSize(theApp.videoOption); + } + else + { + gbBorderOn = false; + theApp.winGbBorderOn = false; + gbBorderAutomatic = false; + theApp.updateWindowSize(theApp.videoOption); + } + + +# else + /// FIXME +# endif +} + +int VBAMovieCreate (const char* filename, const char* authorInfo, uint8 startFlags, uint8 controllerFlags, uint8 typeFlags) +{ + // make sure at least one controller is enabled + if((controllerFlags & MOVIE_CONTROLLERS_ANY_MASK) == 0) + return WRONG_FORMAT; + + if(!emulating) + return UNKNOWN_ERROR; + + loadingMovie = true; + + FILE* file; + STREAM stream; + int fn; + + bool alreadyOpen = (Movie.file != NULL && _stricmp(filename, Movie.filename) == 0); + + if(alreadyOpen) + change_state(MOVIE_STATE_NONE); // have to stop current movie before trying to re-open it + + if(filename[0]=='\0' || !(file = fopen(filename, "wb"))) + {loadingMovie = false; return FILE_NOT_FOUND;} + + if(!alreadyOpen) + change_state(MOVIE_STATE_NONE); // stop current movie when we're able to open the other one + + // clear out the current movie + VBAMovieInit(); + + // fill in the movie's header + Movie.header.uid = (uint32)time(NULL); + Movie.header.magic = VBM_MAGIC; + Movie.header.version = VBM_VERSION; + Movie.header.rerecord_count = 0; + Movie.header.length_frames = 0; + Movie.header.startFlags = startFlags; + Movie.header.controllerFlags = controllerFlags; + Movie.header.typeFlags = typeFlags; + + Movie.header.reservedByte = 0; + + // set emulator settings that make the movie more likely to stay synchronized when it's later played back + SetRecordEmuSettings(); + + // set ROM and BIOS checksums and stuff + CalcROMInfo(); + + // write the header to file + write_movie_header(file, Movie); + + // copy over the metadata / author info + VBAMovieSetMetadata(authorInfo); + + // write the metadata / author info to file + fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file); + + // write snapshot or SRAM if applicable + if(Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT + || Movie.header.startFlags & MOVIE_START_FROM_SRAM) + { + Movie.header.offset_to_savestate = (uint32)ftell(file); + + // close the file and reopen it as a stream: + + fn=_dup(_fileno(file)); + fclose(file); + + if(!(stream = utilGzReopen(fn, "ab"))) // append mode to start at end, no seek necessary + {loadingMovie = false; return FILE_NOT_FOUND;} + + // write the save data: + if(Movie.header.startFlags & MOVIE_START_FROM_SNAPSHOT) + { + // save snapshot + if(!theEmulator.emuWriteStateToStream(stream)) + { + utilGzClose(stream); + {loadingMovie = false; return UNKNOWN_ERROR;} + } + } + else if(Movie.header.startFlags & MOVIE_START_FROM_SRAM) + { + // save SRAM + if(!theEmulator.emuWriteBatteryToStream(stream)) + { + utilGzClose(stream); + {loadingMovie = false; return UNKNOWN_ERROR;} + } + + // 'soft' reset: + theEmulator.emuReset(); + } + + utilGzClose(stream); + + + // reopen the file and seek back to the end + + if(!(file = fopen(filename, "rb+"))) + {loadingMovie = false; return FILE_NOT_FOUND;} + + fseek(file, 0, SEEK_END); + } + else // no snapshot or SRAM + { + HardResetAndSRAMClear(); + } + + Movie.header.offset_to_controller_data = (uint32)ftell(file); + + resetSignaled = false; + controllersLeftThisFrame = Movie.header.controllerFlags; + + // write controller data + Movie.file = file; + Movie.bytesPerFrame = bytes_per_frame(Movie); + Movie.inputBufferPtr = Movie.inputBuffer; + + // write "baseline" controller data + write_frame_controller_data(0); // correct if we can assume the first controller is active, which we can on all GBx/xGB systems + Movie.currentFrame = 0; + + strncpy(Movie.filename, filename, _MAX_PATH); + Movie.filename[_MAX_PATH-1] = '\0'; + Movie.readOnly = false; + change_state(MOVIE_STATE_RECORD); + + systemScreenMessage("Recording movie..."); + {loadingMovie = false; return SUCCESS;} +} + + +void DisplayPressedKeys () +{ + uint32 keys = currentButtons[0] & (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK); + + const static char KeyMap[]= {'A','B','s','S','>','<','^','v','R','L','!','?','{','}','v','^'}; + const static int KeyOrder[]= {5,6,4,7, 0,1, 9,8, 3,2, 12,15,13,14, 10}; // < ^ > v A B L R S s { = } _ ! + char string[256]; + sprintf(string, " "); + + #ifndef WIN32 + + // don't bother color-coding autofire and such + int i; + for (i=0; i < 15; i++) + { + int j = KeyOrder[i]; + int mask = (1 << (j)); + string[strlen(" ")+i] = ((keys & mask)!=0) ? KeyMap[j] : ' '; + } + + systemScreenMessage(string,2,20); + + #else + + const bool eraseAll = !theApp.inputDisplay; + uint32 autoHeldKeys = eraseAll ? 0 : theApp.autoHold & (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK); + uint32 autoFireKeys = eraseAll ? 0 : (theApp.autoFire|theApp.autoFire2) & (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK); + uint32 pressedKeys = eraseAll ? 0 : keys; + + char colorList[64]; + memset(colorList, 1, strlen(string)); + + static int lastKeys = 0; + + int i; + for (i=0; i < 15; i++) + { + const int j = KeyOrder[i]; + const int mask = (1 << (j)); + bool pressed = ((pressedKeys & mask)!=0); + const bool autoHeld = (autoHeldKeys & mask)!=0; + const bool autoFired = (autoFireKeys & mask)!=0; + const bool erased = (lastKeys & mask)!=0 && (!pressed && !autoHeld && !(autoFired&&!pressed)); + extern int textMethod; + if(textMethod != 2 && (autoHeld || (autoFired&&!pressed) || erased)) + { + int colorNum = 1; // default is white + if(autoHeld) + colorNum += (pressed ? 2 : 1); // yellow if pressed, red if not + else if(autoFired) + colorNum += 5; // blue if autofired and not currently pressed + else if(erased) + colorNum += 8; // black on black + + colorList[strlen(" ")+i] = colorNum; + pressed = true; + } + string[strlen(" ")+i] = pressed ? KeyMap[j] : ' '; + } + lastKeys = currentButtons[0]; + lastKeys |= theApp.autoHold & (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK); + lastKeys |= (theApp.autoFire|theApp.autoFire2) & (BUTTON_REGULAR_MASK|BUTTON_RECORDINGONLY_MASK); + + systemScreenMessage(string,2,20, colorList); + + #endif +} + +void VBAUpdateFrameCountDisplay () +{ + char frameDisplayString [64]; + + switch(Movie.state) + { + case MOVIE_STATE_PLAY: + { +# if (defined(WIN32) && !defined(SDL)) + if(theApp.frameCounter) +# else + if(false) /// SDL FIXME +# endif + { + sprintf(frameDisplayString, "%d / %d", Movie.currentFrame, Movie.header.length_frames); + systemScreenMessage(frameDisplayString,1,600); + } + } + break; + + case MOVIE_STATE_RECORD: + { +# if (defined(WIN32) && !defined(SDL)) + if(theApp.frameCounter) +# else + if(false) /// SDL FIXME +# endif + { + sprintf(frameDisplayString, "%d", Movie.currentFrame); + systemScreenMessage(frameDisplayString,1,600); + } + } + break; + + default: + { +# if (defined(WIN32) && !defined(SDL)) + if(theApp.frameCounter) + { + sprintf(frameDisplayString, "%d (no movie)", theApp.globalFrameCount); + systemScreenMessage(frameDisplayString,1,600); + } +# else + /// SDL FIXME +# endif + } + break; + } +} + +void VBAMovieUpdate (int controllerNum) +{ + switch(Movie.state) + { + case MOVIE_STATE_PLAY: + { + if((Movie.header.controllerFlags & MOVIE_CONTROLLER(controllerNum)) == 0) + break; // not a controller we're recognizing + + if(Movie.currentFrame>=Movie.header.length_frames) + { + change_state(MOVIE_STATE_NONE); + systemScreenMessage("Movie end"); + return; + } + else + { + read_frame_controller_data(controllerNum); + ++Movie.currentFrame; + } + } + break; + + case MOVIE_STATE_RECORD: + { + if((Movie.header.controllerFlags & MOVIE_CONTROLLER(controllerNum)) == 0) + break; // not a controller we're recognizing + + write_frame_controller_data(controllerNum); + ++Movie.currentFrame; + Movie.header.length_frames=Movie.currentFrame; + fwrite((Movie.inputBufferPtr - Movie.bytesPerFrame), 1, Movie.bytesPerFrame, Movie.file); + } + break; + + default: + break; + } + + VBAUpdateFrameCountDisplay(); + +#if (defined(WIN32) && !defined(SDL)) + if(theApp.inputDisplay) +#else + if(false) /// SDL FIXME +#endif + DisplayPressedKeys(); + + // if the movie's been set to pause at a certain frame + if(VBAMovieActive() && Movie.pauseFrame >= 0 && Movie.currentFrame >= (uint32)Movie.pauseFrame) + { +# if (defined(WIN32) && !defined(SDL)) + theApp.paused = true; + if(theApp.sound) + theApp.sound->pause(); + theApp.speedupToggle = false; +# else + extern bool paused; // from SDL.cpp + paused = true; + systemSoundPause(); +# endif + Movie.pauseFrame = -1; + } +} + +void VBAMovieStop (bool8 suppress_message) +{ + if(Movie.state!=MOVIE_STATE_NONE) + { + change_state(MOVIE_STATE_NONE); + if(!suppress_message) + systemScreenMessage("Movie stop"); + } +} + +int VBAMovieGetInfo (const char* filename, SMovie* info) +{ + flush_movie(); + + assert(info != NULL); + if(info == NULL) + return -1; + + FILE* file; + int result; + SMovie & local_movie = *info; + + memset(info, 0, sizeof(*info)); + if(filename[0]=='\0' || !(file=fopen(filename, "rb"))) + return FILE_NOT_FOUND; + + // read header + if((result=(read_movie_header(file, local_movie)))!=SUCCESS) + return result; + + // read the metadata / author info from file + fread(local_movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, file); + + + strncpy(local_movie.filename, filename, _MAX_PATH); + local_movie.filename[_MAX_PATH-1] = '\0'; + + if(Movie.file != NULL && _stricmp(local_movie.filename, Movie.filename) == 0) // alreadyOpen + { + local_movie.bytesPerFrame = Movie.bytesPerFrame; + local_movie.header.length_frames = Movie.header.length_frames; + } + else + { + // recalculate length of movie from the file size + local_movie.bytesPerFrame = bytes_per_frame(local_movie); + fseek(file, 0, SEEK_END); + int fileSize = ftell(file); + local_movie.header.length_frames = (fileSize - local_movie.header.offset_to_controller_data) / local_movie.bytesPerFrame - 1; + } + + fclose(file); + + if(_access(filename, W_OK)) + info->readOnly = true; + + return SUCCESS; +} + +bool8 VBAMovieActive () +{ + return (Movie.state != MOVIE_STATE_NONE); +} + +bool8 VBAMovieLoading () +{ + return loadingMovie; +} + +bool8 VBAMovieReadOnly () +{ + if(!VBAMovieActive()) + return false; + + return Movie.readOnly; +} + +void VBAMovieToggleReadOnly () +{ + if(!VBAMovieActive()) + return; + + Movie.readOnly = !Movie.readOnly; + + systemScreenMessage(Movie.readOnly ? "Movie now read-only" : "Movie now editable"); +} + +uint32 VBAMovieGetId () +{ + if(!VBAMovieActive()) + return 0; + + return Movie.header.uid; +} + +uint32 VBAMovieGetLength () +{ + if(!VBAMovieActive()) + return 0; + + return Movie.header.length_frames; +} + +uint32 VBAMovieGetFrameCounter () +{ + if(!VBAMovieActive()) + return 0; + + return Movie.currentFrame; +} + +void VBAMovieFreeze (uint8** buf, uint32* size) +{ + // sanity check + if(!VBAMovieActive()) + { + return; + } + + *buf = NULL; + *size = 0; + + // compute size needed for the buffer + uint32 size_needed = sizeof(Movie.header.uid) + sizeof(Movie.currentFrame) + sizeof(Movie.header.length_frames); // room for header.uid, currentFrame, and header.length_frames + size_needed += (uint32)(Movie.bytesPerFrame * (Movie.header.length_frames+1)); + *buf=new uint8[size_needed]; + *size=size_needed; + + uint8* ptr = *buf; + if(!ptr) + { + return; + } + + Write32(Movie.header.uid, ptr); + Write32(Movie.currentFrame, ptr); + Write32(Movie.header.length_frames, ptr); + + memcpy(ptr, Movie.inputBuffer, Movie.bytesPerFrame * (Movie.header.length_frames+1)); +} + +bool8 VBAMovieSwitchToRecording () +{ + if(Movie.state != MOVIE_STATE_PLAY || Movie.readOnly) + return false; + + change_state(MOVIE_STATE_RECORD); + systemScreenMessage("Movie re-record"); + + Movie.header.length_frames = Movie.currentFrame; + ++Movie.header.rerecord_count; + + flush_movie(); + + return true; +} + +int VBAMovieUnfreeze (const uint8* buf, uint32 size) +{ + // sanity check + if(!VBAMovieActive()) + { + return NOT_FROM_A_MOVIE; + } + + const uint8* ptr = buf; + if(size < sizeof(Movie.header.uid) + sizeof(Movie.currentFrame) + sizeof(Movie.header.length_frames)) + { + return WRONG_FORMAT; + } + + uint32 movie_id = Read32(ptr); + uint32 current_frame = Read32(ptr); + uint32 max_frame = Read32(ptr); + uint32 space_needed = (Movie.bytesPerFrame * (max_frame+1)); + + if(movie_id != Movie.header.uid) + return NOT_FROM_THIS_MOVIE; + + if(current_frame > max_frame) + return INVALID_FRAME; + + if(space_needed > size) + return WRONG_FORMAT; + + if(!Movie.readOnly) + { + // here, we are going to take the input data from the savestate + // and make it the input data for the current movie, then continue + // writing new input data at the currentFrame pointer + change_state(MOVIE_STATE_RECORD); +/// systemScreenMessage("Movie re-record"); + + Movie.currentFrame = current_frame; + Movie.header.length_frames = max_frame; + ++Movie.header.rerecord_count; + + reserve_buffer_space(space_needed); + memcpy(Movie.inputBuffer, ptr, space_needed); + flush_movie(); + fseek(Movie.file, Movie.header.offset_to_controller_data+(Movie.bytesPerFrame * (Movie.currentFrame+1)), SEEK_SET); + } + else + { + // here, we are going to keep the input data from the movie file + // and simply rewind to the currentFrame pointer + // this will cause a desync if the savestate is not in sync + // with the on-disk recording data, but it's easily solved + // by loading another savestate or playing the movie from the beginning + + // and older savestate might have a currentFrame pointer past + // the end of the input data, so check for that here + if(current_frame > Movie.header.length_frames) + return INVALID_FRAME; + + change_state(MOVIE_STATE_PLAY); +/// systemScreenMessage("Movie rewind"); + + Movie.currentFrame = current_frame; + } + + Movie.inputBufferPtr = Movie.inputBuffer + (Movie.bytesPerFrame * Movie.currentFrame); + +/// for(int controller = 0 ; controller < MOVIE_NUM_OF_POSSIBLE_CONTROLLERS ; controller++) +/// if((Movie.header.controllerFlags & MOVIE_CONTROLLER(controller)) != 0) +/// read_frame_controller_data(controller); + read_frame_controller_data(0); // correct if we can assume the first controller is active, which we can on all GBx/xGB systems + + return SUCCESS; +} + +uint32 VBAGetCurrentInputOf (int controllerNum, bool normalOnly) +{ + if(controllerNum < 0 || controllerNum >= MOVIE_NUM_OF_POSSIBLE_CONTROLLERS) + return 0; + + return normalOnly ? (currentButtons[controllerNum] & BUTTON_REGULAR_MASK) : currentButtons[controllerNum]; +} + +uint32 VBAMovieGetState () +{ + if(!VBAMovieActive()) + return MOVIE_STATE_NONE; + + return Movie.state; +} + +void VBAMovieSignalReset () +{ + if(ignoreNextReset) + { + ignoreNextReset = false; + return; + } + + if(Movie.state == MOVIE_STATE_RECORD) + resetSignaled = true; +} + +void VBAMovieSignalIgnoreNextReset () +{ + ignoreNextReset = true; +} + +void VBAMovieSetMetadata (const char * info) +{ + memcpy(Movie.authorInfo, info, MOVIE_METADATA_SIZE); // strncpy would omit post-0 bytes + Movie.authorInfo[MOVIE_METADATA_SIZE-1] = '\0'; + + if(Movie.file) + { + // (over-)write the header + fseek(Movie.file, 0, SEEK_SET); + write_movie_header(Movie.file, Movie); + + // write the metadata / author info to file + fwrite(Movie.authorInfo, 1, sizeof(char) * MOVIE_METADATA_SIZE, Movie.file); + + fflush(Movie.file); + } +} + +void VBAMovieRestart () +{ + if(VBAMovieActive()) + { + VBAMovieStop(true); + + char movieName [_MAX_PATH]; + strcpy(movieName, Movie.filename); + VBAMovieOpen(movieName, Movie.readOnly); // can't just pass in Movie.filename, since VBAMovieOpen clears out Movie's variables + } +} + +void VBAMovieSetPauseAt (int at) +{ + Movie.pauseFrame = at; +} diff --git a/src/movie.h b/src/movie.h new file mode 100644 index 0000000..5753ba0 --- /dev/null +++ b/src/movie.h @@ -0,0 +1,169 @@ +#ifndef _MOVIE_H_ +#define _MOVIE_H_ + +#include +#include +#include + +#ifndef SUCCESS +# define SUCCESS 1 +# define WRONG_FORMAT (-1) +# define WRONG_VERSION (-2) +# define FILE_NOT_FOUND (-3) +# define NOT_FROM_THIS_MOVIE (-4) +# define NOT_FROM_A_MOVIE (-5) +# define INVALID_FRAME (-6) +# define UNKNOWN_ERROR (-7) +#endif + + +#define VBM_MAGIC (0x1a4D4256) // VBM0x1a +#define VBM_VERSION (1) +#define VBM_HEADER_SIZE (64) +#define CONTROLLER_DATA_SIZE (2) +#define BUFFER_GROWTH_SIZE (4096) +#define MOVIE_METADATA_SIZE (192) +#define MOVIE_METADATA_AUTHOR_SIZE (64) + +#define MOVIE_START_FROM_SNAPSHOT (1<<0) +#define MOVIE_START_FROM_SRAM (1<<1) + +#define MOVIE_CONTROLLER(i) (1<<(i)) +#define MOVIE_CONTROLLERS_ANY_MASK (MOVIE_CONTROLLER(0)|MOVIE_CONTROLLER(1)|MOVIE_CONTROLLER(2)|MOVIE_CONTROLLER(3)) +#define MOVIE_NUM_OF_POSSIBLE_CONTROLLERS (4) + +#define MOVIE_TYPE_GBA (1<<0) +#define MOVIE_TYPE_GBC (1<<1) +#define MOVIE_TYPE_SGB (1<<2) + +#define MOVIE_SETTING_USEBIOSFILE (1<<0) +#define MOVIE_SETTING_SKIPBIOSFILE (1<<1) +#define MOVIE_SETTING_RTCENABLE (1<<2) +#define MOVIE_SETTING_UNSUPPORTED1 (1<<3) +#define MOVIE_SETTING_LAGHACK (1<<4) +#define MOVIE_SETTING_GBCFF55FIX (1<<5) + + +#define ZLIB + +///#ifdef ZLIB +#ifndef WIN32 +#include "zlib.h" +#endif +#define STREAM gzFile +/*#define READ_STREAM(p,l,s) gzread (s,p,l) +#define WRITE_STREAM(p,l,s) gzwrite (s,p,l) +#define OPEN_STREAM(f,m) gzopen (f,m) +#define REOPEN_STREAM(f,m) gzdopen (f,m) +#define FIND_STREAM(f) gztell(f) +#define REVERT_STREAM(f,o,s) gzseek(f,o,s) +#define CLOSE_STREAM(s) gzclose (s) +#else +#define STREAM FILE * +#define READ_STREAM(p,l,s) fread (p,1,l,s) +#define WRITE_STREAM(p,l,s) fwrite (p,1,l,s) +#define OPEN_STREAM(f,m) fopen (f,m) +#define REOPEN_STREAM(f,m) fdopen (f,m) +#define FIND_STREAM(f) ftell(f) +#define REVERT_STREAM(f,o,s) fseek(f,o,s) +#define CLOSE_STREAM(s) fclose (s) +#endif*/ + +typedef unsigned char uint8; +typedef signed char bool8; +typedef char int8; + +typedef unsigned short uint16; +typedef short int16; + +typedef unsigned long uint32; +typedef long int32; + +typedef unsigned long long uint64; +typedef long long int64; + + +enum MovieState +{ + MOVIE_STATE_NONE=0, + MOVIE_STATE_PLAY, + MOVIE_STATE_RECORD +}; + +struct SMovieFileHeader +{ + uint32 magic; // VBM0x1a + uint32 version; // 1 + int32 uid; // used to match savestates to a particular movie + uint32 length_frames; + uint32 rerecord_count; + uint8 startFlags; + uint8 controllerFlags; + uint8 typeFlags; + uint8 optionFlags; + uint32 saveType; // emulator setting value + uint32 flashSize; // emulator setting value + uint32 gbEmulatorType; // emulator setting value + char romTitle [12]; + uint8 reservedByte; + uint8 romCRC; // the CRC of the ROM used while recording + uint16 romOrBiosChecksum; // the Checksum of the ROM used while recording, or a CRC of the BIOS if GBA + uint32 romGameCode; // the Game Code of the ROM used while recording, or "\0\0\0\0" if not GBA + uint32 offset_to_savestate; // offset to the savestate or SRAM inside file, set to 0 if unused + uint32 offset_to_controller_data; // offset to the controller data inside file +}; + +struct SMovie +{ + enum MovieState state; + char filename [/*_MAX_PATH*/260]; + FILE* file; + bool8 readOnly; + int pauseFrame; + + SMovieFileHeader header; + char authorInfo [MOVIE_METADATA_SIZE]; + + uint32 currentFrame; // should = length_frames when recording, and be < length_frames when playing + uint32 bytesPerFrame; + uint8* inputBuffer; + uint32 inputBufferSize; + uint8* inputBufferPtr; +}; + +// methods used by the user-interface code +int VBAMovieOpen (const char* filename, bool8 read_only); +int VBAMovieCreate (const char* filename, const char* authorInfo, uint8 startFlags, uint8 controllerFlags, uint8 typeFlags); +int VBAMovieGetInfo (const char* filename, SMovie* info); +void VBAMovieStop (bool8 suppress_message); +const char *VBAChooseMovieFilename(bool8 read_only); + +// methods used by the emulation +void VBAMovieInit (); +void VBAMovieUpdate (int controllerNum=0); +void VBAUpdateFrameCountDisplay (); +//bool8 VBAMovieRewind (uint32 at_frame); +void VBAMovieFreeze (uint8** buf, uint32* size); +int VBAMovieUnfreeze (const uint8* buf, uint32 size); +void VBAMovieRestart (); + +// accessor functions +bool8 VBAMovieActive (); +bool8 VBAMovieLoading (); +// the following accessors return 0/false if !VBAMovieActive() +bool8 VBAMovieReadOnly (); +uint32 VBAMovieGetId (); +uint32 VBAMovieGetLength (); +uint32 VBAMovieGetFrameCounter (); +uint32 VBAMovieGetState (); + +uint32 VBAGetCurrentInputOf (int controllerNum, bool normalOnly=true); +void VBAMovieSignalReset (); +void VBAMovieSignalIgnoreNextReset (); +void VBAMovieSetMetadata (const char * info); +void VBAMovieToggleReadOnly (); +bool8 VBAMovieSwitchToRecording (); +void VBAMovieSetPauseAt (); +void VBAMovieSetPauseAt (int at); + +#endif diff --git a/src/nesvideos-piece.cpp b/src/nesvideos-piece.cpp new file mode 100644 index 0000000..2003114 --- /dev/null +++ b/src/nesvideos-piece.cpp @@ -0,0 +1,515 @@ +#include +#include +#include +#include + +/* Note: This module assumes everyone uses RGB15 as display depth */ + +static std::string VIDEO_CMD = + "mencoder - -o test0.avi" + " -noskip -mc 0" + " -ovc lavc" + " -oac mp3lame" + " -lameopts preset=256:aq=2:mode=3" + " -lavcopts vcodec=ffv1:context=0:format=BGR32:coder=0:vstrict=-1" + " >& mencoder.log"; + +static void FlushWrite(FILE* fp, const unsigned char*buf, unsigned length); + +#define BGR24 (0x42475218) // BGR24 fourcc +#define BGR16 (0x42475210) // BGR16 fourcc +#define BGR15 (0x4247520F) // BGR15 fourcc + +static FILE* (*openFunc) (const char*, const char*) = NULL; +static int (*closeFunc) (FILE*) = NULL; + +#if (defined(WIN32) || defined(win32)) // capital is standard, but check for either + #include + #define popen _popen; + #define pclose _pclose; +#endif + +#define u32(n) (n)&255,((n)>>8)&255,((n)>>16)&255,((n)>>24)&255 +#define u16(n) (n)&255,((n)>>8)&255 +#define s4(s) s[0],s[1],s[2],s[3] + +static const unsigned FPS_SCALE = (0x1000000); + +// general-purpose A/V sync debugging, ignored unless explicitly enabled with NESVideoEnableDebugging +static void (*debugVideoMessageFunc)(const char *msg) = NULL; +static void (*debugAudioMessageFunc)(const char *msg) = NULL; +static unsigned audioFramesWritten=0, videoFramesWritten=1; // logo adds 1 "frame" to audio, so offset that (A/V frames shouldn't necessarily match up depending on the rates, but should at least make them start out matching in case they do) +static double audioSecondsWritten=0, videoSecondsWritten=0; + + +static class AVI +{ + FILE* avifp; + + bool KnowVideo; + unsigned width; + unsigned height; + unsigned fps_scaled; + std::vector VideoBuffer; + + bool KnowAudio; + unsigned rate; + unsigned chans; + unsigned bits; + std::vector AudioBuffer; + +public: + AVI() : + avifp(NULL), + KnowVideo(false), + KnowAudio(false) + { + } + ~AVI() + { + if(avifp) closeFunc(avifp); + } + + void Audio(unsigned r,unsigned b,unsigned c, + const unsigned char*d, unsigned nsamples) + { + if(!KnowAudio) + { + rate = r; + chans = c; + bits = b; + KnowAudio = true; + CheckFlushing(); + } + unsigned bytes = nsamples*chans*(bits/8); + + if(debugAudioMessageFunc) + { + audioFramesWritten++; + audioSecondsWritten += (double)nsamples / (double)rate; // += bytes times seconds per byte + char temp [64]; + sprintf(temp, "A: %.2lf s, %d f", audioSecondsWritten, audioFramesWritten); + debugAudioMessageFunc(temp); + } + + if(KnowVideo) + SendAudioFrame(d, bytes); + else + { + AudioBuffer.insert(AudioBuffer.end(), d, d+bytes); + fprintf(stderr, "Buffering %u bytes of audio\n", bytes); + } + } + void Video(unsigned w,unsigned h,unsigned f, const unsigned char*d) + { + if(!KnowVideo) + { + width=w; + height=h; + fps_scaled=f; + KnowVideo = true; + CheckFlushing(); + } + + unsigned bytes = width*height*2; + + //std::vector tmp(bytes, 'k'); + //d = &tmp[0]; + + if(debugVideoMessageFunc) + { + videoFramesWritten++; + videoSecondsWritten += (double)FPS_SCALE / (double)fps_scaled; // += seconds per frame + char temp [64]; + sprintf(temp, "V: %.2lf s, %d f", videoSecondsWritten, videoFramesWritten); + debugVideoMessageFunc(temp); + } + + if(KnowAudio) + SendVideoFrame(d, bytes); + else + { + VideoBuffer.insert(VideoBuffer.end(), d, d+bytes); + fprintf(stderr, "Buffering %u bytes of video\n", bytes); + } + } + +private: + void CheckFlushing() + { + //AudioBuffer.clear(); + //VideoBuffer.clear(); + + if(KnowAudio && KnowVideo) + { + unsigned last_offs; + + // Flush Audio + + last_offs = 0; + while(last_offs < AudioBuffer.size()) + { + unsigned bytes = rate / (fps_scaled / FPS_SCALE); + bytes *= chans*(bits/8); + + unsigned remain = AudioBuffer.size() - last_offs; + if(bytes > remain) bytes = remain; + if(!bytes) break; + + unsigned begin = last_offs; + last_offs += bytes; + SendAudioFrame(&AudioBuffer[begin], bytes); + } + AudioBuffer.erase(AudioBuffer.begin(), AudioBuffer.begin()+last_offs); + + // Flush Video + + last_offs = 0; + while(last_offs < VideoBuffer.size()) + { + unsigned bytes = width*height*2; + unsigned remain = VideoBuffer.size() - last_offs; + if(bytes > remain) bytes = remain; + if(!bytes)break; + + unsigned begin = last_offs; + last_offs += bytes; + SendVideoFrame(&VideoBuffer[begin], bytes); + } + VideoBuffer.erase(VideoBuffer.begin(), VideoBuffer.begin()+last_offs); + } + } + + void SendVideoFrame(const unsigned char* vidbuf, unsigned framesize) + { + CheckBegin(); + + //fprintf(stderr, "Writing 00dc of %u bytes\n", framesize); + + const unsigned char header[] = { s4("00dc"), u32(framesize) }; + FlushWrite(avifp, header, sizeof(header)); + FlushWrite(avifp, vidbuf, framesize); + } + + void SendAudioFrame(const unsigned char* audbuf, unsigned framesize) + { + CheckBegin(); + + //fprintf(stderr, "Writing 01wb of %u bytes\n", framesize); + + const unsigned char header[] = { s4("01wb"), u32(framesize) }; + FlushWrite(avifp, header, sizeof(header)); + FlushWrite(avifp, audbuf, framesize); + } + + void CheckBegin() + { + if(avifp) return; + + if(!openFunc) openFunc = popen; // default + if(!closeFunc) closeFunc = pclose; // default + + avifp = openFunc(VIDEO_CMD.c_str(), "wb"); + if(!avifp) return; + + const unsigned fourcc = BGR16; + const unsigned framesize = width*height*2; + + const unsigned aud_rate = rate; + const unsigned aud_chans = chans; + const unsigned aud_bits = bits; + + const unsigned nframes = 0; //unknown + const unsigned scale = FPS_SCALE; + const unsigned scaled_fps = fps_scaled; + + const unsigned SIZE_strh_vids = 4 + 4*2 + 2*2 + 8*4 + 2*4; + const unsigned SIZE_strf_vids = 4*3 + 2*2 + 4*6; + const unsigned SIZE_strl_vids = 4+ 4+(4+SIZE_strh_vids) + 4+(4+SIZE_strf_vids); + + const unsigned SIZE_strh_auds = 4 + 4*3 + 2*2 + 4*8 + 2*4; + const unsigned SIZE_strf_auds = 2*2 + 4*2 + 2*3; + const unsigned SIZE_strl_auds = 4+ 4+(4+SIZE_strh_auds) + 4+(4+SIZE_strf_auds); + + const unsigned SIZE_avih = 4*12; + const unsigned SIZE_hdrl = 4+4+ (4+SIZE_avih) + 4 + (4+SIZE_strl_vids) + 4 + (4+SIZE_strl_auds); + const unsigned SIZE_movi = 4 + nframes*(4+4+framesize); + const unsigned SIZE_avi = 4+4+ (4+SIZE_hdrl) + 4 + (4+SIZE_movi); + + const unsigned char AVIheader[] = + { + s4("RIFF"), + u32(SIZE_avi), + s4("AVI "), + + // HEADER + + s4("LIST"), + u32(SIZE_hdrl), + s4("hdrl"), + + s4("avih"), + u32(SIZE_avih), + u32(0), + u32(0), + u32(0), + u32(0), + u32(nframes), + u32(0), + u32(2), // two streams + u32(0), + u32(0), + u32(0), + u32(0), + u32(0), + + // VIDEO HEADER + + s4("LIST"), + u32(SIZE_strl_vids), + s4("strl"), + + s4("strh"), + u32(SIZE_strh_vids), + s4("vids"), + u32(0), + u32(0), + u16(0), + u16(0), + u32(0), + u32(scale), + u32(scaled_fps), + u32(0), + u32(0), + u32(0), + u32(0), + u32(0), + u16(0), + u16(0), + u16(0), + u16(0), + + s4("strf"), + u32(SIZE_strf_vids), + u32(0), + u32(width), + u32(height), + u16(0), + u16(0), + u32(fourcc), + u32(0), + u32(0), + u32(0), + u32(0), + u32(0), + + // AUDIO HEADER + + s4("LIST"), + u32(SIZE_strl_auds), + s4("strl"), + + s4("strh"), + u32(SIZE_strh_auds), + s4("auds"), + u32(0), //fourcc + u32(0), //handler + u32(0), //flags + u16(0), //prio + u16(0), //lang + u32(0), //init frames + u32(1), //scale + u32(aud_rate), + u32(0), //start + u32(0), //rate*length + u32(1048576), //suggested bufsize + u32(0), //quality + u32(aud_chans * (aud_bits / 8)), //sample size + u16(0), //frame size + u16(0), + u16(0), + u16(0), + + s4("strf"), + u32(SIZE_strf_auds), + u16(1), // pcm format + u16(aud_chans), + u32(aud_rate), + u32(aud_rate * aud_chans * (aud_bits/8)), // samples per second + u16(aud_chans * (aud_bits/8)), //block align + u16(aud_bits), //bits + u16(0), //cbSize + + // MOVIE + + s4("LIST"), + u32(SIZE_movi), + s4("movi") + }; + + FlushWrite(avifp, AVIheader, sizeof(AVIheader)); + } +} AVI; + +extern "C" +{ + int LoggingEnabled = 0; /* 0=no, 1=yes, 2=recording! */ + + const char* NESVideoGetVideoCmd() + { + return VIDEO_CMD.c_str(); + } + void NESVideoSetVideoCmd(const char *cmd) + { + VIDEO_CMD = cmd; + } + void NESVideoEnableDebugging( void videoMessageFunc(const char *msg), void audioMessageFunc(const char *msg) ) + { + debugVideoMessageFunc = videoMessageFunc; + debugAudioMessageFunc = audioMessageFunc; + } + void NESVideoSetFileFuncs( FILE* open(const char *,const char *), int close(FILE*) ) + { + openFunc = open; + closeFunc = close; + } + + void NESVideoLoggingVideo + (const void*data, unsigned width,unsigned height, + unsigned fps_scaled + ) + { + if(LoggingEnabled < 2) return; + + unsigned LogoFrames = fps_scaled >> 24; + + static bool First = true; + if(First) + { + First=false; + /* Bisqwit's logo addition routine. */ + /* If you don't have his files, this function does nothing + * and it does not matter at all. + */ + + const char *background = + width==320 ? "logo320_240" + : width==160 ? "logo160_144" + : width==240 ? "logo240_160" + : height>224 ? "logo256_240" + : "logo256_224"; + + /* Note: This should be 1 second long. */ + for(unsigned frame = 0; frame < LogoFrames; ++frame) + { + char Buf[4096]; + sprintf(Buf, "/shares/home/bisqwit/povray/nesvlogo/%s_f%u.tga", + background, frame); + + FILE*fp = fopen(Buf, "rb"); + if(!fp) // write blackness when missing frames to keep the intro 1 second long: + { + unsigned bytes = width*height*2; + unsigned char* buf = (unsigned char*)malloc(bytes); + if(buf) + { + memset(buf,0,bytes); + AVI.Video(width,height,fps_scaled, buf); + if(debugVideoMessageFunc) videoFramesWritten--; + free(buf); + } + } + else // write 1 frame of the logo: + { + int idlen = fgetc(fp); + /* Silently ignore all other header data. + * These files are assumed to be uncompressed BGR24 tga files with Y swapped. + * Even their geometry is assumed to match perfectly. + */ + fseek(fp, 1+1+2+2+1+ /*org*/2+2+ /*geo*/2+2+ 1+1+idlen, SEEK_CUR); + + bool yflip=true; + std::vector data(width*height*3); + for(unsigned y=height; y-->0; ) + fread(&data[y*width*3], 1, width*3, fp); + fclose(fp); + + std::vector result(width*height); + for(unsigned pos=0, max=result.size(); pos 0) + { + unsigned bytes = n*chans*(bits/8); + unsigned char* buf = (unsigned char*)malloc(bytes); + if(buf) + { + memset(buf,0,bytes); + AVI.Audio(rate,bits,chans, buf, n); + free(buf); + } + } + } + + AVI.Audio(rate,bits,chans, (const unsigned char*) data, nsamples); + } +} /* extern "C" */ + + + +static void FlushWrite(FILE* fp, const unsigned char*buf, unsigned length) +{ +/// unsigned failures = 0; +/// const static int FAILURE_THRESH = 8092; // don't want to loop infinitely if we keep failing to make progress - actually maybe you would want this, so the checking is disabled + while(length > 0 /*&& failures < FAILURE_THRESH*/) + { + unsigned written = fwrite(buf, 1, length, fp); +/// if(written == 0) +/// failures++; +/// else +/// { + length -= written; + buf += written; +/// failures = 0; +/// } + } +/// if(failures >= FAILURE_THRESH) +/// { +/// fprintf(stderr, "FlushWrite() failed to write %d bytes %d times - giving up.", length, failures); +/// LoggingEnabled = 0; +/// } +} diff --git a/src/nesvideos-piece.h b/src/nesvideos-piece.h new file mode 100644 index 0000000..9c62c7d --- /dev/null +++ b/src/nesvideos-piece.h @@ -0,0 +1,48 @@ +#ifndef NESVPIECEhh +#define NESVPIECEhh + +#define NESVIDEOS_LOGGING 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Is video logging enabled? 0=no, 1=yes, 2=active. Default value: 0 */ +extern int LoggingEnabled; + +/* Get and set the video recording command (shell command) */ +extern const char* NESVideoGetVideoCmd(); +extern void NESVideoSetVideoCmd(const char *cmd); + +/* Tells to use these functions for obtaining/releasing FILE pointers for writing - if not specified, popen/pclose are used. */ +extern void NESVideoSetFileFuncs( FILE* openFunc(const char *,const char *), int closeFunc(FILE*) ); + +/* Tells to call these functions per frame with amounts (seconds and frames) of video and audio progress */ +extern void NESVideoEnableDebugging( void videoMessageFunc(const char *msg), void audioMessageFunc(const char *msg) ); + +/* Save 1 frame of video. (Assumed to be 16-bit RGB) */ +/* FPS is scaled by 24 bits (*0x1000000) */ +/* Does not do anything if LoggingEnabled<2. */ +extern void NESVideoLoggingVideo + (const void*data, unsigned width, unsigned height, + unsigned fps_scaled); + +/* Save N bytes of audio. bytes_per_second is required on the first call. */ +/* Does not do anything if LoggingEnabled<2. */ +/* The interval of calling this function is not important, as long as all the audio + * data is eventually written without too big delay (5 seconds is too big) + * This function may be called multiple times per video frame, or once per a few video + * frames, or anything in between. Just that all audio data must be written exactly once, + * and in order. */ +extern void NESVideoLoggingAudio + (const void*data, + unsigned rate, unsigned bits, unsigned chans, + unsigned nsamples); +/* nsamples*chans*(bits/8) = bytes in *data. */ +/* rate*chans*(bits/8) = bytes per second. */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/pixel.cpp b/src/pixel.cpp new file mode 100644 index 0000000..5673ed2 --- /dev/null +++ b/src/pixel.cpp @@ -0,0 +1,150 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" + +extern int RGB_LOW_BITS_MASK; + +void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *xP = (u32 *) deltaPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + u32 currentDelta; + u32 nextDelta; + + finish = (u8 *) bP + ((width+2) << 1); + nextPixel = *bP++; + nextDelta = *xP++; + + do { + currentPixel = nextPixel; + currentDelta = nextDelta; + nextPixel = *bP++; + nextDelta = *xP++; + + if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) { + u32 colorA, colorB, product; + + *(xP - 2) = currentPixel; +#ifdef WORDS_BIGENDIAN + colorA = currentPixel >> 16; + colorB = currentPixel & 0xffff; +#else + colorA = currentPixel & 0xffff; + colorB = currentPixel >> 16; +#endif + product = (((colorA & colorMask) >> 1) & colorMask) >> 1; + +#ifdef WORDS_BIGENDIAN + *(nL) = (product << 16) | (product); + *(dP) = (colorA << 16) | product; +#else + *(nL) = product | (product << 16); + *(dP) = colorA | (product << 16); +#endif + +#ifdef WORDS_BIGENDIAN + colorA = nextPixel >> 16; +#else + colorA = nextPixel & 0xffff; +#endif + product = (((colorB & colorMask) >> 1) & colorMask) >> 1; +#ifdef WORDS_BIGENDIAN + *(nL + 1) = (product << 16) | (product); + *(dP + 1) = (colorB << 16) | (product); +#else + *(nL + 1) = (product) | (product << 16); + *(dP + 1) = (colorB) | (product << 16); +#endif + } + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + deltaPtr += srcPitch; + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~RGB_LOW_BITS_MASK; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + // u32 *xP = (u32 *) deltaPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + + finish = (u8 *) bP + ((width+1) << 2); + nextPixel = *bP++; + + do { + currentPixel = nextPixel; + nextPixel = *bP++; + + u32 colorA, colorB, product; + + colorA = currentPixel; + colorB = nextPixel; + + product = (((colorA & colorMask) >> 1) & colorMask) >> 1; + *(nL) = product; + *(nL+1) = product; + *(dP) = colorA; + *(dP+1) = product; + + nextPixel = *bP++; + colorA = nextPixel; + product = (((colorB & colorMask) >> 1) & colorMask) >> 1; + *(nL + 2) = product; + *(nL + 3) = product; + *(dP + 2) = colorB; + *(dP + 3) = product; + + dP += 4; + nL += 4; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} diff --git a/src/prof/Makefile.am b/src/prof/Makefile.am new file mode 100644 index 0000000..d1ae6fc --- /dev/null +++ b/src/prof/Makefile.am @@ -0,0 +1,7 @@ +noinst_LIBRARIES = libprof.a + +libprof_a_SOURCES = \ + gmon.h \ + gmon_out.h \ + prof.cpp \ + prof.h diff --git a/src/prof/Makefile.in b/src/prof/Makefile.in new file mode 100644 index 0000000..cff82d0 --- /dev/null +++ b/src/prof/Makefile.in @@ -0,0 +1,414 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +noinst_LIBRARIES = libprof.a + +libprof_a_SOURCES = \ + gmon.h \ + gmon_out.h \ + prof.cpp \ + prof.h + +subdir = src/prof +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + +libprof_a_AR = $(AR) cru +libprof_a_LIBADD = +am_libprof_a_OBJECTS = prof.$(OBJEXT) +libprof_a_OBJECTS = $(am_libprof_a_OBJECTS) + +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/prof.Po +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = $(libprof_a_SOURCES) +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am +SOURCES = $(libprof_a_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/prof/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + +AR = ar + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libprof.a: $(libprof_a_OBJECTS) $(libprof_a_DEPENDENCIES) + -rm -f libprof.a + $(libprof_a_AR) libprof.a $(libprof_a_OBJECTS) $(libprof_a_LIBADD) + $(RANLIB) libprof.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prof.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/prof/gmon.h b/src/prof/gmon.h new file mode 100644 index 0000000..7f1c333 --- /dev/null +++ b/src/prof/gmon.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1983, 1991, 1993, 2001 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef gmon_h +#define gmon_h + +/* Size of the 4.4BSD gmon header */ +#define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4)) +#define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4)) + +#if 0 /* For documentation purposes only. */ + struct raw_phdr + { + char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ + char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ + char ncnt[4]; /* size of sample buffer (plus this + header) */ + + char version[4]; /* version number */ + char profrate[4]; /* profiling clock rate */ + char spare[3*4]; /* reserved */ + }; +#endif + +#define GMONVERSION 0x00051879 + +/* Size of the old BSD gmon header */ +#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) + +/* FIXME: Checking host compiler defines here means that we can't + use a cross gprof alpha OSF. */ +#if defined(__alpha__) && defined (__osf__) +#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4) +#else +#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4) +#endif + +#if 0 /* For documentation purposes only. */ + struct old_raw_phdr + { + char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ + char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ + char ncnt[4]; /* size of sample buffer (plus this + header) */ +#if defined (__alpha__) && defined (__osf__) + /* + * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to + * a size that is a multiple of 8. + */ + char pad[4]; +#endif + }; +#endif + +/* + * Histogram counters are unsigned shorts: + */ +#define HISTCOUNTER unsigned short + +/* + * Fraction of text space to allocate for histogram counters here, 1/2: + */ +#define HISTFRACTION 2 + +/* + * Fraction of text space to allocate for from hash buckets. The + * value of HASHFRACTION is based on the minimum number of bytes of + * separation between two subroutine call points in the object code. + * Given MIN_SUBR_SEPARATION bytes of separation the value of + * HASHFRACTION is calculated as: + * + * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); + * + * For the VAX, the shortest two call sequence is: + * + * calls $0,(r0) + * calls $0,(r0) + * + * which is separated by only three bytes, thus HASHFRACTION is + * calculated as: + * + * HASHFRACTION = 3 / (2 * 2 - 1) = 1 + * + * Note that the division above rounds down, thus if MIN_SUBR_FRACTION + * is less than three, this algorithm will not work! + */ +#define HASHFRACTION 1 + +/* + * Percent of text space to allocate for tostructs with a minimum: + */ +#define ARCDENSITY 2 +#define MINARCS 50 + +struct tostruct + { + char *selfpc; + int count; + unsigned short link; + }; + +/* + * A raw arc, with pointers to the calling site and the called site + * and a count. Everything is defined in terms of characters so + * as to get a packed representation (otherwise, different compilers + * might introduce different padding): + */ +#if 0 /* For documentation purposes only. */ + struct raw_arc + { + char from_pc[sizeof(void *)]; + char self_pc[sizeof(void *)]; + char count[sizeof(long)]; + }; +#endif + +/* + * General rounding functions: + */ +#define ROUNDDOWN(x,y) (((x)/(y))*(y)) +#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) + +#endif /* gmon_h */ diff --git a/src/prof/gmon_out.h b/src/prof/gmon_out.h new file mode 100644 index 0000000..25dce59 --- /dev/null +++ b/src/prof/gmon_out.h @@ -0,0 +1,45 @@ +/* gmon_out.h + + Copyright 2000, 2001 Free Software Foundation, Inc. + +This file is part of GNU Binutils. + +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. */ + +/* A gmon.out file consists of a header (defined by gmon_hdr) followed + by a sequence of records. Each record starts with a one-byte tag + identifying the type of records, followed by records specific data. */ +#ifndef gmon_out_h +#define gmon_out_h + +#define GMON_MAGIC "gmon" /* magic cookie */ +#define GMON_VERSION 1 /* version number */ + +/* Raw header as it appears on file (without padding). */ +struct gmon_hdr + { + char cookie[4]; + char version[4]; + char spare[3 * 4]; + }; + +/* Types of records in this file. */ +typedef enum + { + GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2 + } +GMON_Record_Tag; + +#endif /* gmon_out_h */ diff --git a/src/prof/prof.cpp b/src/prof/prof.cpp new file mode 100644 index 0000000..3ef7894 --- /dev/null +++ b/src/prof/prof.cpp @@ -0,0 +1,403 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// adapted from gmon.c +/*- + * Copyright (c) 1991, 1998 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. [rescinded 22 July 1999] + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include "gmon.h" +#include "gmon_out.h" + +#include "../GBA.h" +#include "../NLS.h" + +/* + * froms is actually a bunch of unsigned shorts indexing tos + */ +static int profiling = 3; +static unsigned short *froms; +static struct tostruct *tos = 0; +static long tolimit = 0; +static u32 s_lowpc = 0; +static u32 s_highpc = 0; +static unsigned long s_textsize = 0; + +static int ssiz; +static char *sbuf; +static int s_scale; + +static int hz = 0; +static int hist_num_bins = 0; +static char hist_dimension[16] = "seconds"; +static char hist_dimension_abbrev = 's'; + +/* see profil(2) where this is describe (incorrectly) */ +#define SCALE_1_TO_1 0x10000L + +void profPut32(char *b, u32 v) +{ + b[0] = v & 255; + b[1] = (v >> 8) & 255; + b[2] = (v >> 16) & 255; + b[3] = (v >> 24) & 255; +} + +void profPut16(char *b, u16 v) +{ + b[0] = v & 255; + b[1] = (v >> 8) & 255; +} + +int profWrite8(FILE *f, u8 b) +{ + if(fwrite(&b, 1, 1, f) != 1) + return 1; + return 0; +} + +int profWrite32(FILE *f, u32 v) +{ + char buf[4]; + + profPut32(buf, v); + if(fwrite(buf, 1, 4, f) != 4) + return 1; + return 0; +} + +int profWrite(FILE *f, char *buf, unsigned int n) +{ + if(fwrite(buf, 1, n, f) != n) + return 1; + return 0; +} + +/* Control profiling; + profiling is what mcount checks to see if + all the data structures are ready. */ + +void profControl(int mode) +{ + if (mode) { + /* start */ +#ifdef PROFILING + cpuProfil(sbuf, ssiz, (u32)s_lowpc, s_scale); +#endif + profiling = 0; + } else { + /* stop */ +#ifdef PROFILING + cpuProfil(NULL, 0, 0, 0); +#endif + profiling = 3; + } +} + + +#define MSG N_("No space for profiling buffer(s)\n") + +void profStartup(u32 lowpc, u32 highpc) +{ + int monsize; + char *buffer; + int o; + + /* + * round lowpc and highpc to multiples of the density we're using + * so the rest of the scaling (here and in gprof) stays in ints. + */ + lowpc = ROUNDDOWN(lowpc, HISTFRACTION*sizeof(HISTCOUNTER)); + s_lowpc = lowpc; + highpc = ROUNDUP(highpc, HISTFRACTION*sizeof(HISTCOUNTER)); + s_highpc = highpc; + s_textsize = highpc - lowpc; + monsize = (s_textsize / HISTFRACTION); + buffer = (char *)calloc(1, 2*monsize ); + if ( buffer == NULL ) { + systemMessage(0, MSG); + return; + } + froms = (unsigned short *) calloc(1, 4*s_textsize / HASHFRACTION ); + if ( froms == NULL ) { + systemMessage(0, MSG); + free(buffer); + buffer = NULL; + return; + } + tolimit = s_textsize * ARCDENSITY / 100; + if ( tolimit < MINARCS ) { + tolimit = MINARCS; + } else if ( tolimit > 65534 ) { + tolimit = 65534; + } + tos = (struct tostruct *) calloc(1, tolimit * sizeof( struct tostruct ) ); + if ( tos == NULL ) { + systemMessage(0, MSG); + + free(buffer); + buffer = NULL; + + free(froms); + froms = NULL; + + return; + } + tos[0].link = 0; + sbuf = buffer; + ssiz = monsize; + if ( monsize <= 0 ) + return; + o = highpc - lowpc; + if( monsize < o ) + s_scale = (int)(( (float) monsize / o ) * SCALE_1_TO_1); + else + s_scale = SCALE_1_TO_1; + profControl(1); +} + +void profCleanup() +{ + FILE *fd; + int fromindex; + int endfrom; + u32 frompc; + int toindex; + struct gmon_hdr ghdr; + + profControl(0); + fd = fopen( "gmon.out" , "wb" ); + if ( fd == NULL ) { + systemMessage( 0, "mcount: gmon.out" ); + return; + } + + memcpy(&ghdr.cookie[0], GMON_MAGIC, 4); + profPut32((char *)ghdr.version, GMON_VERSION); + + if(fwrite(&ghdr, sizeof(ghdr), 1, fd) != 1) { + systemMessage(0, "mcount: gmon.out header"); + fclose(fd); + return; + } + + if(hz == 0) + hz = 100; + + hist_num_bins = ssiz; + + if(profWrite8(fd, GMON_TAG_TIME_HIST) || + profWrite32(fd, (u32)s_lowpc) || + profWrite32(fd, (u32)s_highpc) || + profWrite32(fd, hist_num_bins) || + profWrite32(fd, hz) || + profWrite(fd, hist_dimension, 15) || + profWrite(fd, &hist_dimension_abbrev, 1)) { + systemMessage(0, "mcount: gmon.out hist"); + fclose(fd); + return; + } + u16 *hist_sample = (u16 *)sbuf; + + u16 count; + int i; + + for(i = 0; i < hist_num_bins; ++i) { + profPut16((char *)&count, hist_sample[i]); + + if(fwrite(&count, sizeof(count), 1, fd) != 1) { + systemMessage(0, "mcount: gmon.out sample"); + fclose(fd); + return; + } + } + + endfrom = s_textsize / (HASHFRACTION * sizeof(*froms)); + for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) { + if ( froms[fromindex] == 0 ) { + continue; + } + frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms)); + for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) { + if(profWrite8(fd, GMON_TAG_CG_ARC) || + profWrite32(fd, (u32)frompc) || + profWrite32(fd, (u32)tos[toindex].selfpc) || + profWrite32(fd, tos[toindex].count)) { + systemMessage(0, "mcount: arc"); + fclose(fd); + return; + } + } + } + fclose(fd); +} + +void profCount() +{ + register char *selfpc; + register unsigned short *frompcindex; + register struct tostruct *top; + register struct tostruct *prevtop; + register long toindex; + + /* + * find the return address for mcount, + * and the return address for mcount's caller. + */ + + /* selfpc = pc pushed by mcount call. + This identifies the function that was just entered. */ + selfpc = (char *) reg[14].I; + /* frompcindex = pc in preceding frame. + This identifies the caller of the function just entered. */ + frompcindex = (unsigned short *) reg[12].I; + /* + * check that we are profiling + * and that we aren't recursively invoked. + */ + if (profiling) { + goto out; + } + profiling++; + /* + * check that frompcindex is a reasonable pc value. + * for example: signal catchers get called from the stack, + * not from text space. too bad. + */ + frompcindex = (unsigned short *) ((long) frompcindex - (long) s_lowpc); + if ((unsigned long) frompcindex > s_textsize) { + goto done; + } + frompcindex = + &froms[((long) frompcindex) / (HASHFRACTION * sizeof(*froms))]; + toindex = *frompcindex; + if (toindex == 0) { + /* + * first time traversing this arc + */ + toindex = ++tos[0].link; + if (toindex >= tolimit) { + goto overflow; + } + *frompcindex = (unsigned short)toindex; + top = &tos[toindex]; + top->selfpc = selfpc; + top->count = 1; + top->link = 0; + goto done; + } + top = &tos[toindex]; + if (top->selfpc == selfpc) { + /* + * arc at front of chain; usual case. + */ + top->count++; + goto done; + } + /* + * have to go looking down chain for it. + * top points to what we are looking at, + * prevtop points to previous top. + * we know it is not at the head of the chain. + */ + for (; /* goto done */; ) { + if (top->link == 0) { + /* + * top is end of the chain and none of the chain + * had top->selfpc == selfpc. + * so we allocate a new tostruct + * and link it to the head of the chain. + */ + toindex = ++tos[0].link; + if (toindex >= tolimit) { + goto overflow; + } + top = &tos[toindex]; + top->selfpc = selfpc; + top->count = 1; + top->link = *frompcindex; + *frompcindex = (unsigned short)toindex; + goto done; + } + /* + * otherwise, check the next arc on the chain. + */ + prevtop = top; + top = &tos[top->link]; + if (top->selfpc == selfpc) { + /* + * there it is. + * increment its count + * move it to the head of the chain. + */ + top->count++; + toindex = prevtop->link; + prevtop->link = top->link; + top->link = *frompcindex; + *frompcindex = (unsigned short)toindex; + goto done; + } + + } + done: + profiling--; + /* and fall through */ + out: + return; /* normal return restores saved registers */ + + overflow: + profiling++; /* halt further profiling */ +#define TOLIMIT "mcount: tos overflow\n" + systemMessage(0, TOLIMIT); + goto out; +} + +void profSetHertz(int h) +{ + hz = h; +} diff --git a/src/prof/prof.h b/src/prof/prof.h new file mode 100644 index 0000000..5ebb0dc --- /dev/null +++ b/src/prof/prof.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_PROF_PROF_H +#define VBA_PROF_PROF_H + +/* Control profiling; + profiling is what mcount checks to see if + all the data structures are ready. */ + +extern void profControl(int mode); +extern void profStartup(u32 lowpc, u32 highpc); +extern void profCleanup(); +extern void profCount(); + +extern void profSetHertz(int hertz); +#endif + diff --git a/src/remote.cpp b/src/remote.cpp new file mode 100644 index 0000000..40fdb3d --- /dev/null +++ b/src/remote.cpp @@ -0,0 +1,698 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#ifndef WIN32 +# include +# include +# include +# ifdef HAVE_NETINET_IN_H +# include +# endif // HAVE_NETINET_IN_H +# ifdef HAVE_ARPA_INET_H +# include +# else // ! HAVE_ARPA_INET_H +# define socklen_t int +# endif // ! HAVE_ARPA_INET_H +#else // WIN32 +# include +# include +# define socklen_t int +# define close closesocket +# define read _read +# define write _write +#endif // WIN32 + +#include "GBA.h" + +extern bool debugger; +extern void CPUUpdateCPSR(); +#ifdef SDL +extern void (*dbgMain)(); +extern void (*dbgSignal)(int,int); +extern void debuggerMain(); +extern void debuggerSignal(int,int); +#endif + +int remotePort = 55555; +int remoteSignal = 5; +int remoteSocket = -1; +int remoteListenSocket = -1; +bool remoteConnected = false; +bool remoteResumed = false; + +int (*remoteSendFnc)(char *, int) = NULL; +int (*remoteRecvFnc)(char *, int) = NULL; +bool (*remoteInitFnc)() = NULL; +void (*remoteCleanUpFnc)() = NULL; + +#ifndef SDL +void remoteSetSockets(SOCKET l, SOCKET r) +{ + remoteSocket = r; + remoteListenSocket = l; +} +#endif + +int remoteTcpSend(char *data, int len) +{ + return send(remoteSocket, data, len, 0); +} + +int remoteTcpRecv(char *data, int len) +{ + return recv(remoteSocket, data, len, 0); +} + +bool remoteTcpInit() +{ + if(remoteSocket == -1) { +#ifdef WIN32 + WSADATA wsaData; + int error = WSAStartup(MAKEWORD(1,1),&wsaData); +#endif // WIN32 + int s = socket(PF_INET, SOCK_STREAM, 0); + + remoteListenSocket = s; + + if(s < 0) { + fprintf(stderr,"Error opening socket\n"); + exit(-1); + } + int tmp = 1; + setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)); + + // char hostname[256]; + // gethostname(hostname, 256); + + // hostent *ent = gethostbyname(hostname); + // unsigned long a = *((unsigned long *)ent->h_addr); + + sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_port = htons(remotePort); + addr.sin_addr.s_addr = htonl(0); + int count = 0; + while(count < 3) { + if(bind(s, (sockaddr *)&addr, sizeof(addr))) { + addr.sin_port = htons(ntohs(addr.sin_port)+1); + } else + break; + } + if(count == 3) { + fprintf(stderr,"Error binding \n"); + exit(-1); + } + + fprintf(stderr,"Listening for a connection at port %d\n", + ntohs(addr.sin_port)); + + if(listen(s, 1)) { + fprintf(stderr, "Error listening\n"); + exit(-1); + } + socklen_t len = sizeof(addr); + +#ifdef WIN32 + int flag = 0; + ioctlsocket(s, FIONBIO, (unsigned long *)&flag); +#endif // WIN32 + int s2 = accept(s, (sockaddr *)&addr, &len); + if(s2 > 0) { + fprintf(stderr, "Got a connection from %s %d\n", + inet_ntoa((in_addr)addr.sin_addr), + ntohs(addr.sin_port)); + } else { +#ifdef WIN32 + int error = WSAGetLastError(); +#endif // WIN32 + } + char dummy; + recv(s2, &dummy, 1, 0); + if(dummy != '+') { + fprintf(stderr, "ACK not received\n"); + exit(-1); + } + remoteSocket = s2; + // close(s); + } + return true; +} + +void remoteTcpCleanUp() +{ + if(remoteSocket > 0) { + fprintf(stderr, "Closing remote socket\n"); + close(remoteSocket); + remoteSocket = -1; + } + if(remoteListenSocket > 0) { + fprintf(stderr, "Closing listen socket\n"); + close(remoteListenSocket); + remoteListenSocket = -1; + } +} + +int remotePipeSend(char *data, int len) +{ + int res = write(1, data, len); + return res; +} + +int remotePipeRecv(char *data, int len) +{ + int res = read(0, data, len); + return res; +} + +bool remotePipeInit() +{ + char dummy; + read(0, &dummy, 1); + if(dummy != '+') { + fprintf(stderr, "ACK not received\n"); + exit(-1); + } + + return true; +} + +void remotePipeCleanUp() +{ +} + +void remoteSetPort(int port) +{ + remotePort = port; +} + +void remoteSetProtocol(int p) +{ + if(p == 0) { + remoteSendFnc = remoteTcpSend; + remoteRecvFnc = remoteTcpRecv; + remoteInitFnc = remoteTcpInit; + remoteCleanUpFnc = remoteTcpCleanUp; + } else { + remoteSendFnc = remotePipeSend; + remoteRecvFnc = remotePipeRecv; + remoteInitFnc = remotePipeInit; + remoteCleanUpFnc = remotePipeCleanUp; + } +} + +void remoteInit() +{ + if(remoteInitFnc) + remoteInitFnc(); +} + +void remotePutPacket(char *packet) +{ + char *hex = "0123456789abcdef"; + char buffer[1024]; + + int count = strlen(packet); + + unsigned char csum = 0; + + char *p = buffer; + *p++ = '$'; + + for(int i = 0 ;i < count; i++) { + csum += packet[i]; + *p++ = packet[i]; + } + *p++ = '#'; + *p++ = hex[csum>>4]; + *p++ = hex[csum & 15]; + *p++ = 0; + // printf("Sending %s\n", buffer); + remoteSendFnc(buffer, count + 4); + + char c = 0; + remoteRecvFnc(&c, 1); + /* + if(c == '+') + printf("ACK\n"); + else if(c=='-') + printf("NACK\n"); + */ +} + +#define debuggerReadMemory(addr) \ + (*(u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]) + +#define debuggerReadHalfWord(addr) \ + (*(u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]) + +#define debuggerReadByte(addr) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] + +#define debuggerWriteMemory(addr, value) \ + *(u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] = (value) + +#define debuggerWriteHalfWord(addr, value) \ + *(u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] = (value) + +#define debuggerWriteByte(addr, value) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] = (value) + +void remoteOutput(char *s, u32 addr) +{ + char buffer[16384]; + + char *d = buffer; + *d++ = 'O'; + + if(s) { + char c = *s++; + while(c) { + sprintf(d, "%02x", c); + d += 2; + c = *s++; + } + } else { + char c= debuggerReadByte(addr); + addr++; + while(c) { + sprintf(d, "%02x", c); + d += 2; + c = debuggerReadByte(addr); + addr++; + } + } + remotePutPacket(buffer); + // fprintf(stderr, "Output sent %s\n", buffer); +} + +void remoteSendSignal() +{ + char buffer[1024]; + sprintf(buffer, "S%02x", remoteSignal); + remotePutPacket(buffer); +} + +void remoteSendStatus() +{ + char buffer[1024]; + sprintf(buffer, "T%02x", remoteSignal); + char *s = buffer; + s += 3; + for(int i = 0; i < 15; i++) { + u32 v = reg[i].I; + sprintf(s, "%02x:%02x%02x%02x%02x;",i, + (v & 255), + (v >> 8) & 255, + (v >> 16) & 255, + (v >> 24) & 255); + s += 12; + } + u32 v = armNextPC; + sprintf(s, "0f:%02x%02x%02x%02x;", (v & 255), + (v >> 8) & 255, + (v >> 16) & 255, + (v >> 24) & 255); + s += 12; + CPUUpdateCPSR(); + v = reg[16].I; + sprintf(s, "19:%02x%02x%02x%02x;", (v & 255), + (v >> 8) & 255, + (v >> 16) & 255, + (v >> 24) & 255); + s += 12; + *s = 0; + // printf("Sending %s\n", buffer); + remotePutPacket(buffer); +} + +void remoteBinaryWrite(char *p) +{ + u32 address; + int count; + sscanf(p,"%x,%x:", &address, &count); + // printf("Binary write for %08x %d\n", address, count); + + p = strchr(p, ':'); + p++; + for(int i = 0; i < count; i++) { + u8 b = *p++; + switch(b) { + case 0x7d: + b = *p++; + debuggerWriteByte(address, (b^0x20)); + address++; + break; + default: + debuggerWriteByte(address, b); + address++; + break; + } + } + // printf("ROM is %08x\n", debuggerReadMemory(0x8000254)); + remotePutPacket("OK"); +} + +void remoteMemoryWrite(char *p) +{ + u32 address; + int count; + sscanf(p,"%x,%x:", &address, &count); + // printf("Memory write for %08x %d\n", address, count); + + p = strchr(p, ':'); + p++; + for(int i = 0; i < count; i++) { + u8 v = 0; + char c = *p++; + if(c <= '9') + v = (c - '0') << 4; + else + v = (c + 10 - 'a') << 4; + c = *p++; + if(c <= '9') + v += (c - '0'); + else + v += (c + 10 - 'a'); + debuggerWriteByte(address, v); + address++; + } + // printf("ROM is %08x\n", debuggerReadMemory(0x8000254)); + remotePutPacket("OK"); +} + +void remoteMemoryRead(char *p) +{ + u32 address; + int count; + sscanf(p,"%x,%x:", &address, &count); + // printf("Memory read for %08x %d\n", address, count); + + char buffer[1024]; + + char *s = buffer; + for(int i = 0; i < count; i++) { + u8 b = debuggerReadByte(address); + sprintf(s, "%02x", b); + address++; + s += 2; + } + *s = 0; + remotePutPacket(buffer); +} + +void remoteStepOverRange(char *p) +{ + u32 address; + u32 final; + sscanf(p, "%x,%x", &address, &final); + + remotePutPacket("OK"); + + remoteResumed = true; + do { + CPULoop(1); + if(debugger) + break; + } while(armNextPC >= address && armNextPC < final); + + remoteResumed = false; + + remoteSendStatus(); +} + +void remoteWriteWatch(char *p, bool active) +{ + u32 address; + int count; + sscanf(p, ",%x,%x#", &address, &count); + + fprintf(stderr, "Write watch for %08x %d\n", address, count); + + if(address < 0x2000000 || address > 0x3007fff) { + remotePutPacket("E01"); + return; + } + + if(address > 0x203ffff && address < 0x3000000) { + remotePutPacket("E01"); + return; + } + + u32 final = address + count; + + if(address < 0x2040000 && final > 0x2040000) { + remotePutPacket("E01"); + return; + } else if(address < 0x3008000 && final > 0x3008000) { + remotePutPacket("E01"); + return; + } + + for(int i = 0; i < count; i++) { + if((address >> 24) == 2) + freezeWorkRAM[address & 0x3ffff] = active; + else + freezeInternalRAM[address & 0x7fff] = active; + address++; + } + + remotePutPacket("OK"); +} + +void remoteReadRegisters(char *p) +{ + char buffer[1024]; + + char *s = buffer; + int i; + // regular registers + for(i = 0; i < 15; i++) { + u32 v = reg[i].I; + sprintf(s, "%02x%02x%02x%02x", v & 255, (v >> 8) & 255, + (v >> 16) & 255, (v >> 24) & 255); + s += 8; + } + // PC + u32 pc = armNextPC; + sprintf(s, "%02x%02x%02x%02x", pc & 255, (pc >> 8) & 255, + (pc >> 16) & 255, (pc >> 24) & 255); + s += 8; + + // floating point registers (24-bit) + for(i = 0; i < 8; i++) { + sprintf(s, "000000000000000000000000"); + s += 24; + } + + // FP status register + sprintf(s, "00000000"); + s += 8; + // CPSR + CPUUpdateCPSR(); + u32 v = reg[16].I; + sprintf(s, "%02x%02x%02x%02x", v & 255, (v >> 8) & 255, + (v >> 16) & 255, (v >> 24) & 255); + s += 8; + *s = 0; + remotePutPacket(buffer); +} + +void remoteWriteRegister(char *p) +{ + int r; + + sscanf(p, "%x=", &r); + + p = strchr(p, '='); + p++; + + char c = *p++; + + u32 v = 0; + + u8 data[4] = {0,0,0,0}; + + int i = 0; + + while(c != '#') { + u8 b = 0; + if(c <= '9') + b = (c - '0') << 4; + else + b = (c + 10 - 'a') << 4; + c = *p++; + if(c <= '9') + b += (c - '0'); + else + b += (c + 10 - 'a'); + data[i++] = b; + c = *p++; + } + + v = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + + // printf("Write register %d=%08x\n", r, v); + reg[r].I = v; + if(r == 15) { + armNextPC = v; + if(armState) + reg[15].I = v + 4; + else + reg[15].I = v + 2; + } + remotePutPacket("OK"); +} + +extern int emulating; + +void remoteStubMain() +{ + if(!debugger) + return; + + if(remoteResumed) { + remoteSendStatus(); + remoteResumed = false; + } + + while(1) { + char buffer[1024]; + int res = remoteRecvFnc(buffer, 1024); + + if(res == -1) { + fprintf(stderr, "GDB connection lost\n"); +#ifdef SDL + dbgMain = debuggerMain; + dbgSignal = debuggerSignal; +#endif + debugger = false; + break; + } + + // fprintf(stderr, "Received %s\n", buffer); + char *p = buffer; + char c = *p++; + char pp = '+'; + remoteSendFnc(&pp, 1); + + if(c != '$') + continue; + c= *p++; + switch(c) { + case '?': + remoteSendSignal(); + break; + case 'D': + remotePutPacket("OK"); +#ifdef SDL + dbgMain = debuggerMain; + dbgSignal = debuggerSignal; +#endif + remoteResumed = true; + debugger = false; + return; + case 'e': + remoteStepOverRange(p); + break; + case 'k': + remotePutPacket("OK"); +#ifdef SDL + dbgMain = debuggerMain; + dbgSignal = debuggerSignal; +#endif + debugger = false; + emulating = false; + return; + case 'C': + remoteResumed = true; + debugger = false; + return; + case 'c': + remoteResumed = true; + debugger = false; + return; + case 's': + remoteResumed = true; + remoteSignal = 5; + CPULoop(1); + if(remoteResumed) { + remoteResumed = false; + remoteSendStatus(); + } + break; + case 'g': + remoteReadRegisters(p); + break; + case 'P': + remoteWriteRegister(p); + break; + case 'M': + remoteMemoryWrite(p); + break; + case 'm': + remoteMemoryRead(p); + break; + case 'X': + remoteBinaryWrite(p); + break; + case 'H': + remotePutPacket("OK"); + break; + case 'q': + remotePutPacket(""); + break; + case 'Z': + if(*p++ == '2') { + remoteWriteWatch(p, true); + } else + remotePutPacket(""); + break; + case 'z': + if(*p++ == '2') { + remoteWriteWatch(p, false); + } else + remotePutPacket(""); + break; + default: + { + *(strchr(p, '#') + 3) = 0; + fprintf(stderr, "Unknown packet %s\n", --p); + remotePutPacket(""); + } + break; + } + } +} + +void remoteStubSignal(int sig, int number) +{ + remoteSignal = sig; + remoteResumed = false; + remoteSendStatus(); + debugger = true; +} + +void remoteCleanUp() +{ + if(remoteCleanUpFnc) + remoteCleanUpFnc(); +} diff --git a/src/scanline.cpp b/src/scanline.cpp new file mode 100644 index 0000000..21610a8 --- /dev/null +++ b/src/scanline.cpp @@ -0,0 +1,230 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" + +extern int RGB_LOW_BITS_MASK; + +void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + + finish = (u8 *) bP + ((width+2) << 1); + nextPixel = *bP++; + + do { + currentPixel = nextPixel; + nextPixel = *bP++; + u32 colorA, colorB; + +#ifdef WORDS_BIGENDIAN + colorA = currentPixel >> 16; + colorB = currentPixel & 0xffff; +#else + colorA = currentPixel & 0xffff; + colorB = currentPixel >> 16; +#endif + + *(dP) = colorA | colorA<<16; + *(nL) = 0; + +#ifdef WORDS_BIGENDIAN + colorA = nextPixel >> 16; +#else + colorA = nextPixel & 0xffff; +#endif + + *(dP + 1) = colorB | (colorB << 16); + *(nL + 1) = 0; + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + + finish = (u8 *) bP + ((width+1) << 2); + nextPixel = *bP++; + + do { + currentPixel = nextPixel; + nextPixel = *bP++; + + u32 colorA, colorB; + + colorA = currentPixel; + colorB = nextPixel; + + *(dP) = colorA; + *(dP+1) = colorA; + *(nL) = 0; + *(nL+1) = 0; + + *(dP + 2) = colorB; + *(dP + 3) = colorB; + *(nL+2) = 0; + *(nL+3) = 0; + + nextPixel = *bP++; + + dP += 4; + nL += 4; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + + finish = (u8 *) bP + ((width+2) << 1); + nextPixel = *bP++; + + do { + currentPixel = nextPixel; + nextPixel = *bP++; + + u32 colorA, colorB; + +#ifdef WORDS_BIGENDIAN + colorA = currentPixel >> 16; + colorB = currentPixel & 0xFFFF; +#else + colorA = currentPixel & 0xFFFF; + colorB = currentPixel >> 16; +#endif + + *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1))) << 16; + colorA = ((colorA & colorMask) >> 1); + colorA += ((colorA & colorMask) >> 1); + *(nL) = colorA; + + colorA = nextPixel & 0xFFFF; + + *(dP + 1) = colorB = colorB | ((((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1))) << 16; + colorB = ((colorB & colorMask) >> 1); + colorB += ((colorB & colorMask) >> 1); + + *(nL + 1) = colorB; + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + u32 colorMask = ~RGB_LOW_BITS_MASK; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + u32 nextPixel; + + finish = (u8 *) bP + ((width+1) << 2); + nextPixel = *bP++; + + do { + currentPixel = nextPixel; + nextPixel = *bP++; + + u32 colorA, colorB, temp; + + colorA = currentPixel; + colorB = nextPixel; + + *(dP) = colorA; + *(dP+1) = temp = ((colorA & colorMask) >> 1) + + ((colorB & colorMask) >> 1); + temp = ((temp & colorMask) >> 1); + temp += ((temp & colorMask) >> 1); + colorA = ((colorA & colorMask) >> 1); + colorA += ((colorA & colorMask) >> 1); + + *(nL) = colorA; + *(nL+1) = temp; + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} diff --git a/src/sdl/Makefile.am b/src/sdl/Makefile.am new file mode 100644 index 0000000..bcc9f92 --- /dev/null +++ b/src/sdl/Makefile.am @@ -0,0 +1,159 @@ +bin_PROGRAMS = VisualBoyAdvance + +noinst_PROGRAMS = TestEmu + +VisualBoyAdvance_SOURCES = \ + SDL.cpp \ + debugger.cpp \ + debugger.h \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bilinear.cpp \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../expr-lex.cpp \ + ../expr.cpp \ + ../expr.cpp.h \ + ../exprNode.cpp \ + ../exprNode.h \ + ../getopt.c \ + ../getopt.h \ + ../getopt1.c \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interframe.cpp \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + +VisualBoyAdvance_LDADD = @VBA_LIBS@ @SDL_LIBS@ + +VisualBoyAdvance_DEPENDENCIES = @VBA_LIBS@ + +TestEmu_SOURCES = \ + TestEmu.cpp \ + debugger.cpp \ + debugger.h \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../expr-lex.cpp \ + ../expr.cpp \ + ../expr.cpp.h \ + ../exprNode.cpp \ + ../exprNode.h \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + +TestEmu_LDADD = @VBA_LIBS@ @SDL_LIBS@ + +TestEmu_DEPENDENCIES = @VBA_LIBS@ + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src \ + -DSDL \ + -DSYSCONFDIR=\"$(sysconfdir)\" + +AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@ diff --git a/src/sdl/Makefile.in b/src/sdl/Makefile.in new file mode 100644 index 0000000..59aee5e --- /dev/null +++ b/src/sdl/Makefile.in @@ -0,0 +1,1538 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +bin_PROGRAMS = VisualBoyAdvance + +noinst_PROGRAMS = TestEmu + +VisualBoyAdvance_SOURCES = \ + SDL.cpp \ + debugger.cpp \ + debugger.h \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bilinear.cpp \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../expr-lex.cpp \ + ../expr.cpp \ + ../expr.cpp.h \ + ../exprNode.cpp \ + ../exprNode.h \ + ../getopt.c \ + ../getopt.h \ + ../getopt1.c \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interframe.cpp \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + + +VisualBoyAdvance_LDADD = @VBA_LIBS@ @SDL_LIBS@ + +VisualBoyAdvance_DEPENDENCIES = @VBA_LIBS@ + +TestEmu_SOURCES = \ + TestEmu.cpp \ + debugger.cpp \ + debugger.h \ + ../2xSaI.cpp \ + ../AutoBuild.h \ + ../Cheats.cpp \ + ../Cheats.h \ + ../EEprom.cpp \ + ../EEprom.h \ + ../Flash.cpp \ + ../Flash.h \ + ../GBA.cpp \ + ../GBA.h \ + ../GBAinline.h \ + ../Gfx.cpp \ + ../Gfx.h \ + ../Globals.cpp \ + ../Globals.h \ + ../Mode0.cpp \ + ../Mode1.cpp \ + ../Mode2.cpp \ + ../Mode3.cpp \ + ../Mode4.cpp \ + ../Mode5.cpp \ + ../NLS.h \ + ../Port.h \ + ../RTC.cpp \ + ../RTC.h \ + ../Sound.cpp \ + ../Sound.h \ + ../Sram.cpp \ + ../Sram.h \ + ../System.h \ + ../Text.cpp \ + ../Text.h \ + ../Util.cpp \ + ../Util.h \ + ../admame.cpp \ + ../agbprint.cpp \ + ../agbprint.h \ + ../arm-new.h \ + ../armdis.cpp \ + ../armdis.h \ + ../bios.cpp \ + ../bios.h \ + ../elf.cpp \ + ../elf.h \ + ../expr-lex.cpp \ + ../expr.cpp \ + ../expr.cpp.h \ + ../exprNode.cpp \ + ../exprNode.h \ + ../hq2x.cpp \ + ../hq2x.h \ + ../interp.h \ + ../lq2x.h \ + ../memgzio.c \ + ../memgzio.h \ + ../motionblur.cpp \ + ../pixel.cpp \ + ../remote.cpp \ + ../scanline.cpp \ + ../simple2x.cpp \ + ../thumb.h \ + ../unzip.cpp \ + ../unzip.h + + +TestEmu_LDADD = @VBA_LIBS@ @SDL_LIBS@ + +TestEmu_DEPENDENCIES = @VBA_LIBS@ + +AM_CPPFLAGS = \ + -I$(top_srcdir)/src \ + -DSDL \ + -DSYSCONFDIR=\"$(sysconfdir)\" + + +AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@ +subdir = src/sdl +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +bin_PROGRAMS = VisualBoyAdvance$(EXEEXT) +noinst_PROGRAMS = TestEmu$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) + +am_TestEmu_OBJECTS = TestEmu.$(OBJEXT) debugger.$(OBJEXT) \ + 2xSaI.$(OBJEXT) Cheats.$(OBJEXT) EEprom.$(OBJEXT) \ + Flash.$(OBJEXT) GBA.$(OBJEXT) Gfx.$(OBJEXT) Globals.$(OBJEXT) \ + Mode0.$(OBJEXT) Mode1.$(OBJEXT) Mode2.$(OBJEXT) Mode3.$(OBJEXT) \ + Mode4.$(OBJEXT) Mode5.$(OBJEXT) RTC.$(OBJEXT) Sound.$(OBJEXT) \ + Sram.$(OBJEXT) Text.$(OBJEXT) Util.$(OBJEXT) admame.$(OBJEXT) \ + agbprint.$(OBJEXT) armdis.$(OBJEXT) bios.$(OBJEXT) \ + elf.$(OBJEXT) expr-lex.$(OBJEXT) expr.$(OBJEXT) \ + exprNode.$(OBJEXT) hq2x.$(OBJEXT) memgzio.$(OBJEXT) \ + motionblur.$(OBJEXT) pixel.$(OBJEXT) remote.$(OBJEXT) \ + scanline.$(OBJEXT) simple2x.$(OBJEXT) unzip.$(OBJEXT) +TestEmu_OBJECTS = $(am_TestEmu_OBJECTS) +TestEmu_LDFLAGS = +am_VisualBoyAdvance_OBJECTS = SDL.$(OBJEXT) debugger.$(OBJEXT) \ + 2xSaI.$(OBJEXT) Cheats.$(OBJEXT) EEprom.$(OBJEXT) \ + Flash.$(OBJEXT) GBA.$(OBJEXT) Gfx.$(OBJEXT) Globals.$(OBJEXT) \ + Mode0.$(OBJEXT) Mode1.$(OBJEXT) Mode2.$(OBJEXT) Mode3.$(OBJEXT) \ + Mode4.$(OBJEXT) Mode5.$(OBJEXT) RTC.$(OBJEXT) Sound.$(OBJEXT) \ + Sram.$(OBJEXT) Text.$(OBJEXT) Util.$(OBJEXT) admame.$(OBJEXT) \ + agbprint.$(OBJEXT) armdis.$(OBJEXT) bilinear.$(OBJEXT) \ + bios.$(OBJEXT) elf.$(OBJEXT) expr-lex.$(OBJEXT) expr.$(OBJEXT) \ + exprNode.$(OBJEXT) getopt.$(OBJEXT) getopt1.$(OBJEXT) \ + hq2x.$(OBJEXT) interframe.$(OBJEXT) memgzio.$(OBJEXT) \ + motionblur.$(OBJEXT) pixel.$(OBJEXT) remote.$(OBJEXT) \ + scanline.$(OBJEXT) simple2x.$(OBJEXT) unzip.$(OBJEXT) +VisualBoyAdvance_OBJECTS = $(am_VisualBoyAdvance_OBJECTS) +VisualBoyAdvance_LDFLAGS = + +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/2xSaI.Po ./$(DEPDIR)/Cheats.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/EEprom.Po ./$(DEPDIR)/Flash.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/GBA.Po ./$(DEPDIR)/Gfx.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Globals.Po ./$(DEPDIR)/Mode0.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Mode1.Po ./$(DEPDIR)/Mode2.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Mode3.Po ./$(DEPDIR)/Mode4.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Mode5.Po ./$(DEPDIR)/RTC.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/SDL.Po ./$(DEPDIR)/Sound.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Sram.Po ./$(DEPDIR)/TestEmu.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/Text.Po ./$(DEPDIR)/Util.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/admame.Po ./$(DEPDIR)/agbprint.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/armdis.Po ./$(DEPDIR)/bilinear.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/bios.Po ./$(DEPDIR)/debugger.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/elf.Po ./$(DEPDIR)/expr-lex.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/expr.Po ./$(DEPDIR)/exprNode.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/getopt1.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/hq2x.Po ./$(DEPDIR)/interframe.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/memgzio.Po ./$(DEPDIR)/motionblur.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/pixel.Po ./$(DEPDIR)/remote.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/scanline.Po ./$(DEPDIR)/simple2x.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/unzip.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +DIST_SOURCES = $(TestEmu_SOURCES) $(VisualBoyAdvance_SOURCES) +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am +SOURCES = $(TestEmu_SOURCES) $(VisualBoyAdvance_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .cpp .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/sdl/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) +TestEmu$(EXEEXT): $(TestEmu_OBJECTS) $(TestEmu_DEPENDENCIES) + @rm -f TestEmu$(EXEEXT) + $(CXXLINK) $(TestEmu_LDFLAGS) $(TestEmu_OBJECTS) $(TestEmu_LDADD) $(LIBS) +VisualBoyAdvance$(EXEEXT): $(VisualBoyAdvance_OBJECTS) $(VisualBoyAdvance_DEPENDENCIES) + @rm -f VisualBoyAdvance$(EXEEXT) + $(CXXLINK) $(VisualBoyAdvance_LDFLAGS) $(VisualBoyAdvance_OBJECTS) $(VisualBoyAdvance_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/2xSaI.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cheats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EEprom.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GBA.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gfx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Globals.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode0.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode3.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode4.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mode5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RTC.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDL.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sound.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sram.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TestEmu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Text.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/admame.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agbprint.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/armdis.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bilinear.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bios.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debugger.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expr-lex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exprNode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hq2x.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interframe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memgzio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motionblur.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remote.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanline.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple2x.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzip.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` + +memgzio.o: ../memgzio.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT memgzio.o -MD -MP -MF "$(DEPDIR)/memgzio.Tpo" \ +@am__fastdepCC_TRUE@ -c -o memgzio.o `test -f '../memgzio.c' || echo '$(srcdir)/'`../memgzio.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/memgzio.Tpo" "$(DEPDIR)/memgzio.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/memgzio.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../memgzio.c' object='memgzio.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/memgzio.Po' tmpdepfile='$(DEPDIR)/memgzio.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memgzio.o `test -f '../memgzio.c' || echo '$(srcdir)/'`../memgzio.c + +memgzio.obj: ../memgzio.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT memgzio.obj -MD -MP -MF "$(DEPDIR)/memgzio.Tpo" \ +@am__fastdepCC_TRUE@ -c -o memgzio.obj `if test -f '../memgzio.c'; then $(CYGPATH_W) '../memgzio.c'; else $(CYGPATH_W) '$(srcdir)/../memgzio.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/memgzio.Tpo" "$(DEPDIR)/memgzio.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/memgzio.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../memgzio.c' object='memgzio.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/memgzio.Po' tmpdepfile='$(DEPDIR)/memgzio.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memgzio.obj `if test -f '../memgzio.c'; then $(CYGPATH_W) '../memgzio.c'; else $(CYGPATH_W) '$(srcdir)/../memgzio.c'; fi` + +getopt.o: ../getopt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt.o -MD -MP -MF "$(DEPDIR)/getopt.Tpo" \ +@am__fastdepCC_TRUE@ -c -o getopt.o `test -f '../getopt.c' || echo '$(srcdir)/'`../getopt.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/getopt.Tpo" "$(DEPDIR)/getopt.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/getopt.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt.c' object='getopt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/getopt.Po' tmpdepfile='$(DEPDIR)/getopt.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt.o `test -f '../getopt.c' || echo '$(srcdir)/'`../getopt.c + +getopt.obj: ../getopt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt.obj -MD -MP -MF "$(DEPDIR)/getopt.Tpo" \ +@am__fastdepCC_TRUE@ -c -o getopt.obj `if test -f '../getopt.c'; then $(CYGPATH_W) '../getopt.c'; else $(CYGPATH_W) '$(srcdir)/../getopt.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/getopt.Tpo" "$(DEPDIR)/getopt.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/getopt.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt.c' object='getopt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/getopt.Po' tmpdepfile='$(DEPDIR)/getopt.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt.obj `if test -f '../getopt.c'; then $(CYGPATH_W) '../getopt.c'; else $(CYGPATH_W) '$(srcdir)/../getopt.c'; fi` + +getopt1.o: ../getopt1.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt1.o -MD -MP -MF "$(DEPDIR)/getopt1.Tpo" \ +@am__fastdepCC_TRUE@ -c -o getopt1.o `test -f '../getopt1.c' || echo '$(srcdir)/'`../getopt1.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/getopt1.Tpo" "$(DEPDIR)/getopt1.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/getopt1.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt1.c' object='getopt1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/getopt1.Po' tmpdepfile='$(DEPDIR)/getopt1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt1.o `test -f '../getopt1.c' || echo '$(srcdir)/'`../getopt1.c + +getopt1.obj: ../getopt1.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt1.obj -MD -MP -MF "$(DEPDIR)/getopt1.Tpo" \ +@am__fastdepCC_TRUE@ -c -o getopt1.obj `if test -f '../getopt1.c'; then $(CYGPATH_W) '../getopt1.c'; else $(CYGPATH_W) '$(srcdir)/../getopt1.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/getopt1.Tpo" "$(DEPDIR)/getopt1.Po"; \ +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/getopt1.Tpo"; exit 1; \ +@am__fastdepCC_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../getopt1.c' object='getopt1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/getopt1.Po' tmpdepfile='$(DEPDIR)/getopt1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt1.obj `if test -f '../getopt1.c'; then $(CYGPATH_W) '../getopt1.c'; else $(CYGPATH_W) '$(srcdir)/../getopt1.c'; fi` + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` + +2xSaI.o: ../2xSaI.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT 2xSaI.o -MD -MP -MF "$(DEPDIR)/2xSaI.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o 2xSaI.o `test -f '../2xSaI.cpp' || echo '$(srcdir)/'`../2xSaI.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/2xSaI.Tpo" "$(DEPDIR)/2xSaI.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/2xSaI.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../2xSaI.cpp' object='2xSaI.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/2xSaI.Po' tmpdepfile='$(DEPDIR)/2xSaI.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o 2xSaI.o `test -f '../2xSaI.cpp' || echo '$(srcdir)/'`../2xSaI.cpp + +2xSaI.obj: ../2xSaI.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT 2xSaI.obj -MD -MP -MF "$(DEPDIR)/2xSaI.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o 2xSaI.obj `if test -f '../2xSaI.cpp'; then $(CYGPATH_W) '../2xSaI.cpp'; else $(CYGPATH_W) '$(srcdir)/../2xSaI.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/2xSaI.Tpo" "$(DEPDIR)/2xSaI.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/2xSaI.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../2xSaI.cpp' object='2xSaI.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/2xSaI.Po' tmpdepfile='$(DEPDIR)/2xSaI.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o 2xSaI.obj `if test -f '../2xSaI.cpp'; then $(CYGPATH_W) '../2xSaI.cpp'; else $(CYGPATH_W) '$(srcdir)/../2xSaI.cpp'; fi` + +Cheats.o: ../Cheats.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Cheats.o -MD -MP -MF "$(DEPDIR)/Cheats.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Cheats.o `test -f '../Cheats.cpp' || echo '$(srcdir)/'`../Cheats.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Cheats.Tpo" "$(DEPDIR)/Cheats.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Cheats.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Cheats.cpp' object='Cheats.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Cheats.Po' tmpdepfile='$(DEPDIR)/Cheats.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Cheats.o `test -f '../Cheats.cpp' || echo '$(srcdir)/'`../Cheats.cpp + +Cheats.obj: ../Cheats.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Cheats.obj -MD -MP -MF "$(DEPDIR)/Cheats.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Cheats.obj `if test -f '../Cheats.cpp'; then $(CYGPATH_W) '../Cheats.cpp'; else $(CYGPATH_W) '$(srcdir)/../Cheats.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Cheats.Tpo" "$(DEPDIR)/Cheats.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Cheats.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Cheats.cpp' object='Cheats.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Cheats.Po' tmpdepfile='$(DEPDIR)/Cheats.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Cheats.obj `if test -f '../Cheats.cpp'; then $(CYGPATH_W) '../Cheats.cpp'; else $(CYGPATH_W) '$(srcdir)/../Cheats.cpp'; fi` + +EEprom.o: ../EEprom.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT EEprom.o -MD -MP -MF "$(DEPDIR)/EEprom.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o EEprom.o `test -f '../EEprom.cpp' || echo '$(srcdir)/'`../EEprom.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/EEprom.Tpo" "$(DEPDIR)/EEprom.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/EEprom.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../EEprom.cpp' object='EEprom.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/EEprom.Po' tmpdepfile='$(DEPDIR)/EEprom.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o EEprom.o `test -f '../EEprom.cpp' || echo '$(srcdir)/'`../EEprom.cpp + +EEprom.obj: ../EEprom.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT EEprom.obj -MD -MP -MF "$(DEPDIR)/EEprom.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o EEprom.obj `if test -f '../EEprom.cpp'; then $(CYGPATH_W) '../EEprom.cpp'; else $(CYGPATH_W) '$(srcdir)/../EEprom.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/EEprom.Tpo" "$(DEPDIR)/EEprom.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/EEprom.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../EEprom.cpp' object='EEprom.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/EEprom.Po' tmpdepfile='$(DEPDIR)/EEprom.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o EEprom.obj `if test -f '../EEprom.cpp'; then $(CYGPATH_W) '../EEprom.cpp'; else $(CYGPATH_W) '$(srcdir)/../EEprom.cpp'; fi` + +Flash.o: ../Flash.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Flash.o -MD -MP -MF "$(DEPDIR)/Flash.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Flash.o `test -f '../Flash.cpp' || echo '$(srcdir)/'`../Flash.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Flash.Tpo" "$(DEPDIR)/Flash.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Flash.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Flash.cpp' object='Flash.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Flash.Po' tmpdepfile='$(DEPDIR)/Flash.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Flash.o `test -f '../Flash.cpp' || echo '$(srcdir)/'`../Flash.cpp + +Flash.obj: ../Flash.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Flash.obj -MD -MP -MF "$(DEPDIR)/Flash.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Flash.obj `if test -f '../Flash.cpp'; then $(CYGPATH_W) '../Flash.cpp'; else $(CYGPATH_W) '$(srcdir)/../Flash.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Flash.Tpo" "$(DEPDIR)/Flash.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Flash.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Flash.cpp' object='Flash.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Flash.Po' tmpdepfile='$(DEPDIR)/Flash.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Flash.obj `if test -f '../Flash.cpp'; then $(CYGPATH_W) '../Flash.cpp'; else $(CYGPATH_W) '$(srcdir)/../Flash.cpp'; fi` + +GBA.o: ../GBA.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT GBA.o -MD -MP -MF "$(DEPDIR)/GBA.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o GBA.o `test -f '../GBA.cpp' || echo '$(srcdir)/'`../GBA.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/GBA.Tpo" "$(DEPDIR)/GBA.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/GBA.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../GBA.cpp' object='GBA.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/GBA.Po' tmpdepfile='$(DEPDIR)/GBA.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GBA.o `test -f '../GBA.cpp' || echo '$(srcdir)/'`../GBA.cpp + +GBA.obj: ../GBA.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT GBA.obj -MD -MP -MF "$(DEPDIR)/GBA.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o GBA.obj `if test -f '../GBA.cpp'; then $(CYGPATH_W) '../GBA.cpp'; else $(CYGPATH_W) '$(srcdir)/../GBA.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/GBA.Tpo" "$(DEPDIR)/GBA.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/GBA.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../GBA.cpp' object='GBA.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/GBA.Po' tmpdepfile='$(DEPDIR)/GBA.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GBA.obj `if test -f '../GBA.cpp'; then $(CYGPATH_W) '../GBA.cpp'; else $(CYGPATH_W) '$(srcdir)/../GBA.cpp'; fi` + +Gfx.o: ../Gfx.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Gfx.o -MD -MP -MF "$(DEPDIR)/Gfx.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Gfx.o `test -f '../Gfx.cpp' || echo '$(srcdir)/'`../Gfx.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Gfx.Tpo" "$(DEPDIR)/Gfx.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Gfx.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Gfx.cpp' object='Gfx.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Gfx.Po' tmpdepfile='$(DEPDIR)/Gfx.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Gfx.o `test -f '../Gfx.cpp' || echo '$(srcdir)/'`../Gfx.cpp + +Gfx.obj: ../Gfx.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Gfx.obj -MD -MP -MF "$(DEPDIR)/Gfx.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Gfx.obj `if test -f '../Gfx.cpp'; then $(CYGPATH_W) '../Gfx.cpp'; else $(CYGPATH_W) '$(srcdir)/../Gfx.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Gfx.Tpo" "$(DEPDIR)/Gfx.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Gfx.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Gfx.cpp' object='Gfx.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Gfx.Po' tmpdepfile='$(DEPDIR)/Gfx.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Gfx.obj `if test -f '../Gfx.cpp'; then $(CYGPATH_W) '../Gfx.cpp'; else $(CYGPATH_W) '$(srcdir)/../Gfx.cpp'; fi` + +Globals.o: ../Globals.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Globals.o -MD -MP -MF "$(DEPDIR)/Globals.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Globals.o `test -f '../Globals.cpp' || echo '$(srcdir)/'`../Globals.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Globals.Tpo" "$(DEPDIR)/Globals.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Globals.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Globals.cpp' object='Globals.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Globals.Po' tmpdepfile='$(DEPDIR)/Globals.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Globals.o `test -f '../Globals.cpp' || echo '$(srcdir)/'`../Globals.cpp + +Globals.obj: ../Globals.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Globals.obj -MD -MP -MF "$(DEPDIR)/Globals.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Globals.obj `if test -f '../Globals.cpp'; then $(CYGPATH_W) '../Globals.cpp'; else $(CYGPATH_W) '$(srcdir)/../Globals.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Globals.Tpo" "$(DEPDIR)/Globals.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Globals.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Globals.cpp' object='Globals.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Globals.Po' tmpdepfile='$(DEPDIR)/Globals.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Globals.obj `if test -f '../Globals.cpp'; then $(CYGPATH_W) '../Globals.cpp'; else $(CYGPATH_W) '$(srcdir)/../Globals.cpp'; fi` + +Mode0.o: ../Mode0.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode0.o -MD -MP -MF "$(DEPDIR)/Mode0.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode0.o `test -f '../Mode0.cpp' || echo '$(srcdir)/'`../Mode0.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode0.Tpo" "$(DEPDIR)/Mode0.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode0.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode0.cpp' object='Mode0.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode0.Po' tmpdepfile='$(DEPDIR)/Mode0.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode0.o `test -f '../Mode0.cpp' || echo '$(srcdir)/'`../Mode0.cpp + +Mode0.obj: ../Mode0.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode0.obj -MD -MP -MF "$(DEPDIR)/Mode0.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode0.obj `if test -f '../Mode0.cpp'; then $(CYGPATH_W) '../Mode0.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode0.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode0.Tpo" "$(DEPDIR)/Mode0.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode0.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode0.cpp' object='Mode0.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode0.Po' tmpdepfile='$(DEPDIR)/Mode0.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode0.obj `if test -f '../Mode0.cpp'; then $(CYGPATH_W) '../Mode0.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode0.cpp'; fi` + +Mode1.o: ../Mode1.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode1.o -MD -MP -MF "$(DEPDIR)/Mode1.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode1.o `test -f '../Mode1.cpp' || echo '$(srcdir)/'`../Mode1.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode1.Tpo" "$(DEPDIR)/Mode1.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode1.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode1.cpp' object='Mode1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode1.Po' tmpdepfile='$(DEPDIR)/Mode1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode1.o `test -f '../Mode1.cpp' || echo '$(srcdir)/'`../Mode1.cpp + +Mode1.obj: ../Mode1.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode1.obj -MD -MP -MF "$(DEPDIR)/Mode1.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode1.obj `if test -f '../Mode1.cpp'; then $(CYGPATH_W) '../Mode1.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode1.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode1.Tpo" "$(DEPDIR)/Mode1.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode1.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode1.cpp' object='Mode1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode1.Po' tmpdepfile='$(DEPDIR)/Mode1.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode1.obj `if test -f '../Mode1.cpp'; then $(CYGPATH_W) '../Mode1.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode1.cpp'; fi` + +Mode2.o: ../Mode2.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode2.o -MD -MP -MF "$(DEPDIR)/Mode2.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode2.o `test -f '../Mode2.cpp' || echo '$(srcdir)/'`../Mode2.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode2.Tpo" "$(DEPDIR)/Mode2.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode2.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode2.cpp' object='Mode2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode2.Po' tmpdepfile='$(DEPDIR)/Mode2.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode2.o `test -f '../Mode2.cpp' || echo '$(srcdir)/'`../Mode2.cpp + +Mode2.obj: ../Mode2.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode2.obj -MD -MP -MF "$(DEPDIR)/Mode2.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode2.obj `if test -f '../Mode2.cpp'; then $(CYGPATH_W) '../Mode2.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode2.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode2.Tpo" "$(DEPDIR)/Mode2.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode2.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode2.cpp' object='Mode2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode2.Po' tmpdepfile='$(DEPDIR)/Mode2.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode2.obj `if test -f '../Mode2.cpp'; then $(CYGPATH_W) '../Mode2.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode2.cpp'; fi` + +Mode3.o: ../Mode3.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode3.o -MD -MP -MF "$(DEPDIR)/Mode3.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode3.o `test -f '../Mode3.cpp' || echo '$(srcdir)/'`../Mode3.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode3.Tpo" "$(DEPDIR)/Mode3.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode3.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode3.cpp' object='Mode3.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode3.Po' tmpdepfile='$(DEPDIR)/Mode3.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode3.o `test -f '../Mode3.cpp' || echo '$(srcdir)/'`../Mode3.cpp + +Mode3.obj: ../Mode3.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode3.obj -MD -MP -MF "$(DEPDIR)/Mode3.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode3.obj `if test -f '../Mode3.cpp'; then $(CYGPATH_W) '../Mode3.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode3.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode3.Tpo" "$(DEPDIR)/Mode3.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode3.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode3.cpp' object='Mode3.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode3.Po' tmpdepfile='$(DEPDIR)/Mode3.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode3.obj `if test -f '../Mode3.cpp'; then $(CYGPATH_W) '../Mode3.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode3.cpp'; fi` + +Mode4.o: ../Mode4.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode4.o -MD -MP -MF "$(DEPDIR)/Mode4.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode4.o `test -f '../Mode4.cpp' || echo '$(srcdir)/'`../Mode4.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode4.Tpo" "$(DEPDIR)/Mode4.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode4.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode4.cpp' object='Mode4.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode4.Po' tmpdepfile='$(DEPDIR)/Mode4.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode4.o `test -f '../Mode4.cpp' || echo '$(srcdir)/'`../Mode4.cpp + +Mode4.obj: ../Mode4.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode4.obj -MD -MP -MF "$(DEPDIR)/Mode4.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode4.obj `if test -f '../Mode4.cpp'; then $(CYGPATH_W) '../Mode4.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode4.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode4.Tpo" "$(DEPDIR)/Mode4.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode4.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode4.cpp' object='Mode4.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode4.Po' tmpdepfile='$(DEPDIR)/Mode4.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode4.obj `if test -f '../Mode4.cpp'; then $(CYGPATH_W) '../Mode4.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode4.cpp'; fi` + +Mode5.o: ../Mode5.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode5.o -MD -MP -MF "$(DEPDIR)/Mode5.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode5.o `test -f '../Mode5.cpp' || echo '$(srcdir)/'`../Mode5.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode5.Tpo" "$(DEPDIR)/Mode5.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode5.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode5.cpp' object='Mode5.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode5.Po' tmpdepfile='$(DEPDIR)/Mode5.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode5.o `test -f '../Mode5.cpp' || echo '$(srcdir)/'`../Mode5.cpp + +Mode5.obj: ../Mode5.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Mode5.obj -MD -MP -MF "$(DEPDIR)/Mode5.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Mode5.obj `if test -f '../Mode5.cpp'; then $(CYGPATH_W) '../Mode5.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode5.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Mode5.Tpo" "$(DEPDIR)/Mode5.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Mode5.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Mode5.cpp' object='Mode5.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Mode5.Po' tmpdepfile='$(DEPDIR)/Mode5.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Mode5.obj `if test -f '../Mode5.cpp'; then $(CYGPATH_W) '../Mode5.cpp'; else $(CYGPATH_W) '$(srcdir)/../Mode5.cpp'; fi` + +RTC.o: ../RTC.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT RTC.o -MD -MP -MF "$(DEPDIR)/RTC.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o RTC.o `test -f '../RTC.cpp' || echo '$(srcdir)/'`../RTC.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/RTC.Tpo" "$(DEPDIR)/RTC.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/RTC.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../RTC.cpp' object='RTC.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/RTC.Po' tmpdepfile='$(DEPDIR)/RTC.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o RTC.o `test -f '../RTC.cpp' || echo '$(srcdir)/'`../RTC.cpp + +RTC.obj: ../RTC.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT RTC.obj -MD -MP -MF "$(DEPDIR)/RTC.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o RTC.obj `if test -f '../RTC.cpp'; then $(CYGPATH_W) '../RTC.cpp'; else $(CYGPATH_W) '$(srcdir)/../RTC.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/RTC.Tpo" "$(DEPDIR)/RTC.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/RTC.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../RTC.cpp' object='RTC.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/RTC.Po' tmpdepfile='$(DEPDIR)/RTC.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o RTC.obj `if test -f '../RTC.cpp'; then $(CYGPATH_W) '../RTC.cpp'; else $(CYGPATH_W) '$(srcdir)/../RTC.cpp'; fi` + +Sound.o: ../Sound.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Sound.o -MD -MP -MF "$(DEPDIR)/Sound.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Sound.o `test -f '../Sound.cpp' || echo '$(srcdir)/'`../Sound.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Sound.Tpo" "$(DEPDIR)/Sound.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Sound.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sound.cpp' object='Sound.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Sound.Po' tmpdepfile='$(DEPDIR)/Sound.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Sound.o `test -f '../Sound.cpp' || echo '$(srcdir)/'`../Sound.cpp + +Sound.obj: ../Sound.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Sound.obj -MD -MP -MF "$(DEPDIR)/Sound.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Sound.obj `if test -f '../Sound.cpp'; then $(CYGPATH_W) '../Sound.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sound.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Sound.Tpo" "$(DEPDIR)/Sound.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Sound.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sound.cpp' object='Sound.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Sound.Po' tmpdepfile='$(DEPDIR)/Sound.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Sound.obj `if test -f '../Sound.cpp'; then $(CYGPATH_W) '../Sound.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sound.cpp'; fi` + +Sram.o: ../Sram.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Sram.o -MD -MP -MF "$(DEPDIR)/Sram.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Sram.o `test -f '../Sram.cpp' || echo '$(srcdir)/'`../Sram.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Sram.Tpo" "$(DEPDIR)/Sram.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Sram.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sram.cpp' object='Sram.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Sram.Po' tmpdepfile='$(DEPDIR)/Sram.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Sram.o `test -f '../Sram.cpp' || echo '$(srcdir)/'`../Sram.cpp + +Sram.obj: ../Sram.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Sram.obj -MD -MP -MF "$(DEPDIR)/Sram.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Sram.obj `if test -f '../Sram.cpp'; then $(CYGPATH_W) '../Sram.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sram.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Sram.Tpo" "$(DEPDIR)/Sram.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Sram.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Sram.cpp' object='Sram.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Sram.Po' tmpdepfile='$(DEPDIR)/Sram.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Sram.obj `if test -f '../Sram.cpp'; then $(CYGPATH_W) '../Sram.cpp'; else $(CYGPATH_W) '$(srcdir)/../Sram.cpp'; fi` + +Text.o: ../Text.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Text.o -MD -MP -MF "$(DEPDIR)/Text.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Text.o `test -f '../Text.cpp' || echo '$(srcdir)/'`../Text.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Text.Tpo" "$(DEPDIR)/Text.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Text.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Text.cpp' object='Text.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Text.Po' tmpdepfile='$(DEPDIR)/Text.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Text.o `test -f '../Text.cpp' || echo '$(srcdir)/'`../Text.cpp + +Text.obj: ../Text.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Text.obj -MD -MP -MF "$(DEPDIR)/Text.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Text.obj `if test -f '../Text.cpp'; then $(CYGPATH_W) '../Text.cpp'; else $(CYGPATH_W) '$(srcdir)/../Text.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Text.Tpo" "$(DEPDIR)/Text.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Text.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Text.cpp' object='Text.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Text.Po' tmpdepfile='$(DEPDIR)/Text.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Text.obj `if test -f '../Text.cpp'; then $(CYGPATH_W) '../Text.cpp'; else $(CYGPATH_W) '$(srcdir)/../Text.cpp'; fi` + +Util.o: ../Util.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Util.o -MD -MP -MF "$(DEPDIR)/Util.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Util.o `test -f '../Util.cpp' || echo '$(srcdir)/'`../Util.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Util.Tpo" "$(DEPDIR)/Util.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Util.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Util.cpp' object='Util.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Util.Po' tmpdepfile='$(DEPDIR)/Util.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Util.o `test -f '../Util.cpp' || echo '$(srcdir)/'`../Util.cpp + +Util.obj: ../Util.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Util.obj -MD -MP -MF "$(DEPDIR)/Util.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o Util.obj `if test -f '../Util.cpp'; then $(CYGPATH_W) '../Util.cpp'; else $(CYGPATH_W) '$(srcdir)/../Util.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/Util.Tpo" "$(DEPDIR)/Util.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/Util.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../Util.cpp' object='Util.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/Util.Po' tmpdepfile='$(DEPDIR)/Util.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Util.obj `if test -f '../Util.cpp'; then $(CYGPATH_W) '../Util.cpp'; else $(CYGPATH_W) '$(srcdir)/../Util.cpp'; fi` + +admame.o: ../admame.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT admame.o -MD -MP -MF "$(DEPDIR)/admame.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o admame.o `test -f '../admame.cpp' || echo '$(srcdir)/'`../admame.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/admame.Tpo" "$(DEPDIR)/admame.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/admame.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../admame.cpp' object='admame.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/admame.Po' tmpdepfile='$(DEPDIR)/admame.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o admame.o `test -f '../admame.cpp' || echo '$(srcdir)/'`../admame.cpp + +admame.obj: ../admame.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT admame.obj -MD -MP -MF "$(DEPDIR)/admame.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o admame.obj `if test -f '../admame.cpp'; then $(CYGPATH_W) '../admame.cpp'; else $(CYGPATH_W) '$(srcdir)/../admame.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/admame.Tpo" "$(DEPDIR)/admame.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/admame.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../admame.cpp' object='admame.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/admame.Po' tmpdepfile='$(DEPDIR)/admame.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o admame.obj `if test -f '../admame.cpp'; then $(CYGPATH_W) '../admame.cpp'; else $(CYGPATH_W) '$(srcdir)/../admame.cpp'; fi` + +agbprint.o: ../agbprint.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT agbprint.o -MD -MP -MF "$(DEPDIR)/agbprint.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o agbprint.o `test -f '../agbprint.cpp' || echo '$(srcdir)/'`../agbprint.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/agbprint.Tpo" "$(DEPDIR)/agbprint.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/agbprint.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../agbprint.cpp' object='agbprint.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/agbprint.Po' tmpdepfile='$(DEPDIR)/agbprint.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o agbprint.o `test -f '../agbprint.cpp' || echo '$(srcdir)/'`../agbprint.cpp + +agbprint.obj: ../agbprint.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT agbprint.obj -MD -MP -MF "$(DEPDIR)/agbprint.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o agbprint.obj `if test -f '../agbprint.cpp'; then $(CYGPATH_W) '../agbprint.cpp'; else $(CYGPATH_W) '$(srcdir)/../agbprint.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/agbprint.Tpo" "$(DEPDIR)/agbprint.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/agbprint.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../agbprint.cpp' object='agbprint.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/agbprint.Po' tmpdepfile='$(DEPDIR)/agbprint.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o agbprint.obj `if test -f '../agbprint.cpp'; then $(CYGPATH_W) '../agbprint.cpp'; else $(CYGPATH_W) '$(srcdir)/../agbprint.cpp'; fi` + +armdis.o: ../armdis.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT armdis.o -MD -MP -MF "$(DEPDIR)/armdis.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o armdis.o `test -f '../armdis.cpp' || echo '$(srcdir)/'`../armdis.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/armdis.Tpo" "$(DEPDIR)/armdis.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/armdis.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../armdis.cpp' object='armdis.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/armdis.Po' tmpdepfile='$(DEPDIR)/armdis.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o armdis.o `test -f '../armdis.cpp' || echo '$(srcdir)/'`../armdis.cpp + +armdis.obj: ../armdis.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT armdis.obj -MD -MP -MF "$(DEPDIR)/armdis.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o armdis.obj `if test -f '../armdis.cpp'; then $(CYGPATH_W) '../armdis.cpp'; else $(CYGPATH_W) '$(srcdir)/../armdis.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/armdis.Tpo" "$(DEPDIR)/armdis.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/armdis.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../armdis.cpp' object='armdis.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/armdis.Po' tmpdepfile='$(DEPDIR)/armdis.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o armdis.obj `if test -f '../armdis.cpp'; then $(CYGPATH_W) '../armdis.cpp'; else $(CYGPATH_W) '$(srcdir)/../armdis.cpp'; fi` + +bios.o: ../bios.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bios.o -MD -MP -MF "$(DEPDIR)/bios.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o bios.o `test -f '../bios.cpp' || echo '$(srcdir)/'`../bios.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/bios.Tpo" "$(DEPDIR)/bios.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/bios.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bios.cpp' object='bios.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/bios.Po' tmpdepfile='$(DEPDIR)/bios.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bios.o `test -f '../bios.cpp' || echo '$(srcdir)/'`../bios.cpp + +bios.obj: ../bios.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bios.obj -MD -MP -MF "$(DEPDIR)/bios.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o bios.obj `if test -f '../bios.cpp'; then $(CYGPATH_W) '../bios.cpp'; else $(CYGPATH_W) '$(srcdir)/../bios.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/bios.Tpo" "$(DEPDIR)/bios.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/bios.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bios.cpp' object='bios.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/bios.Po' tmpdepfile='$(DEPDIR)/bios.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bios.obj `if test -f '../bios.cpp'; then $(CYGPATH_W) '../bios.cpp'; else $(CYGPATH_W) '$(srcdir)/../bios.cpp'; fi` + +elf.o: ../elf.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT elf.o -MD -MP -MF "$(DEPDIR)/elf.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o elf.o `test -f '../elf.cpp' || echo '$(srcdir)/'`../elf.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/elf.Tpo" "$(DEPDIR)/elf.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/elf.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../elf.cpp' object='elf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/elf.Po' tmpdepfile='$(DEPDIR)/elf.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o elf.o `test -f '../elf.cpp' || echo '$(srcdir)/'`../elf.cpp + +elf.obj: ../elf.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT elf.obj -MD -MP -MF "$(DEPDIR)/elf.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o elf.obj `if test -f '../elf.cpp'; then $(CYGPATH_W) '../elf.cpp'; else $(CYGPATH_W) '$(srcdir)/../elf.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/elf.Tpo" "$(DEPDIR)/elf.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/elf.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../elf.cpp' object='elf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/elf.Po' tmpdepfile='$(DEPDIR)/elf.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o elf.obj `if test -f '../elf.cpp'; then $(CYGPATH_W) '../elf.cpp'; else $(CYGPATH_W) '$(srcdir)/../elf.cpp'; fi` + +expr-lex.o: ../expr-lex.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT expr-lex.o -MD -MP -MF "$(DEPDIR)/expr-lex.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o expr-lex.o `test -f '../expr-lex.cpp' || echo '$(srcdir)/'`../expr-lex.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/expr-lex.Tpo" "$(DEPDIR)/expr-lex.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/expr-lex.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../expr-lex.cpp' object='expr-lex.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/expr-lex.Po' tmpdepfile='$(DEPDIR)/expr-lex.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o expr-lex.o `test -f '../expr-lex.cpp' || echo '$(srcdir)/'`../expr-lex.cpp + +expr-lex.obj: ../expr-lex.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT expr-lex.obj -MD -MP -MF "$(DEPDIR)/expr-lex.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o expr-lex.obj `if test -f '../expr-lex.cpp'; then $(CYGPATH_W) '../expr-lex.cpp'; else $(CYGPATH_W) '$(srcdir)/../expr-lex.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/expr-lex.Tpo" "$(DEPDIR)/expr-lex.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/expr-lex.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../expr-lex.cpp' object='expr-lex.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/expr-lex.Po' tmpdepfile='$(DEPDIR)/expr-lex.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o expr-lex.obj `if test -f '../expr-lex.cpp'; then $(CYGPATH_W) '../expr-lex.cpp'; else $(CYGPATH_W) '$(srcdir)/../expr-lex.cpp'; fi` + +expr.o: ../expr.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT expr.o -MD -MP -MF "$(DEPDIR)/expr.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o expr.o `test -f '../expr.cpp' || echo '$(srcdir)/'`../expr.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/expr.Tpo" "$(DEPDIR)/expr.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/expr.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../expr.cpp' object='expr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/expr.Po' tmpdepfile='$(DEPDIR)/expr.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o expr.o `test -f '../expr.cpp' || echo '$(srcdir)/'`../expr.cpp + +expr.obj: ../expr.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT expr.obj -MD -MP -MF "$(DEPDIR)/expr.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o expr.obj `if test -f '../expr.cpp'; then $(CYGPATH_W) '../expr.cpp'; else $(CYGPATH_W) '$(srcdir)/../expr.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/expr.Tpo" "$(DEPDIR)/expr.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/expr.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../expr.cpp' object='expr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/expr.Po' tmpdepfile='$(DEPDIR)/expr.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o expr.obj `if test -f '../expr.cpp'; then $(CYGPATH_W) '../expr.cpp'; else $(CYGPATH_W) '$(srcdir)/../expr.cpp'; fi` + +exprNode.o: ../exprNode.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT exprNode.o -MD -MP -MF "$(DEPDIR)/exprNode.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o exprNode.o `test -f '../exprNode.cpp' || echo '$(srcdir)/'`../exprNode.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/exprNode.Tpo" "$(DEPDIR)/exprNode.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/exprNode.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../exprNode.cpp' object='exprNode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/exprNode.Po' tmpdepfile='$(DEPDIR)/exprNode.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o exprNode.o `test -f '../exprNode.cpp' || echo '$(srcdir)/'`../exprNode.cpp + +exprNode.obj: ../exprNode.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT exprNode.obj -MD -MP -MF "$(DEPDIR)/exprNode.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o exprNode.obj `if test -f '../exprNode.cpp'; then $(CYGPATH_W) '../exprNode.cpp'; else $(CYGPATH_W) '$(srcdir)/../exprNode.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/exprNode.Tpo" "$(DEPDIR)/exprNode.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/exprNode.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../exprNode.cpp' object='exprNode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/exprNode.Po' tmpdepfile='$(DEPDIR)/exprNode.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o exprNode.obj `if test -f '../exprNode.cpp'; then $(CYGPATH_W) '../exprNode.cpp'; else $(CYGPATH_W) '$(srcdir)/../exprNode.cpp'; fi` + +hq2x.o: ../hq2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hq2x.o -MD -MP -MF "$(DEPDIR)/hq2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o hq2x.o `test -f '../hq2x.cpp' || echo '$(srcdir)/'`../hq2x.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/hq2x.Tpo" "$(DEPDIR)/hq2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/hq2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../hq2x.cpp' object='hq2x.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/hq2x.Po' tmpdepfile='$(DEPDIR)/hq2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hq2x.o `test -f '../hq2x.cpp' || echo '$(srcdir)/'`../hq2x.cpp + +hq2x.obj: ../hq2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hq2x.obj -MD -MP -MF "$(DEPDIR)/hq2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o hq2x.obj `if test -f '../hq2x.cpp'; then $(CYGPATH_W) '../hq2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../hq2x.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/hq2x.Tpo" "$(DEPDIR)/hq2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/hq2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../hq2x.cpp' object='hq2x.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/hq2x.Po' tmpdepfile='$(DEPDIR)/hq2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hq2x.obj `if test -f '../hq2x.cpp'; then $(CYGPATH_W) '../hq2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../hq2x.cpp'; fi` + +motionblur.o: ../motionblur.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT motionblur.o -MD -MP -MF "$(DEPDIR)/motionblur.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o motionblur.o `test -f '../motionblur.cpp' || echo '$(srcdir)/'`../motionblur.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/motionblur.Tpo" "$(DEPDIR)/motionblur.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/motionblur.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../motionblur.cpp' object='motionblur.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/motionblur.Po' tmpdepfile='$(DEPDIR)/motionblur.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o motionblur.o `test -f '../motionblur.cpp' || echo '$(srcdir)/'`../motionblur.cpp + +motionblur.obj: ../motionblur.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT motionblur.obj -MD -MP -MF "$(DEPDIR)/motionblur.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o motionblur.obj `if test -f '../motionblur.cpp'; then $(CYGPATH_W) '../motionblur.cpp'; else $(CYGPATH_W) '$(srcdir)/../motionblur.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/motionblur.Tpo" "$(DEPDIR)/motionblur.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/motionblur.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../motionblur.cpp' object='motionblur.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/motionblur.Po' tmpdepfile='$(DEPDIR)/motionblur.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o motionblur.obj `if test -f '../motionblur.cpp'; then $(CYGPATH_W) '../motionblur.cpp'; else $(CYGPATH_W) '$(srcdir)/../motionblur.cpp'; fi` + +pixel.o: ../pixel.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT pixel.o -MD -MP -MF "$(DEPDIR)/pixel.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o pixel.o `test -f '../pixel.cpp' || echo '$(srcdir)/'`../pixel.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/pixel.Tpo" "$(DEPDIR)/pixel.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/pixel.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../pixel.cpp' object='pixel.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/pixel.Po' tmpdepfile='$(DEPDIR)/pixel.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pixel.o `test -f '../pixel.cpp' || echo '$(srcdir)/'`../pixel.cpp + +pixel.obj: ../pixel.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT pixel.obj -MD -MP -MF "$(DEPDIR)/pixel.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o pixel.obj `if test -f '../pixel.cpp'; then $(CYGPATH_W) '../pixel.cpp'; else $(CYGPATH_W) '$(srcdir)/../pixel.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/pixel.Tpo" "$(DEPDIR)/pixel.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/pixel.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../pixel.cpp' object='pixel.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/pixel.Po' tmpdepfile='$(DEPDIR)/pixel.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pixel.obj `if test -f '../pixel.cpp'; then $(CYGPATH_W) '../pixel.cpp'; else $(CYGPATH_W) '$(srcdir)/../pixel.cpp'; fi` + +remote.o: ../remote.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT remote.o -MD -MP -MF "$(DEPDIR)/remote.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o remote.o `test -f '../remote.cpp' || echo '$(srcdir)/'`../remote.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/remote.Tpo" "$(DEPDIR)/remote.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/remote.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../remote.cpp' object='remote.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/remote.Po' tmpdepfile='$(DEPDIR)/remote.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o remote.o `test -f '../remote.cpp' || echo '$(srcdir)/'`../remote.cpp + +remote.obj: ../remote.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT remote.obj -MD -MP -MF "$(DEPDIR)/remote.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o remote.obj `if test -f '../remote.cpp'; then $(CYGPATH_W) '../remote.cpp'; else $(CYGPATH_W) '$(srcdir)/../remote.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/remote.Tpo" "$(DEPDIR)/remote.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/remote.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../remote.cpp' object='remote.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/remote.Po' tmpdepfile='$(DEPDIR)/remote.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o remote.obj `if test -f '../remote.cpp'; then $(CYGPATH_W) '../remote.cpp'; else $(CYGPATH_W) '$(srcdir)/../remote.cpp'; fi` + +scanline.o: ../scanline.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT scanline.o -MD -MP -MF "$(DEPDIR)/scanline.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o scanline.o `test -f '../scanline.cpp' || echo '$(srcdir)/'`../scanline.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/scanline.Tpo" "$(DEPDIR)/scanline.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/scanline.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../scanline.cpp' object='scanline.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/scanline.Po' tmpdepfile='$(DEPDIR)/scanline.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o scanline.o `test -f '../scanline.cpp' || echo '$(srcdir)/'`../scanline.cpp + +scanline.obj: ../scanline.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT scanline.obj -MD -MP -MF "$(DEPDIR)/scanline.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o scanline.obj `if test -f '../scanline.cpp'; then $(CYGPATH_W) '../scanline.cpp'; else $(CYGPATH_W) '$(srcdir)/../scanline.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/scanline.Tpo" "$(DEPDIR)/scanline.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/scanline.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../scanline.cpp' object='scanline.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/scanline.Po' tmpdepfile='$(DEPDIR)/scanline.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o scanline.obj `if test -f '../scanline.cpp'; then $(CYGPATH_W) '../scanline.cpp'; else $(CYGPATH_W) '$(srcdir)/../scanline.cpp'; fi` + +simple2x.o: ../simple2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT simple2x.o -MD -MP -MF "$(DEPDIR)/simple2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o simple2x.o `test -f '../simple2x.cpp' || echo '$(srcdir)/'`../simple2x.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/simple2x.Tpo" "$(DEPDIR)/simple2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/simple2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../simple2x.cpp' object='simple2x.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/simple2x.Po' tmpdepfile='$(DEPDIR)/simple2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o simple2x.o `test -f '../simple2x.cpp' || echo '$(srcdir)/'`../simple2x.cpp + +simple2x.obj: ../simple2x.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT simple2x.obj -MD -MP -MF "$(DEPDIR)/simple2x.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o simple2x.obj `if test -f '../simple2x.cpp'; then $(CYGPATH_W) '../simple2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../simple2x.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/simple2x.Tpo" "$(DEPDIR)/simple2x.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/simple2x.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../simple2x.cpp' object='simple2x.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/simple2x.Po' tmpdepfile='$(DEPDIR)/simple2x.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o simple2x.obj `if test -f '../simple2x.cpp'; then $(CYGPATH_W) '../simple2x.cpp'; else $(CYGPATH_W) '$(srcdir)/../simple2x.cpp'; fi` + +unzip.o: ../unzip.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT unzip.o -MD -MP -MF "$(DEPDIR)/unzip.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o unzip.o `test -f '../unzip.cpp' || echo '$(srcdir)/'`../unzip.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/unzip.Tpo" "$(DEPDIR)/unzip.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/unzip.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../unzip.cpp' object='unzip.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/unzip.Po' tmpdepfile='$(DEPDIR)/unzip.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o unzip.o `test -f '../unzip.cpp' || echo '$(srcdir)/'`../unzip.cpp + +unzip.obj: ../unzip.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT unzip.obj -MD -MP -MF "$(DEPDIR)/unzip.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o unzip.obj `if test -f '../unzip.cpp'; then $(CYGPATH_W) '../unzip.cpp'; else $(CYGPATH_W) '$(srcdir)/../unzip.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/unzip.Tpo" "$(DEPDIR)/unzip.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/unzip.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../unzip.cpp' object='unzip.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/unzip.Po' tmpdepfile='$(DEPDIR)/unzip.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o unzip.obj `if test -f '../unzip.cpp'; then $(CYGPATH_W) '../unzip.cpp'; else $(CYGPATH_W) '$(srcdir)/../unzip.cpp'; fi` + +bilinear.o: ../bilinear.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bilinear.o -MD -MP -MF "$(DEPDIR)/bilinear.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o bilinear.o `test -f '../bilinear.cpp' || echo '$(srcdir)/'`../bilinear.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/bilinear.Tpo" "$(DEPDIR)/bilinear.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/bilinear.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bilinear.cpp' object='bilinear.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/bilinear.Po' tmpdepfile='$(DEPDIR)/bilinear.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bilinear.o `test -f '../bilinear.cpp' || echo '$(srcdir)/'`../bilinear.cpp + +bilinear.obj: ../bilinear.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT bilinear.obj -MD -MP -MF "$(DEPDIR)/bilinear.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o bilinear.obj `if test -f '../bilinear.cpp'; then $(CYGPATH_W) '../bilinear.cpp'; else $(CYGPATH_W) '$(srcdir)/../bilinear.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/bilinear.Tpo" "$(DEPDIR)/bilinear.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/bilinear.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../bilinear.cpp' object='bilinear.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/bilinear.Po' tmpdepfile='$(DEPDIR)/bilinear.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o bilinear.obj `if test -f '../bilinear.cpp'; then $(CYGPATH_W) '../bilinear.cpp'; else $(CYGPATH_W) '$(srcdir)/../bilinear.cpp'; fi` + +interframe.o: ../interframe.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT interframe.o -MD -MP -MF "$(DEPDIR)/interframe.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o interframe.o `test -f '../interframe.cpp' || echo '$(srcdir)/'`../interframe.cpp; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/interframe.Tpo" "$(DEPDIR)/interframe.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/interframe.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../interframe.cpp' object='interframe.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/interframe.Po' tmpdepfile='$(DEPDIR)/interframe.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o interframe.o `test -f '../interframe.cpp' || echo '$(srcdir)/'`../interframe.cpp + +interframe.obj: ../interframe.cpp +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT interframe.obj -MD -MP -MF "$(DEPDIR)/interframe.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o interframe.obj `if test -f '../interframe.cpp'; then $(CYGPATH_W) '../interframe.cpp'; else $(CYGPATH_W) '$(srcdir)/../interframe.cpp'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/interframe.Tpo" "$(DEPDIR)/interframe.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/interframe.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../interframe.cpp' object='interframe.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/interframe.Po' tmpdepfile='$(DEPDIR)/interframe.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o interframe.obj `if test -f '../interframe.cpp'; then $(CYGPATH_W) '../interframe.cpp'; else $(CYGPATH_W) '$(srcdir)/../interframe.cpp'; fi` +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +CTAGS = ctags +CTAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp new file mode 100644 index 0000000..095b3c4 --- /dev/null +++ b/src/sdl/SDL.cpp @@ -0,0 +1,3516 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include +#include +#include + +#include "AutoBuild.h" + +#include "SDL.h" +#include "GBA.h" +#include "agbprint.h" +#include "Flash.h" +#include "Port.h" +#include "debugger.h" +#include "RTC.h" +#include "Sound.h" +#include "Text.h" +#include "unzip.h" +#include "Util.h" +#include "gb/GB.h" +#include "gb/gbGlobals.h" +#include "movie.h" + +#define GBC_CAPABLE ((gbRom[0x143] & 0x80) != 0) +#define SGB_CAPABLE (gbRom[0x146] == 0x03) + +#ifndef WIN32 +# include +# define GETCWD getcwd +#else // WIN32 +# include +# define GETCWD _getcwd +#endif // WIN32 + +#ifndef __GNUC__ +# define HAVE_DECL_GETOPT 0 +# define __STDC__ 1 +# include "getopt.h" +#else // ! __GNUC__ +# define HAVE_DECL_GETOPT 1 +# include "getopt.h" +#endif // ! __GNUC__ + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif +extern bool soundEcho; +extern bool soundLowPass; +extern bool soundReverse; +extern int Init_2xSaI(u32); +extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int); +extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int); +extern void Super2xSaI(u8*,u32,u8*,u8*,u32,int,int); +extern void Super2xSaI32(u8*,u32,u8*,u8*,u32,int,int); +extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int); +extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int); +extern void Pixelate(u8*,u32,u8*,u8*,u32,int,int); +extern void Pixelate32(u8*,u32,u8*,u8*,u32,int,int); +extern void MotionBlur(u8*,u32,u8*,u8*,u32,int,int); +extern void MotionBlur32(u8*,u32,u8*,u8*,u32,int,int); +extern void AdMame2x(u8*,u32,u8*,u8*,u32,int,int); +extern void AdMame2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void Simple2x(u8*,u32,u8*,u8*,u32,int,int); +extern void Simple2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void Bilinear(u8*,u32,u8*,u8*,u32,int,int); +extern void Bilinear32(u8*,u32,u8*,u8*,u32,int,int); +extern void BilinearPlus(u8*,u32,u8*,u8*,u32,int,int); +extern void BilinearPlus32(u8*,u32,u8*,u8*,u32,int,int); +extern void Scanlines(u8*,u32,u8*,u8*,u32,int,int); +extern void Scanlines32(u8*,u32,u8*,u8*,u32,int,int); +extern void ScanlinesTV(u8*,u32,u8*,u8*,u32,int,int); +extern void ScanlinesTV32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2x(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void lq2x(u8*,u32,u8*,u8*,u32,int,int); +extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int); + +extern void SmartIB(u8*,u32,int,int); +extern void SmartIB32(u8*,u32,int,int); +extern void MotionBlurIB(u8*,u32,int,int); +extern void MotionBlurIB32(u8*,u32,int,int); + +void Init_Overlay(SDL_Surface *surface, int overlaytype); +void Quit_Overlay(void); +void Draw_Overlay(SDL_Surface *surface, int size); + +extern void remoteInit(); +extern void remoteCleanUp(); +extern void remoteStubMain(); +extern void remoteStubSignal(int,int); +extern void remoteOutput(char *, u32); +extern void remoteSetProtocol(int); +extern void remoteSetPort(int); +extern void debuggerOutput(char *, u32); + +extern void CPUUpdateRenderBuffers(bool); + +struct EmulatedSystem emulator = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + false, + 0 +}; + +SDL_Surface *surface = NULL; +SDL_Overlay *overlay = NULL; +SDL_Rect overlay_rect; + +int systemSpeed = 0; +int systemRedShift = 0; +int systemBlueShift = 0; +int systemGreenShift = 0; +int systemColorDepth = 0; +int systemDebug = 0; +int systemVerbose = 0; +int systemFrameSkip = 0; +int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + +int srcPitch = 0; +int srcWidth = 0; +int srcHeight = 0; +int destWidth = 0; +int destHeight = 0; + +int sensorX = 2047; +int sensorY = 2047; + +int filter = 0; +u8 *delta = NULL; + +int sdlPrintUsage = 0; +int disableMMX = 0; + +int cartridgeType = 3; +int sizeOption = 0; +int captureFormat = 0; +int useMovie = 0; + +int pauseWhenInactive = 0; +int active = 1; +int emulating = 0; +int RGB_LOW_BITS_MASK=0x821; +u32 systemColorMap32[0x10000]; +u16 systemColorMap16[0x10000]; +u16 systemGbPalette[24]; +void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = NULL; +void (*ifbFunction)(u8*,u32,int,int) = NULL; +int ifbType = 0; +char filename[2048]; +char ipsname[2048]; +char biosFileName[2048]; +char movieFileName[2048]; +char captureDir[2048]; +char saveDir[2048]; +char batteryDir[2048]; + +static char *rewindMemory = NULL; +static int rewindPos = 0; +static int rewindTopPos = 0; +static int rewindCounter = 0; +static int rewindCount = 0; +static bool rewindSaveNeeded = false; +static int rewindTimer = 0; + +#define REWIND_SIZE 400000 + +#define _stricmp strcasecmp + +bool sdlButtons[4][12] = { + { false, false, false, false, false, false, + false, false, false, false, false, false }, + { false, false, false, false, false, false, + false, false, false, false, false, false }, + { false, false, false, false, false, false, + false, false, false, false, false, false }, + { false, false, false, false, false, false, + false, false, false, false, false, false } +}; + +bool sdlMotionButtons[4] = { false, false, false, false }; + +int sdlNumDevices = 0; +SDL_Joystick **sdlDevices = NULL; + +bool wasPaused = false; +int autoFrameSkip = 0; +int frameskipadjust = 0; +int showRenderedFrames = 0; +int renderedFrames = 0; + +int throttle = 0; +u32 throttleLastTime = 0; +u32 autoFrameSkipLastTime = 0; + +int showSpeed = 1; +int showSpeedTransparent = 1; +bool disableStatusMessages = false; +bool paused = false; +bool pauseNextFrame = false; +bool debugger = false; +bool debuggerStub = false; +int fullscreen = 0; +bool systemSoundOn = false; +bool yuv = false; +int yuvType = 0; +bool removeIntros = false; +int sdlFlashSize = 0; +int sdlAutoIPS = 1; +int sdlRtcEnable = 0; +int sdlAgbPrint = 0; + +int sdlDefaultJoypad = 0; + +extern void debuggerSignal(int,int); + +void (*dbgMain)() = debuggerMain; +void (*dbgSignal)(int,int) = debuggerSignal; +void (*dbgOutput)(char *, u32) = debuggerOutput; + +int mouseCounter = 0; +int autoFire = 0; +bool autoFireToggle = false; + +bool screenMessage[8] = {false,false,false,false,false,false,false,false}; +char screenMessageBuffer[8][21]; +u32 screenMessageTime[8] = {0,0,0,0,0,0,0,0}; +u32 screenMessageDuration[8] = {0,0,0,0,0,0,0,0}; + +SDL_cond *cond = NULL; +SDL_mutex *mutex = NULL; +u8 sdlBuffer[4096]; +int sdlSoundLen = 0; + +char *arg0; + +#ifndef C_CORE +u8 sdlStretcher[16384]; +int sdlStretcherPos; +#else +void (*sdlStretcher)(u8 *, u8*) = NULL; +#endif + +#include "inputGlobal.h" + +u16 joypad[4][12] = { + { SDLK_LEFT, SDLK_RIGHT, + SDLK_UP, SDLK_DOWN, + SDLK_z, SDLK_x, + SDLK_RETURN,SDLK_BACKSPACE, + SDLK_a, SDLK_s, + SDLK_SPACE, SDLK_F12 + }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; + +u16 defaultJoypad[12] = { + SDLK_LEFT, SDLK_RIGHT, + SDLK_UP, SDLK_DOWN, + SDLK_z, SDLK_x, + SDLK_RETURN,SDLK_BACKSPACE, + SDLK_a, SDLK_s, + SDLK_SPACE, SDLK_F12 +}; + +u16 motion[4] = { + SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2 +}; + +u16 defaultMotion[4] = { + SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2 +}; + +struct option sdlOptions[] = { + { "agb-print", no_argument, &sdlAgbPrint, 1 }, + { "auto-frameskip", no_argument, &autoFrameSkip, 1 }, + { "bios", required_argument, 0, 'b' }, + { "config", required_argument, 0, 'c' }, + { "debug", no_argument, 0, 'd' }, + { "filter", required_argument, 0, 'f' }, + { "filter-normal", no_argument, &filter, 0 }, + { "filter-tv-mode", no_argument, &filter, 1 }, + { "filter-2xsai", no_argument, &filter, 2 }, + { "filter-super-2xsai", no_argument, &filter, 3 }, + { "filter-super-eagle", no_argument, &filter, 4 }, + { "filter-pixelate", no_argument, &filter, 5 }, + { "filter-motion-blur", no_argument, &filter, 6 }, + { "filter-advmame", no_argument, &filter, 7 }, + { "filter-simple2x", no_argument, &filter, 8 }, + { "filter-bilinear", no_argument, &filter, 9 }, + { "filter-bilinear+", no_argument, &filter, 10 }, + { "filter-scanlines", no_argument, &filter, 11 }, + { "filter-hq2x", no_argument, &filter, 12 }, + { "filter-lq2x", no_argument, &filter, 13 }, + { "flash-size", required_argument, 0, 'S' }, + { "flash-64k", no_argument, &sdlFlashSize, 0 }, + { "flash-128k", no_argument, &sdlFlashSize, 1 }, + { "frameskip", required_argument, 0, 's' }, + { "fullscreen", no_argument, &fullscreen, 1 }, + { "gdb", required_argument, 0, 'G' }, + { "help", no_argument, &sdlPrintUsage, 1 }, + { "ifb-none", no_argument, &ifbType, 0 }, + { "ifb-motion-blur", no_argument, &ifbType, 1 }, + { "ifb-smart", no_argument, &ifbType, 2 }, + { "ips", required_argument, 0, 'i' }, + { "no-agb-print", no_argument, &sdlAgbPrint, 0 }, + { "no-auto-frameskip", no_argument, &autoFrameSkip, 0 }, + { "no-debug", no_argument, 0, 'N' }, + { "no-ips", no_argument, &sdlAutoIPS, 0 }, + { "no-mmx", no_argument, &disableMMX, 1 }, + { "no-pause-when-inactive", no_argument, &pauseWhenInactive, 0 }, + { "no-rtc", no_argument, &sdlRtcEnable, 0 }, + { "no-show-speed", no_argument, &showSpeed, 0 }, + { "no-throttle", no_argument, &throttle, 0 }, + { "pause-when-inactive", no_argument, &pauseWhenInactive, 1 }, + { "profile", optional_argument, 0, 'P' }, + { "rtc", no_argument, &sdlRtcEnable, 1 }, + { "save-type", required_argument, 0, 't' }, + { "save-auto", no_argument, &cpuSaveType, 0 }, + { "save-eeprom", no_argument, &cpuSaveType, 1 }, + { "save-sram", no_argument, &cpuSaveType, 2 }, + { "save-flash", no_argument, &cpuSaveType, 3 }, + { "save-sensor", no_argument, &cpuSaveType, 4 }, + { "save-none", no_argument, &cpuSaveType, 5 }, + { "show-speed-normal", no_argument, &showSpeed, 1 }, + { "show-speed-detailed", no_argument, &showSpeed, 2 }, + { "throttle", required_argument, 0, 'T' }, + { "verbose", required_argument, 0, 'v' }, + { "video-1x", no_argument, &sizeOption, 0 }, + { "video-2x", no_argument, &sizeOption, 1 }, + { "video-3x", no_argument, &sizeOption, 2 }, + { "video-4x", no_argument, &sizeOption, 3 }, + { "yuv", required_argument, 0, 'Y' }, + { "recordmovie", required_argument, 0, 'r' }, + { "playmovie", required_argument, 0, 'p' }, + { "watchmovie", required_argument, 0, 'w' }, + { NULL, no_argument, NULL, 0 } +}; + +extern bool CPUIsGBAImage(char *); +extern bool gbIsGameboyRom(char *); + +#ifndef C_CORE +#define SDL_LONG(val) \ + *((u32 *)&sdlStretcher[sdlStretcherPos]) = val;\ + sdlStretcherPos+=4; + +#define SDL_AND_EAX(val) \ + sdlStretcher[sdlStretcherPos++] = 0x25;\ + SDL_LONG(val); + +#define SDL_AND_EBX(val) \ + sdlStretcher[sdlStretcherPos++] = 0x81;\ + sdlStretcher[sdlStretcherPos++] = 0xe3;\ + SDL_LONG(val); + +#define SDL_OR_EAX_EBX \ + sdlStretcher[sdlStretcherPos++] = 0x09;\ + sdlStretcher[sdlStretcherPos++] = 0xd8; + +#define SDL_LOADL_EBX \ + sdlStretcher[sdlStretcherPos++] = 0x8b;\ + sdlStretcher[sdlStretcherPos++] = 0x1f; + +#define SDL_LOADW \ + sdlStretcher[sdlStretcherPos++] = 0x66;\ + sdlStretcher[sdlStretcherPos++] = 0x8b;\ + sdlStretcher[sdlStretcherPos++] = 0x06;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc6;\ + sdlStretcher[sdlStretcherPos++] = 0x02; + +#define SDL_LOADL \ + sdlStretcher[sdlStretcherPos++] = 0x8b;\ + sdlStretcher[sdlStretcherPos++] = 0x06;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc6;\ + sdlStretcher[sdlStretcherPos++] = 0x04; + +#define SDL_LOADL2 \ + sdlStretcher[sdlStretcherPos++] = 0x8b;\ + sdlStretcher[sdlStretcherPos++] = 0x06;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc6;\ + sdlStretcher[sdlStretcherPos++] = 0x03; + +#define SDL_STOREW \ + sdlStretcher[sdlStretcherPos++] = 0x66;\ + sdlStretcher[sdlStretcherPos++] = 0x89;\ + sdlStretcher[sdlStretcherPos++] = 0x07;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc7;\ + sdlStretcher[sdlStretcherPos++] = 0x02; + +#define SDL_STOREL \ + sdlStretcher[sdlStretcherPos++] = 0x89;\ + sdlStretcher[sdlStretcherPos++] = 0x07;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc7;\ + sdlStretcher[sdlStretcherPos++] = 0x04; + +#define SDL_STOREL2 \ + sdlStretcher[sdlStretcherPos++] = 0x89;\ + sdlStretcher[sdlStretcherPos++] = 0x07;\ + sdlStretcher[sdlStretcherPos++] = 0x83;\ + sdlStretcher[sdlStretcherPos++] = 0xc7;\ + sdlStretcher[sdlStretcherPos++] = 0x03; + +#define SDL_RET \ + sdlStretcher[sdlStretcherPos++] = 0xc3; + +#define SDL_PUSH_EAX \ + sdlStretcher[sdlStretcherPos++] = 0x50; + +#define SDL_PUSH_ECX \ + sdlStretcher[sdlStretcherPos++] = 0x51; + +#define SDL_PUSH_EBX \ + sdlStretcher[sdlStretcherPos++] = 0x53; + +#define SDL_PUSH_ESI \ + sdlStretcher[sdlStretcherPos++] = 0x56; + +#define SDL_PUSH_EDI \ + sdlStretcher[sdlStretcherPos++] = 0x57; + +#define SDL_POP_EAX \ + sdlStretcher[sdlStretcherPos++] = 0x58; + +#define SDL_POP_ECX \ + sdlStretcher[sdlStretcherPos++] = 0x59; + +#define SDL_POP_EBX \ + sdlStretcher[sdlStretcherPos++] = 0x5b; + +#define SDL_POP_ESI \ + sdlStretcher[sdlStretcherPos++] = 0x5e; + +#define SDL_POP_EDI \ + sdlStretcher[sdlStretcherPos++] = 0x5f; + +#define SDL_MOV_ECX(val) \ + sdlStretcher[sdlStretcherPos++] = 0xb9;\ + SDL_LONG(val); + +#define SDL_REP_MOVSB \ + sdlStretcher[sdlStretcherPos++] = 0xf3;\ + sdlStretcher[sdlStretcherPos++] = 0xa4; + +#define SDL_REP_MOVSW \ + sdlStretcher[sdlStretcherPos++] = 0xf3;\ + sdlStretcher[sdlStretcherPos++] = 0x66;\ + sdlStretcher[sdlStretcherPos++] = 0xa5; + +#define SDL_REP_MOVSL \ + sdlStretcher[sdlStretcherPos++] = 0xf3;\ + sdlStretcher[sdlStretcherPos++] = 0xa5; + +void sdlMakeStretcher(int width) +{ + sdlStretcherPos = 0; + switch(systemColorDepth) { + case 16: + if(sizeOption) { + SDL_PUSH_EAX; + SDL_PUSH_ESI; + SDL_PUSH_EDI; + for(int i = 0; i < width; i++) { + SDL_LOADW; + SDL_STOREW; + SDL_STOREW; + if(sizeOption > 1) { + SDL_STOREW; + } + if(sizeOption > 2) { + SDL_STOREW; + } + } + SDL_POP_EDI; + SDL_POP_ESI; + SDL_POP_EAX; + SDL_RET; + } else { + SDL_PUSH_ESI; + SDL_PUSH_EDI; + SDL_PUSH_ECX; + SDL_MOV_ECX(width); + SDL_REP_MOVSW; + SDL_POP_ECX; + SDL_POP_EDI; + SDL_POP_ESI; + SDL_RET; + } + break; + case 24: + if(sizeOption) { + SDL_PUSH_EAX; + SDL_PUSH_ESI; + SDL_PUSH_EDI; + int w = width - 1; + for(int i = 0; i < w; i++) { + SDL_LOADL2; + SDL_STOREL2; + SDL_STOREL2; + if(sizeOption > 1) { + SDL_STOREL2; + } + if(sizeOption > 2) { + SDL_STOREL2; + } + } + // need to write the last one + SDL_LOADL2; + SDL_STOREL2; + if(sizeOption > 1) { + SDL_STOREL2; + } + if(sizeOption > 2) { + SDL_STOREL2; + } + SDL_AND_EAX(0x00ffffff); + SDL_PUSH_EBX; + SDL_LOADL_EBX; + SDL_AND_EBX(0xff000000); + SDL_OR_EAX_EBX; + SDL_POP_EBX; + SDL_STOREL2; + SDL_POP_EDI; + SDL_POP_ESI; + SDL_POP_EAX; + SDL_RET; + } else { + SDL_PUSH_ESI; + SDL_PUSH_EDI; + SDL_PUSH_ECX; + SDL_MOV_ECX(3*width); + SDL_REP_MOVSB; + SDL_POP_ECX; + SDL_POP_EDI; + SDL_POP_ESI; + SDL_RET; + } + break; + case 32: + if(sizeOption) { + SDL_PUSH_EAX; + SDL_PUSH_ESI; + SDL_PUSH_EDI; + for(int i = 0; i < width; i++) { + SDL_LOADL; + SDL_STOREL; + SDL_STOREL; + if(sizeOption > 1) { + SDL_STOREL; + } + if(sizeOption > 2) { + SDL_STOREL; + } + } + SDL_POP_EDI; + SDL_POP_ESI; + SDL_POP_EAX; + SDL_RET; + } else { + SDL_PUSH_ESI; + SDL_PUSH_EDI; + SDL_PUSH_ECX; + SDL_MOV_ECX(width); + SDL_REP_MOVSL; + SDL_POP_ECX; + SDL_POP_EDI; + SDL_POP_ESI; + SDL_RET; + } + break; + } +} + +#ifdef _MSC_VER +#define SDL_CALL_STRETCHER \ + {\ + __asm mov eax, stretcher\ + __asm mov edi, dest\ + __asm mov esi, src\ + __asm call eax\ + } +#else +#define SDL_CALL_STRETCHER \ + asm volatile("call *%%eax"::"a" (stretcher),"S" (src),"D" (dest)) +#endif +#else +#define SDL_CALL_STRETCHER \ + sdlStretcher(src, dest) + +void sdlStretch16x1(u8 *src, u8 *dest) +{ + u16 *s = (u16 *)src; + u16 *d = (u16 *)dest; + for(int i = 0; i < srcWidth; i++) + *d++ = *s++; +} + +void sdlStretch16x2(u8 *src, u8 *dest) +{ + u16 *s = (u16 *)src; + u16 *d = (u16 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s++; + } +} + +void sdlStretch16x3(u8 *src, u8 *dest) +{ + u16 *s = (u16 *)src; + u16 *d = (u16 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s; + *d++ = *s++; + } +} + +void sdlStretch16x4(u8 *src, u8 *dest) +{ + u16 *s = (u16 *)src; + u16 *d = (u16 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s; + *d++ = *s; + *d++ = *s++; + } +} + +void (*sdlStretcher16[4])(u8 *, u8 *) = { + sdlStretch16x1, + sdlStretch16x2, + sdlStretch16x3, + sdlStretch16x4 +}; + +void sdlStretch32x1(u8 *src, u8 *dest) +{ + u32 *s = (u32 *)src; + u32 *d = (u32 *)dest; + for(int i = 0; i < srcWidth; i++) + *d++ = *s++; +} + +void sdlStretch32x2(u8 *src, u8 *dest) +{ + u32 *s = (u32 *)src; + u32 *d = (u32 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s++; + } +} + +void sdlStretch32x3(u8 *src, u8 *dest) +{ + u32 *s = (u32 *)src; + u32 *d = (u32 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s; + *d++ = *s++; + } +} + +void sdlStretch32x4(u8 *src, u8 *dest) +{ + u32 *s = (u32 *)src; + u32 *d = (u32 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *s; + *d++ = *s; + *d++ = *s++; + } +} + +void (*sdlStretcher32[4])(u8 *, u8 *) = { + sdlStretch32x1, + sdlStretch32x2, + sdlStretch32x3, + sdlStretch32x4 +}; + +void sdlStretch24x1(u8 *src, u8 *dest) +{ + u8 *s = src; + u8 *d = dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } +} + +void sdlStretch24x2(u8 *src, u8 *dest) +{ + u8 *s = (u8 *)src; + u8 *d = (u8 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + } +} + +void sdlStretch24x3(u8 *src, u8 *dest) +{ + u8 *s = (u8 *)src; + u8 *d = (u8 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + } +} + +void sdlStretch24x4(u8 *src, u8 *dest) +{ + u8 *s = (u8 *)src; + u8 *d = (u8 *)dest; + for(int i = 0; i < srcWidth; i++) { + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + *d++ = *s; + *d++ = *(s+1); + *d++ = *(s+2); + s += 3; + } +} + +void (*sdlStretcher24[4])(u8 *, u8 *) = { + sdlStretch24x1, + sdlStretch24x2, + sdlStretch24x3, + sdlStretch24x4 +}; + +#endif + +u32 sdlFromHex(char *s) +{ + u32 value; + sscanf(s, "%x", &value); + return value; +} + +#ifdef __MSC__ +#define stat _stat +#define S_IFDIR _S_IFDIR +#endif + +void sdlCheckDirectory(char *dir) +{ + struct stat buf; + + int len = strlen(dir); + + char *p = dir + len - 1; + + if(*p == '/' || + *p == '\\') + *p = 0; + + if(stat(dir, &buf) == 0) { + if(!(buf.st_mode & S_IFDIR)) { + fprintf(stderr, "Error: %s is not a directory\n", dir); + dir[0] = 0; + } + } else { + fprintf(stderr, "Error: %s does not exist\n", dir); + dir[0] = 0; + } +} + +char *sdlGetFilename(char *name) +{ + static char filebuffer[2048]; + + int len = strlen(name); + + char *p = name + len - 1; + + while(true) { + if(*p == '/' || + *p == '\\') { + p++; + break; + } + len--; + p--; + if(len == 0) + break; + } + + if(len == 0) + strcpy(filebuffer, name); + else + strcpy(filebuffer, p); + return filebuffer; +} + +FILE *sdlFindFile(const char *name) +{ + char buffer[4096]; + char path[2048]; + +#ifdef WIN32 +#define PATH_SEP ";" +#define FILE_SEP '\\' +#define EXE_NAME "VisualBoyAdvance-SDL.exe" +#else // ! WIN32 +#define PATH_SEP ":" +#define FILE_SEP '/' +#define EXE_NAME "VisualBoyAdvance" +#endif // ! WIN32 + + fprintf(stderr, "Searching for file %s\n", name); + + if(GETCWD(buffer, 2048)) { + fprintf(stderr, "Searching current directory: %s\n", buffer); + } + + FILE *f = fopen(name, "r"); + if(f != NULL) { + return f; + } + + char *home = getenv("HOME"); + + if(home != NULL) { + fprintf(stderr, "Searching home directory: %s\n", home); + sprintf(path, "%s%c%s", home, FILE_SEP, name); + f = fopen(path, "r"); + if(f != NULL) + return f; + } + +#ifdef WIN32 + home = getenv("USERPROFILE"); + if(home != NULL) { + fprintf(stderr, "Searching user profile directory: %s\n", home); + sprintf(path, "%s%c%s", home, FILE_SEP, name); + f = fopen(path, "r"); + if(f != NULL) + return f; + } +#else // ! WIN32 + fprintf(stderr, "Searching system config directory: %s\n", SYSCONFDIR); + sprintf(path, "%s%c%s", SYSCONFDIR, FILE_SEP, name); + f = fopen(path, "r"); + if(f != NULL) + return f; +#endif // ! WIN32 + + if(!strchr(arg0, '/') && + !strchr(arg0, '\\')) { + char *path = getenv("PATH"); + + if(path != NULL) { + fprintf(stderr, "Searching PATH\n"); + strncpy(buffer, path, 4096); + buffer[4095] = 0; + char *tok = strtok(buffer, PATH_SEP); + + while(tok) { + sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME); + f = fopen(path, "r"); + if(f != NULL) { + char path2[2048]; + fclose(f); + sprintf(path2, "%s%c%s", tok, FILE_SEP, name); + f = fopen(path2, "r"); + if(f != NULL) { + fprintf(stderr, "Found at %s\n", path2); + return f; + } + } + tok = strtok(NULL, PATH_SEP); + } + } + } else { + // executable is relative to some directory + fprintf(stderr, "Searching executable directory\n"); + strcpy(buffer, arg0); + char *p = strrchr(buffer, FILE_SEP); + if(p) { + *p = 0; + sprintf(path, "%s%c%s", buffer, FILE_SEP, name); + f = fopen(path, "r"); + if(f != NULL) + return f; + } + } + return NULL; +} + +void sdlReadPreferences(FILE *f) +{ + char buffer[2048]; + + while(1) { + char *s = fgets(buffer, 2048, f); + + if(s == NULL) + break; + + char *p = strchr(s, '#'); + + if(p) + *p = 0; + + char *token = strtok(s, " \t\n\r="); + + if(!token) + continue; + + if(strlen(token) == 0) + continue; + + char *key = token; + char *value = strtok(NULL, "\t\n\r"); + + if(value == NULL) { + fprintf(stderr, "Empty value for key %s\n", key); + continue; + } + + if(!strcmp(key,"Joy0_Left")) { + joypad[0][KEY_LEFT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Right")) { + joypad[0][KEY_RIGHT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Up")) { + joypad[0][KEY_UP] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Down")) { + joypad[0][KEY_DOWN] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_A")) { + joypad[0][KEY_BUTTON_A] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_B")) { + joypad[0][KEY_BUTTON_B] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_L")) { + joypad[0][KEY_BUTTON_L] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_R")) { + joypad[0][KEY_BUTTON_R] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Start")) { + joypad[0][KEY_BUTTON_START] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Select")) { + joypad[0][KEY_BUTTON_SELECT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Speed")) { + joypad[0][KEY_BUTTON_SPEED] = sdlFromHex(value); + } else if(!strcmp(key, "Joy0_Capture")) { + joypad[0][KEY_BUTTON_CAPTURE] = sdlFromHex(value); + } else if(!strcmp(key,"Joy1_Left")) { + joypad[1][KEY_LEFT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Right")) { + joypad[1][KEY_RIGHT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Up")) { + joypad[1][KEY_UP] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Down")) { + joypad[1][KEY_DOWN] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_A")) { + joypad[1][KEY_BUTTON_A] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_B")) { + joypad[1][KEY_BUTTON_B] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_L")) { + joypad[1][KEY_BUTTON_L] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_R")) { + joypad[1][KEY_BUTTON_R] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Start")) { + joypad[1][KEY_BUTTON_START] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Select")) { + joypad[1][KEY_BUTTON_SELECT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Speed")) { + joypad[1][KEY_BUTTON_SPEED] = sdlFromHex(value); + } else if(!strcmp(key, "Joy1_Capture")) { + joypad[1][KEY_BUTTON_CAPTURE] = sdlFromHex(value); + } else if(!strcmp(key,"Joy2_Left")) { + joypad[2][KEY_LEFT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Right")) { + joypad[2][KEY_RIGHT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Up")) { + joypad[2][KEY_UP] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Down")) { + joypad[2][KEY_DOWN] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_A")) { + joypad[2][KEY_BUTTON_A] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_B")) { + joypad[2][KEY_BUTTON_B] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_L")) { + joypad[2][KEY_BUTTON_L] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_R")) { + joypad[2][KEY_BUTTON_R] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Start")) { + joypad[2][KEY_BUTTON_START] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Select")) { + joypad[2][KEY_BUTTON_SELECT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Speed")) { + joypad[2][KEY_BUTTON_SPEED] = sdlFromHex(value); + } else if(!strcmp(key, "Joy2_Capture")) { + joypad[2][KEY_BUTTON_CAPTURE] = sdlFromHex(value); + } else if(!strcmp(key,"Joy4_Left")) { + joypad[4][KEY_LEFT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Right")) { + joypad[4][KEY_RIGHT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Up")) { + joypad[4][KEY_UP] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Down")) { + joypad[4][KEY_DOWN] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_A")) { + joypad[4][KEY_BUTTON_A] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_B")) { + joypad[4][KEY_BUTTON_B] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_L")) { + joypad[4][KEY_BUTTON_L] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_R")) { + joypad[4][KEY_BUTTON_R] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Start")) { + joypad[4][KEY_BUTTON_START] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Select")) { + joypad[4][KEY_BUTTON_SELECT] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Speed")) { + joypad[4][KEY_BUTTON_SPEED] = sdlFromHex(value); + } else if(!strcmp(key, "Joy4_Capture")) { + joypad[4][KEY_BUTTON_CAPTURE] = sdlFromHex(value); + } else if(!strcmp(key, "Motion_Left")) { + motion[KEY_LEFT] = sdlFromHex(value); + } else if(!strcmp(key, "Motion_Right")) { + motion[KEY_RIGHT] = sdlFromHex(value); + } else if(!strcmp(key, "Motion_Up")) { + motion[KEY_UP] = sdlFromHex(value); + } else if(!strcmp(key, "Motion_Down")) { + motion[KEY_DOWN] = sdlFromHex(value); + } else if(!strcmp(key, "frameSkip")) { + frameSkip = sdlFromHex(value); + if(frameSkip < 0 || frameSkip > 9) + frameSkip = 2; + } else if(!strcmp(key, "gbFrameSkip")) { + gbFrameSkip = sdlFromHex(value); + if(gbFrameSkip < 0 || gbFrameSkip > 9) + gbFrameSkip = 0; + } else if(!strcmp(key, "video")) { + sizeOption = sdlFromHex(value); + if(sizeOption < 0 || sizeOption > 3) + sizeOption = 1; + } else if(!strcmp(key, "fullScreen")) { + fullscreen = sdlFromHex(value) ? 1 : 0; + } else if(!strcmp(key, "useBios")) { + useBios = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "skipBios")) { + skipBios = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "biosFile")) { + strcpy(biosFileName, value); + } else if(!strcmp(key, "filter")) { + filter = sdlFromHex(value); + if(filter < 0 || filter > 13) + filter = 0; + } else if(!strcmp(key, "disableStatus")) { + disableStatusMessages = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "borderOn")) { + gbBorderOn = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "borderAutomatic")) { + gbBorderAutomatic = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "emulatorType")) { + gbEmulatorType = sdlFromHex(value); + if(gbEmulatorType < 0 || gbEmulatorType > 5) + gbEmulatorType = 1; + } else if(!strcmp(key, "colorOption")) { + gbColorOption = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "captureDir")) { + sdlCheckDirectory(value); + strcpy(captureDir, value); + } else if(!strcmp(key, "saveDir")) { + sdlCheckDirectory(value); + strcpy(saveDir, value); + } else if(!strcmp(key, "batteryDir")) { + sdlCheckDirectory(value); + strcpy(batteryDir, value); + } else if(!strcmp(key, "captureFormat")) { + captureFormat = sdlFromHex(value); + } else if(!strcmp(key, "soundQuality")) { + soundQuality = sdlFromHex(value); + switch(soundQuality) { + case 1: + case 2: + case 4: + break; + default: + fprintf(stderr, "Unknown sound quality %d. Defaulting to 22Khz\n", + soundQuality); + soundQuality = 2; + break; + } + } else if(!strcmp(key, "soundOff")) { + soundOffFlag = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "soundEnable")) { + int res = sdlFromHex(value) & 0x30f; + soundEnable(res); + soundDisable(~res); + } else if(!strcmp(key, "soundEcho")) { + soundEcho = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "soundLowPass")) { + soundLowPass = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "soundReverse")) { + soundReverse = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "soundVolume")) { + soundVolume = sdlFromHex(value); + if(soundVolume < 0 || soundVolume > 3) + soundVolume = 0; + } else if(!strcmp(key, "removeIntros")) { + removeIntros = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "saveType")) { + cpuSaveType = sdlFromHex(value); + if(cpuSaveType < 0 || cpuSaveType > 5) + cpuSaveType = 0; + } else if(!strcmp(key, "flashSize")) { + sdlFlashSize = sdlFromHex(value); + if(sdlFlashSize != 0 && sdlFlashSize != 1) + sdlFlashSize = 0; + } else if(!strcmp(key, "ifbType")) { + ifbType = sdlFromHex(value); + if(ifbType < 0 || ifbType > 2) + ifbType = 0; + } else if(!strcmp(key, "showSpeed")) { + showSpeed = sdlFromHex(value); + if(showSpeed < 0 || showSpeed > 2) + showSpeed = 1; + } else if(!strcmp(key, "showSpeedTransparent")) { + showSpeedTransparent = sdlFromHex(value); + } else if(!strcmp(key, "autoFrameSkip")) { + autoFrameSkip = sdlFromHex(value); + } else if(!strcmp(key, "throttle")) { + throttle = sdlFromHex(value); + if(throttle != 0 && (throttle < 5 || throttle > 1000)) + throttle = 0; + } else if(!strcmp(key, "disableMMX")) { +#ifdef MMX + cpu_mmx = sdlFromHex(value) ? false : true; +#endif + } else if(!strcmp(key, "pauseWhenInactive")) { + pauseWhenInactive = sdlFromHex(value) ? true : false; + } else if(!strcmp(key, "agbPrint")) { + sdlAgbPrint = sdlFromHex(value); + } else if(!strcmp(key, "rtcEnabled")) { + sdlRtcEnable = sdlFromHex(value); + } else if(!strcmp(key, "rewindTimer")) { + rewindTimer = sdlFromHex(value); + if(rewindTimer < 0 || rewindTimer > 600) + rewindTimer = 0; + rewindTimer *= 6; // convert value to 10 frames multiple + } else if(!strcmp(key, "enhancedDetection")) { + cpuEnhancedDetection = sdlFromHex(value) ? true : false; + } else { + fprintf(stderr, "Unknown configuration key %s\n", key); + } + } +} + +void sdlReadPreferences() +{ + FILE *f = sdlFindFile("VisualBoyAdvance.cfg"); + + if(f == NULL) { + fprintf(stderr, "Configuration file NOT FOUND (using defaults)\n"); + return; + } else + fprintf(stderr, "Reading configuration file.\n"); + + sdlReadPreferences(f); + + fclose(f); +} + +static void sdlApplyPerImagePreferences() +{ + FILE *f = sdlFindFile("vba-over.ini"); + if(!f) { + fprintf(stderr, "vba-over.ini NOT FOUND (using emulator settings)\n"); + return; + } else + fprintf(stderr, "Reading vba-over.ini\n"); + + char buffer[7]; + buffer[0] = '['; + buffer[1] = rom[0xac]; + buffer[2] = rom[0xad]; + buffer[3] = rom[0xae]; + buffer[4] = rom[0xaf]; + buffer[5] = ']'; + buffer[6] = 0; + + char readBuffer[2048]; + + bool found = false; + + while(1) { + char *s = fgets(readBuffer, 2048, f); + + if(s == NULL) + break; + + char *p = strchr(s, ';'); + + if(p) + *p = 0; + + char *token = strtok(s, " \t\n\r="); + + if(!token) + continue; + if(strlen(token) == 0) + continue; + + if(!strcmp(token, buffer)) { + found = true; + break; + } + } + + if(found) { + while(1) { + char *s = fgets(readBuffer, 2048, f); + + if(s == NULL) + break; + + char *p = strchr(s, ';'); + if(p) + *p = 0; + + char *token = strtok(s, " \t\n\r="); + if(!token) + continue; + if(strlen(token) == 0) + continue; + + if(token[0] == '[') // starting another image settings + break; + char *value = strtok(NULL, "\t\n\r="); + if(value == NULL) + continue; + + if(!strcmp(token, "rtcEnabled")) + rtcEnable(atoi(value) == 0 ? false : true); + else if(!strcmp(token, "flashSize")) { + int size = atoi(value); + if(size == 0x10000 || size == 0x20000) + flashSetSize(size); + } else if(!strcmp(token, "saveType")) { + int save = atoi(value); + if(save >= 0 && save <= 5) + cpuSaveType = save; + } + } + } + fclose(f); +} + +static int sdlCalculateShift(u32 mask) +{ + int m = 0; + + while(mask) { + m++; + mask >>= 1; + } + + return m-5; +} + +static int sdlCalculateMaskWidth(u32 mask) +{ + int m = 0; + int mask2 = mask; + + while(mask2) { + m++; + mask2 >>= 1; + } + + int m2 = 0; + mask2 = mask; + while(!(mask2 & 1)) { + m2++; + mask2 >>= 1; + } + + return m - m2; +} + +void sdlWriteState(int num) +{ + char stateName[2048]; + + if(saveDir[0]) + sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename), + num+1); + else + sprintf(stateName,"%s%d.sgm", filename, num+1); + if(emulator.emuWriteState) + emulator.emuWriteState(stateName); + sprintf(stateName, "Wrote state %d", num+1); + systemScreenMessage(stateName); +} + +void sdlReadState(int num) +{ + char stateName[2048]; + + if(saveDir[0]) + sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename), + num+1); + else + sprintf(stateName,"%s%d.sgm", filename, num+1); + + if(emulator.emuReadState) + emulator.emuReadState(stateName); + + sprintf(stateName, "Loaded state %d", num+1); + systemScreenMessage(stateName); +} + +void sdlWriteBattery() +{ + char buffer[1048]; + + if(batteryDir[0]) + sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename)); + else + sprintf(buffer, "%s.sav", filename); + + emulator.emuWriteBattery(buffer); + + systemScreenMessage("Wrote battery"); +} + +void sdlReadBattery() +{ + char buffer[1048]; + + if(batteryDir[0]) + sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename)); + else + sprintf(buffer, "%s.sav", filename); + + bool res = false; + + res = emulator.emuReadBattery(buffer); + + if(res) + systemScreenMessage("Loaded battery"); +} + +#define MOD_KEYS (KMOD_CTRL|KMOD_SHIFT|KMOD_ALT|KMOD_META) +#define MOD_NOCTRL (KMOD_SHIFT|KMOD_ALT|KMOD_META) +#define MOD_NOALT (KMOD_CTRL|KMOD_SHIFT|KMOD_META) +#define MOD_NOSHIFT (KMOD_CTRL|KMOD_ALT|KMOD_META) + +void sdlUpdateKey(int key, bool down) +{ + int i; + for(int j = 0; j < 4; j++) { + for(i = 0 ; i < 12; i++) { + if((joypad[j][i] & 0xf000) == 0) { + if(key == joypad[j][i]) + sdlButtons[j][i] = down; + } + } + } + for(i = 0 ; i < 4; i++) { + if((motion[i] & 0xf000) == 0) { + if(key == motion[i]) + sdlMotionButtons[i] = down; + } + } +} + +void sdlUpdateJoyButton(int which, + int button, + bool pressed) +{ + int i; + for(int j = 0; j < 4; j++) { + for(i = 0; i < 12; i++) { + int dev = (joypad[j][i] >> 12); + int b = joypad[j][i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (b >= 128) && (b == (button+128))) { + sdlButtons[j][i] = pressed; + } + } + } + } + for(i = 0; i < 4; i++) { + int dev = (motion[i] >> 12); + int b = motion[i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (b >= 128) && (b == (button+128))) { + sdlMotionButtons[i] = pressed; + } + } + } +} + +void sdlUpdateJoyHat(int which, + int hat, + int value) +{ + int i; + for(int j = 0; j < 4; j++) { + for(i = 0; i < 12; i++) { + int dev = (joypad[j][i] >> 12); + int a = joypad[j][i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) { + int dir = a & 3; + int v = 0; + switch(dir) { + case 0: + v = value & SDL_HAT_UP; + break; + case 1: + v = value & SDL_HAT_DOWN; + break; + case 2: + v = value & SDL_HAT_RIGHT; + break; + case 3: + v = value & SDL_HAT_LEFT; + break; + } + sdlButtons[j][i] = (v ? true : false); + } + } + } + } + for(i = 0; i < 4; i++) { + int dev = (motion[i] >> 12); + int a = motion[i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) { + int dir = a & 3; + int v = 0; + switch(dir) { + case 0: + v = value & SDL_HAT_UP; + break; + case 1: + v = value & SDL_HAT_DOWN; + break; + case 2: + v = value & SDL_HAT_RIGHT; + break; + case 3: + v = value & SDL_HAT_LEFT; + break; + } + sdlMotionButtons[i] = (v ? true : false); + } + } + } +} + +void sdlUpdateJoyAxis(int which, + int axis, + int value) +{ + int i; + for(int j = 0; j < 4; j++) { + for(i = 0; i < 12; i++) { + int dev = (joypad[j][i] >> 12); + int a = joypad[j][i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (a < 32) && ((a>>1) == axis)) { + sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384); + } + } + } + } + for(i = 0; i < 4; i++) { + int dev = (motion[i] >> 12); + int a = motion[i] & 0xfff; + if(dev) { + dev--; + + if((dev == which) && (a < 32) && ((a>>1) == axis)) { + sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384); + } + } + } +} + +bool sdlCheckJoyKey(int key) +{ + int dev = (key >> 12) - 1; + int what = key & 0xfff; + + if(what >= 128) { + // joystick button + int button = what - 128; + + if(button >= SDL_JoystickNumButtons(sdlDevices[dev])) + return false; + } else if (what < 0x20) { + // joystick axis + what >>= 1; + if(what >= SDL_JoystickNumAxes(sdlDevices[dev])) + return false; + } else if (what < 0x30) { + // joystick hat + what = (what & 15); + what >>= 2; + if(what >= SDL_JoystickNumHats(sdlDevices[dev])) + return false; + } + + // no problem found + return true; +} + +void sdlCheckKeys() +{ + sdlNumDevices = SDL_NumJoysticks(); + + if(sdlNumDevices) + sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices * + sizeof(SDL_Joystick **)); + int i; + + bool usesJoy = false; + + for(int j = 0; j < 4; j++) { + for(i = 0; i < 12; i++) { + int dev = joypad[j][i] >> 12; + if(dev) { + dev--; + bool ok = false; + + if(sdlDevices) { + if(dev < sdlNumDevices) { + if(sdlDevices[dev] == NULL) { + sdlDevices[dev] = SDL_JoystickOpen(dev); + } + + ok = sdlCheckJoyKey(joypad[j][i]); + } else + ok = false; + } + + if(!ok) + joypad[j][i] = defaultJoypad[i]; + else + usesJoy = true; + } + } + } + + for(i = 0; i < 4; i++) { + int dev = motion[i] >> 12; + if(dev) { + dev--; + bool ok = false; + + if(sdlDevices) { + if(dev < sdlNumDevices) { + if(sdlDevices[dev] == NULL) { + sdlDevices[dev] = SDL_JoystickOpen(dev); + } + + ok = sdlCheckJoyKey(motion[i]); + } else + ok = false; + } + + if(!ok) + motion[i] = defaultMotion[i]; + else + usesJoy = true; + } + } + + if(usesJoy) + SDL_JoystickEventState(SDL_ENABLE); +} + +void sdlPollEvents() +{ + SDL_Event event; + while(SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_QUIT: + emulating = 0; + break; + case SDL_ACTIVEEVENT: + if(pauseWhenInactive && (event.active.state & SDL_APPINPUTFOCUS)) { + active = event.active.gain; + if(active) { + if(!paused) { + if(emulating) + soundResume(); + } + } else { + wasPaused = true; + if(pauseWhenInactive) { + if(emulating) + soundPause(); + } + + memset(delta,255,sizeof(delta)); + } + } + break; + case SDL_MOUSEMOTION: + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: + if(fullscreen) { + SDL_ShowCursor(SDL_ENABLE); + mouseCounter = 120; + } + break; + case SDL_JOYHATMOTION: + sdlUpdateJoyHat(event.jhat.which, + event.jhat.hat, + event.jhat.value); + break; + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + sdlUpdateJoyButton(event.jbutton.which, + event.jbutton.button, + event.jbutton.state == SDL_PRESSED); + break; + case SDL_JOYAXISMOTION: + sdlUpdateJoyAxis(event.jaxis.which, + event.jaxis.axis, + event.jaxis.value); + break; + case SDL_KEYDOWN: + sdlUpdateKey(event.key.keysym.sym, true); + break; + case SDL_KEYUP: + switch(event.key.keysym.sym) { + case SDLK_r: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + if(emulating) { + emulator.emuReset(); + + systemScreenMessage("Reset"); + } + } + break; + case SDLK_b: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + if(emulating && emulator.emuReadMemState && rewindMemory + && rewindCount) { + rewindPos = --rewindPos & 7; + emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos], + REWIND_SIZE); + rewindCount--; + rewindCounter = 0; + systemScreenMessage("Rewind"); + } + } + break; + case SDLK_p: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + paused = !paused; + SDL_PauseAudio(paused); + if(paused) + wasPaused = true; + } + break; + case SDLK_ESCAPE: + emulating = 0; + break; + case SDLK_f: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + int flags = 0; + fullscreen = !fullscreen; + if(fullscreen) + flags |= SDL_FULLSCREEN; + SDL_SetVideoMode(destWidth, destHeight, systemColorDepth, flags); + // if(SDL_WM_ToggleFullScreen(surface)) + // fullscreen = !fullscreen; + } + break; + case SDLK_F11: + if(dbgMain != debuggerMain) { + if(armState) { + armNextPC -= 4; + reg[15].I -= 4; + } else { + armNextPC -= 2; + reg[15].I -= 2; + } + } + debugger = true; + break; + case SDLK_F1: + case SDLK_F2: + case SDLK_F3: + case SDLK_F4: + case SDLK_F5: + case SDLK_F6: + case SDLK_F7: + case SDLK_F8: + case SDLK_F9: + case SDLK_F10: + if(!(event.key.keysym.mod & MOD_NOSHIFT) && + (event.key.keysym.mod & KMOD_SHIFT)) { + sdlWriteState(event.key.keysym.sym-SDLK_F1); + } else if(!(event.key.keysym.mod & MOD_KEYS)) { + sdlReadState(event.key.keysym.sym-SDLK_F1); + } + break; + case SDLK_1: + case SDLK_2: + case SDLK_3: + case SDLK_4: + if(!(event.key.keysym.mod & MOD_NOALT) && + (event.key.keysym.mod & KMOD_ALT)) { + char *disableMessages[4] = + { "autofire A disabled", + "autofire B disabled", + "autofire R disabled", + "autofire L disabled"}; + char *enableMessages[4] = + { "autofire A", + "autofire B", + "autofire R", + "autofire L"}; + int mask = 1 << (event.key.keysym.sym - SDLK_1); + if(event.key.keysym.sym > SDLK_2) + mask <<= 6; + if(autoFire & mask) { + autoFire &= ~mask; + systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]); + } else { + autoFire |= mask; + systemScreenMessage(enableMessages[event.key.keysym.sym - SDLK_1]); + } + } if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + int mask = 0x0100 << (event.key.keysym.sym - SDLK_1); + layerSettings ^= mask; + layerEnable = DISPCNT & layerSettings; + CPUUpdateRenderBuffers(false); + } + break; + case SDLK_5: + case SDLK_6: + case SDLK_7: + case SDLK_8: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + int mask = 0x0100 << (event.key.keysym.sym - SDLK_1); + layerSettings ^= mask; + layerEnable = DISPCNT & layerSettings; + } + break; + case SDLK_n: + if(!(event.key.keysym.mod & MOD_NOCTRL) && + (event.key.keysym.mod & KMOD_CTRL)) { + if(paused) + paused = false; + pauseNextFrame = true; + } + break; + default: + break; + } + sdlUpdateKey(event.key.keysym.sym, false); + break; + } + } +} + +void usage(char *cmd) +{ + printf("%s [option ...] file\n", cmd); + printf("\ +\n\ +Options:\n\ + -1, --video-1x 1x\n\ + -2, --video-2x 2x\n\ + -3, --video-3x 3x\n\ + -4, --video-4x 4x\n\ + -F, --fullscreen Full screen\n\ + -G, --gdb=PROTOCOL GNU Remote Stub mode:\n\ + tcp - use TCP at port 55555\n\ + tcp:PORT - use TCP at port PORT\n\ + pipe - use pipe transport\n\ + -N, --no-debug Don't parse debug information\n\ + -S, --flash-size=SIZE Set the Flash size\n\ + --flash-64k 0 - 64K Flash\n\ + --flash-128k 1 - 128K Flash\n\ + -T, --throttle=THROTTLE Set the desired throttle (5...1000)\n\ + -Y, --yuv=TYPE Use YUV overlay for drawing:\n\ + 0 - YV12\n\ + 1 - UYVY\n\ + 2 - YVYU\n\ + 3 - YUY2\n\ + 4 - IYUV\n\ + -b, --bios=BIOS Use given bios file\n\ + -c, --config=FILE Read the given configuration file\n\ + -d, --debug Enter debugger\n\ + -f, --filter=FILTER Select filter:\n\ + --filter-normal 0 - normal mode\n\ + --filter-tv-mode 1 - TV Mode\n\ + --filter-2xsai 2 - 2xSaI\n\ + --filter-super-2xsai 3 - Super 2xSaI\n\ + --filter-super-eagle 4 - Super Eagle\n\ + --filter-pixelate 5 - Pixelate\n\ + --filter-motion-blur 6 - Motion Blur\n\ + --filter-advmame 7 - AdvanceMAME Scale2x\n\ + --filter-simple2x 8 - Simple2x\n\ + --filter-bilinear 9 - Bilinear\n\ + --filter-bilinear+ 10 - Bilinear Plus\n\ + --filter-scanlines 11 - Scanlines\n\ + --filter-hq2x 12 - hq2x\n\ + --filter-lq2x 13 - lq2x\n\ + -h, --help Print this help\n\ + -i, --ips=PATCH Apply given IPS patch\n\ + -P, --profile=[HERTZ] Enable profiling\n\ + -s, --frameskip=FRAMESKIP Set frame skip (0...9)\n\ +"); + printf("\ + -t, --save-type=TYPE Set the available save type\n\ + --save-auto 0 - Automatic (EEPROM, SRAM, FLASH)\n\ + --save-eeprom 1 - EEPROM\n\ + --save-sram 2 - SRAM\n\ + --save-flash 3 - FLASH\n\ + --save-sensor 4 - EEPROM+Sensor\n\ + --save-none 5 - NONE\n\ + -v, --verbose=VERBOSE Set verbose logging (trace.log)\n\ + 1 - SWI\n\ + 2 - Unaligned memory access\n\ + 4 - Illegal memory write\n\ + 8 - Illegal memory read\n\ + 16 - DMA 0\n\ + 32 - DMA 1\n\ + 64 - DMA 2\n\ + 128 - DMA 3\n\ + 256 - Undefined instruction\n\ + 512 - AGBPrint messages\n\ +\n\ +Long options only:\n\ + --agb-print Enable AGBPrint support\n\ + --auto-frameskip Enable auto frameskipping\n\ + --ifb-none No interframe blending\n\ + --ifb-motion-blur Interframe motion blur\n\ + --ifb-smart Smart interframe blending\n\ + --no-agb-print Disable AGBPrint support\n\ + --no-auto-frameskip Disable auto frameskipping\n\ + --no-ips Do not apply IPS patch\n\ + --no-mmx Disable MMX support\n\ + --no-pause-when-inactive Don't pause when inactive\n\ + --no-rtc Disable RTC support\n\ + --no-show-speed Don't show emulation speed\n\ + --no-throttle Disable thrrotle\n\ + --pause-when-inactive Pause when inactive\n\ + --rtc Enable RTC support\n\ + --show-speed-normal Show emulation speed\n\ + --show-speed-detailed Show detailed speed data\n\ +"); + printf("\ + -r, --recordmovie=filename Start recording input movie\n\ + -p, --playmovie=filename Play input movie non-read-only\n\ + -w, --watchmovie=filename Play input movie in read-only mode\n\ +"); +} + +int main(int argc, char **argv) +{ + fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION); + + arg0 = argv[0]; + + captureDir[0] = 0; + saveDir[0] = 0; + batteryDir[0] = 0; + ipsname[0] = 0; + + int op = -1; + + frameSkip = 2; + gbBorderOn = 0; + + parseDebug = true; + + sdlReadPreferences(); + + sdlPrintUsage = 0; + + while((op = getopt_long(argc, + argv, + "FNT:Y:G:D:b:c:df:hi:p::s:t:v:1234", + sdlOptions, + NULL)) != -1) { + switch(op) { + case 0: + // long option already processed by getopt_long + break; + case 'b': + useBios = true; + if(optarg == NULL) { + fprintf(stderr, "Missing BIOS file name\n"); + exit(-1); + } + strcpy(biosFileName, optarg); + break; + case 'c': + { + if(optarg == NULL) { + fprintf(stderr, "Missing config file name\n"); + exit(-1); + } + FILE *f = fopen(optarg, "r"); + if(f == NULL) { + fprintf(stderr, "File not found %s\n", optarg); + exit(-1); + } + sdlReadPreferences(f); + fclose(f); + } + break; + case 'd': + debugger = true; + break; + case 'h': + sdlPrintUsage = 1; + break; + case 'i': + if(optarg == NULL) { + fprintf(stderr, "Missing IPS name\n"); + exit(-1); + strcpy(ipsname, optarg); + } + break; + case 'Y': + yuv = true; + if(optarg) { + yuvType = atoi(optarg); + switch(yuvType) { + case 0: + yuvType = SDL_YV12_OVERLAY; + break; + case 1: + yuvType = SDL_UYVY_OVERLAY; + break; + case 2: + yuvType = SDL_YVYU_OVERLAY; + break; + case 3: + yuvType = SDL_YUY2_OVERLAY; + break; + case 4: + yuvType = SDL_IYUV_OVERLAY; + break; + default: + yuvType = SDL_YV12_OVERLAY; + } + } else + yuvType = SDL_YV12_OVERLAY; + break; + case 'G': + dbgMain = remoteStubMain; + dbgSignal = remoteStubSignal; + dbgOutput = remoteOutput; + debugger = true; + debuggerStub = true; + if(optarg) { + char *s = optarg; + if(strncmp(s,"tcp:", 4) == 0) { + s+=4; + int port = atoi(s); + remoteSetProtocol(0); + remoteSetPort(port); + } else if(strcmp(s,"tcp") == 0) { + remoteSetProtocol(0); + } else if(strcmp(s, "pipe") == 0) { + remoteSetProtocol(1); + } else { + fprintf(stderr, "Unknown protocol %s\n", s); + exit(-1); + } + } else { + remoteSetProtocol(0); + } + break; + case 'N': + parseDebug = false; + break; + case 'D': + if(optarg) { + systemDebug = atoi(optarg); + } else { + systemDebug = 1; + } + break; + case 'F': + fullscreen = 1; + mouseCounter = 120; + break; + case 'f': + if(optarg) { + filter = atoi(optarg); + } else { + filter = 0; + } + break; + + case 'r': + if(optarg == NULL) { + fprintf(stderr, "ERROR: --recordMovie ('r') needs movie filename as option\n"); + exit(-1); + } + strcpy(movieFileName, optarg); + useMovie = 1; + break; + case 'p': // play without read-only (editable) + if(optarg == NULL) { + fprintf(stderr, "ERROR: --playMovie ('p') needs movie filename as option\n"); + exit(-1); + } + strcpy(movieFileName, optarg); + useMovie = 2; + break; + case 'w': // play with read-only + if(optarg == NULL) { + fprintf(stderr, "ERROR: --watchMovie ('w') needs movie filename as option\n"); + exit(-1); + } + strcpy(movieFileName, optarg); + useMovie = 3; + break; + + case 'P': +#ifdef PROFILING + if(optarg) { + cpuEnableProfiling(atoi(optarg)); + } else + cpuEnableProfiling(100); +#endif + break; + case 'S': + sdlFlashSize = atoi(optarg); + if(sdlFlashSize < 0 || sdlFlashSize > 1) + sdlFlashSize = 0; + break; + case 's': + if(optarg) { + int a = atoi(optarg); + if(a >= 0 && a <= 9) { + gbFrameSkip = a; + frameSkip = a; + } + } else { + frameSkip = 2; + gbFrameSkip = 0; + } + break; + case 't': + if(optarg) { + int a = atoi(optarg); + if(a < 0 || a > 5) + a = 0; + cpuSaveType = a; + } + break; + case 'T': + if(optarg) { + int t = atoi(optarg); + if(t < 5 || t > 1000) + t = 0; + throttle = t; + } + break; + case 'v': + if(optarg) { + systemVerbose = atoi(optarg); + } else + systemVerbose = 0; + break; + case '1': + sizeOption = 0; + break; + case '2': + sizeOption = 1; + break; + case '3': + sizeOption = 2; + break; + case '4': + sizeOption = 3; + break; + case '?': + sdlPrintUsage = 1; + break; + } + } + + if(sdlPrintUsage) { + usage(argv[0]); + exit(-1); + } + +#ifdef MMX + if(disableMMX) + cpu_mmx = 0; +#endif + + if(rewindTimer) + rewindMemory = (char *)malloc(8*REWIND_SIZE); + + if(sdlFlashSize == 0) + flashSetSize(0x10000); + else + flashSetSize(0x20000); + + rtcEnable(sdlRtcEnable ? true : false); + agbPrintEnable(sdlAgbPrint ? true : false); + + if(!debuggerStub) { + if(optind >= argc) { + systemMessage(0,"Missing image name"); + usage(argv[0]); + exit(-1); + } + } + + if(filter) { + sizeOption = 1; + } + + for(int i = 0; i < 24;) { + systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); + systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + systemGbPalette[i++] = 0; + } + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + if(optind < argc) { + char *szFile = argv[optind]; + + utilGetBaseName(szFile, filename); + char *p = strrchr(filename, '.'); + + if(p) + *p = 0; + + if(ipsname[0] == 0) + sprintf(ipsname, "%s.ips", filename); + + bool failed = false; + + IMAGE_TYPE type = utilFindType(szFile); + + if(type == IMAGE_UNKNOWN) { + systemMessage(0, "Unknown file type %s", szFile); + exit(-1); + } + cartridgeType = (int)type; + + if(type == IMAGE_GB) { + failed = !gbLoadRom(szFile); + if(!failed) { + cartridgeType = 1; + emulator = GBSystem; + if(sdlAutoIPS) { + int size = gbRomSize; + utilApplyIPS(ipsname, &gbRom, &size); + if(size != gbRomSize) { + extern bool gbUpdateSizes(); + gbUpdateSizes(); + gbReset(); + } + } + } + } else if(type == IMAGE_GBA) { + int size = CPULoadRom(szFile); + failed = (size == 0); + if(!failed) { + // if(cpuEnhancedDetection && cpuSaveType == 0) { + // utilGBAFindSave(rom, size); + // } + + sdlApplyPerImagePreferences(); + + cartridgeType = 0; + emulator = GBASystem; + + /* disabled due to problems + if(removeIntros && rom != NULL) { + WRITE32LE(&rom[0], 0xea00002e); + } + */ + + CPUInit(biosFileName, useBios); + CPUReset(); + if(sdlAutoIPS) { + int size = 0x2000000; + utilApplyIPS(ipsname, &rom, &size); + if(size != 0x2000000) { + CPUReset(); + } + } + } + } + + if(failed) { + systemMessage(0, "Failed to load file %s", szFile); + exit(-1); + } + } else { + cartridgeType = 0; + strcpy(filename, "gnu_stub"); + rom = (u8 *)malloc(0x2000000); + workRAM = (u8 *)calloc(1, 0x40000); + bios = (u8 *)calloc(1,0x4000); + internalRAM = (u8 *)calloc(1,0x8000); + paletteRAM = (u8 *)calloc(1,0x400); + vram = (u8 *)calloc(1, 0x20000); + oam = (u8 *)calloc(1, 0x400); + pix = (u8 *)calloc(1, 4 * 240 * 160); + ioMem = (u8 *)calloc(1, 0x400); + + emulator = GBASystem; + + CPUInit(biosFileName, useBios); + CPUReset(); + } + + sdlReadBattery(); + + if(debuggerStub) + remoteInit(); + + int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO| + SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE; + + if(soundOffFlag) + flags ^= SDL_INIT_AUDIO; + + if(SDL_Init(flags)) { + systemMessage(0, "Failed to init SDL: %s", SDL_GetError()); + exit(-1); + } + + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)) { + systemMessage(0, "Failed to init joystick support: %s", SDL_GetError()); + } + + sdlCheckKeys(); + + if(cartridgeType == 0) { + srcWidth = 240; + srcHeight = 160; + systemFrameSkip = frameSkip; + } else if (cartridgeType == 1) { + if(gbBorderOn) { + srcWidth = 256; + srcHeight = 224; + gbBorderLineSkip = 256; + gbBorderColumnSkip = 48; + gbBorderRowSkip = 40; + } else { + srcWidth = 160; + srcHeight = 144; + gbBorderLineSkip = 160; + gbBorderColumnSkip = 0; + gbBorderRowSkip = 0; + } + systemFrameSkip = gbFrameSkip; + } else { + srcWidth = 320; + srcHeight = 240; + } + + destWidth = (sizeOption+1)*srcWidth; + destHeight = (sizeOption+1)*srcHeight; + + surface = SDL_SetVideoMode(destWidth, destHeight, 16, + SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF| + (fullscreen ? SDL_FULLSCREEN : 0)); + + if(surface == NULL) { + systemMessage(0, "Failed to set video mode"); + SDL_Quit(); + exit(-1); + } + + systemRedShift = sdlCalculateShift(surface->format->Rmask); + systemGreenShift = sdlCalculateShift(surface->format->Gmask); + systemBlueShift = sdlCalculateShift(surface->format->Bmask); + + systemColorDepth = surface->format->BitsPerPixel; + if(systemColorDepth == 15) + systemColorDepth = 16; + + if(yuv) { + Init_Overlay(surface, yuvType); + systemColorDepth = 32; + systemRedShift = 3; + systemGreenShift = 11; + systemBlueShift = 19; + } + + if(systemColorDepth != 16 && systemColorDepth != 24 && + systemColorDepth != 32) { + fprintf(stderr,"Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth); + exit(-1); + } + +#ifndef C_CORE + sdlMakeStretcher(srcWidth); +#else + switch(systemColorDepth) { + case 16: + sdlStretcher = sdlStretcher16[sizeOption]; + break; + case 24: + sdlStretcher = sdlStretcher24[sizeOption]; + break; + case 32: + sdlStretcher = sdlStretcher32[sizeOption]; + break; + default: + fprintf(stderr, "Unsupported resolution: %d\n", systemColorDepth); + exit(-1); + } +#endif + + fprintf(stderr,"Color depth: %d\n", systemColorDepth); + + if(systemColorDepth == 16) { + if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) { + Init_2xSaI(565); + RGB_LOW_BITS_MASK = 0x821; + } else { + Init_2xSaI(555); + RGB_LOW_BITS_MASK = 0x421; + } + if(cartridgeType == 2) { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) | + (((i & 0x7c0) >> 6) << systemGreenShift) | + (((i & 0xf800) >> 11) << systemRedShift); + } + } else { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + srcPitch = srcWidth * 2+4; + } else { + if(systemColorDepth != 32) + filterFunction = NULL; + RGB_LOW_BITS_MASK = 0x010101; + if(systemColorDepth == 32) { + Init_2xSaI(32); + } + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + if(systemColorDepth == 32) + srcPitch = srcWidth*4 + 4; + else + srcPitch = srcWidth*3; + } + + if(systemColorDepth != 32) { + switch(filter) { + case 0: + filterFunction = NULL; + break; + case 1: + filterFunction = ScanlinesTV; + break; + case 2: + filterFunction = _2xSaI; + break; + case 3: + filterFunction = Super2xSaI; + break; + case 4: + filterFunction = SuperEagle; + break; + case 5: + filterFunction = Pixelate; + break; + case 6: + filterFunction = MotionBlur; + break; + case 7: + filterFunction = AdMame2x; + break; + case 8: + filterFunction = Simple2x; + break; + case 9: + filterFunction = Bilinear; + break; + case 10: + filterFunction = BilinearPlus; + break; + case 11: + filterFunction = Scanlines; + break; + case 12: + filterFunction = hq2x; + break; + case 13: + filterFunction = lq2x; + break; + default: + filterFunction = NULL; + break; + } + } else { + switch(filter) { + case 0: + filterFunction = NULL; + break; + case 1: + filterFunction = ScanlinesTV32; + break; + case 2: + filterFunction = _2xSaI32; + break; + case 3: + filterFunction = Super2xSaI32; + break; + case 4: + filterFunction = SuperEagle32; + break; + case 5: + filterFunction = Pixelate32; + break; + case 6: + filterFunction = MotionBlur32; + break; + case 7: + filterFunction = AdMame2x32; + break; + case 8: + filterFunction = Simple2x32; + break; + case 9: + filterFunction = Bilinear32; + break; + case 10: + filterFunction = BilinearPlus32; + break; + case 11: + filterFunction = Scanlines32; + break; + case 12: + filterFunction = hq2x32; + break; + case 13: + filterFunction = lq2x32; + break; + default: + filterFunction = NULL; + break; + } + } + + if(systemColorDepth == 16) { + switch(ifbType) { + case 0: + default: + ifbFunction = NULL; + break; + case 1: + ifbFunction = MotionBlurIB; + break; + case 2: + ifbFunction = SmartIB; + break; + } + } else if(systemColorDepth == 32) { + switch(ifbType) { + case 0: + default: + ifbFunction = NULL; + break; + case 1: + ifbFunction = MotionBlurIB32; + break; + case 2: + ifbFunction = SmartIB32; + break; + } + } else + ifbFunction = NULL; + + if(delta == NULL) { + delta = (u8*)malloc(322*242*4); + memset(delta, 255, 322*242*4); + } + + emulating = 1; + renderedFrames = 0; + + if(!soundOffFlag) + soundInit(); + + autoFrameSkipLastTime = throttleLastTime = systemGetClock(); + + switch(useMovie) + { + case 1: // --recordMovie + VBAMovieCreate(movieFileName, + /*authorInfo*/"", + /*startFlags*/0, + /*controllerFlags*/MOVIE_CONTROLLER(0), + /*typeFlags*/(cartridgeType==IMAGE_GBA)?(MOVIE_TYPE_GBA):(GBC_CAPABLE?MOVIE_TYPE_GBC:MOVIE_TYPE_SGB)); + break; + case 2: // --playMovie + VBAMovieOpen(movieFileName, false); + break; + case 3: // --watchMovie + VBAMovieOpen(movieFileName, true); + break; + default: + break; + } + + SDL_WM_SetCaption("VisualBoyAdvance", NULL); + + while(emulating) { + if(!paused && active) { + if(debugger && emulator.emuHasDebugger) + dbgMain(); + else { + emulator.emuMain(emulator.emuCount); + if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) { + rewindCount++; + if(rewindCount > 8) + rewindCount = 8; + if(emulator.emuWriteMemState && + emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], + REWIND_SIZE)) { + rewindPos = ++rewindPos & 7; + if(rewindCount == 8) + rewindTopPos = ++rewindTopPos & 7; + } + } + + rewindSaveNeeded = false; + } + } else { + SDL_Delay(500); + } + sdlPollEvents(); + if(mouseCounter) { + mouseCounter--; + if(mouseCounter == 0) + SDL_ShowCursor(SDL_DISABLE); + } + } + + emulating = 0; + fprintf(stderr,"Shutting down\n"); + remoteCleanUp(); + soundShutdown(); + + if(gbRom != NULL || rom != NULL) { + sdlWriteBattery(); + emulator.emuCleanUp(); + } + + if(delta) { + free(delta); + delta = NULL; + } + + SDL_Quit(); + return 0; +} + +void systemMessage(int num, const char *msg, ...) +{ + char buffer[2048]; + va_list valist; + + va_start(valist, msg); + vsprintf(buffer, msg, valist); + + fprintf(stderr, "%s\n", buffer); + va_end(valist); +} + +void systemDrawScreen() +{ + renderedFrames++; + + if(yuv) { + Draw_Overlay(surface, sizeOption+1); + return; + } + + SDL_LockSurface(surface); + + for(int slot = 0 ; slot < 8 ; slot++) + { + if(screenMessage[slot]) { + if(cartridgeType == 1 && gbBorderOn) { + gbSgbRenderBorder(); + } + if(((systemGetClock() - screenMessageTime[slot]) < screenMessageDuration[slot]) && + !disableStatusMessages) { + drawText(pix, srcPitch, 10, srcHeight - 20*(slot+1), + screenMessageBuffer[slot]); + } else { + screenMessage[slot] = false; + } + } + } + + if(ifbFunction) { + if(systemColorDepth == 16) + ifbFunction(pix+destWidth+4, destWidth+4, srcWidth, srcHeight); + else + ifbFunction(pix+destWidth*2+4, destWidth*2+4, srcWidth, srcHeight); + } + + if(filterFunction) { + if(systemColorDepth == 16) + filterFunction(pix+destWidth+4,destWidth+4, delta, + (u8*)surface->pixels,surface->pitch, + srcWidth, + srcHeight); + else + filterFunction(pix+destWidth*2+4, + destWidth*2+4, + delta, + (u8*)surface->pixels, + surface->pitch, + srcWidth, + srcHeight); + } else { + int destPitch = surface->pitch; + u8 *src = pix; + u8 *dest = (u8*)surface->pixels; + int i; + u32 *stretcher = (u32 *)sdlStretcher; + if(systemColorDepth == 16) + src += srcPitch; + int option = sizeOption; + if(yuv) + option = 0; + switch(sizeOption) { + case 0: + for(i = 0; i < srcHeight; i++) { + SDL_CALL_STRETCHER; + src += srcPitch; + dest += destPitch; + } + break; + case 1: + for(i = 0; i < srcHeight; i++) { + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + src += srcPitch; + dest += destPitch; + } + break; + case 2: + for(i = 0; i < srcHeight; i++) { + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + src += srcPitch; + dest += destPitch; + } + break; + case 3: + for(i = 0; i < srcHeight; i++) { + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + dest += destPitch; + SDL_CALL_STRETCHER; + src += srcPitch; + dest += destPitch; + } + break; + } + } + + if(showSpeed && fullscreen) { + char buffer[50]; + if(showSpeed == 1) + sprintf(buffer, "%d%%", systemSpeed); + else + sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + showRenderedFrames); + if(showSpeedTransparent) + drawTextTransp((u8*)surface->pixels, + surface->pitch, + 10, + surface->h-20, + buffer); + else + drawText((u8*)surface->pixels, + surface->pitch, + 10, + surface->h-20, + buffer); + } + + SDL_UnlockSurface(surface); + // SDL_UpdateRect(surface, 0, 0, destWidth, destHeight); + SDL_Flip(surface); +} + +bool systemReadJoypads() +{ + return true; +} + +u32 systemReadJoypad(int which, bool sensor) +{ + if(which < 0 || which > 3) + which = sdlDefaultJoypad; + + u32 res = 0; + + if(sdlButtons[which][KEY_BUTTON_A]) + res |= 1; + if(sdlButtons[which][KEY_BUTTON_B]) + res |= 2; + if(sdlButtons[which][KEY_BUTTON_SELECT]) + res |= 4; + if(sdlButtons[which][KEY_BUTTON_START]) + res |= 8; + if(sdlButtons[which][KEY_RIGHT]) + res |= 16; + if(sdlButtons[which][KEY_LEFT]) + res |= 32; + if(sdlButtons[which][KEY_UP]) + res |= 64; + if(sdlButtons[which][KEY_DOWN]) + res |= 128; + if(sdlButtons[which][KEY_BUTTON_R]) + res |= 256; + if(sdlButtons[which][KEY_BUTTON_L]) + res |= 512; +/* + // disallow L+R or U+D of being pressed at the same time + if((res & 48) == 48) + res &= ~16; + if((res & 192) == 192) + res &= ~128; +*/ + if(sdlButtons[which][KEY_BUTTON_SPEED]) + res |= 1024; + if(sdlButtons[which][KEY_BUTTON_CAPTURE]) + res |= 2048; + + if(autoFire) { + res &= (~autoFire); + if(autoFireToggle) + res |= autoFire; + autoFireToggle = !autoFireToggle; + } + + return res; +} + +void systemWriteJoypad(int which, u32 buttons) +{ + if(which < 0 || which > 3) + which = sdlDefaultJoypad; + + sdlButtons[which][KEY_BUTTON_A] = (buttons & 1) != 0; + sdlButtons[which][KEY_BUTTON_B] = (buttons & 2) != 0; + sdlButtons[which][KEY_BUTTON_SELECT] = (buttons & 4) != 0; + sdlButtons[which][KEY_BUTTON_START] = (buttons & 8) != 0; + sdlButtons[which][KEY_RIGHT] = (buttons & 16) != 0; + sdlButtons[which][KEY_LEFT] = (buttons & 32) != 0; + sdlButtons[which][KEY_UP] = (buttons & 64) != 0; + sdlButtons[which][KEY_DOWN] = (buttons & 128) != 0; + sdlButtons[which][KEY_BUTTON_R] = (buttons & 256) != 0; + sdlButtons[which][KEY_BUTTON_L] = (buttons & 512) != 0; +} + +void systemSetTitle(const char *title) +{ + SDL_WM_SetCaption(title, NULL); +} + +void systemShowSpeed(int speed) +{ + systemSpeed = speed; + + showRenderedFrames = renderedFrames; + renderedFrames = 0; + + if(!fullscreen && showSpeed) { + char buffer[80]; + if(showSpeed == 1) + sprintf(buffer, "VisualBoyAdvance-%3d%%", systemSpeed); + else + sprintf(buffer, "VisualBoyAdvance-%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + showRenderedFrames); + + systemSetTitle(buffer); + } +} + +void systemFrame() +{ +} + +void system10Frames(int rate) +{ + u32 time = systemGetClock(); + if(!wasPaused && autoFrameSkip && !throttle) { + u32 diff = time - autoFrameSkipLastTime; + int speed = 100; + + if(diff) + speed = (1000000/rate)/diff; + + if(speed >= 98) { + frameskipadjust++; + + if(frameskipadjust >= 3) { + frameskipadjust=0; + if(systemFrameSkip > 0) + systemFrameSkip--; + } + } else { + if(speed < 80) + frameskipadjust -= (90 - speed)/5; + else if(systemFrameSkip < 9) + frameskipadjust--; + + if(frameskipadjust <= -2) { + frameskipadjust += 2; + if(systemFrameSkip < 9) + systemFrameSkip++; + } + } + } + if(!wasPaused && throttle) { + if(!speedup) { + u32 diff = time - throttleLastTime; + + int target = (1000000/(rate*throttle)); + int d = (target - diff); + + if(d > 0) { + SDL_Delay(d); + } + } + throttleLastTime = systemGetClock(); + } + if(rewindMemory) { + if(++rewindCounter >= rewindTimer) { + rewindSaveNeeded = true; + rewindCounter = 0; + } + } + + if(systemSaveUpdateCounter) { + if(--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED) { + sdlWriteBattery(); + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + } + } + + wasPaused = false; + autoFrameSkipLastTime = time; +} + +void systemScreenCapture(int a) +{ + char buffer[2048]; + + if(captureFormat) { + if(captureDir[0]) + sprintf(buffer, "%s/%s%02d.bmp", captureDir, sdlGetFilename(filename), a); + else + sprintf(buffer, "%s%02d.bmp", filename, a); + + emulator.emuWriteBMP(buffer); + } else { + if(captureDir[0]) + sprintf(buffer, "%s/%s%02d.png", captureDir, sdlGetFilename(filename), a); + else + sprintf(buffer, "%s%02d.png", filename, a); + emulator.emuWritePNG(buffer); + } + + systemScreenMessage("Screen capture"); +} + +void soundCallback(void *,u8 *stream,int len) +{ + if(!emulating) + return; + SDL_mutexP(mutex); + // printf("Locked mutex\n"); + if(!speedup && !throttle) { + while(sdlSoundLen < 2048*2) { + if(emulating) + SDL_CondWait(cond, mutex); + else + break; + } + } + if(emulating) { + // printf("Copying data\n"); + memcpy(stream, sdlBuffer, len); + } + sdlSoundLen = 0; + if(mutex) + SDL_mutexV(mutex); +} + +void systemWriteDataToSoundBuffer() +{ + if(SDL_GetAudioStatus() != SDL_AUDIO_PLAYING) + SDL_PauseAudio(0); + bool cont = true; + while(cont && !speedup && !throttle) { + SDL_mutexP(mutex); + // printf("Waiting for len < 2048 (speed up %d)\n", speedup); + if(sdlSoundLen < 2048*2) + cont = false; + SDL_mutexV(mutex); + } + + int len = soundBufferLen; + int copied = 0; + if((sdlSoundLen+len) >= 2048*2) { + // printf("Case 1\n"); + memcpy(&sdlBuffer[sdlSoundLen],soundFinalWave, 2048*2-sdlSoundLen); + copied = 2048*2 - sdlSoundLen; + sdlSoundLen = 2048*2; + SDL_CondSignal(cond); + cont = true; + if(!speedup && !throttle) { + while(cont) { + SDL_mutexP(mutex); + if(sdlSoundLen < 2048*2) + cont = false; + SDL_mutexV(mutex); + } + memcpy(&sdlBuffer[0],&(((u8 *)soundFinalWave)[copied]), + soundBufferLen-copied); + sdlSoundLen = soundBufferLen-copied; + } else { + memcpy(&sdlBuffer[0], &(((u8 *)soundFinalWave)[copied]), +soundBufferLen); + } + } else { + // printf("case 2\n"); + memcpy(&sdlBuffer[sdlSoundLen], soundFinalWave, soundBufferLen); + sdlSoundLen += soundBufferLen; + } +} + +bool systemSoundInit() +{ + SDL_AudioSpec audio; + + switch(soundQuality) { + case 1: + audio.freq = 44100; + soundBufferLen = 1470*2; + break; + case 2: + audio.freq = 22050; + soundBufferLen = 736*2; + break; + case 4: + audio.freq = 11025; + soundBufferLen = 368*2; + break; + } + audio.format=AUDIO_S16SYS; + audio.channels = 2; + audio.samples = 1024; + audio.callback = soundCallback; + audio.userdata = NULL; + if(SDL_OpenAudio(&audio, NULL)) { + fprintf(stderr,"Failed to open audio: %s\n", SDL_GetError()); + return false; + } + soundBufferTotalLen = soundBufferLen*10; + cond = SDL_CreateCond(); + mutex = SDL_CreateMutex(); + sdlSoundLen = 0; + systemSoundOn = true; + return true; +} + +void systemSoundShutdown() +{ + SDL_mutexP(mutex); + SDL_CondSignal(cond); + SDL_mutexV(mutex); + SDL_DestroyCond(cond); + cond = NULL; + SDL_DestroyMutex(mutex); + mutex = NULL; + SDL_CloseAudio(); +} + +void systemSoundPause() +{ + SDL_PauseAudio(1); +} + +void systemSoundResume() +{ + SDL_PauseAudio(0); +} + +void systemSoundReset() +{ +} + +u32 systemGetClock() +{ + return SDL_GetTicks(); +} + +void systemUpdateMotionSensor() +{ + if(sdlMotionButtons[KEY_LEFT]) { + sensorX += 3; + if(sensorX > 2197) + sensorX = 2197; + if(sensorX < 2047) + sensorX = 2057; + } else if(sdlMotionButtons[KEY_RIGHT]) { + sensorX -= 3; + if(sensorX < 1897) + sensorX = 1897; + if(sensorX > 2047) + sensorX = 2037; + } else if(sensorX > 2047) { + sensorX -= 2; + if(sensorX < 2047) + sensorX = 2047; + } else { + sensorX += 2; + if(sensorX > 2047) + sensorX = 2047; + } + + if(sdlMotionButtons[KEY_UP]) { + sensorY += 3; + if(sensorY > 2197) + sensorY = 2197; + if(sensorY < 2047) + sensorY = 2057; + } else if(sdlMotionButtons[KEY_DOWN]) { + sensorY -= 3; + if(sensorY < 1897) + sensorY = 1897; + if(sensorY > 2047) + sensorY = 2037; + } else if(sensorY > 2047) { + sensorY -= 2; + if(sensorY < 2047) + sensorY = 2047; + } else { + sensorY += 2; + if(sensorY > 2047) + sensorY = 2047; + } +} + +int systemGetSensorX() +{ + return sensorX; +} + +int systemGetSensorY() +{ + return sensorY; +} + +void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast) +{ +} + +void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList) +{ + screenMessage[slot] = true; + screenMessageTime[slot] = systemGetClock(); + screenMessageDuration[slot] = duration; + if(strlen(msg) > 20) { + strncpy(screenMessageBuffer[slot], msg, 20); + screenMessageBuffer[slot][20] = 0; + } else + strcpy(screenMessageBuffer[slot], msg); +} + +bool systemCanChangeSoundQuality() +{ + return false; +} + +bool systemPauseOnFrame() +{ + if(pauseNextFrame) { + paused = true; + pauseNextFrame = false; + return true; + } + return false; +} + +// Code donated by Niels Wagenaar (BoycottAdvance) + +// GBA screensize. +#define GBA_WIDTH 240 +#define GBA_HEIGHT 160 + +void Init_Overlay(SDL_Surface *gbascreen, int overlaytype) +{ + + overlay = SDL_CreateYUVOverlay( GBA_WIDTH, + GBA_HEIGHT, + overlaytype, gbascreen); + fprintf(stderr, "Created %dx%dx%d %s %s overlay\n", + overlay->w,overlay->h,overlay->planes, + overlay->hw_overlay?"hardware":"software", + overlay->format==SDL_YV12_OVERLAY?"YV12": + overlay->format==SDL_IYUV_OVERLAY?"IYUV": + overlay->format==SDL_YUY2_OVERLAY?"YUY2": + overlay->format==SDL_UYVY_OVERLAY?"UYVY": + overlay->format==SDL_YVYU_OVERLAY?"YVYU": + "Unknown"); +} + +void Quit_Overlay(void) +{ + + SDL_FreeYUVOverlay(overlay); +} + +/* NOTE: These RGB conversion functions are not intended for speed, + only as examples. +*/ +inline void RGBtoYUV(Uint8 *rgb, int *yuv) +{ + yuv[0] = (int)((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16); + yuv[1] = (int)(128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2])); + yuv[2] = (int)(128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2])); +} + +inline void ConvertRGBtoYV12(SDL_Overlay *o) +{ + int x,y; + int yuv[3]; + Uint8 *p,*op[3]; + + SDL_LockYUVOverlay(o); + + /* Black initialization */ + /* + memset(o->pixels[0],0,o->pitches[0]*o->h); + memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); + memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); + */ + + /* Convert */ + for(y=0; y<160 && yh; y++) { + p=(Uint8 *)pix+srcPitch*y; + op[0]=o->pixels[0]+o->pitches[0]*y; + op[1]=o->pixels[1]+o->pitches[1]*(y/2); + op[2]=o->pixels[2]+o->pitches[2]*(y/2); + for(x=0; x<240 && xw; x++) { + RGBtoYUV(p,yuv); + *(op[0]++)=yuv[0]; + if(x%2==0 && y%2==0) { + *(op[1]++)=yuv[2]; + *(op[2]++)=yuv[1]; + } + p+=4;//s->format->BytesPerPixel; + } + } + + SDL_UnlockYUVOverlay(o); +} + +inline void ConvertRGBtoIYUV(SDL_Overlay *o) +{ + int x,y; + int yuv[3]; + Uint8 *p,*op[3]; + + SDL_LockYUVOverlay(o); + + /* Black initialization */ + /* + memset(o->pixels[0],0,o->pitches[0]*o->h); + memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2)); + memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); + */ + + /* Convert */ + for(y=0; y<160 && yh; y++) { + p=(Uint8 *)pix+srcPitch*y; + op[0]=o->pixels[0]+o->pitches[0]*y; + op[1]=o->pixels[1]+o->pitches[1]*(y/2); + op[2]=o->pixels[2]+o->pitches[2]*(y/2); + for(x=0; x<240 && xw; x++) { + RGBtoYUV(p,yuv); + *(op[0]++)=yuv[0]; + if(x%2==0 && y%2==0) { + *(op[1]++)=yuv[1]; + *(op[2]++)=yuv[2]; + } + p+=4; //s->format->BytesPerPixel; + } + } + + SDL_UnlockYUVOverlay(o); +} + +inline void ConvertRGBtoUYVY(SDL_Overlay *o) +{ + int x,y; + int yuv[3]; + Uint8 *p,*op; + + SDL_LockYUVOverlay(o); + + for(y=0; y<160 && yh; y++) { + p=(Uint8 *)pix+srcPitch*y; + op=o->pixels[0]+o->pitches[0]*y; + for(x=0; x<240 && xw; x++) { + RGBtoYUV(p,yuv); + if(x%2==0) { + *(op++)=yuv[1]; + *(op++)=yuv[0]; + *(op++)=yuv[2]; + } else + *(op++)=yuv[0]; + + p+=4; //s->format->BytesPerPixel; + } + } + + SDL_UnlockYUVOverlay(o); +} + +inline void ConvertRGBtoYVYU(SDL_Overlay *o) +{ + int x,y; + int yuv[3]; + Uint8 *p,*op; + + SDL_LockYUVOverlay(o); + + for(y=0; y<160 && yh; y++) { + p=(Uint8 *)pix+srcPitch*y; + op=o->pixels[0]+o->pitches[0]*y; + for(x=0; x<240 && xw; x++) { + RGBtoYUV(p,yuv); + if(x%2==0) { + *(op++)=yuv[0]; + *(op++)=yuv[2]; + op[1]=yuv[1]; + } else { + *op=yuv[0]; + op+=2; + } + + p+=4; //s->format->BytesPerPixel; + } + } + + SDL_UnlockYUVOverlay(o); +} + +inline void ConvertRGBtoYUY2(SDL_Overlay *o) +{ + int x,y; + int yuv[3]; + Uint8 *p,*op; + + SDL_LockYUVOverlay(o); + + for(y=0; y<160 && yh; y++) { + p=(Uint8 *)pix+srcPitch*y; + op=o->pixels[0]+o->pitches[0]*y; + for(x=0; x<240 && xw; x++) { + RGBtoYUV(p,yuv); + if(x%2==0) { + *(op++)=yuv[0]; + *(op++)=yuv[1]; + op[1]=yuv[2]; + } else { + *op=yuv[0]; + op+=2; + } + + p+=4; //s->format->BytesPerPixel; + } + } + + SDL_UnlockYUVOverlay(o); +} + +inline void Convert32bit(SDL_Surface *display) +{ + switch(overlay->format) { + case SDL_YV12_OVERLAY: + ConvertRGBtoYV12(overlay); + break; + case SDL_UYVY_OVERLAY: + ConvertRGBtoUYVY(overlay); + break; + case SDL_YVYU_OVERLAY: + ConvertRGBtoYVYU(overlay); + break; + case SDL_YUY2_OVERLAY: + ConvertRGBtoYUY2(overlay); + break; + case SDL_IYUV_OVERLAY: + ConvertRGBtoIYUV(overlay); + break; + default: + fprintf(stderr, "cannot convert RGB picture to obtained YUV format!\n"); + exit(1); + break; + } + +} + + +inline void Draw_Overlay(SDL_Surface *display, int size) +{ + SDL_LockYUVOverlay(overlay); + + Convert32bit(display); + + overlay_rect.x = 0; + overlay_rect.y = 0; + overlay_rect.w = GBA_WIDTH * size; + overlay_rect.h = GBA_HEIGHT * size; + + SDL_DisplayYUVOverlay(overlay, &overlay_rect); + SDL_UnlockYUVOverlay(overlay); +} + +void systemGbBorderOn() +{ + srcWidth = 256; + srcHeight = 224; + gbBorderLineSkip = 256; + gbBorderColumnSkip = 48; + gbBorderRowSkip = 40; + + destWidth = (sizeOption+1)*srcWidth; + destHeight = (sizeOption+1)*srcHeight; + + surface = SDL_SetVideoMode(destWidth, destHeight, 16, + SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF| + (fullscreen ? SDL_FULLSCREEN : 0)); +#ifndef C_CORE + sdlMakeStretcher(srcWidth); +#else + switch(systemColorDepth) { + case 16: + sdlStretcher = sdlStretcher16[sizeOption]; + break; + case 24: + sdlStretcher = sdlStretcher24[sizeOption]; + break; + case 32: + sdlStretcher = sdlStretcher32[sizeOption]; + break; + default: + fprintf(stderr, "Unsupported resolution: %d\n", systemColorDepth); + exit(-1); + } +#endif + + if(systemColorDepth == 16) { + if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) { + Init_2xSaI(565); + RGB_LOW_BITS_MASK = 0x821; + } else { + Init_2xSaI(555); + RGB_LOW_BITS_MASK = 0x421; + } + if(cartridgeType == 2) { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) | + (((i & 0x7c0) >> 6) << systemGreenShift) | + (((i & 0xf800) >> 11) << systemRedShift); + } + } else { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + srcPitch = srcWidth * 2+4; + } else { + if(systemColorDepth != 32) + filterFunction = NULL; + RGB_LOW_BITS_MASK = 0x010101; + if(systemColorDepth == 32) { + Init_2xSaI(32); + } + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + if(systemColorDepth == 32) + srcPitch = srcWidth*4 + 4; + else + srcPitch = srcWidth*3; + } +} diff --git a/src/sdl/TestEmu.cpp b/src/sdl/TestEmu.cpp new file mode 100644 index 0000000..5c96bb9 --- /dev/null +++ b/src/sdl/TestEmu.cpp @@ -0,0 +1,448 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include +#include +#include + +#include "AutoBuild.h" + +#include "GBA.h" +#include "debugger.h" +#include "Sound.h" +#include "unzip.h" +#include "Util.h" +#include "gb/GB.h" +#include "gb/gbGlobals.h" + +#ifndef WIN32 +# include +# define GETCWD getcwd +#else // WIN32 +# include +# define GETCWD _getcwd +#endif // WIN32 + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif +extern bool soundEcho; +extern bool soundLowPass; +extern bool soundReverse; + +extern void remoteInit(); +extern void remoteCleanUp(); +extern void remoteStubMain(); +extern void remoteStubSignal(int,int); +extern void remoteOutput(char *, u32); +extern void remoteSetProtocol(int); +extern void remoteSetPort(int); +extern void debuggerOutput(char *, u32); + +struct EmulatedSystem emulator; + +int systemRedShift = 0; +int systemBlueShift = 16; +int systemGreenShift = 8; +int systemColorDepth = 32; +int systemDebug = 0; +int systemVerbose = 0; +int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + +int cartridgeType = 3; +int captureFormat = 0; + +int emulating = 0; +int RGB_LOW_BITS_MASK=0x821; +int systemFrameSkip = 0; +u32 systemColorMap32[0x10000]; +u16 systemColorMap16[0x10000]; +u16 systemGbPalette[24]; +char filename[2048]; +char biosFileName[2048]; +char captureDir[2048]; +char saveDir[2048]; +char batteryDir[2048]; + +bool paused = false; +bool debugger = true; +bool debuggerStub = false; +bool systemSoundOn = false; +bool removeIntros = false; + +extern void debuggerSignal(int,int); + +void (*dbgMain)() = debuggerMain; +void (*dbgSignal)(int,int) = debuggerSignal; +void (*dbgOutput)(char *, u32) = debuggerOutput; + +char *sdlGetFilename(char *name) +{ + static char filebuffer[2048]; + + int len = strlen(name); + + char *p = name + len - 1; + + while(true) { + if(*p == '/' || + *p == '\\') { + p++; + break; + } + len--; + p--; + if(len == 0) + break; + } + + if(len == 0) + strcpy(filebuffer, name); + else + strcpy(filebuffer, p); + return filebuffer; +} + +void usage(char *cmd) +{ + printf("%s file-name\n",cmd); +} + +int main(int argc, char **argv) +{ + fprintf(stderr,"VisualBoyAdvance-Test version %s\n", VERSION); + + captureDir[0] = 0; + saveDir[0] = 0; + batteryDir[0] = 0; + + char buffer[1024]; + + systemFrameSkip = frameSkip = 2; + gbBorderOn = 0; + + parseDebug = true; + + if(!debuggerStub) { + if(argc <= 1) { + systemMessage(0,"Missing image name"); + usage(argv[0]); + exit(-1); + } + } + + for(int i = 0; i < 24;) { + systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); + systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + systemGbPalette[i++] = 0; + } + + if(argc == 2) { + char *szFile = argv[optind]; + bool failed = false; + if(CPUIsZipFile(szFile)) { + unzFile unz = unzOpen(szFile); + + if(unz == NULL) { + systemMessage(0, "Cannot open file %s", szFile); + exit(-1); + } + int r = unzGoToFirstFile(unz); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(0, "Bad ZIP file %s", szFile); + exit(-1); + } + + bool found = false; + + unz_file_info info; + + while(true) { + r = unzGetCurrentFileInfo(unz, + &info, + buffer, + sizeof(buffer), + NULL, + 0, + NULL, + 0); + + if(r != UNZ_OK) { + unzClose(unz); + systemMessage(0,"Bad ZIP file %s", szFile); + exit(-1); + } + + if(utilIsGBImage(buffer)) { + found = true; + cartridgeType = 1; + break; + } + if(utilIsGBAImage(buffer)) { + found = true; + cartridgeType = 0; + break; + } + + r = unzGoToNextFile(unz); + + if(r != UNZ_OK) + break; + } + + if(!found) { + unzClose(unz); + systemMessage(0, "No image found on ZIP file %s", szFile); + exit(-1); + } + + unzClose(unz); + } + + if(utilIsGBImage(szFile) || cartridgeType == 1) { + failed = !gbLoadRom(szFile); + cartridgeType = 1; + emulator = GBSystem; + } else if(utilIsGBAImage(szFile) || cartridgeType == 0) { + failed = !CPULoadRom(szFile); + cartridgeType = 0; + emulator = GBASystem; + + CPUInit(biosFileName, useBios); + CPUReset(); + } else { + systemMessage(0, "Unknown file type %s", szFile); + exit(-1); + } + + if(failed) { + systemMessage(0, "Failed to load file %s", szFile); + exit(-1); + } + strcpy(filename, szFile); + char *p = strrchr(filename, '.'); + + if(p) + *p = 0; + } else { + cartridgeType = 0; + strcpy(filename, "gnu_stub"); + rom = (u8 *)malloc(0x2000000); + workRAM = (u8 *)calloc(1, 0x40000); + bios = (u8 *)calloc(1,0x4000); + internalRAM = (u8 *)calloc(1,0x8000); + paletteRAM = (u8 *)calloc(1,0x400); + vram = (u8 *)calloc(1, 0x20000); + oam = (u8 *)calloc(1, 0x400); + pix = (u8 *)calloc(1, 4 * 240 * 160); + ioMem = (u8 *)calloc(1, 0x400); + + emulator = GBASystem; + + CPUInit(biosFileName, useBios); + CPUReset(); + } + + if(debuggerStub) + remoteInit(); + + if(cartridgeType == 0) { + } else if (cartridgeType == 1) { + if(gbBorderOn) { + gbBorderLineSkip = 256; + gbBorderColumnSkip = 48; + gbBorderRowSkip = 40; + } else { + gbBorderLineSkip = 160; + gbBorderColumnSkip = 0; + gbBorderRowSkip = 0; + } + } else { + } + + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + + emulating = 1; + soundInit(); + + while(emulating) { + if(!paused) { + if(debugger && emulator.emuHasDebugger) + dbgMain(); + else + emulator.emuMain(emulator.emuCount); + } + } + emulating = 0; + fprintf(stderr,"Shutting down\n"); + remoteCleanUp(); + soundShutdown(); + + if(gbRom != NULL || rom != NULL) { + emulator.emuCleanUp(); + } + + return 0; +} + +void systemMessage(int num, const char *msg, ...) +{ + char buffer[2048]; + va_list valist; + + va_start(valist, msg); + vsprintf(buffer, msg, valist); + + fprintf(stderr, "%s\n", buffer); + va_end(valist); +} + +void systemDrawScreen() +{ +} + +bool systemReadJoypads() +{ + return true; +} + +u32 systemReadJoypad(int,bool) +{ + return 0; +} + +void systemShowSpeed(int speed) +{ +} + +void system10Frames(int rate) +{ +} + +void systemFrame() +{ +} + +void systemSetTitle(const char *title) +{ +} + +void systemScreenCapture(int a) +{ + char buffer[2048]; + + if(captureFormat) { + if(captureDir[0]) + sprintf(buffer, "%s/%s%02d.bmp", captureDir, sdlGetFilename(filename), a); + else + sprintf(buffer, "%s%02d.bmp", filename, a); + + emulator.emuWriteBMP(buffer); + } else { + if(captureDir[0]) + sprintf(buffer, "%s/%s%02d.png", captureDir, sdlGetFilename(filename), a); + else + sprintf(buffer, "%s%02d.png", filename, a); + emulator.emuWritePNG(buffer); + } + + systemScreenMessage("Screen capture"); +} + +u32 systemReadJoypadExtended() +{ + return 0; +} + +void systemWriteDataToSoundBuffer() +{ +} + +bool systemSoundInit() +{ + return true; +} + +void systemSoundShutdown() +{ +} + +void systemSoundPause() +{ +} + +void systemSoundResume() +{ +} + +void systemSoundReset() +{ +} + +static int ticks = 0; + +u32 systemGetClock() +{ + return ticks++; +} + +void systemUpdateMotionSensor() +{ +} + +int systemGetSensorX() +{ + return 0; +} + +int systemGetSensorY() +{ + return 0; +} + +void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast) +{ +} + +void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList) +{ +} + +bool systemCanChangeSoundQuality() +{ + return false; +} + +bool systemPauseOnFrame() +{ + return false; +} + +void systemGbBorderOn() +{ +} diff --git a/src/sdl/debugger.cpp b/src/sdl/debugger.cpp new file mode 100644 index 0000000..31ec557 --- /dev/null +++ b/src/sdl/debugger.cpp @@ -0,0 +1,1454 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +#include "GBA.h" +#include "Port.h" +#include "armdis.h" +#include "elf.h" +#include "exprNode.h" + +extern bool debugger; +extern int emulating; + +extern struct EmulatedSystem emulator; + +#define debuggerReadMemory(addr) \ + READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define debuggerReadHalfWord(addr) \ + READ16LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) + +#define debuggerReadByte(addr) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] + +#define debuggerWriteMemory(addr, value) \ + WRITE32LE(&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], value) + +#define debuggerWriteHalfWord(addr, value) \ + WRITE16LE(&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], value) + +#define debuggerWriteByte(addr, value) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] = (value) + +struct breakpointInfo { + u32 address; + u32 value; + int size; +}; + +struct DebuggerCommand { + char *name; + void (*function)(int,char **); + char *help; + char *syntax; +}; + +void debuggerContinueAfterBreakpoint(); + +void debuggerHelp(int,char **); +void debuggerNext(int,char **); +void debuggerContinue(int, char **); +void debuggerRegisters(int, char **); +void debuggerBreak(int, char **); +void debuggerBreakDelete(int, char **); +void debuggerBreakList(int, char **); +void debuggerBreakArm(int, char **); +void debuggerBreakWriteClear(int, char **); +void debuggerBreakThumb(int, char **); +void debuggerBreakWrite(int, char **); +void debuggerDebug(int, char **); +void debuggerDisassemble(int, char **); +void debuggerDisassembleArm(int, char **); +void debuggerDisassembleThumb(int, char **); +void debuggerEditByte(int, char **); +void debuggerEditHalfWord(int, char **); +void debuggerEdit(int, char **); +void debuggerIo(int, char **); +void debuggerLocals(int, char **); +void debuggerMemoryByte(int, char **); +void debuggerMemoryHalfWord(int, char **); +void debuggerMemory(int, char **); +void debuggerPrint(int, char **); +void debuggerQuit(int, char **); +void debuggerSetRadix(int, char **); +void debuggerSymbols(int, char **); +void debuggerVerbose(int, char **); +void debuggerWhere(int, char **); + +DebuggerCommand debuggerCommands[] = { + { "?", debuggerHelp, "Shows this help information. Type ? for command help", "[]" }, + { "ba", debuggerBreakArm, "Adds an ARM breakpoint", "
" }, + { "bd", debuggerBreakDelete,"Deletes a breakpoint", "" }, + { "bl", debuggerBreakList, "Lists breakpoints" }, + { "bpw", debuggerBreakWrite, "Break on write", "
" }, + { "bpwc", debuggerBreakWriteClear, "Clear break on write", NULL }, + { "break", debuggerBreak, "Adds a breakpoint on the given function", "||" }, + { "bt", debuggerBreakThumb, "Adds a THUMB breakpoint", "
" }, + { "c", debuggerContinue, "Continues execution" , NULL }, + { "d", debuggerDisassemble, "Disassembles instructions", "[
[]]" }, + { "da", debuggerDisassembleArm, "Disassembles ARM instructions", "[
[]]" }, + { "dt", debuggerDisassembleThumb, "Disassembles THUMB instructions", "[
[]]" }, + { "eb", debuggerEditByte, "Modify memory location (byte)", "
" }, + { "eh", debuggerEditHalfWord,"Modify memory location (half-word)","
" }, + { "ew", debuggerEdit, "Modify memory location (word)", "
for command help", "[]" }, + { "io", debuggerIo, "Show I/O registers status", "[video|video2|dma|timer|misc]" }, + { "locals", debuggerLocals, "Shows local variables", NULL }, + { "mb", debuggerMemoryByte, "Shows memory contents (bytes)", "
" }, + { "mh", debuggerMemoryHalfWord, "Shows memory contents (half-words)", "
"}, + { "mw", debuggerMemory, "Shows memory contents (words)", "
" }, + { "n", debuggerNext, "Executes the next instruction", "[]" }, + { "print", debuggerPrint, "Print the value of a expression (if known)", "[/x|/o|/d] " }, + { "q", debuggerQuit, "Quits the emulator", NULL }, + { "r", debuggerRegisters, "Shows ARM registers", NULL }, + { "radix", debuggerSetRadix, "Sets the print radix", "" }, + { "symbols", debuggerSymbols, "List symbols", "[]" }, +#ifndef FINAL_VERSION + { "trace", debuggerDebug, "Sets the trace level", "" }, +#endif +#ifdef DEV_VERSION + { "verbose", debuggerVerbose, "Change verbose setting", "" }, +#endif + { "where", debuggerWhere, "Shows call chain", NULL }, + { NULL, NULL, NULL, NULL} // end marker +}; + +breakpointInfo debuggerBreakpointList[100]; + +int debuggerNumOfBreakpoints = 0; +bool debuggerAtBreakpoint = false; +int debuggerBreakpointNumber = 0; +int debuggerRadix = 0; + +void debuggerApplyBreakpoint(u32 address, int num, int size) +{ + if(size) + debuggerWriteMemory(address, (u32)(0xe1200070 | + (num & 0xf) | + ((num<<4)&0xf0))); + else + debuggerWriteHalfWord(address, + (u16)(0xbe00 | num)); +} + +void debuggerDisableBreakpoints() +{ + for(int i = 0; i < debuggerNumOfBreakpoints; i++) { + if(debuggerBreakpointList[i].size) + debuggerWriteMemory(debuggerBreakpointList[i].address, + debuggerBreakpointList[i].value); + else + debuggerWriteHalfWord(debuggerBreakpointList[i].address, + debuggerBreakpointList[i].value); + } +} + +void debuggerEnableBreakpoints(bool skipPC) +{ + for(int i = 0; i < debuggerNumOfBreakpoints; i++) { + if(debuggerBreakpointList[i].address == armNextPC && skipPC) + continue; + + debuggerApplyBreakpoint(debuggerBreakpointList[i].address, + i, + debuggerBreakpointList[i].size); + } +} + +void debuggerUsage(char *cmd) +{ + for(int i = 0; ; i++) { + if(debuggerCommands[i].name) { + if(!strcmp(debuggerCommands[i].name, cmd)) { + printf("%s %s\t%s\n", + debuggerCommands[i].name, + debuggerCommands[i].syntax ? debuggerCommands[i].syntax : "", + debuggerCommands[i].help); + break; + } + } else { + printf("Unrecognized command '%s'.", cmd); + break; + } + } +} + +void debuggerPrintBaseType(Type *t, u32 value, u32 location, + LocationType type, + int bitSize, int bitOffset) +{ + if(bitSize) { + if(bitOffset) + value >>= ((t->size*8)-bitOffset-bitSize); + value &= (1 << bitSize)-1; + } else { + if(t->size == 2) + value &= 0xFFFF; + else if(t->size == 1) + value &= 0xFF; + } + + if(t->size == 8) { + u64 value = 0; + if(type == LOCATION_memory) { + value = debuggerReadMemory(location) | + ((u64)debuggerReadMemory(location+4)<<32); + } else if(type == LOCATION_register) { + value = reg[location].I | ((u64)reg[location+1].I << 32); + } + switch(t->encoding) { + case DW_ATE_signed: + switch(debuggerRadix) { + case 0: + printf("%lld", value); + break; + case 1: + printf("0x%llx", value); + break; + case 2: + printf("0%llo", value); + break; + } + break; + case DW_ATE_unsigned: + switch(debuggerRadix) { + case 0: + printf("%llu", value); + break; + case 1: + printf("0x%llx", value); + break; + case 2: + printf("0%llo", value); + break; + } + break; + default: + printf("Unknowing 64-bit encoding\n"); + } + return; + } + + switch(t->encoding) { + case DW_ATE_boolean: + if(value) + printf("true"); + else + printf("false"); + break; + case DW_ATE_signed: + switch(debuggerRadix) { + case 0: + printf("%d", value); + break; + case 1: + printf("0x%x", value); + break; + case 2: + printf("0%o", value); + break; + } + break; + case DW_ATE_unsigned: + case DW_ATE_unsigned_char: + switch(debuggerRadix) { + case 0: + printf("%u", value); + break; + case 1: + printf("0x%x", value); + break; + case 2: + printf("0%o", value); + break; + } + break; + default: + printf("UNKNOWN BASE %d %08x", t->encoding, value); + } +} + +char *debuggerPrintType(Type *t) +{ + char buffer[1024]; + static char buffer2[1024]; + + if(t->type == TYPE_pointer) { + if(t->pointer) + strcpy(buffer, debuggerPrintType(t->pointer)); + else + strcpy(buffer, "void"); + sprintf(buffer2, "%s *", buffer); + return buffer2; + } else if(t->type == TYPE_reference) { + strcpy(buffer, debuggerPrintType(t->pointer)); + sprintf(buffer2, "%s &", buffer); + return buffer2; + } + return t->name; +} + +void debuggerPrintValueInternal(Function *, Type *, ELFBlock *, int, int, u32); +void debuggerPrintValueInternal(Function *f, Type *t, + int bitSize, int bitOffset, + u32 objLocation, LocationType type); + +u32 debuggerGetValue(u32 location, LocationType type) +{ + switch(type) { + case LOCATION_memory: + return debuggerReadMemory(location); + case LOCATION_register: + return reg[location].I; + case LOCATION_value: + return location; + } + return 0; +} + +void debuggerPrintPointer(Type *t, u32 value) +{ + printf("(%s)0x%08x", debuggerPrintType(t), value); +} + +void debuggerPrintReference(Type *t, u32 value) +{ + printf("(%s)0x%08x", debuggerPrintType(t), value); +} + +void debuggerPrintFunction(Type *t, u32 value) +{ + printf("(%s)0x%08x", debuggerPrintType(t), value); +} + +void debuggerPrintArray(Type *t, u32 value) +{ + // todo + printf("(%s[])0x%08x", debuggerPrintType(t->array->type), value); +} + +void debuggerPrintMember(Function *f, + Member *m, + u32 objLocation, + u32 location) +{ + int bitSize = m->bitSize; + if(bitSize) { + u32 value = 0; + int off = m->bitOffset; + int size = m->byteSize; + u32 v = 0; + if(size == 1) + v = debuggerReadByte(location); + else if(size == 2) + v = debuggerReadHalfWord(location); + else if(size == 4) + v = debuggerReadMemory(location); + + while(bitSize) { + int top = size*8 - off; + int bot = top - bitSize; + top--; + if(bot >= 0) { + value = (v >> (size*8 - bitSize - off)) & ((1 << bitSize)-1); + bitSize = 0; + } else { + value |= (v & ((1 << top)-1)) << (bitSize - top); + bitSize -= (top+1); + location -= size; + off = 0; + if(size == 1) + v = debuggerReadByte(location); + else if(size == 2) + v = debuggerReadHalfWord(location); + else + v = debuggerReadMemory(location); + } + } + debuggerPrintBaseType(m->type, value, location, LOCATION_memory, + bitSize, 0); + } else { + debuggerPrintValueInternal(f, m->type, m->location, m->bitSize, + m->bitOffset, objLocation); + } +} + +void debuggerPrintStructure(Function *f, Type *t, u32 objLocation) +{ + printf("{"); + int count = t->structure->memberCount; + int i = 0; + while(i < count) { + Member *m = &t->structure->members[i]; + printf("%s=", m->name); + LocationType type; + u32 location = elfDecodeLocation(f, m->location, &type, objLocation); + debuggerPrintMember(f, m, objLocation, location); + i++; + if(i < count) + printf(","); + } + printf("}"); +} + +void debuggerPrintUnion(Function *f, Type *t, u32 objLocation) +{ + // todo + printf("{"); + int count = t->structure->memberCount; + int i = 0; + while(i < count) { + Member *m = &t->structure->members[i]; + printf("%s=", m->name); + debuggerPrintMember(f, m, objLocation, 0); + i++; + if(i < count) + printf(","); + } + printf("}"); +} + +void debuggerPrintEnum(Type *t, u32 value) +{ + int i; + for(i = 0; i < t->enumeration->count; i++) { + EnumMember *m = (EnumMember *)&t->enumeration->members[i]; + if(value == m->value) { + printf(m->name); + return; + } + } + printf("(UNKNOWN VALUE) %d", value); +} + +void debuggerPrintValueInternal(Function *f, Type *t, + int bitSize, int bitOffset, + u32 objLocation, LocationType type) +{ + u32 value = debuggerGetValue(objLocation, type); + if(!t) { + printf("void"); + return; + } + switch(t->type) { + case TYPE_base: + debuggerPrintBaseType(t, value, objLocation, type, bitSize, bitOffset); + break; + case TYPE_pointer: + debuggerPrintPointer(t, value); + break; + case TYPE_reference: + debuggerPrintReference(t, value); + break; + case TYPE_function: + debuggerPrintFunction(t, value); + break; + case TYPE_array: + debuggerPrintArray(t, objLocation); + break; + case TYPE_struct: + debuggerPrintStructure(f, t, objLocation); + break; + case TYPE_union: + debuggerPrintUnion(f, t, objLocation); + break; + case TYPE_enum: + debuggerPrintEnum(t, value); + break; + default: + printf("%08x", value); + break; + } +} + +void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc, + int bitSize, int bitOffset, u32 objLocation) +{ + LocationType type; + u32 location; + if(loc) { + if(objLocation) + location = elfDecodeLocation(f, loc, &type, objLocation); + else + location = elfDecodeLocation(f, loc,&type); + } else { + location = objLocation; + type = LOCATION_memory; + } + + debuggerPrintValueInternal(f, t, bitSize, bitOffset, location, type); +} + +void debuggerPrintValue(Function *f, Object *o) +{ + debuggerPrintValueInternal(f, o->type, o->location, 0, 0, 0); + + printf("\n"); +} + +void debuggerSymbols(int argc, char **argv) +{ + int i = 0; + u32 value; + u32 size; + int type; + bool match = false; + int matchSize = 0; + char *matchStr = NULL; + + if(argc == 2) { + match = true; + matchSize = strlen(argv[1]); + matchStr = argv[1]; + } + printf("Symbol Value Size Type \n"); + printf("-------------------- ------- -------- -------\n"); + char *s = NULL; + while((s = elfGetSymbol(i, &value, &size, &type))) { + if(*s) { + if(match) { + if(strncmp(s, matchStr, matchSize) != 0) { + i++; + continue; + } + } + char *ts = "?"; + switch(type) { + case 2: + ts = "ARM"; + break; + case 0x0d: + ts = "THUMB"; + break; + case 1: + ts = "DATA"; + break; + } + printf("%-20s %08x %08x %-7s\n", + s, value, size, ts); + } + i++; + } +} + +void debuggerSetRadix(int argc, char **argv) +{ + if(argc != 2) + debuggerUsage(argv[0]); + else { + int r = atoi(argv[1]); + + bool error = false; + switch(r) { + case 10: + debuggerRadix = 0; + break; + case 8: + debuggerRadix = 2; + break; + case 16: + debuggerRadix = 1; + break; + default: + error = true; + printf("Unknown radix %d. Valid values are 8, 10 and 16.\n", r); + break; + } + if(!error) + printf("Radix set to %d\n", r); + } +} + +void debuggerPrint(int argc, char **argv) +{ + if(argc != 2 && argc != 3) { + debuggerUsage(argv[0]); + } else { + u32 pc = armNextPC; + Function *f = NULL; + CompileUnit *u = NULL; + + elfGetCurrentFunction(pc, + &f, &u); + + int oldRadix = debuggerRadix; + if(argc == 3) { + if(argv[1][0] == '/') { + if(argv[1][1] == 'x') + debuggerRadix = 1; + else if(argv[1][1] == 'o') + debuggerRadix = 2; + else if(argv[1][1] == 'd') + debuggerRadix = 0; + else { + printf("Unknown format %c\n", argv[1][1]); + return; + } + } else { + printf("Unknown option %s\n", argv[1]); + return; + } + } + + char *s = argc == 2 ? argv[1] : argv[2]; + + extern char *exprString; + extern int exprCol; + extern int yyparse(); + exprString = s; + exprCol = 0; + if(!yyparse()) { + extern Node *result; + if(result->resolve(result, f, u)) { + if(result->member) + debuggerPrintMember(f, + result->member, + result->objLocation, + result->location); + else + debuggerPrintValueInternal(f, result->type, 0, 0, + result->location, + result->locType); + printf("\n"); + } else { + printf("Error resolving expression\n"); + } + } else { + printf("Error parsing expression:\n"); + printf("%s\n", s); + exprCol--; + for(int i = 0; i < exprCol; i++) + printf(" "); + printf("^\n"); + } + extern void exprCleanBuffer(); + exprCleanBuffer(); + exprNodeCleanUp(); + debuggerRadix = oldRadix; + } +} + +void debuggerHelp(int n, char **args) +{ + if(n == 2) { + debuggerUsage(args[1]); + } else { + for(int i = 0; ; i++) { + if(debuggerCommands[i].name) { + printf("%s\t%s\n", debuggerCommands[i].name, debuggerCommands[i].help); + } else + break; + } + } +} + +void debuggerDebug(int n, char **args) +{ + if(n == 2) { + int v = 0; + sscanf(args[1], "%d", &v); + systemDebug = v; + printf("Debug level set to %d\n", systemDebug); + } else + debuggerUsage("trace"); +} + +void debuggerVerbose(int n, char **args) +{ + if(n == 2) { + int v = 0; + sscanf(args[1], "%d", &v); + systemVerbose = v; + printf("Verbose level set to %d\n", systemVerbose); + } else + debuggerUsage("verbose"); +} + +void debuggerWhere(int n, char **args) +{ + void elfPrintCallChain(u32); + elfPrintCallChain(armNextPC); +} + +void debuggerLocals(int n, char **args) +{ + Function *f = NULL; + CompileUnit *u = NULL; + u32 pc = armNextPC; + if(elfGetCurrentFunction(pc, + &f, &u)) { + Object *o = f->parameters; + while(o) { + printf("%s=", o->name); + debuggerPrintValue(f, o); + o = o->next; + } + + o = f->variables; + while(o) { + bool visible = o->startScope ? pc>=o->startScope : true; + if(visible) + visible = o->endScope ? pc < o->endScope : true; + if(visible) { + printf("%s=", o->name); + debuggerPrintValue(f, o); + } + o = o->next; + } + } else { + printf("No information for current address\n"); + } +} + +void debuggerNext(int n, char **args) +{ + int count = 1; + if(n == 2) { + sscanf(args[1], "%d", &count); + } + for(int i = 0; i < count; i++) { + if(debuggerAtBreakpoint) { + debuggerContinueAfterBreakpoint(); + debuggerEnableBreakpoints(false); + } else + emulator.emuMain(1); + } + debuggerDisableBreakpoints(); + Function *f = NULL; + CompileUnit *u = NULL; + u32 a = armNextPC; + if(elfGetCurrentFunction(a, &f, &u)) { + char *file; + int line = elfFindLine(u, f, a, &file); + + printf("File %s, function %s, line %d\n", file, f->name, + line); + } + debuggerRegisters(0, NULL); +} + +void debuggerContinue(int n, char **args) +{ + if(debuggerAtBreakpoint) + debuggerContinueAfterBreakpoint(); + debuggerEnableBreakpoints(false); + debugger = false; +} + +void debuggerSignal(int sig,int number) +{ + switch(sig) { + case 4: + { + printf("Illegal instruction at %08x\n", armNextPC); + debugger = true; + } + break; + case 5: + { + printf("Breakpoint %d reached\n", number); + debugger = true; + debuggerAtBreakpoint = true; + debuggerBreakpointNumber = number; + debuggerDisableBreakpoints(); + + Function *f = NULL; + CompileUnit *u = NULL; + + if(elfGetCurrentFunction(armNextPC, &f, &u)) { + char *file; + int line = elfFindLine(u,f,armNextPC,&file); + printf("File %s, function %s, line %d\n", file, f->name, + line); + } + } + break; + default: + printf("Unknown signal %d\n", sig); + break; + } +} + +void debuggerBreakList(int, char **) +{ + printf("Num Address Type Symbol\n"); + printf("--- -------- ----- ------\n"); + for(int i = 0; i < debuggerNumOfBreakpoints; i++) { + printf("%3d %08x %s %s\n",i, debuggerBreakpointList[i].address, + debuggerBreakpointList[i].size ? "ARM" : "THUMB", + elfGetAddressSymbol(debuggerBreakpointList[i].address)); + } +} + +void debuggerBreakDelete(int n, char **args) +{ + if(n == 2) { + int n = 0; + sscanf(args[1], "%d", &n); + printf("Deleting breakpoint %d (%d)\n", n, debuggerNumOfBreakpoints); + if(n >= 0 && n < debuggerNumOfBreakpoints) { + n++; + if(n < debuggerNumOfBreakpoints) { + for(int i = n; i < debuggerNumOfBreakpoints; i++) { + debuggerBreakpointList[i-1].address = + debuggerBreakpointList[i].address; + debuggerBreakpointList[i-1].value = + debuggerBreakpointList[i].value; + debuggerBreakpointList[i-1].size = + debuggerBreakpointList[i].size; + } + } + debuggerNumOfBreakpoints--; + } + } else + debuggerUsage("bd"); +} + +void debuggerBreak(int n, char **args) +{ + if(n == 2) { + u32 address = 0; + u32 value = 0; + int type = 0; + char *s = args[1]; + char c = *s; + if(strchr(s, ':')) { + char *name = s; + char *l = strchr(s, ':'); + *l++ = 0; + int line = atoi(l); + + u32 addr; + Function *f; + CompileUnit *u; + + if(elfFindLineInModule(&addr, name, line)) { + if(elfGetCurrentFunction(addr, &f, &u)) { + u32 addr2; + if(elfGetSymbolAddress(f->name, &addr2, &value, &type)) { + address = addr; + } else { + printf("Unable to get function symbol data\n"); + return; + } + } else { + printf("Unable to find function for address\n"); + return; + } + } else { + printf("Unable to find module or line\n"); + return; + } + } else if(c >= '0' && c <= '9') { + int line = atoi(s); + Function *f; + CompileUnit *u; + u32 addr; + + if(elfGetCurrentFunction(armNextPC, &f, &u)) { + if(elfFindLineInUnit(&addr, u, line)) { + if(elfGetCurrentFunction(addr, &f, &u)) { + u32 addr2; + if(elfGetSymbolAddress(f->name, &addr2, &value, &type)) { + address = addr; + } else { + printf("Unable to get function symbol data\n"); + return; + } + } else { + printf("Unable to find function for address\n"); + return; + } + } else { + printf("Unable to find line\n"); + return; + } + } else { + printf("Cannot find current function\n"); + return; + } + } else { + if(!elfGetSymbolAddress(s, &address, &value, &type)) { + printf("Function %s not found\n", args[1]); + return; + } + } + if(type == 0x02 || type == 0x0d) { + int i = debuggerNumOfBreakpoints; + int size = 0; + if(type == 2) + size = 1; + debuggerBreakpointList[i].address = address; + debuggerBreakpointList[i].value = type == 0x02 ? + debuggerReadMemory(address) : debuggerReadHalfWord(address); + debuggerBreakpointList[i].size = size; + // debuggerApplyBreakpoint(address, i, size); + debuggerNumOfBreakpoints++; + if(size) + printf("Added ARM breakpoint at %08x\n", address); + else + printf("Added THUMB breakpoint at %08x\n", address); + } else { + printf("%s is not a function symbol\n", args[1]); + } + } else + debuggerUsage("break"); +} + +void debuggerBreakThumb(int n, char **args) +{ + if(n == 2) { + u32 address = 0; + sscanf(args[1],"%x", &address); + int i = debuggerNumOfBreakpoints; + debuggerBreakpointList[i].address = address; + debuggerBreakpointList[i].value = debuggerReadHalfWord(address); + debuggerBreakpointList[i].size = 0; + // debuggerApplyBreakpoint(address, i, 0); + debuggerNumOfBreakpoints++; + printf("Added THUMB breakpoint at %08x\n", address); + } else + debuggerUsage("bt"); +} + +void debuggerBreakArm(int n, char **args) +{ + if(n == 2) { + u32 address = 0; + sscanf(args[1],"%x", &address); + int i = debuggerNumOfBreakpoints; + debuggerBreakpointList[i].address = address; + debuggerBreakpointList[i].value = debuggerReadMemory(address); + debuggerBreakpointList[i].size = 1; + // debuggerApplyBreakpoint(address, i, 1); + debuggerNumOfBreakpoints++; + printf("Added ARM breakpoint at %08x\n", address); + } else + debuggerUsage("ba"); +} + +void debuggerBreakOnWrite(u32 *mem, u32 oldvalue, u32 value, int size) +{ + u32 address = 0; + if(mem >= (u32*)&workRAM[0] && mem <= (u32*)&workRAM[0x3ffff]) + address = 0x2000000 + ((u32)mem - (u32)&workRAM[0]); + else + address = 0x3000000 + ((u32)mem - (u32)&internalRAM[0]); + + if(size == 2) + printf("Breakpoint (on write) address %08x old:%08x new:%08x\n", + address, oldvalue, value); + else if(size == 1) + printf("Breakpoint (on write) address %08x old:%04x new:%04x\n", + address, (u16)oldvalue,(u16)value); + else + printf("Breakpoint (on write) address %08x old:%02x new:%02x\n", + address, (u8)oldvalue, (u8)value); + debugger = true; +} + +void debuggerBreakWriteClear(int n, char **args) +{ + memset(freezeWorkRAM, false, 0x40000); + memset(freezeInternalRAM, false, 0x8000); + printf("Cleared all break on write\n"); +} + +void debuggerBreakWrite(int n, char **args) +{ + if(n == 3) { + if(cheatsNumber != 0) { + printf("Cheats are enabled. Cannot continue.\n"); + return; + } + u32 address = 0; + sscanf(args[1], "%x", &address); + int n = 0; + sscanf(args[2], "%d", &n); + + if(address < 0x2000000 || address > 0x3007fff) { + printf("Invalid address: %08x\n", address); + return; + } + + if(address > 0x203ffff && address < 0x3000000) { + printf("Invalid address: %08x\n", address); + return; + } + + u32 final = address + n; + + if(address < 0x2040000 && final > 0x2040000) { + printf("Invalid byte count: %d\n", n); + return; + } else if(address < 0x3008000 && final > 0x3008000) { + printf("Invalid byte count: %d\n", n); + return; + } + printf("Added break on write at %08x for %d bytes\n", address, n); + for(int i = 0; i < n; i++) { + if((address >> 24) == 2) + freezeWorkRAM[address & 0x3ffff] = true; + else + freezeInternalRAM[address & 0x7fff] = true; + address++; + } + } else + debuggerUsage("bpw"); +} + +void debuggerDisassembleArm(int n, char **args) +{ + char buffer[80]; + u32 pc = reg[15].I; + pc -= 4; + int count = 20; + if(n >= 2) { + sscanf(args[1], "%x", &pc); + } + if(pc & 3) { + printf("Misaligned address %08x\n", pc); + pc &= 0xfffffffc; + } + if(n >= 3) { + sscanf(args[2], "%d", &count); + } + int i = 0; + int len = 0; + char format[30]; + for(i = 0; i < count; i++) { + int l = strlen(elfGetAddressSymbol(pc+4*i)); + if(l > len) + len = l; + } + sprintf(format, "%%08x %%-%ds %%s\n", len); + for(i = 0; i < count; i++) { + u32 addr = pc; + pc += disArm(pc, buffer, 2); + printf(format, addr, elfGetAddressSymbol(addr), buffer); + } +} + +void debuggerDisassembleThumb(int n, char **args) +{ + char buffer[80]; + u32 pc = reg[15].I; + pc -= 2; + int count = 20; + if(n >= 2) { + sscanf(args[1], "%x", &pc); + } + if(pc & 1) { + printf("Misaligned address %08x\n", pc); + pc &= 0xfffffffe; + } + if(n >= 3) { + sscanf(args[2], "%d", &count); + } + + int i = 0; + int len = 0; + char format[30]; + for(i = 0; i < count; i++) { + int l = strlen(elfGetAddressSymbol(pc+2*i)); + if(l > len) + len = l; + } + sprintf(format, "%%08x %%-%ds %%s\n", len); + + for(i = 0; i < count; i++) { + u32 addr = pc; + pc += disThumb(pc, buffer, 2); + printf(format, addr, elfGetAddressSymbol(addr), buffer); + } +} + +void debuggerDisassemble(int n, char **args) +{ + if(armState) + debuggerDisassembleArm(n, args); + else + debuggerDisassembleThumb(n, args); +} + +void debuggerContinueAfterBreakpoint() +{ + printf("Continuing after breakpoint\n"); + debuggerEnableBreakpoints(true); + emulator.emuMain(1); + debuggerAtBreakpoint = false; +} + +void debuggerRegisters(int, char **) +{ + char *command[3]; + char buffer[10]; + + printf("R00=%08x R04=%08x R08=%08x R12=%08x\n", + reg[0].I, reg[4].I, reg[8].I, reg[12].I); + printf("R01=%08x R05=%08x R09=%08x R13=%08x\n", + reg[1].I, reg[5].I, reg[9].I, reg[13].I); + printf("R02=%08x R06=%08x R10=%08x R14=%08x\n", + reg[2].I, reg[6].I, reg[10].I, reg[14].I); + printf("R03=%08x R07=%08x R11=%08x R15=%08x\n", + reg[3].I, reg[7].I, reg[11].I, reg[15].I); + printf("CPSR=%08x (%c%c%c%c%c%c%c Mode: %02x)\n", + reg[16].I, + (N_FLAG ? 'N' : '.'), + (Z_FLAG ? 'Z' : '.'), + (C_FLAG ? 'C' : '.'), + (V_FLAG ? 'V' : '.'), + (armIrqEnable ? '.' : 'I'), + ((!(reg[16].I & 0x40)) ? '.' : 'F'), + (armState ? '.' : 'T'), + armMode); + sprintf(buffer,"%08x", armState ? reg[15].I - 4 : reg[15].I - 2); + command[0]="m"; + command[1]=buffer; + command[2]="1"; + debuggerDisassemble(3, command); +} + +void debuggerIoVideo() +{ + printf("DISPCNT = %04x\n", DISPCNT); + printf("DISPSTAT = %04x\n", DISPSTAT); + printf("VCOUNT = %04x\n", VCOUNT); + printf("BG0CNT = %04x\n", BG0CNT); + printf("BG1CNT = %04x\n", BG1CNT); + printf("BG2CNT = %04x\n", BG2CNT); + printf("BG3CNT = %04x\n", BG3CNT); + printf("WIN0H = %04x\n", WIN0H); + printf("WIN0V = %04x\n", WIN0V); + printf("WIN1H = %04x\n", WIN1H); + printf("WIN1V = %04x\n", WIN1V); + printf("WININ = %04x\n", WININ); + printf("WINOUT = %04x\n", WINOUT); + printf("MOSAIC = %04x\n", MOSAIC); + printf("BLDMOD = %04x\n", BLDMOD); + printf("COLEV = %04x\n", COLEV); + printf("COLY = %04x\n", COLY); +} + +void debuggerIoVideo2() +{ + printf("BG0HOFS = %04x\n", BG0HOFS); + printf("BG0VOFS = %04x\n", BG0VOFS); + printf("BG1HOFS = %04x\n", BG1HOFS); + printf("BG1VOFS = %04x\n", BG1VOFS); + printf("BG2HOFS = %04x\n", BG2HOFS); + printf("BG2VOFS = %04x\n", BG2VOFS); + printf("BG3HOFS = %04x\n", BG3HOFS); + printf("BG3VOFS = %04x\n", BG3VOFS); + printf("BG2PA = %04x\n", BG2PA); + printf("BG2PB = %04x\n", BG2PB); + printf("BG2PC = %04x\n", BG2PC); + printf("BG2PD = %04x\n", BG2PD); + printf("BG2X = %08x\n", (BG2X_H<<16)|BG2X_L); + printf("BG2Y = %08x\n", (BG2Y_H<<16)|BG2Y_L); + printf("BG3PA = %04x\n", BG3PA); + printf("BG3PB = %04x\n", BG3PB); + printf("BG3PC = %04x\n", BG3PC); + printf("BG3PD = %04x\n", BG3PD); + printf("BG3X = %08x\n", (BG3X_H<<16)|BG3X_L); + printf("BG3Y = %08x\n", (BG3Y_H<<16)|BG3Y_L); +} + +void debuggerIoDMA() +{ + printf("DM0SAD = %08x\n", (DM0SAD_H<<16)|DM0SAD_L); + printf("DM0DAD = %08x\n", (DM0DAD_H<<16)|DM0DAD_L); + printf("DM0CNT = %08x\n", (DM0CNT_H<<16)|DM0CNT_L); + printf("DM1SAD = %08x\n", (DM1SAD_H<<16)|DM1SAD_L); + printf("DM1DAD = %08x\n", (DM1DAD_H<<16)|DM1DAD_L); + printf("DM1CNT = %08x\n", (DM1CNT_H<<16)|DM1CNT_L); + printf("DM2SAD = %08x\n", (DM2SAD_H<<16)|DM2SAD_L); + printf("DM2DAD = %08x\n", (DM2DAD_H<<16)|DM2DAD_L); + printf("DM2CNT = %08x\n", (DM2CNT_H<<16)|DM2CNT_L); + printf("DM3SAD = %08x\n", (DM3SAD_H<<16)|DM3SAD_L); + printf("DM3DAD = %08x\n", (DM3DAD_H<<16)|DM3DAD_L); + printf("DM3CNT = %08x\n", (DM3CNT_H<<16)|DM3CNT_L); +} + +void debuggerIoTimer() +{ + printf("TM0D = %04x\n", TM0D); + printf("TM0CNT = %04x\n", TM0CNT); + printf("TM1D = %04x\n", TM1D); + printf("TM1CNT = %04x\n", TM1CNT); + printf("TM2D = %04x\n", TM2D); + printf("TM2CNT = %04x\n", TM2CNT); + printf("TM3D = %04x\n", TM3D); + printf("TM3CNT = %04x\n", TM3CNT); +} + +void debuggerIoMisc() +{ + printf("P1 = %04x\n", P1); + printf("IE = %04x\n", IE); + printf("IF = %04x\n", IF); + printf("IME = %04x\n", IME); +} + +void debuggerIo(int n, char **args) +{ + if(n == 1) { + debuggerIoVideo(); + return; + } + if(!strcmp(args[1], "video")) + debuggerIoVideo(); + else if(!strcmp(args[1], "video2")) + debuggerIoVideo2(); + else if(!strcmp(args[1], "dma")) + debuggerIoDMA(); + else if(!strcmp(args[1], "timer")) + debuggerIoTimer(); + else if(!strcmp(args[1], "misc")) + debuggerIoMisc(); + else printf("Unrecognized option %s\n", args[1]); +} + +void debuggerEditByte(int n, char **args) +{ + if(n == 3) { + u32 address; + u32 byte; + sscanf(args[1], "%x", &address); + sscanf(args[2], "%x", &byte); + debuggerWriteByte(address, (u8)byte); + } else + debuggerUsage("eb"); +} + +void debuggerEditHalfWord(int n, char **args) +{ + if(n == 3) { + u32 address; + u32 byte; + sscanf(args[1], "%x", &address); + if(address & 1) { + printf("Error: address must be half-word aligned\n"); + return; + } + sscanf(args[2], "%x", &byte); + debuggerWriteHalfWord(address, (u16)byte); + } else + debuggerUsage("eh"); +} + +void debuggerEdit(int n, char **args) +{ + if(n == 3) { + u32 address; + u32 byte; + sscanf(args[1], "%x", &address); + if(address & 3) { + printf("Error: address must be word aligned\n"); + return; + } + sscanf(args[2], "%x", &byte); + debuggerWriteMemory(address, (u32)byte); + } else + debuggerUsage("ew"); +} + + +#define ASCII(c) (c) < 32 ? '.' : (c) > 127 ? '.' : (c) + +void debuggerMemoryByte(int n, char **args) +{ + if(n == 2) { + u32 addr = 0; + sscanf(args[1], "%x", &addr); + for(int ii = 0; ii < 16; ii++) { + int a = debuggerReadByte(addr); + int b = debuggerReadByte(addr+1); + int c = debuggerReadByte(addr+2); + int d = debuggerReadByte(addr+3); + int e = debuggerReadByte(addr+4); + int f = debuggerReadByte(addr+5); + int g = debuggerReadByte(addr+6); + int h = debuggerReadByte(addr+7); + int i = debuggerReadByte(addr+8); + int j = debuggerReadByte(addr+9); + int k = debuggerReadByte(addr+10); + int l = debuggerReadByte(addr+11); + int m = debuggerReadByte(addr+12); + int n = debuggerReadByte(addr+13); + int o = debuggerReadByte(addr+14); + int p = debuggerReadByte(addr+15); + + printf("%08x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", + addr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p, + ASCII(a),ASCII(b),ASCII(c),ASCII(d), + ASCII(e),ASCII(f),ASCII(g),ASCII(h), + ASCII(i),ASCII(j),ASCII(k),ASCII(l), + ASCII(m),ASCII(n),ASCII(o),ASCII(p)); + addr += 16; + } + } else + debuggerUsage("mb"); +} + +void debuggerMemoryHalfWord(int n, char **args) +{ + if(n == 2) { + u32 addr = 0; + sscanf(args[1], "%x", &addr); + addr = addr & 0xfffffffe; + for(int ii = 0; ii < 16; ii++) { + int a = debuggerReadByte(addr); + int b = debuggerReadByte(addr+1); + int c = debuggerReadByte(addr+2); + int d = debuggerReadByte(addr+3); + int e = debuggerReadByte(addr+4); + int f = debuggerReadByte(addr+5); + int g = debuggerReadByte(addr+6); + int h = debuggerReadByte(addr+7); + int i = debuggerReadByte(addr+8); + int j = debuggerReadByte(addr+9); + int k = debuggerReadByte(addr+10); + int l = debuggerReadByte(addr+11); + int m = debuggerReadByte(addr+12); + int n = debuggerReadByte(addr+13); + int o = debuggerReadByte(addr+14); + int p = debuggerReadByte(addr+15); + + printf("%08x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", + addr,b,a,d,c,f,e,h,g,j,i,l,k,n,m,p,o, + ASCII(a),ASCII(b),ASCII(c),ASCII(d), + ASCII(e),ASCII(f),ASCII(g),ASCII(h), + ASCII(i),ASCII(j),ASCII(k),ASCII(l), + ASCII(m),ASCII(n),ASCII(o),ASCII(p)); + addr += 16; + } + } else + debuggerUsage("mh"); +} + +void debuggerMemory(int n, char **args) +{ + if(n == 2) { + u32 addr = 0; + sscanf(args[1], "%x", &addr); + addr = addr & 0xfffffffc; + for(int ii = 0; ii < 16; ii++) { + int a = debuggerReadByte(addr); + int b = debuggerReadByte(addr+1); + int c = debuggerReadByte(addr+2); + int d = debuggerReadByte(addr+3); + + int e = debuggerReadByte(addr+4); + int f = debuggerReadByte(addr+5); + int g = debuggerReadByte(addr+6); + int h = debuggerReadByte(addr+7); + + int i = debuggerReadByte(addr+8); + int j = debuggerReadByte(addr+9); + int k = debuggerReadByte(addr+10); + int l = debuggerReadByte(addr+11); + + int m = debuggerReadByte(addr+12); + int n = debuggerReadByte(addr+13); + int o = debuggerReadByte(addr+14); + int p = debuggerReadByte(addr+15); + + printf("%08x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", + addr,d,c,b,a,h,g,f,e,l,k,j,i,p,o,n,m, + ASCII(a),ASCII(b),ASCII(c),ASCII(d), + ASCII(e),ASCII(f),ASCII(g),ASCII(h), + ASCII(i),ASCII(j),ASCII(k),ASCII(l), + ASCII(m),ASCII(n),ASCII(o),ASCII(p)); + addr += 16; + } + } else + debuggerUsage("mw"); +} + +void debuggerQuit(int, char **) +{ + char buffer[10]; + printf("Are you sure you want to quit (y/n)? "); + fgets(buffer, 1024, stdin); + + if(buffer[0] == 'y' || buffer[0] == 'Y') { + debugger = false; + emulating = false; + } +} + +void debuggerOutput(char *s, u32 addr) +{ + if(s) + printf(s); + else { + char c; + + c = debuggerReadByte(addr); + addr++; + while(c) { + putchar(c); + c = debuggerReadByte(addr); + addr++; + } + } +} + +void debuggerMain() +{ + char buffer[1024]; + char *commands[10]; + int commandCount = 0; + + if(emulator.emuUpdateCPSR) + emulator.emuUpdateCPSR(); + debuggerRegisters(0, NULL); + + while(debugger) { + systemSoundPause(); + printf("debugger> "); + commandCount = 0; + char *s = fgets(buffer, 1024, stdin); + + commands[0] = strtok(s, " \t\n"); + if(commands[0] == NULL) + continue; + commandCount++; + while((s = strtok(NULL, " \t\n"))) { + commands[commandCount++] = s; + if(commandCount == 10) + break; + } + + for(int j = 0; ; j++) { + if(debuggerCommands[j].name == NULL) { + printf("Unrecognized command %s. Type h for help.\n", commands[0]); + break; + } + if(!strcmp(commands[0], debuggerCommands[j].name)) { + debuggerCommands[j].function(commandCount, commands); + break; + } + } + } +} diff --git a/src/sdl/debugger.h b/src/sdl/debugger.h new file mode 100644 index 0000000..695ed21 --- /dev/null +++ b/src/sdl/debugger.h @@ -0,0 +1,20 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +extern void debuggerMain(); diff --git a/src/simple2x.cpp b/src/simple2x.cpp new file mode 100644 index 0000000..17b3f04 --- /dev/null +++ b/src/simple2x.cpp @@ -0,0 +1,106 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "System.h" + +void Simple2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + + finish = (u8 *) bP + ((width+2) << 1); + currentPixel = *bP++; + + do { +#ifdef WORDS_BIGENDIAN + u32 color = currentPixel >> 16; +#else + u32 color = currentPixel & 0xffff; +#endif + + color = color | (color << 16); + + *(dP) = color; + *(nL) = color; + +#ifdef WORDS_BIGENDIAN + color = currentPixel & 0xffff; +#else + color = currentPixel >> 16; +#endif + color = color| (color << 16); + *(dP + 1) = color; + *(nL + 1) = color; + + currentPixel = *bP++; + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} + +void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, + u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *nextLine, *finish; + + nextLine = dstPtr + dstPitch; + + do { + u32 *bP = (u32 *) srcPtr; + u32 *dP = (u32 *) dstPtr; + u32 *nL = (u32 *) nextLine; + u32 currentPixel; + + finish = (u8 *) bP + ((width+1) << 2); + currentPixel = *bP++; + + do { + u32 color = currentPixel; + + *(dP) = color; + *(dP+1) = color; + *(nL) = color; + *(nL + 1) = color; + + currentPixel = *bP++; + + dP += 2; + nL += 2; + } while ((u8 *) bP < finish); + + srcPtr += srcPitch; + dstPtr += dstPitch << 1; + nextLine += dstPitch << 1; + } + while (--height); +} diff --git a/src/thumb.h b/src/thumb.h new file mode 100644 index 0000000..41333a2 --- /dev/null +++ b/src/thumb.h @@ -0,0 +1,2474 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2005 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifdef C_CORE +#define NEG(i) ((i) >> 31) +#define POS(i) ((~(i)) >> 31) +#define ADDCARRY(a, b, c) \ + C_FLAG = ((NEG(a) & NEG(b)) |\ + (NEG(a) & POS(c)) |\ + (NEG(b) & POS(c))) ? true : false; +#define ADDOVERFLOW(a, b, c) \ + V_FLAG = ((NEG(a) & NEG(b) & POS(c)) |\ + (POS(a) & POS(b) & NEG(c))) ? true : false; +#define SUBCARRY(a, b, c) \ + C_FLAG = ((NEG(a) & POS(b)) |\ + (NEG(a) & POS(c)) |\ + (POS(b) & POS(c))) ? true : false; +#define SUBOVERFLOW(a, b, c)\ + V_FLAG = ((NEG(a) & POS(b) & POS(c)) |\ + (POS(a) & NEG(b) & NEG(c))) ? true : false; +#define ADD_RD_RS_RN \ + {\ + u32 lhs = reg[source].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define ADD_RD_RS_O3 \ + {\ + u32 lhs = reg[source].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define ADD_RN_O8(d) \ + {\ + u32 lhs = reg[(d)].I;\ + u32 rhs = (opcode & 255);\ + u32 res = lhs + rhs;\ + reg[(d)].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define CMN_RD_RS \ + {\ + u32 lhs = reg[dest].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define ADC_RD_RS \ + {\ + u32 lhs = reg[dest].I;\ + u32 rhs = value;\ + u32 res = lhs + rhs + (u32)C_FLAG;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + ADDCARRY(lhs, rhs, res);\ + ADDOVERFLOW(lhs, rhs, res);\ + } +#define SUB_RD_RS_RN \ + {\ + u32 lhs = reg[source].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define SUB_RD_RS_O3 \ + {\ + u32 lhs = reg[source].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define SUB_RN_O8(d) \ + {\ + u32 lhs = reg[(d)].I;\ + u32 rhs = (opcode & 255);\ + u32 res = lhs - rhs;\ + reg[(d)].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define CMP_RN_O8(d) \ + {\ + u32 lhs = reg[(d)].I;\ + u32 rhs = (opcode & 255);\ + u32 res = lhs - rhs;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define SBC_RD_RS \ + {\ + u32 lhs = reg[dest].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs - !((u32)C_FLAG);\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#define LSL_RD_RM_I5 \ + {\ + C_FLAG = (reg[source].I >> (32 - shift)) & 1 ? true : false;\ + value = reg[source].I << shift;\ + } +#define LSL_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (32 - value)) & 1 ? true : false;\ + value = reg[dest].I << value;\ + } +#define LSR_RD_RM_I5 \ + {\ + C_FLAG = (reg[source].I >> (shift - 1)) & 1 ? true : false;\ + value = reg[source].I >> shift;\ + } +#define LSR_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false;\ + value = reg[dest].I >> value;\ + } +#define ASR_RD_RM_I5 \ + {\ + C_FLAG = ((s32)reg[source].I >> (int)(shift - 1)) & 1 ? true : false;\ + value = (s32)reg[source].I >> (int)shift;\ + } +#define ASR_RD_RS \ + {\ + C_FLAG = ((s32)reg[dest].I >> (int)(value - 1)) & 1 ? true : false;\ + value = (s32)reg[dest].I >> (int)value;\ + } +#define ROR_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false;\ + value = ((reg[dest].I << (32 - value)) |\ + (reg[dest].I >> value));\ + } +#define NEG_RD_RS \ + {\ + u32 lhs = reg[source].I;\ + u32 rhs = 0;\ + u32 res = rhs - lhs;\ + reg[dest].I = res;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(rhs, lhs, res);\ + SUBOVERFLOW(rhs, lhs, res);\ + } +#define CMP_RD_RS \ + {\ + u32 lhs = reg[dest].I;\ + u32 rhs = value;\ + u32 res = lhs - rhs;\ + Z_FLAG = (res == 0) ? true : false;\ + N_FLAG = NEG(res) ? true : false;\ + SUBCARRY(lhs, rhs, res);\ + SUBOVERFLOW(lhs, rhs, res);\ + } +#else +#ifdef __GNUC__ +#ifdef __POWERPC__ + #define ADD_RD_RS_RN \ + { \ + register int Flags; \ + register int Result; \ + asm volatile("addco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[source].I), \ + "r" (value) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define ADD_RD_RS_O3 ADD_RD_RS_RN + #define ADD_RN_O8(d) \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("addco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[(d)].I), \ + "r" (opcode & 255) \ + ); \ + reg[(d)].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define CMN_RD_RS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("addco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[dest].I), \ + "r" (value) \ + ); \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define ADC_RD_RS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("mtspr xer, %4\n" \ + "addeo. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[dest].I), \ + "r" (value), \ + "r" (C_FLAG << 29) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define SUB_RD_RS_RN \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[source].I), \ + "r" (value) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define SUB_RD_RS_O3 SUB_RD_RS_RN + #define SUB_RN_O8(d) \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[(d)].I), \ + "r" (opcode & 255) \ + ); \ + reg[(d)].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define CMP_RN_O8(d) \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[(d)].I), \ + "r" (opcode & 255) \ + ); \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define SBC_RD_RS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("mtspr xer, %4\n" \ + "subfeo. %0, %3, %2\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[dest].I), \ + "r" (value), \ + "r" (C_FLAG << 29) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define LSL_RD_RM_I5 \ + {\ + C_FLAG = (reg[source].I >> (32 - shift)) & 1 ? true : false;\ + value = reg[source].I << shift;\ + } + #define LSL_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (32 - value)) & 1 ? true : false;\ + value = reg[dest].I << value;\ + } + #define LSR_RD_RM_I5 \ + {\ + C_FLAG = (reg[source].I >> (shift - 1)) & 1 ? true : false;\ + value = reg[source].I >> shift;\ + } + #define LSR_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false;\ + value = reg[dest].I >> value;\ + } + #define ASR_RD_RM_I5 \ + {\ + C_FLAG = ((s32)reg[source].I >> (int)(shift - 1)) & 1 ? true : false;\ + value = (s32)reg[source].I >> (int)shift;\ + } + #define ASR_RD_RS \ + {\ + C_FLAG = ((s32)reg[dest].I >> (int)(value - 1)) & 1 ? true : false;\ + value = (s32)reg[dest].I >> (int)value;\ + } + #define ROR_RD_RS \ + {\ + C_FLAG = (reg[dest].I >> (value - 1)) & 1 ? true : false;\ + value = ((reg[dest].I << (32 - value)) |\ + (reg[dest].I >> value));\ + } + #define NEG_RD_RS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subfco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[source].I), \ + "r" (0) \ + ); \ + reg[dest].I = Result; \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } + #define CMP_RD_RS \ + {\ + register int Flags; \ + register int Result; \ + asm volatile("subco. %0, %2, %3\n" \ + "mcrxr cr1\n" \ + "mfcr %1\n" \ + : "=r" (Result), \ + "=r" (Flags) \ + : "r" (reg[dest].I), \ + "r" (value) \ + ); \ + Z_FLAG = (Flags >> 29) & 1; \ + N_FLAG = (Flags >> 31) & 1; \ + C_FLAG = (Flags >> 25) & 1; \ + V_FLAG = (Flags >> 26) & 1; \ + } +#else +#define ADD_RD_RS_RN \ + asm ("add %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[source].I)); +#define ADD_RD_RS_O3 \ + asm ("add %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[source].I)); +#define ADD_RN_O8(d) \ + asm ("add %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[(d)].I)\ + : "r" (opcode & 255), "b" (reg[(d)].I)); +#define CMN_RD_RS \ + asm ("add %0, %1;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : \ + : "r" (value), "r" (reg[dest].I):"1"); +#define ADC_RD_RS \ + asm ("bt $0, C_FLAG;"\ + "adc %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setcb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[dest].I)); +#define SUB_RD_RS_RN \ + asm ("sub %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[source].I)); +#define SUB_RD_RS_O3 \ + asm ("sub %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[source].I)); +#define SUB_RN_O8(d) \ + asm ("sub %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[(d)].I)\ + : "r" (opcode & 255), "b" (reg[(d)].I)); +#define CMP_RN_O8(d) \ + asm ("sub %0, %1;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : \ + : "r" (opcode & 255), "r" (reg[(d)].I) : "1"); +#define SBC_RD_RS \ + asm volatile ("bt $0, C_FLAG;"\ + "cmc;"\ + "sbb %1, %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "r" (value), "b" (reg[dest].I) : "cc", "memory"); +#define LSL_RD_RM_I5 \ + asm ("shl %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[source].I), "c" (shift)); +#define LSL_RD_RS \ + asm ("shl %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[dest].I), "c" (value)); +#define LSR_RD_RM_I5 \ + asm ("shr %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[source].I), "c" (shift)); +#define LSR_RD_RS \ + asm ("shr %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[dest].I), "c" (value)); +#define ASR_RD_RM_I5 \ + asm ("sar %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[source].I), "c" (shift)); +#define ASR_RD_RS \ + asm ("sar %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[dest].I), "c" (value)); +#define ROR_RD_RS \ + asm ("ror %%cl, %%eax;"\ + "setcb C_FLAG;"\ + : "=a" (value)\ + : "a" (reg[dest].I), "c" (value)); +#define NEG_RD_RS \ + asm ("neg %%ebx;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : "=b" (reg[dest].I)\ + : "b" (reg[source].I)); +#define CMP_RD_RS \ + asm ("sub %0, %1;"\ + "setsb N_FLAG;"\ + "setzb Z_FLAG;"\ + "setncb C_FLAG;"\ + "setob V_FLAG;"\ + : \ + : "r" (value), "r" (reg[dest].I):"1"); +#endif +#else +#define ADD_RD_RS_RN \ + {\ + __asm mov eax, source\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm add ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define ADD_RD_RS_O3 \ + {\ + __asm mov eax, source\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm add ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define ADD_RN_O8(d) \ + {\ + __asm mov ebx, opcode\ + __asm and ebx, 255\ + __asm add dword ptr [OFFSET reg+4*(d)], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define CMN_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm add ebx, value\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define ADC_RD_RS \ + {\ + __asm mov ebx, dest\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm bt word ptr C_FLAG, 0\ + __asm adc ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define SUB_RD_RS_RN \ + {\ + __asm mov eax, source\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm sub ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define SUB_RD_RS_O3 \ + {\ + __asm mov eax, source\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm sub ebx, value\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define SUB_RN_O8(d) \ + {\ + __asm mov ebx, opcode\ + __asm and ebx, 255\ + __asm sub dword ptr [OFFSET reg + 4*(d)], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define CMP_RN_O8(d) \ + {\ + __asm mov eax, dword ptr [OFFSET reg+4*(d)]\ + __asm mov ebx, opcode\ + __asm and ebx, 255\ + __asm sub eax, ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define SBC_RD_RS \ + {\ + __asm mov ebx, dest\ + __asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\ + __asm mov eax, value\ + __asm bt word ptr C_FLAG, 0\ + __asm cmc\ + __asm sbb ebx, eax\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg + 4*eax], ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define LSL_RD_RM_I5 \ + {\ + __asm mov eax, source\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shl eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define LSL_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr value\ + __asm shl eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define LSR_RD_RM_I5 \ + {\ + __asm mov eax, source\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr shift\ + __asm shr eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define LSR_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\ + __asm mov cl, byte ptr value\ + __asm shr eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define ASR_RD_RM_I5 \ + {\ + __asm mov eax, source\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm mov cl, byte ptr shift\ + __asm sar eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define ASR_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm mov cl, byte ptr value\ + __asm sar eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define ROR_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov eax, dword ptr [OFFSET reg + 4*eax]\ + __asm mov cl, byte ptr value\ + __asm ror eax, cl\ + __asm mov value, eax\ + __asm setc byte ptr C_FLAG\ + } +#define NEG_RD_RS \ + {\ + __asm mov ebx, source\ + __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\ + __asm neg ebx\ + __asm mov eax, dest\ + __asm mov dword ptr [OFFSET reg+4*eax],ebx\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#define CMP_RD_RS \ + {\ + __asm mov eax, dest\ + __asm mov ebx, dword ptr [OFFSET reg+4*eax]\ + __asm sub ebx, value\ + __asm sets byte ptr N_FLAG\ + __asm setz byte ptr Z_FLAG\ + __asm setnc byte ptr C_FLAG\ + __asm seto byte ptr V_FLAG\ + } +#endif +#endif + +u32 opcode = CPUReadHalfWordQuick(armNextPC); +clockTicks = thumbCycles[opcode >> 8] + memoryWaitFetch[(armNextPC >> 24) & 15]; +#ifndef FINAL_VERSION +if(armNextPC == stop) { + armNextPC = armNextPC++; +} +#endif + +armNextPC = reg[15].I; +reg[15].I += 2; + +switch(opcode >> 8) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + { + // LSL Rd, Rm, #Imm 5 + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + int shift = (opcode >> 6) & 0x1f; + u32 value; + + if(shift) { + LSL_RD_RM_I5; + } else { + value = reg[source].I; + } + reg[dest].I = value; + // C_FLAG set above + N_FLAG = (value & 0x80000000 ? true : false); + Z_FLAG = (value ? false : true); + } + break; + case 0x08: + case 0x09: + case 0x0a: + case 0x0b: + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + { + // LSR Rd, Rm, #Imm 5 + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + int shift = (opcode >> 6) & 0x1f; + u32 value; + + if(shift) { + LSR_RD_RM_I5; + } else { + C_FLAG = reg[source].I & 0x80000000 ? true : false; + value = 0; + } + reg[dest].I = value; + // C_FLAG set above + N_FLAG = (value & 0x80000000 ? true : false); + Z_FLAG = (value ? false : true); + } + break; + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + { + // ASR Rd, Rm, #Imm 5 + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + int shift = (opcode >> 6) & 0x1f; + u32 value; + + if(shift) { + ASR_RD_RM_I5; + } else { + if(reg[source].I & 0x80000000) { + value = 0xFFFFFFFF; + C_FLAG = true; + } else { + value = 0; + C_FLAG = false; + } + } + reg[dest].I = value; + // C_FLAG set above + N_FLAG = (value & 0x80000000 ? true : false); + Z_FLAG = (value ? false :true); + } + break; + case 0x18: + case 0x19: + { + // ADD Rd, Rs, Rn + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + u32 value = reg[(opcode>>6)& 0x07].I; + ADD_RD_RS_RN; + } + break; + case 0x1a: + case 0x1b: + { + // SUB Rd, Rs, Rn + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + u32 value = reg[(opcode>>6)& 0x07].I; + SUB_RD_RS_RN; + } + break; + case 0x1c: + case 0x1d: + { + // ADD Rd, Rs, #Offset3 + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + u32 value = (opcode >> 6) & 7; + ADD_RD_RS_O3; + } + break; + case 0x1e: + case 0x1f: + { + // SUB Rd, Rs, #Offset3 + int dest = opcode & 0x07; + int source = (opcode >> 3) & 0x07; + u32 value = (opcode >> 6) & 7; + SUB_RD_RS_O3; + } + break; + case 0x20: + // MOV R0, #Offset8 + reg[0].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[0].I ? false : true); + break; + case 0x21: + // MOV R1, #Offset8 + reg[1].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[1].I ? false : true); + break; + case 0x22: + // MOV R2, #Offset8 + reg[2].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[2].I ? false : true); + break; + case 0x23: + // MOV R3, #Offset8 + reg[3].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[3].I ? false : true); + break; + case 0x24: + // MOV R4, #Offset8 + reg[4].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[4].I ? false : true); + break; + case 0x25: + // MOV R5, #Offset8 + reg[5].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[5].I ? false : true); + break; + case 0x26: + // MOV R6, #Offset8 + reg[6].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[6].I ? false : true); + break; + case 0x27: + // MOV R7, #Offset8 + reg[7].I = opcode & 255; + N_FLAG = false; + Z_FLAG = (reg[7].I ? false : true); + break; + case 0x28: + // CMP R0, #Offset8 + CMP_RN_O8(0); + break; + case 0x29: + // CMP R1, #Offset8 + CMP_RN_O8(1); + break; + case 0x2a: + // CMP R2, #Offset8 + CMP_RN_O8(2); + break; + case 0x2b: + // CMP R3, #Offset8 + CMP_RN_O8(3); + break; + case 0x2c: + // CMP R4, #Offset8 + CMP_RN_O8(4); + break; + case 0x2d: + // CMP R5, #Offset8 + CMP_RN_O8(5); + break; + case 0x2e: + // CMP R6, #Offset8 + CMP_RN_O8(6); + break; + case 0x2f: + // CMP R7, #Offset8 + CMP_RN_O8(7); + break; + case 0x30: + // ADD R0,#Offset8 + ADD_RN_O8(0); + break; + case 0x31: + // ADD R1,#Offset8 + ADD_RN_O8(1); + break; + case 0x32: + // ADD R2,#Offset8 + ADD_RN_O8(2); + break; + case 0x33: + // ADD R3,#Offset8 + ADD_RN_O8(3); + break; + case 0x34: + // ADD R4,#Offset8 + ADD_RN_O8(4); + break; + case 0x35: + // ADD R5,#Offset8 + ADD_RN_O8(5); + break; + case 0x36: + // ADD R6,#Offset8 + ADD_RN_O8(6); + break; + case 0x37: + // ADD R7,#Offset8 + ADD_RN_O8(7); + break; + case 0x38: + // SUB R0,#Offset8 + SUB_RN_O8(0); + break; + case 0x39: + // SUB R1,#Offset8 + SUB_RN_O8(1); + break; + case 0x3a: + // SUB R2,#Offset8 + SUB_RN_O8(2); + break; + case 0x3b: + // SUB R3,#Offset8 + SUB_RN_O8(3); + break; + case 0x3c: + // SUB R4,#Offset8 + SUB_RN_O8(4); + break; + case 0x3d: + // SUB R5,#Offset8 + SUB_RN_O8(5); + break; + case 0x3e: + // SUB R6,#Offset8 + SUB_RN_O8(6); + break; + case 0x3f: + // SUB R7,#Offset8 + SUB_RN_O8(7); + break; + case 0x40: + switch((opcode >> 6) & 3) { + case 0x00: + { + // AND Rd, Rs + int dest = opcode & 7; + reg[dest].I &= reg[(opcode >> 3)&7].I; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; +#ifdef BKPT_SUPPORT +#define THUMB_CONSOLE_OUTPUT(a,b) \ + if((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) {\ + extern void (*dbgOutput)(char *, u32);\ + dbgOutput((a), (b));\ + } +#else +#define THUMB_CONSOLE_OUTPUT(a,b) +#endif + THUMB_CONSOLE_OUTPUT(NULL, reg[2].I); + } + break; + case 0x01: + // EOR Rd, Rs + { + int dest = opcode & 7; + reg[dest].I ^= reg[(opcode >> 3)&7].I; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; + } + break; + case 0x02: + // LSL Rd, Rs + { + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].B.B0; + if(value) { + if(value == 32) { + value = 0; + C_FLAG = (reg[dest].I & 1 ? true : false); + } else if(value < 32) { + LSL_RD_RS; + } else { + value = 0; + C_FLAG = false; + } + reg[dest].I = value; + } + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; + clockTicks++; + } + break; + case 0x03: + { + // LSR Rd, Rs + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].B.B0; + if(value) { + if(value == 32) { + value = 0; + C_FLAG = (reg[dest].I & 0x80000000 ? true : false); + } else if(value < 32) { + LSR_RD_RS; + } else { + value = 0; + C_FLAG = false; + } + reg[dest].I = value; + } + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; + clockTicks++; + } + break; + } + break; + case 0x41: + switch((opcode >> 6) & 3) { + case 0x00: + { + // ASR Rd, Rs + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].B.B0; + // ASR + if(value) { + if(value < 32) { + ASR_RD_RS; + reg[dest].I = value; + } else { + if(reg[dest].I & 0x80000000){ + reg[dest].I = 0xFFFFFFFF; + C_FLAG = true; + } else { + reg[dest].I = 0x00000000; + C_FLAG = false; + } + } + } + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; + clockTicks++; + } + break; + case 0x01: + { + // ADC Rd, Rs + int dest = opcode & 0x07; + u32 value = reg[(opcode >> 3)&7].I; + // ADC + ADC_RD_RS; + } + break; + case 0x02: + { + // SBC Rd, Rs + int dest = opcode & 0x07; + u32 value = reg[(opcode >> 3)&7].I; + + // SBC + SBC_RD_RS; + } + break; + case 0x03: + // ROR Rd, Rs + { + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].B.B0; + + if(value) { + value = value & 0x1f; + if(value == 0) { + C_FLAG = (reg[dest].I & 0x80000000 ? true : false); + } else { + ROR_RD_RS; + reg[dest].I = value; + } + } + clockTicks++; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + Z_FLAG = reg[dest].I ? false : true; + } + break; + } + break; + case 0x42: + switch((opcode >> 6) & 3) { + case 0x00: + { + // TST Rd, Rs + u32 value = reg[opcode & 7].I & reg[(opcode >> 3) & 7].I; + N_FLAG = value & 0x80000000 ? true : false; + Z_FLAG = value ? false : true; + } + break; + case 0x01: + { + // NEG Rd, Rs + int dest = opcode & 7; + int source = (opcode >> 3) & 7; + NEG_RD_RS; + } + break; + case 0x02: + { + // CMP Rd, Rs + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].I; + CMP_RD_RS; + } + break; + case 0x03: + { + // CMN Rd, Rs + int dest = opcode & 7; + u32 value = reg[(opcode >> 3)&7].I; + // CMN + CMN_RD_RS; + } + break; + } + break; + case 0x43: + switch((opcode >> 6) & 3) { + case 0x00: + { + // ORR Rd, Rs + int dest = opcode & 7; + reg[dest].I |= reg[(opcode >> 3) & 7].I; + Z_FLAG = reg[dest].I ? false : true; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + } + break; + case 0x01: + { + // MUL Rd, Rs + int dest = opcode & 7; + u32 rm = reg[(opcode >> 3) & 7].I; + reg[dest].I = reg[dest].I * rm; + if (((s32)rm) < 0) + rm = ~rm; + if ((rm & 0xFFFFFF00) == 0) + clockTicks += 1; + else if ((rm & 0xFFFF0000) == 0) + clockTicks += 2; + else if ((rm & 0xFF000000) == 0) + clockTicks += 3; + else + clockTicks += 4; + Z_FLAG = reg[dest].I ? false : true; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + } + break; + case 0x02: + { + // BIC Rd, Rs + int dest = opcode & 7; + reg[dest].I &= (~reg[(opcode >> 3) & 7].I); + Z_FLAG = reg[dest].I ? false : true; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + } + break; + case 0x03: + { + // MVN Rd, Rs + int dest = opcode & 7; + reg[dest].I = ~reg[(opcode >> 3) & 7].I; + Z_FLAG = reg[dest].I ? false : true; + N_FLAG = reg[dest].I & 0x80000000 ? true : false; + } + break; + } + break; + case 0x44: + { + int dest = opcode & 7; + int base = (opcode >> 3) & 7; + switch((opcode >> 6)& 3) { + default: + goto unknown_thumb; + case 1: + // ADD Rd, Hs + reg[dest].I += reg[base+8].I; + break; + case 2: + // ADD Hd, Rs + reg[dest+8].I += reg[base].I; + if(dest == 7) { + reg[15].I &= 0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks++; + } + break; + case 3: + // ADD Hd, Hs + reg[dest+8].I += reg[base+8].I; + if(dest == 7) { + reg[15].I &= 0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks++; + } + break; + } + } + break; + case 0x45: + { + int dest = opcode & 7; + int base = (opcode >> 3) & 7; + u32 value; + switch((opcode >> 6) & 3) { + case 0: + // CMP Rd, Hs + value = reg[base].I; + CMP_RD_RS; + break; + case 1: + // CMP Rd, Hs + value = reg[base+8].I; + CMP_RD_RS; + break; + case 2: + // CMP Hd, Rs + value = reg[base].I; + dest += 8; + CMP_RD_RS; + break; + case 3: + // CMP Hd, Hs + value = reg[base+8].I; + dest += 8; + CMP_RD_RS; + break; + } + } + break; + case 0x46: + { + int dest = opcode & 7; + int base = (opcode >> 3) & 7; + switch((opcode >> 6) & 3) { + case 0: + // this form should not be used... + // MOV Rd, Rs + reg[dest].I = reg[base].I; + break; + case 1: + // MOV Rd, Hs + reg[dest].I = reg[base+8].I; + break; + case 2: + // MOV Hd, Rs + reg[dest+8].I = reg[base].I; + if(dest == 7) { + reg[15].I &= 0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks++; + } + break; + case 3: + // MOV Hd, Hs + reg[dest+8].I = reg[base+8].I; + if(dest == 7) { + reg[15].I &= 0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks++; + } + break; + } + } + break; + case 0x47: + { + int base = (opcode >> 3) & 7; + switch((opcode >>6) & 3) { + case 0: + // BX Rs + reg[15].I = (reg[base].I) & 0xFFFFFFFE; + if(reg[base].I & 1) { + armState = false; + armNextPC = reg[15].I; + reg[15].I += 2; + } else { + armState = true; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + break; + case 1: + // BX Hs + reg[15].I = (reg[8+base].I) & 0xFFFFFFFE; + if(reg[8+base].I & 1) { + armState = false; + armNextPC = reg[15].I; + reg[15].I += 2; + } else { + armState = true; + reg[15].I &= 0xFFFFFFFC; + armNextPC = reg[15].I; + reg[15].I += 4; + } + break; + default: + goto unknown_thumb; + } + } + break; + case 0x48: + // LDR R0,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[0].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x49: + // LDR R1,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[1].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4a: + // LDR R2,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[2].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4b: + // LDR R3,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[3].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4c: + // LDR R4,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[4].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4d: + // LDR R5,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[5].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4e: + // LDR R6,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[6].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x4f: + // LDR R7,[PC, #Imm] + { + u32 address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2); + reg[7].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x50: + case 0x51: + // STR Rd, [Rs, Rn] + { + u32 + address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + CPUWriteMemory(address, + reg[opcode & 7].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x52: + case 0x53: + // STRH Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + CPUWriteHalfWord(address, + reg[opcode&7].W.W0); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x54: + case 0x55: + // STRB Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode >>6)&7].I; + CPUWriteByte(address, + reg[opcode & 7].B.B0); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x56: + case 0x57: + // LDSB Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + reg[opcode&7].I = (s8)CPUReadByte(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x58: + case 0x59: + // LDR Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + reg[opcode&7].I = CPUReadMemory(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x5a: + case 0x5b: + // LDRH Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + reg[opcode&7].I = CPUReadHalfWord(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x5c: + case 0x5d: + // LDRB Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + reg[opcode&7].I = CPUReadByte(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x5e: + case 0x5f: + // LDSH Rd, [Rs, Rn] + { + u32 address = reg[(opcode>>3)&7].I + reg[(opcode>>6)&7].I; + reg[opcode&7].I = (s16)CPUReadHalfWordSigned(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + // STR Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)<<2); + CPUWriteMemory(address, + reg[opcode&7].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x68: + case 0x69: + case 0x6a: + case 0x6b: + case 0x6c: + case 0x6d: + case 0x6e: + case 0x6f: + // LDR Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)<<2); + reg[opcode&7].I = CPUReadMemory(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + // STRB Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)); + CPUWriteByte(address, + reg[opcode&7].B.B0); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x78: + case 0x79: + case 0x7a: + case 0x7b: + case 0x7c: + case 0x7d: + case 0x7e: + case 0x7f: + // LDRB Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)); + reg[opcode&7].I = CPUReadByte(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + // STRH Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)<<1); + CPUWriteHalfWord(address, + reg[opcode&7].W.W0); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x88: + case 0x89: + case 0x8a: + case 0x8b: + case 0x8c: + case 0x8d: + case 0x8e: + case 0x8f: + // LDRH Rd, [Rs, #Imm] + { + u32 address = reg[(opcode>>3)&7].I + (((opcode>>6)&31)<<1); + reg[opcode&7].I = CPUReadHalfWord(address); + clockTicks += CPUUpdateTicksAccess16(address); + } + break; + case 0x90: + // STR R0, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[0].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x91: + // STR R1, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[1].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x92: + // STR R2, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[2].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x93: + // STR R3, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[3].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x94: + // STR R4, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[4].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x95: + // STR R5, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[5].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x96: + // STR R6, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[6].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x97: + // STR R7, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + CPUWriteMemory(address, reg[7].I); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x98: + // LDR R0, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[0].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x99: + // LDR R1, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[1].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9a: + // LDR R2, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[2].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9b: + // LDR R3, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[3].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9c: + // LDR R4, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[4].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9d: + // LDR R5, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[5].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9e: + // LDR R6, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[6].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0x9f: + // LDR R7, [SP, #Imm] + { + u32 address = reg[13].I + ((opcode&255)<<2); + reg[7].I = CPUReadMemoryQuick(address); + clockTicks += CPUUpdateTicksAccess32(address); + } + break; + case 0xa0: + // ADD R0, PC, Imm + reg[0].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa1: + // ADD R1, PC, Imm + reg[1].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa2: + // ADD R2, PC, Imm + reg[2].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa3: + // ADD R3, PC, Imm + reg[3].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa4: + // ADD R4, PC, Imm + reg[4].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa5: + // ADD R5, PC, Imm + reg[5].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa6: + // ADD R6, PC, Imm + reg[6].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa7: + // ADD R7, PC, Imm + reg[7].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); + break; + case 0xa8: + // ADD R0, SP, Imm + reg[0].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xa9: + // ADD R1, SP, Imm + reg[1].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xaa: + // ADD R2, SP, Imm + reg[2].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xab: + // ADD R3, SP, Imm + reg[3].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xac: + // ADD R4, SP, Imm + reg[4].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xad: + // ADD R5, SP, Imm + reg[5].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xae: + // ADD R6, SP, Imm + reg[6].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xaf: + // ADD R7, SP, Imm + reg[7].I = reg[13].I + ((opcode&255)<<2); + break; + case 0xb0: + { + // ADD SP, Imm + int offset = (opcode & 127) << 2; + if(opcode & 0x80) + offset = -offset; + reg[13].I += offset; + } + break; +#define PUSH_REG(val, r) \ + if(opcode & (val)) {\ + CPUWriteMemory(address, reg[(r)].I);\ + if(offset)\ + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);\ + else\ + clockTicks += 1 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + address += 4;\ + } + case 0xb4: + // PUSH {Rlist} + { + int offset = 0; + u32 temp = reg[13].I - 4 * cpuBitsSet[opcode & 0xff]; + u32 address = temp & 0xFFFFFFFC; + PUSH_REG(1, 0); + PUSH_REG(2, 1); + PUSH_REG(4, 2); + PUSH_REG(8, 3); + PUSH_REG(16, 4); + PUSH_REG(32, 5); + PUSH_REG(64, 6); + PUSH_REG(128, 7); + reg[13].I = temp; + } + break; + case 0xb5: + // PUSH {Rlist, LR} + { + int offset = 0; + u32 temp = reg[13].I - 4 - 4 * cpuBitsSet[opcode & 0xff]; + u32 address = temp & 0xFFFFFFFC; + PUSH_REG(1, 0); + PUSH_REG(2, 1); + PUSH_REG(4, 2); + PUSH_REG(8, 3); + PUSH_REG(16, 4); + PUSH_REG(32, 5); + PUSH_REG(64, 6); + PUSH_REG(128, 7); + PUSH_REG(256, 14); + reg[13].I = temp; + } + break; +#define POP_REG(val, r) \ + if(opcode & (val)) {\ + reg[(r)].I = CPUReadMemory(address);\ + if(offset)\ + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);\ + else\ + clockTicks += 2 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + address += 4;\ + } + case 0xbc: + // POP {Rlist} + { + int offset = 0; + u32 address = reg[13].I & 0xFFFFFFFC; + u32 temp = reg[13].I + 4*cpuBitsSet[opcode & 0xFF]; + POP_REG(1, 0); + POP_REG(2, 1); + POP_REG(4, 2); + POP_REG(8, 3); + POP_REG(16, 4); + POP_REG(32, 5); + POP_REG(64, 6); + POP_REG(128, 7); + reg[13].I = temp; + } + break; + case 0xbd: + // POP {Rlist, PC} + { + int offset = 0; + u32 address = reg[13].I & 0xFFFFFFFC; + u32 temp = reg[13].I + 4 + 4*cpuBitsSet[opcode & 0xFF]; + POP_REG(1, 0); + POP_REG(2, 1); + POP_REG(4, 2); + POP_REG(8, 3); + POP_REG(16, 4); + POP_REG(32, 5); + POP_REG(64, 6); + POP_REG(128, 7); + reg[15].I = (CPUReadMemory(address) & 0xFFFFFFFE); + if(offset) + clockTicks += CPUUpdateTicksAccessSeq32(address); + else + clockTicks += CPUUpdateTicksAccess32(address); + armNextPC = reg[15].I; + reg[15].I += 2; + reg[13].I = temp; + } + break; +#define THUMB_STM_REG(val,r,b) \ + if(opcode & (val)) {\ + CPUWriteMemory(address, reg[(r)].I);\ + if(!offset) {\ + reg[(b)].I = temp;\ + clockTicks += 1 + CPUUpdateTicksAccess32(address);\ + } else \ + clockTicks += 1 + CPUUpdateTicksAccessSeq32(address);\ + offset = 1;\ + address += 4;\ + } + case 0xc0: + { + // STM R0!, {Rlist} + u32 address = reg[0].I & 0xFFFFFFFC; + u32 temp = reg[0].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 0); + THUMB_STM_REG(2, 1, 0); + THUMB_STM_REG(4, 2, 0); + THUMB_STM_REG(8, 3, 0); + THUMB_STM_REG(16, 4, 0); + THUMB_STM_REG(32, 5, 0); + THUMB_STM_REG(64, 6, 0); + THUMB_STM_REG(128, 7, 0); + } + break; + case 0xc1: + { + // STM R1!, {Rlist} + u32 address = reg[1].I & 0xFFFFFFFC; + u32 temp = reg[1].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 1); + THUMB_STM_REG(2, 1, 1); + THUMB_STM_REG(4, 2, 1); + THUMB_STM_REG(8, 3, 1); + THUMB_STM_REG(16, 4, 1); + THUMB_STM_REG(32, 5, 1); + THUMB_STM_REG(64, 6, 1); + THUMB_STM_REG(128, 7, 1); + } + break; + case 0xc2: + { + // STM R2!, {Rlist} + u32 address = reg[2].I & 0xFFFFFFFC; + u32 temp = reg[2].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 2); + THUMB_STM_REG(2, 1, 2); + THUMB_STM_REG(4, 2, 2); + THUMB_STM_REG(8, 3, 2); + THUMB_STM_REG(16, 4, 2); + THUMB_STM_REG(32, 5, 2); + THUMB_STM_REG(64, 6, 2); + THUMB_STM_REG(128, 7, 2); + } + break; + case 0xc3: + { + // STM R3!, {Rlist} + u32 address = reg[3].I & 0xFFFFFFFC; + u32 temp = reg[3].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 3); + THUMB_STM_REG(2, 1, 3); + THUMB_STM_REG(4, 2, 3); + THUMB_STM_REG(8, 3, 3); + THUMB_STM_REG(16, 4, 3); + THUMB_STM_REG(32, 5, 3); + THUMB_STM_REG(64, 6, 3); + THUMB_STM_REG(128, 7, 3); + } + break; + case 0xc4: + { + // STM R4!, {Rlist} + u32 address = reg[4].I & 0xFFFFFFFC; + u32 temp = reg[4].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 4); + THUMB_STM_REG(2, 1, 4); + THUMB_STM_REG(4, 2, 4); + THUMB_STM_REG(8, 3, 4); + THUMB_STM_REG(16, 4, 4); + THUMB_STM_REG(32, 5, 4); + THUMB_STM_REG(64, 6, 4); + THUMB_STM_REG(128, 7, 4); + } + break; + case 0xc5: + { + // STM R5!, {Rlist} + u32 address = reg[5].I & 0xFFFFFFFC; + u32 temp = reg[5].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 5); + THUMB_STM_REG(2, 1, 5); + THUMB_STM_REG(4, 2, 5); + THUMB_STM_REG(8, 3, 5); + THUMB_STM_REG(16, 4, 5); + THUMB_STM_REG(32, 5, 5); + THUMB_STM_REG(64, 6, 5); + THUMB_STM_REG(128, 7, 5); + } + break; + case 0xc6: + { + // STM R6!, {Rlist} + u32 address = reg[6].I & 0xFFFFFFFC; + u32 temp = reg[6].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 6); + THUMB_STM_REG(2, 1, 6); + THUMB_STM_REG(4, 2, 6); + THUMB_STM_REG(8, 3, 6); + THUMB_STM_REG(16, 4, 6); + THUMB_STM_REG(32, 5, 6); + THUMB_STM_REG(64, 6, 6); + THUMB_STM_REG(128, 7, 6); + } + break; + case 0xc7: + { + // STM R7!, {Rlist} + u32 address = reg[7].I & 0xFFFFFFFC; + u32 temp = reg[7].I + 4*cpuBitsSet[opcode & 0xff]; + int offset = 0; + // store + THUMB_STM_REG(1, 0, 7); + THUMB_STM_REG(2, 1, 7); + THUMB_STM_REG(4, 2, 7); + THUMB_STM_REG(8, 3, 7); + THUMB_STM_REG(16, 4, 7); + THUMB_STM_REG(32, 5, 7); + THUMB_STM_REG(64, 6, 7); + THUMB_STM_REG(128, 7, 7); + } + break; +#define THUMB_LDM_REG(val,r) \ + if(opcode & (val)) {\ + reg[(r)].I = CPUReadMemory(address);\ + if(offset)\ + clockTicks += 2 + CPUUpdateTicksAccessSeq32(address);\ + else\ + clockTicks += 2 + CPUUpdateTicksAccess32(address);\ + offset = 1;\ + address += 4;\ + } + case 0xc8: + { + // LDM R0!, {Rlist} + u32 address = reg[0].I & 0xFFFFFFFC; + u32 temp = reg[0].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 1)) + reg[0].I = temp; + } + break; + case 0xc9: + { + // LDM R1!, {Rlist} + u32 address = reg[1].I & 0xFFFFFFFC; + u32 temp = reg[1].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 2)) + reg[1].I = temp; + } + break; + case 0xca: + { + // LDM R2!, {Rlist} + u32 address = reg[2].I & 0xFFFFFFFC; + u32 temp = reg[2].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 4)) + reg[2].I = temp; + } + break; + case 0xcb: + { + // LDM R3!, {Rlist} + u32 address = reg[3].I & 0xFFFFFFFC; + u32 temp = reg[3].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 8)) + reg[3].I = temp; + } + break; + case 0xcc: + { + // LDM R4!, {Rlist} + u32 address = reg[4].I & 0xFFFFFFFC; + u32 temp = reg[4].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 16)) + reg[4].I = temp; + } + break; + case 0xcd: + { + // LDM R5!, {Rlist} + u32 address = reg[5].I & 0xFFFFFFFC; + u32 temp = reg[5].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 32)) + reg[5].I = temp; + } + break; + case 0xce: + { + // LDM R6!, {Rlist} + u32 address = reg[6].I & 0xFFFFFFFC; + u32 temp = reg[6].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 64)) + reg[6].I = temp; + } + break; + case 0xcf: + { + // LDM R7!, {Rlist} + u32 address = reg[7].I & 0xFFFFFFFC; + u32 temp = reg[7].I + 4*cpuBitsSet[opcode & 0xFF]; + int offset = 0; + // load + THUMB_LDM_REG(1, 0); + THUMB_LDM_REG(2, 1); + THUMB_LDM_REG(4, 2); + THUMB_LDM_REG(8, 3); + THUMB_LDM_REG(16, 4); + THUMB_LDM_REG(32, 5); + THUMB_LDM_REG(64, 6); + THUMB_LDM_REG(128, 7); + if(!(opcode & 128)) + reg[7].I = temp; + } + break; + case 0xd0: + // BEQ offset + if(Z_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd1: + // BNE offset + if(!Z_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd2: + // BCS offset + if(C_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd3: + // BCC offset + if(!C_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd4: + // BMI offset + if(N_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd5: + // BPL offset + if(!N_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd6: + // BVS offset + if(V_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd7: + // BVC offset + if(!V_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd8: + // BHI offset + if(C_FLAG && !Z_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xd9: + // BLS offset + if(!C_FLAG || Z_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xda: + // BGE offset + if(N_FLAG == V_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xdb: + // BLT offset + if(N_FLAG != V_FLAG) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xdc: + // BGT offset + if(!Z_FLAG && (N_FLAG == V_FLAG)) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xdd: + // BLE offset + if(Z_FLAG || (N_FLAG != V_FLAG)) { + reg[15].I += ((s8)(opcode & 0xFF)) << 1; + armNextPC = reg[15].I; + reg[15].I += 2; + clockTicks = 3; + } + break; + case 0xdf: + // SWI #comment + CPUSoftwareInterrupt(opcode & 0xFF); + break; + case 0xe0: + case 0xe1: + case 0xe2: + case 0xe3: + case 0xe4: + case 0xe5: + case 0xe6: + case 0xe7: + { + // B offset + int offset = (opcode & 0x3FF) << 1; + if(opcode & 0x0400) + offset |= 0xFFFFF800; + reg[15].I += offset; + armNextPC = reg[15].I; + reg[15].I += 2; + } + break; + case 0xf0: + case 0xf1: + case 0xf2: + case 0xf3: + { + // BLL #offset + int offset = (opcode & 0x7FF); + reg[14].I = reg[15].I + (offset << 12); + } + break; + case 0xf4: + case 0xf5: + case 0xf6: + case 0xf7: + { + // BLL #offset + int offset = (opcode & 0x7FF); + reg[14].I = reg[15].I + ((offset << 12) | 0xFF800000); + } + break; + case 0xf8: + case 0xf9: + case 0xfa: + case 0xfb: + case 0xfc: + case 0xfd: + case 0xfe: + case 0xff: + { + // BLH #offset + int offset = (opcode & 0x7FF); + u32 temp = reg[15].I-2; + reg[15].I = (reg[14].I + (offset<<1))&0xFFFFFFFE; + armNextPC = reg[15].I; + reg[15].I += 2; + reg[14].I = temp|1; + } + break; +#ifdef BKPT_SUPPORT + case 0xbe: + // BKPT #comment + extern void (*dbgSignal)(int,int); + reg[15].I -= 2; + armNextPC -= 2; + dbgSignal(5, opcode & 255); + return; +#endif + case 0xb1: + case 0xb2: + case 0xb3: + case 0xb6: + case 0xb7: + case 0xb8: + case 0xb9: + case 0xba: + case 0xbb: +#ifndef BKPT_SUPPORT + case 0xbe: +#endif + case 0xbf: + case 0xde: + default: + unknown_thumb: +#ifdef DEV_VERSION + if(systemVerbose & VERBOSE_UNDEFINED) + log("Undefined THUMB instruction %04x at %08x\n", opcode, armNextPC-2); +#endif + CPUUndefinedException(); + break; +} diff --git a/src/unzip.cpp b/src/unzip.cpp new file mode 100644 index 0000000..98c50e9 --- /dev/null +++ b/src/unzip.cpp @@ -0,0 +1,1270 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/* unzip.c -- IO on .zip files using zlib + Version 0.15 beta, Mar 19th, 1998, + + Read unzip.h for more info +*/ + + +#include +#include +#include +#include "zlib.h" +#include "unzip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + + + +#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ + !defined(CASESENSITIVITYDEFAULT_NO) +#define CASESENSITIVITYDEFAULT_NO +#endif + + +#ifndef UNZ_BUFSIZE +#define UNZ_BUFSIZE (16384) +#endif + +#ifndef UNZ_MAXFILENAMEINZIP +#define UNZ_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +const char unz_copyright[] = + " unzip 0.15 Copyright 1998 Gilles Vollant "; + +/* unz_file_info_interntal contain internal info about a file in zipfile*/ +typedef struct unz_file_info_internal_s +{ + uLong offset_curfile;/* relative offset of local header 4 bytes */ +} unz_file_info_internal; + + +/* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ +typedef struct +{ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + FILE* file; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ +} file_in_zip_read_info_s; + + +/* unz_s contain internal information about the zipfile +*/ +typedef struct +{ + FILE* file; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ +} unz_s; + + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ + + +local int unzlocal_getByte(FILE *fin,int *pi) +{ + unsigned char c; + int err = fread(&c, 1, 1, fin); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ferror(fin)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int unzlocal_getShort (FILE *fin,uLong *pX) +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unzlocal_getLong (FILE *fin,uLong *pX) +{ + uLong x ; + int i; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + + +/* My own strcmpi / strcasecmp */ +local int strcmpcasenosensitive_internal (const char *fileName1, + const char *fileName2) +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + +#ifdef CASESENSITIVITYDEFAULT_NO +#define CASESENSITIVITYDEFAULTVALUE 2 +#else +#define CASESENSITIVITYDEFAULTVALUE 1 +#endif + +#ifndef STRCMPCASENOSENTIVEFUNCTION +#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal +#endif + +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + +*/ +extern int ZEXPORT unzStringFileNameCompare (const char *fileName1, + const char *fileName2, + int iCaseSensitivity) +{ + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} + +#define BUFREADCOMMENT (0x400) + +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local uLong unzlocal_SearchCentralDir(FILE *fin) +{ + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (fseek(fin,0,SEEK_END) != 0) + return 0; + + + uSizeFile = ftell( fin ); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (fseek(fin,uReadPos,SEEK_SET)!=0) + break; + + if (fread(buf,(uInt)uReadSize,1,fin)!=1) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer + "zlib/zlib109.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ +extern unzFile ZEXPORT unzOpen (const char *path) +{ + unz_s us; + unz_s *s; + uLong central_pos,uL; + FILE * fin ; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + fin=fopen(path,"rb"); + if (fin==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) + err=UNZ_ERRNO; + + if (fseek(fin,central_pos,SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + fclose(s->file); + TRYFREE(s); + return UNZ_OK; +} + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ +extern int ZEXPORT unzGetGlobalInfo (unzFile file, + unz_global_info *pglobal_info) +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + + +/* + Translate date/time from Dos format to tm_unz (readable more easilty) +*/ +local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm) +{ + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +/* + Get Info about the current file in the zipfile, with internal only info +*/ +local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +local int unzlocal_GetCurrentFileInfoInternal (unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) +{ + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. +*/ +extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) +{ + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); +} + +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ +extern int ZEXPORT unzGoToFirstFile (unzFile file) +{ + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ +extern int ZEXPORT unzGoToNextFile (unzFile file) +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzipStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ +extern int ZEXPORT unzLocateFile (unzFile file, + const char *szFileName, + int iCaseSensitivity) +{ + unz_s* s; + int err; + + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; +} + + +/* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) +*/ +local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s, + uInt *piSizeVar, + uLong *poffset_local_extrafield, + uInt *psize_local_extrafield) +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (fseek(s->file,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; +/* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; +*/ + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + +/* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. +*/ +extern int ZEXPORT unzOpenCurrentFile (unzFile file) +{ + int err=UNZ_OK; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + Store = s->cur_file_info.compression_method==0; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + + s->pfile_in_zip_read = pfile_in_zip_read_info; + return UNZ_OK; +} + + +/* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ +extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) +{ + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, + pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if (pfile_in_zip_read_info->compression_method==0) + { + uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; +} + + +/* + Give the current position in uncompressed data +*/ +extern z_off_t ZEXPORT unztell (unzFile file) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + + +/* + return 1 if the end of file was reached, 0 elsewhere +*/ +extern int ZEXPORT unzeof (unzFile file) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + + + +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ +extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len) +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + + return (int)read_now; +} + +/* + Close the file in zip opened with unzipOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ +extern int ZEXPORT unzCloseCurrentFile (unzFile file) +{ + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; +} + + +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ +extern int ZEXPORT unzGetGlobalComment (unzFile file, + char *szComment, + uLong uSizeBuf) +{ + //int err=UNZ_OK; + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} diff --git a/src/unzip.h b/src/unzip.h new file mode 100644 index 0000000..003e738 --- /dev/null +++ b/src/unzip.h @@ -0,0 +1,294 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/* unzip.h -- IO for uncompress .zip files using zlib + Version 0.15 beta, Mar 19th, 1998, + + Copyright (C) 1998 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE + CAN CHANGE IN FUTURE VERSION !! + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ +/* for more info about .ZIP format, see + ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip */ + +#ifndef _unz_H +#define _unz_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info_s +{ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT unzOpen OF((const char *path)); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer + "zlib/zlib111.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ + +extern int ZEXPORT unzClose OF((unzFile file)); +/* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT unztell OF((unzFile file)); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT unzeof OF((unzFile file)); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _unz_H */ diff --git a/src/win32/.cvsignore b/src/win32/.cvsignore new file mode 100644 index 0000000..5dff38d --- /dev/null +++ b/src/win32/.cvsignore @@ -0,0 +1 @@ +vba.aps diff --git a/src/win32/AVIWrite.cpp b/src/win32/AVIWrite.cpp new file mode 100644 index 0000000..4943224 --- /dev/null +++ b/src/win32/AVIWrite.cpp @@ -0,0 +1,187 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "AVIWrite.h" + +AVIWrite::AVIWrite() +{ + m_failed = false; + m_file = NULL; + m_stream = NULL; + m_streamCompressed = NULL; + m_streamSound = NULL; + m_samplesSound = 0; + + AVIFileInit(); +} + +AVIWrite::~AVIWrite() +{ + if(m_streamSound) + AVIStreamClose(m_streamSound); + + if(m_streamCompressed) + AVIStreamClose(m_streamCompressed); + + if(m_stream) + AVIStreamClose(m_stream); + + if(m_file) + AVIFileClose(m_file); + + AVIFileExit(); +} + +void AVIWrite::SetVideoFormat(BITMAPINFOHEADER *bh) +{ + // force size to 0x28 to avoid extra fields + memcpy(&m_bitmap, bh, 0x28); +} + +void AVIWrite::SetSoundFormat(WAVEFORMATEX *format) +{ + memcpy(&m_soundFormat, format, sizeof(WAVEFORMATEX)); + ZeroMemory(&m_soundHeader, sizeof(AVISTREAMINFO)); + // setup the sound stream header + m_soundHeader.fccType = streamtypeAUDIO; + m_soundHeader.dwQuality = (DWORD)-1; + m_soundHeader.dwScale = format->nBlockAlign; + m_soundHeader.dwInitialFrames = 1; + m_soundHeader.dwRate = format->nAvgBytesPerSec; + m_soundHeader.dwSampleSize = format->nBlockAlign; + + // create the sound stream + if(FAILED(AVIFileCreateStream(m_file, &m_streamSound, &m_soundHeader))) { + m_failed = true; + return; + } + + // setup the sound stream format + if(FAILED(AVIStreamSetFormat(m_streamSound, 0 , (void *)&m_soundFormat, + sizeof(WAVEFORMATEX)))) { + m_failed = true; + return; + } +} + +bool AVIWrite::Open(const char *filename) +{ + // create the AVI file + if(FAILED(AVIFileOpen(&m_file, + filename, + OF_WRITE | OF_CREATE, + NULL))) { + m_failed = true; + return false; + } + // setup the video stream information + ZeroMemory(&m_header, sizeof(AVISTREAMINFO)); + m_header.fccType = streamtypeVIDEO; + m_header.dwScale = 1; + m_header.dwRate = m_fps; + m_header.dwSuggestedBufferSize = m_bitmap.biSizeImage; + + // create the video stream + if(FAILED(AVIFileCreateStream(m_file, + &m_stream, + &m_header))) { + m_failed = true; + return false; + } + + ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS)); + m_arrayOptions[0] = &m_options; + + // call the dialog to setup the compress options to be used + if(!AVISaveOptions(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), 0, 1, &m_stream, m_arrayOptions)) { + m_failed = true; + return false; + } + + // create the compressed stream + if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) { + m_failed = true; + return false; + } + + // setup the video stream format + if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0, + &m_bitmap, + m_bitmap.biSize + + m_bitmap.biClrUsed * sizeof(RGBQUAD)))) { + m_failed = true; + return false; + } + + return true; +} + +bool AVIWrite::AddSound(const char *sound, int len) +{ + // return if we failed somewhere already + if(m_failed) + return false; + + int samples = len / m_soundFormat.nBlockAlign; + + if(FAILED(AVIStreamWrite(m_streamSound, + m_samplesSound, + samples, + (LPVOID)sound, + len, + 0, + NULL, + NULL))) { + m_failed = true; + return false; + } + m_samplesSound += samples; + + return true; +} + +bool AVIWrite::AddFrame(const int frame, const char *bmp) +{ + if (m_failed) + return false; + + // write the frame to the video stream + if(FAILED(AVIStreamWrite(m_streamCompressed, + frame, + 1, + (LPVOID)bmp, + m_bitmap.biSizeImage, + AVIIF_KEYFRAME, + NULL, + NULL))) { + m_failed = true; + return false; + } + return true; +} + +bool AVIWrite::IsSoundAdded() +{ + return m_streamSound != NULL; +} + +void AVIWrite::SetFPS(int f) +{ + m_fps = f; +} diff --git a/src/win32/AVIWrite.h b/src/win32/AVIWrite.h new file mode 100644 index 0000000..74daab9 --- /dev/null +++ b/src/win32/AVIWrite.h @@ -0,0 +1,49 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include + +class AVIWrite { + public: + AVIWrite(); + virtual ~AVIWrite(); + + bool Open(const char *filename); + virtual bool AddFrame(const int number, const char * bmp); + void SetFPS(int fps); + void SetVideoFormat(BITMAPINFOHEADER *); + bool IsSoundAdded(); + void SetSoundFormat(WAVEFORMATEX *); + bool AddSound(const char *sound, int len); + + private: + int m_fps; + WAVEFORMATEX m_soundFormat; + BITMAPINFOHEADER m_bitmap; + AVISTREAMINFO m_header; + AVISTREAMINFO m_soundHeader; + PAVIFILE m_file; + PAVISTREAM m_stream; + PAVISTREAM m_streamCompressed; + PAVISTREAM m_streamSound; + AVICOMPRESSOPTIONS m_options; + AVICOMPRESSOPTIONS *m_arrayOptions[1]; + int m_samplesSound; + bool m_failed; +}; diff --git a/src/win32/AboutDialog.cpp b/src/win32/AboutDialog.cpp new file mode 100644 index 0000000..966e9de --- /dev/null +++ b/src/win32/AboutDialog.cpp @@ -0,0 +1,83 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// AboutDialog.cpp : implementation file +// + +#include "AboutDialog.h" +#include "../AutoBuild.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// AboutDialog dialog + + +AboutDialog::AboutDialog(CWnd* pParent /*=NULL*/) + : CDialog(AboutDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(AboutDialog) + m_version = _T(VERSION); + //}}AFX_DATA_INIT +} + + +void AboutDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AboutDialog) + DDX_Text(pDX, IDC_VERSION, m_version); + DDX_Control(pDX, IDC_URL, m_link); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AboutDialog, CDialog) + //{{AFX_MSG_MAP(AboutDialog) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AboutDialog message handlers + +BOOL AboutDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL); + if(p) { + m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this); + } + + m_link.SetWindowText("http://vba.ngemu.com"); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void AboutDialog::OnOK() +{ + // TODO: Add extra validation here + + CDialog::OnOK(); +} diff --git a/src/win32/AboutDialog.h b/src/win32/AboutDialog.h new file mode 100644 index 0000000..297dd1f --- /dev/null +++ b/src/win32/AboutDialog.h @@ -0,0 +1,73 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_) +#define AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// AboutDialog.h : header file +// +#include "stdafx.h" +#include "Hyperlink.h" +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +// AboutDialog dialog + +class AboutDialog : public CDialog +{ + Hyperlink m_link; + Hyperlink m_translator; + // Construction + public: + AboutDialog(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AboutDialog) + enum { IDD = IDD_ABOUT }; + CString m_version; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AboutDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AboutDialog) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + //}}AFX_MSG + + + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ABOUTDIALOG_H__48D787B2_0699_4F03_827D_404EC70DDDB2__INCLUDED_) diff --git a/src/win32/AccelEditor.cpp b/src/win32/AccelEditor.cpp new file mode 100644 index 0000000..0acd64e --- /dev/null +++ b/src/win32/AccelEditor.cpp @@ -0,0 +1,363 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// AccelEditor.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "AccelEditor.h" +#include "CmdAccelOb.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// AccelEditor dialog + + +AccelEditor::AccelEditor(CWnd* pParent /*=NULL*/) + : ResizeDlg(AccelEditor::IDD, pParent) +{ + //{{AFX_DATA_INIT(AccelEditor) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + mgr = theApp.winAccelMgr; + m_commonOnly = false; +} + + +void AccelEditor::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AccelEditor) + DDX_Control(pDX, IDC_CURRENTS, m_currents); + DDX_Control(pDX, IDC_ALREADY_AFFECTED, m_alreadyAffected); + DDX_Control(pDX, IDC_COMMANDS, m_commands); + DDX_Control(pDX, IDC_COMMANDS_HIDDEN, m_commands_hidden); + DDX_Control(pDX, IDC_EDIT_KEY, m_key); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AccelEditor, CDialog) + //{{AFX_MSG_MAP(AccelEditor) + ON_BN_CLICKED(ID_OK, OnOk) + ON_LBN_SELCHANGE(IDC_COMMANDS, OnSelchangeCommands) + ON_BN_CLICKED(IDC_RESET, OnReset) + ON_BN_CLICKED(IDC_ASSIGN, OnAssign) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(IDC_REMOVE, OnRemove) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AccelEditor message handlers + +BOOL AccelEditor::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_STATIC3, DS_MoveX | DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_ALREADY_AFFECTED, DS_MoveY) + DIALOG_SIZER_ENTRY( ID_OK, DS_MoveX) + DIALOG_SIZER_ENTRY( ID_CANCEL, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_ASSIGN, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_REMOVE, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_RESET, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_COMMANDS, DS_SizeX | DS_SizeY) + DIALOG_SIZER_ENTRY( IDC_CURRENTS, DS_MoveX | DS_SizeY) + DIALOG_SIZER_ENTRY( IDC_EDIT_KEY, DS_MoveX | DS_MoveY) + DIALOG_SIZER_END() + + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\AccelEditor", + NULL); + + InitCommands(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void AccelEditor::InitCommands() +{ + m_commands.ResetContent(); + m_commands_hidden.ResetContent(); + m_alreadyAffected.SetWindowText(""); + + POSITION pos = mgr.m_mapAccelString.GetStartPosition(); + + while(pos != NULL) { + CString command; + WORD wID; + mgr.m_mapAccelString.GetNextAssoc(pos, command, wID); + + CString tempStr = command; + int commonMark = tempStr.Find("(!)", 0); + if(commonMark >= 0) + tempStr.Truncate(commonMark); // cut off the (!) + + if(!m_commonOnly || commonMark >= 0) + { + int index = m_commands.AddString(tempStr); + m_commands.SetItemData(index, wID); + } + else + { + int index = m_commands_hidden.AddString(tempStr); + m_commands_hidden.SetItemData(index, wID); + } + } + + // Update the currents accels associated with the selected command + if (m_commands.SetCurSel(0) != LB_ERR) + OnSelchangeCommands(); +} + +void AccelEditor::OnCancel() +{ + EndDialog(FALSE); +} + +void AccelEditor::OnOk() +{ + EndDialog(TRUE); +} + +void AccelEditor::OnSelchangeCommands() +{ + // Check if some commands exist. + int index = m_commands.GetCurSel(); + if (index == LB_ERR) + return; + + WORD wIDCommand = LOWORD(m_commands.GetItemData(index)); + m_currents.ResetContent(); + + CCmdAccelOb* pCmdAccel; + + if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) { + CAccelsOb* pAccel; + CString szBuffer; + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + + // Add the keys to the 'currents keys' listbox. + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + pAccel->GetString(szBuffer); + index = m_currents.AddString(szBuffer); + // and a pointer to the accel object. + m_currents.SetItemData(index, (DWORD)pAccel); + } + } + // Init the key editor + // m_pKey->ResetKey(); + +} + +void AccelEditor::OnReset() +{ + mgr.Default(); /// FIXME accelerator reset NYI + systemMessage(0,"The \"Reset All Accelerators\" feature is currently unimplemented.\nYou can achieve the same result by closing VBA, opening up your \"vba.ini\" file, deleting the line that starts with \"keyboard\", then reopening VBA."); + InitCommands(); // update the listboxes. +} + +void AccelEditor::OnAssign() +{ + // Control if it's not already affected + CCmdAccelOb* pCmdAccel; + CAccelsOb* pAccel; + WORD wIDCommand; + POSITION pos; + + WORD wKey; + bool bCtrl, bAlt, bShift; + + if (!m_key.GetAccelKey(wKey, bCtrl, bAlt, bShift)) + return; // no valid key, abort + + + // get the currently selected group + int index = m_commands.GetCurSel(); + if (index == LB_ERR) + return; + + // Get the object who manage the accels list, associated to the command. + wIDCommand = LOWORD(m_commands.GetItemData(index)); + + + int count = m_commands.GetCount(); + for (int index2 = 0; index2 < count; index2++) { + + WORD wIDCommand2 = LOWORD(m_commands.GetItemData(index2)); + mgr.m_mapAccelTable.Lookup(wIDCommand2, pCmdAccel); + + pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) { + // the key is already affected (in the same or other command) + // (the parts that are commented out allow for a one-to-many mapping, + // which is only disabled because the MFC stuff that automagically activates the commands + // doesn't seem to be capable of activating more than one command per accelerator...) +// if (wIDCommand != wIDCommand2) { + // the key is already affected by a different command and also not already affected by the same commmand + + CString tempStr = pCmdAccel->m_szCommand; + int commonMark = tempStr.Find("(!)", 0); + if(commonMark >= 0) + tempStr.Truncate(commonMark); // cut off the (!) + + m_alreadyAffected.SetWindowText(tempStr); +// } else { +// // the key is already affected by the same command + m_key.SetSel(0, -1); + mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel); +// m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand); + return; // abort +// } + } + } + } + + // also check against any currently hidden commands + int count2 = m_commands_hidden.GetCount(); + for (int index3 = 0; index3 < count2; index3++) { + + WORD wIDCommand2 = LOWORD(m_commands_hidden.GetItemData(index3)); + mgr.m_mapAccelTable.Lookup(wIDCommand2, pCmdAccel); + + pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel->IsEqual(wKey, bCtrl, bAlt, bShift)) { + // the key is already affected (in the same or other command) + // (the parts that are commented out allow for a one-to-many mapping, + // which is only disabled because the MFC stuff that automagically activates the commands + // doesn't seem to be capable of activating more than one command per accelerator...) +// if (wIDCommand != wIDCommand2) { + // the key is already affected by a different command and also not already affected by the same commmand + CString tempStr = pCmdAccel->m_szCommand; // store because pCmdAccel changes after this + m_alreadyAffected.SetWindowText(tempStr); +// } else { +// // the key is already affected by the same command + m_key.SetSel(0, -1); + mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel); +// m_alreadyAffected.SetWindowText(pCmdAccel->m_szCommand); + + // unhide the conflicting command + // note that it will also stay in the hidden list, but that doesn't matter + int newIndex = m_commands.AddString(tempStr); + m_commands.SetItemData(newIndex, wIDCommand2); + + return; // abort +// } + } + } + } + + + + + if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) != TRUE) + return; + + BYTE cVirt = 0; + if (bCtrl) + cVirt |= FCONTROL; + if (bAlt) + cVirt |= FALT; + if (bShift) + cVirt |= FSHIFT; + + cVirt |= FVIRTKEY; + + // Create the new key... + pAccel = new CAccelsOb(cVirt, wKey, false); + ASSERT(pAccel != NULL); + // ...and add in the list. + pCmdAccel->m_Accels.AddTail(pAccel); + + // Update the listbox. + CString szBuffer; + pAccel->GetString(szBuffer); + + index = m_currents.AddString(szBuffer); + m_currents.SetItemData(index, (DWORD)pAccel); + + // Reset the key editor. + m_key.ResetKey(); +} + +void AccelEditor::OnRemove() +{ + // Some controls + int indexCurrent = m_currents.GetCurSel(); + if (indexCurrent == LB_ERR) + return; + + // 2nd part. + int indexCmd = m_commands.GetCurSel(); + if (indexCmd == LB_ERR) + return; + + // Ref to the ID command + WORD wIDCommand = LOWORD(m_commands.GetItemData(indexCmd)); + + // Run through the accels,and control if it can be deleted. + CCmdAccelOb* pCmdAccel; + if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) { + CAccelsOb* pAccel; + CAccelsOb* pAccelCurrent = (CAccelsOb*)(m_currents.GetItemData(indexCurrent)); + CString szBuffer; + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + POSITION PrevPos; + while (pos != NULL) { + PrevPos = pos; + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel == pAccelCurrent) { + if (!pAccel->m_bLocked) { + // not locked, so we delete the key + pCmdAccel->m_Accels.RemoveAt(PrevPos); + delete pAccel; + // and update the listboxes/key editor/static text + m_currents.DeleteString(indexCurrent); + m_key.ResetKey(); + m_alreadyAffected.SetWindowText(""); + return; + } else { + systemMessage(0,"Unable to remove this\naccelerator (Locked)"); + return; + } + } + } + systemMessage(0,"internal error (CAccelDlgHelper::Remove : pAccel unavailable)"); + return; + } + systemMessage(0,"internal error (CAccelDlgHelper::Remove : Lookup failed)"); +} diff --git a/src/win32/AccelEditor.h b/src/win32/AccelEditor.h new file mode 100644 index 0000000..a5f9118 --- /dev/null +++ b/src/win32/AccelEditor.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_) +#define AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// AccelEditor.h : header file +// +#include "AcceleratorManager.h" +#include "KeyboardEdit.h" +#include "ResizeDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// AccelEditor dialog + +class AccelEditor : public ResizeDlg +{ + // Construction + public: + CAcceleratorManager mgr; + void InitCommands(); + AccelEditor(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AccelEditor) + enum { IDD = IDD_ACCEL_EDITOR }; + CListBox m_currents; + CStatic m_alreadyAffected; + CListBox m_commands; + CListBox m_commands_hidden; + CKeyboardEdit m_key; + //}}AFX_DATA + bool m_commonOnly; + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AccelEditor) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AccelEditor) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnSelchangeCommands(); + afx_msg void OnReset(); + afx_msg void OnAssign(); + afx_msg void OnRemove(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_) diff --git a/src/win32/AcceleratorManager.cpp b/src/win32/AcceleratorManager.cpp new file mode 100644 index 0000000..795b6cc --- /dev/null +++ b/src/win32/AcceleratorManager.cpp @@ -0,0 +1,801 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : AcceleratorManager.cpp +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Author : T.Maurel +// Date : 17.08.98 +// +// Remarks : implementation of the CAcceleratorManager class. +// +//////////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +//#include "resource.h" +#include "../System.h" + +#include "AcceleratorManager.h" +#include "Reg.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +#include // MIIM_STRING + + +////////////////////////////////////////////////////////////////////// +// Constructor/Destructor +////////////////////////////////////////////////////////////////////// +// +// +CAcceleratorManager::CAcceleratorManager() +{ + m_hRegKey = HKEY_CURRENT_USER; + m_szRegKey = ""; + m_bAutoSave = FALSE; + m_pWndConnected = NULL; + + m_bDefaultTable = false; +} + + +////////////////////////////////////////////////////////////////////// +// +// +CAcceleratorManager::~CAcceleratorManager() +{ + if ((m_bAutoSave == true) && (m_szRegKey.IsEmpty() != FALSE)) { + // bool bRet = Write(); + // if (!bRet) + // systemMessage(0, "CAcceleratorManager::~CAcceleratorManager\nError in CAcceleratorManager::Write..."); + } + + Reset(); +} + + +////////////////////////////////////////////////////////////////////// +// Internal fcts +////////////////////////////////////////////////////////////////////// +// +// +void CAcceleratorManager::Reset() +{ + CCmdAccelOb* pCmdAccel; + WORD wKey; + POSITION pos = m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + delete pCmdAccel; + } + m_mapAccelTable.RemoveAll(); + m_mapAccelString.RemoveAll(); + + pos = m_mapAccelTableSaved.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel); + delete pCmdAccel; + } + m_mapAccelTableSaved.RemoveAll(); +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked) +{ + ASSERT(szCommand != NULL); + + WORD wIDCmd; + if (m_mapAccelString.Lookup(szCommand, wIDCmd) == TRUE) { + if (wIDCmd != wIDCommand) + return false; + } + + CCmdAccelOb* pCmdAccel = NULL; + if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) { + if (pCmdAccel->m_szCommand != szCommand) { + return false; + } + CAccelsOb* pAccel; + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel->m_cVirt == cVirt && + pAccel->m_wKey == wKey) + return FALSE; + } + // Adding the accelerator + pCmdAccel->Add(cVirt, wKey, bLocked); + + } else { + pCmdAccel = new CCmdAccelOb(cVirt, wIDCommand, wKey, szCommand, bLocked); + ASSERT(pCmdAccel != NULL); + m_mapAccelTable.SetAt(wIDCommand, pCmdAccel); + } + // 2nd table + m_mapAccelString.SetAt(szCommand, wIDCommand); + return true; +} + + +////////////////////////////////////////////////////////////////////// +// Debug fcts +////////////////////////////////////////////////////////////////////// +// +// +#ifdef _DEBUG +void CAcceleratorManager::AssertValid() const +{ +} + +////////////////////////////////////////////////////////////////////// +// +// +void CAcceleratorManager::Dump(CDumpContext& dc) const +{ + CCmdAccelOb* pCmdAccel; + WORD wKey; + dc << "CAcceleratorManager::Dump :\n"; + dc << "m_mapAccelTable :\n"; + POSITION pos = m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + dc << "a CCmdAccelOb at 0x" << (void*)pCmdAccel << " = {\n"; + dc << pCmdAccel; + dc << "}\n"; + } + dc << "\nm_mapAccelTableSaved\n"; + pos = m_mapAccelTableSaved.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel); + dc << "a CCmdAccelOb at 0x" << (void*)pCmdAccel << " = {\n"; + dc << pCmdAccel; + dc << "}\n"; + } +} +#endif + + +////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////// +// +// +void CAcceleratorManager::Connect(CWnd* pWnd, bool bAutoSave) +{ + ASSERT(m_pWndConnected == NULL); + m_pWndConnected = pWnd; + m_bAutoSave = bAutoSave; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::GetRegKey(HKEY& hRegKey, CString& szRegKey) +{ + if (m_szRegKey.IsEmpty()) + return false; + + hRegKey = m_hRegKey; + szRegKey = m_szRegKey; + return true; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::SetRegKey(HKEY hRegKey, LPCTSTR szRegKey) +{ + ASSERT(hRegKey != NULL); + ASSERT(szRegKey != NULL); + + m_szRegKey = szRegKey; + m_hRegKey = hRegKey; + return true; +} + + +////////////////////////////////////////////////////////////////////// +// Update the application's ACCELs table +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::UpdateWndTable() +{ + int iLoop = 0; + CTypedPtrArray arrayACCEL; + + CCmdAccelOb* pCmdAccel; + WORD wKey; + LPACCEL pACCEL; + CAccelsOb* pAccelOb; + POSITION pos = m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccelOb = pCmdAccel->m_Accels.GetNext(pos); + + pACCEL = new ACCEL; + ASSERT(pACCEL != NULL); + pACCEL->fVirt = pAccelOb->m_cVirt; + pACCEL->key = pAccelOb->m_wKey; + pACCEL->cmd = pCmdAccel->m_wIDCommand; + arrayACCEL.Add(pACCEL); + } + } + + int nAccel = arrayACCEL.GetSize(); + LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL)); + if (!lpAccel) { + for (iLoop = 0; iLoop < nAccel; iLoop++) + delete arrayACCEL.GetAt(iLoop); + arrayACCEL.RemoveAll(); + + return false; + } + + for (iLoop = 0; iLoop < nAccel; iLoop++) { + + pACCEL = arrayACCEL.GetAt(iLoop); + lpAccel[iLoop].fVirt = pACCEL->fVirt; + lpAccel[iLoop].key = pACCEL->key; + lpAccel[iLoop].cmd = pACCEL->cmd; + + delete pACCEL; + } + arrayACCEL.RemoveAll(); + + HACCEL hNewTable = CreateAcceleratorTable(lpAccel, nAccel); + if (!hNewTable) { + ::LocalFree(lpAccel); + return false; + } + HACCEL hOldTable = theApp.hAccel; + if (!::DestroyAcceleratorTable(hOldTable)) { + ::LocalFree(lpAccel); + return false; + } + theApp.hAccel = hNewTable; + ::LocalFree(lpAccel); + + UpdateMenu(GetMenu(*AfxGetApp()->m_pMainWnd)); + + return true; +} + + +////////////////////////////////////////////////////////////////////// +// Create/Destroy accelerators +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wKey) +{ + CCmdAccelOb* pCmdAccel = NULL; + if (m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE) { + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + POSITION PrevPos; + CAccelsOb* pAccel = NULL; + while (pos != NULL) { + PrevPos = pos; + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel->m_bLocked == true) + return false; + + if (pAccel->m_cVirt == cVirt && pAccel->m_wKey == wKey) { + pCmdAccel->m_Accels.RemoveAt(PrevPos); + delete pAccel; + return true; + } + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::DeleteEntry(WORD wIDCommand) +{ + CCmdAccelOb* pCmdAccel = NULL; + VERIFY(m_mapAccelTable.Lookup(wIDCommand, pCmdAccel) == TRUE); + + CAccelsOb* pAccel; + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (pAccel->m_bLocked == true) + return false; + } + m_mapAccelString.RemoveKey(pCmdAccel->m_szCommand); + m_mapAccelTable.RemoveKey(wIDCommand); + delete pCmdAccel; + + return true; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand) +{ + ASSERT(szCommand != NULL); + + WORD wIDCommand; + if (m_mapAccelString.Lookup(szCommand, wIDCommand) == TRUE) { + return DeleteEntry(wIDCommand); + } + return true; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::SetAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked) +{ + ASSERT(szCommand != NULL); + + return AddAccel(cVirt, wIDCommand, wKey, szCommand, bLocked); +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked) +{ + ASSERT(szCommand != NULL); + + ASSERT(m_pWndConnected != NULL); + HACCEL hOriginalTable = theApp.hAccel; + + int nAccel = ::CopyAcceleratorTable(hOriginalTable, NULL, 0); + LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, (nAccel) * sizeof(ACCEL)); + if (!lpAccel) + return false; + ::CopyAcceleratorTable(hOriginalTable, lpAccel, nAccel); + + bool bRet = false; + for (int i = 0; i < nAccel; i++) { + if (lpAccel[i].cmd == wIDCommand) + bRet = AddAccel(lpAccel[i].fVirt, wIDCommand, lpAccel[i].key, szCommand, bLocked); + } + ::LocalFree(lpAccel); + return bRet; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand) +{ + ASSERT(szCommand != NULL); + + WORD wIDDummy; + if (m_mapAccelString.Lookup(szCommand, wIDDummy) == TRUE) + return false; + + CCmdAccelOb* pCmdAccel = new CCmdAccelOb(wIDCommand, szCommand); + ASSERT(pCmdAccel != NULL); + m_mapAccelTable.SetAt(wIDCommand, pCmdAccel); + m_mapAccelString.SetAt(szCommand, wIDCommand); + + return false; +} + + +////////////////////////////////////////////////////////////////////// +// Get a string from the ACCEL definition +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel) +{ + ASSERT(pACCEL != NULL); + + CAccelsOb accel(pACCEL); + accel.GetString(szAccel); + + if (szAccel.IsEmpty()) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel) +{ + CAccelsOb accel(cVirt, nCode); + accel.GetString(szAccel); + + if (szAccel.IsEmpty()) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////// +// Copy function +// +CAcceleratorManager& CAcceleratorManager::operator=(const CAcceleratorManager& accelmgr) +{ + Reset(); + + CCmdAccelOb* pCmdAccel; + CCmdAccelOb* pNewCmdAccel; + WORD wKey; + // Copy the 2 tables : normal accel table... + POSITION pos = accelmgr.m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + accelmgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + pNewCmdAccel = new CCmdAccelOb; + ASSERT(pNewCmdAccel != NULL); + *pNewCmdAccel = *pCmdAccel; + m_mapAccelTable.SetAt(wKey, pNewCmdAccel); + } + // ... and saved accel table. + pos = accelmgr.m_mapAccelTableSaved.GetStartPosition(); + while (pos != NULL) { + accelmgr.m_mapAccelTableSaved.GetNextAssoc(pos, wKey, pCmdAccel); + pNewCmdAccel = new CCmdAccelOb; + ASSERT(pNewCmdAccel != NULL); + *pNewCmdAccel = *pCmdAccel; + m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel); + } + + // The Strings-ID table + CString szKey; + pos = accelmgr.m_mapAccelString.GetStartPosition(); + while (pos != NULL) { + accelmgr.m_mapAccelString.GetNextAssoc(pos, szKey, wKey); + m_mapAccelString.SetAt(szKey, wKey); + } + m_bDefaultTable = accelmgr.m_bDefaultTable; + + return *this; +} + +void CAcceleratorManager::UpdateMenu(HMENU menu) +{ + int count = GetMenuItemCount(menu); + + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + + if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + MENUITEMINFO info; + char ss[128]; + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info) - sizeof(HBITMAP); + info.fMask = MIIM_ID | MIIM_SUBMENU; + for(int i = 0; i < count; i++) { + GetMenuItemInfo(menu, i, TRUE, &info); + + if(info.hSubMenu != NULL) { + UpdateMenu(info.hSubMenu); + } else { + if(info.wID != (UINT)-1) { + MENUITEMINFO info2; + ZeroMemory(&info2, sizeof(info2)); + info2.cbSize = sizeof(info2) - sizeof(HBITMAP); + info2.fMask = MIIM_STRING; + info2.dwTypeData = ss; + info2.cch = 128; + GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2); + CString str = ss; + int index = str.Find('\t'); + if(index != -1) + str = str.Left(index); + + WORD command = info.wID; + + CCmdAccelOb *o; + if(m_mapAccelTable.Lookup(command, o)) { + if(o->m_Accels.GetCount()) { + POSITION pos = o->m_Accels.GetHeadPosition(); + CAccelsOb *accel = o->m_Accels.GetNext(pos); + + CString s; + accel->GetString(s); + str += "\t"; + str += s; + } + } + if(str != ss) + ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str); + } + } + } + } else { + MENUITEMINFO info; + wchar_t ss[128]; + wchar_t str[512]; + + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info); + info.fMask = MIIM_ID | MIIM_SUBMENU; + for(int i = 0; i < count; i++) { + GetMenuItemInfo(menu, i, TRUE, &info); + + if(info.hSubMenu != NULL) { + UpdateMenu(info.hSubMenu); + } else { + if(info.wID != (WORD)-1) { + MENUITEMINFOW info2; + ZeroMemory(&info2, sizeof(info2)); + info2.cbSize = sizeof(info2); + info2.fMask = MIIM_STRING; + info2.dwTypeData = ss; + info2.cch = 128; + GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2); + + wcscpy(str, ss); + + wchar_t *p = wcschr(str, '\t'); + if(p) + *p = 0; + + CCmdAccelOb *o; + WORD command = info.wID; + if(m_mapAccelTable.Lookup(command, o)) { + if(o->m_Accels.GetCount()) { + POSITION pos = o->m_Accels.GetHeadPosition(); + + CAccelsOb *accel = o->m_Accels.GetNext(pos); + + CString s; + accel->GetString(s); + + wchar_t temp[128]; + temp[0] = '\t'; + temp[1] = 0; + wcscat(str, temp); + p = temp; + for(const char *sp = s; *sp; sp++) + *p++ = *sp; + *p = 0; + wcscat(str, temp); + } + } + if(wcscmp(str,ss)) + ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str); + } + } + } + } +} + +////////////////////////////////////////////////////////////////////// +// In/Out to the registry +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey) +{ + ASSERT(szRegKey != NULL); + + m_hRegKey = hRegKey; + m_szRegKey = szRegKey; + + DWORD data[2048/sizeof(DWORD)]; + + DWORD len = sizeof(data); + if(regQueryBinaryValue("keyboard", (char *)data, len)) { + int count = len/sizeof(DWORD); + + CCmdAccelOb* pCmdAccel; + CAccelsOb* pAccel; + DWORD dwIDAccelData, dwAccelData; + BOOL bExistID; + int iIndex = 0; + if(count) { + WORD wKey; + POSITION pos = m_mapAccelTable.GetStartPosition(); + + while(pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + pCmdAccel->DeleteUserAccels(); + } + + while(iIndex < count) { + dwIDAccelData = data[iIndex++]; + + WORD wIDCommand = LOWORD(dwIDAccelData); + bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel); + + if (bExistID) { + pCmdAccel->DeleteUserAccels(); + } + for (int j = 0; j < HIWORD(dwIDAccelData) && iIndex < count; j++) { + dwAccelData = data[iIndex++]; + if (bExistID) { + pAccel = new CAccelsOb; + ASSERT(pAccel != NULL); + pAccel->SetData(dwAccelData); + pCmdAccel->Add(pAccel); + } + } + } + } + UpdateWndTable(); + return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::Load() +{ + BOOL bRet = FALSE; + if (!m_szRegKey.IsEmpty()) + bRet = Load(m_hRegKey, m_szRegKey); + + if (bRet == TRUE) + return true; + else + return false; +} + + +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::Write() +{ + CDWordArray AccelsDatasArray; + CDWordArray CmdDatasArray; + + int iCount = 0; + CCmdAccelOb* pCmdAccel; + CAccelsOb* pAccel; + DWORD dwAccelData; + + WORD wKey; + POSITION pos = m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + CmdDatasArray.RemoveAll(); + + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + // if (!pAccel->m_bLocked) { + dwAccelData = pAccel->GetData(); + CmdDatasArray.Add(dwAccelData); + // } + } + + if (CmdDatasArray.GetSize() > 0) { + CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize())); + + AccelsDatasArray.Append(CmdDatasArray); + iCount++; + } + } + // AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount)); + + int count = AccelsDatasArray.GetSize(); + DWORD *data = (DWORD *)malloc(count * sizeof(DWORD)); + ASSERT(data != NULL); + + for(int index = 0; index < count; index++) + data[index] = AccelsDatasArray[index]; + + regSetBinaryValue("keyboard", (char *)data, count*sizeof(DWORD)); + + AccelsDatasArray.RemoveAll(); + CmdDatasArray.RemoveAll(); + + free(data); + + return true; +} + + +////////////////////////////////////////////////////////////////////// +// Defaults values management. +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::CreateDefaultTable() +{ + if (m_bDefaultTable) + return false; + + CCmdAccelOb* pCmdAccel; + CCmdAccelOb* pNewCmdAccel; + + CAccelsOb* pAccel; + CAccelsOb* pNewAccel; + + WORD wKey; + POSITION pos = m_mapAccelTable.GetStartPosition(); + while (pos != NULL) { + m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + pNewCmdAccel = new CCmdAccelOb; + ASSERT(pNewCmdAccel != NULL); + + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = pCmdAccel->m_Accels.GetNext(pos); + if (!pAccel->m_bLocked) { + pNewAccel = new CAccelsOb; + ASSERT(pNewAccel != NULL); + + *pNewAccel = *pAccel; + pNewCmdAccel->m_Accels.AddTail(pNewAccel); + } + } + if (pNewCmdAccel->m_Accels.GetCount() != 0) { + pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand; + pNewCmdAccel->m_szCommand = pCmdAccel->m_szCommand; + + m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel); + } else + delete pNewCmdAccel; + } + + m_bDefaultTable = true; + return true; +} + +#include "mainwnd.h" +////////////////////////////////////////////////////////////////////// +// +// +bool CAcceleratorManager::Default() +{ + /// this is NYI for some reason, so the "Reset All" button doesn't work + +/* // still doesn't work: + Reset(); + regDeleteValue("keyboard"); + regDeleteValue("keyboardCount"); + Connect((MainWnd *)theApp.m_pMainWnd); + extern void winAccelAddCommands(CAcceleratorManager& mgr); + Load(); + CreateDefaultTable(); + winAccelAddCommands(*this); + UpdateWndTable(); + Write(); + UpdateMenu(theApp.menu); + m_pWndConnected = NULL; +*/ + return true; +} diff --git a/src/win32/AcceleratorManager.h b/src/win32/AcceleratorManager.h new file mode 100644 index 0000000..73d3740 --- /dev/null +++ b/src/win32/AcceleratorManager.h @@ -0,0 +1,144 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : AcceleratorManager.h +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Author : T.Maurel +// Date : 17.08.98 +// +// Remarks : interface for the CAcceleratorManager class. +// +//////////////////////////////////////////////////////////////////////////////// +#if !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_) +#define AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + + + +#include "CmdAccelOb.h" + + +// Helper map +#include // MFC Templates extension +#ifndef CMapStringToWord +typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord; +#endif + +#ifndef CMapWordToCCmdAccelOb +typedef CMap< WORD, WORD&, CCmdAccelOb*, CCmdAccelOb*& > CMapWordToCCmdAccelOb; +#endif + + +////////////////////////////////////////////////////////////////////// +// +// +class CAcceleratorManager : public CObject { + friend class AccelEditor; + public: + CAcceleratorManager(); + virtual ~CAcceleratorManager(); + + // Operations + public: + void UpdateMenu(HMENU menu); + void UpdateMenu(); + // Connection to the main application wnd + void Connect(CWnd *pWnd, bool bAutoSave = true); + // In/Out with the registry + bool Load(HKEY hRegKey, LPCTSTR szRegKey); + bool Load(); + bool Write(); + // Get the initials accels, not the user's + bool Default(); + // Save a copy in the 2 maps called xxxSaved, which are used in case + // of Default(), to reload the defaults accels. + bool CreateDefaultTable(); + bool IsDefaultTableAvailable() {return m_bDefaultTable;} + bool IsMapStringCommandsEmpty() { + if (m_mapAccelString.IsEmpty()) + return true; + else + return false; + } + + // Registry access configuration + bool GetRegKey(HKEY& hRegKey, CString &szRegKey); + bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey); + bool IsAutoSave() {return m_bAutoSave;} + void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;} + + // Helper fct, used for new menus strings + bool GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel); + bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel); + + // Update the ACCELS table in the application, from the specified + // datas in the manager. + bool UpdateWndTable(); + + // Modification helper fcts + bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, + LPCTSTR szCommand, bool bLocked = false); + bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true); + bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand); + + bool DeleteEntry(LPCTSTR szCommand); + bool DeleteEntry(WORD wIDCommand); + bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract); + + // Affectation operator + CAcceleratorManager& operator=(const CAcceleratorManager& accelmgr); + + public: +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + protected: + // Erase all the datas + void Reset(); + // Internal affect fct. + bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, + LPCTSTR szCommand, bool bLocked); + + // Attributes + protected: + CWnd *m_pWndConnected; + + // User datas +/*TEMP HACK*/public: CMapStringToWord m_mapAccelString; +/*TEMP HACK*/public: CMapWordToCCmdAccelOb m_mapAccelTable; + protected: + // Default datas + CMapWordToCCmdAccelOb m_mapAccelTableSaved; + bool m_bDefaultTable; + + // Where the users datas will be saved in the registry + HKEY m_hRegKey; + CString m_szRegKey; + // if true, there is an auto-save in the registry, when the destructor is called + bool m_bAutoSave; + +}; + + +#endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_) diff --git a/src/win32/Associate.cpp b/src/win32/Associate.cpp new file mode 100644 index 0000000..7eca0f8 --- /dev/null +++ b/src/win32/Associate.cpp @@ -0,0 +1,128 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Associate.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Associate.h" +#include "Reg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// Associate dialog + + +Associate::Associate(CWnd* pParent /*=NULL*/) + : CDialog(Associate::IDD, pParent) +{ + //{{AFX_DATA_INIT(Associate) + m_agb = FALSE; + m_bin = FALSE; + m_cgb = FALSE; + m_gb = FALSE; + m_gba = FALSE; + m_gbc = FALSE; + m_sgb = FALSE; + //}}AFX_DATA_INIT +} + + +void Associate::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(Associate) + DDX_Check(pDX, IDC_AGB, m_agb); + DDX_Check(pDX, IDC_BIN, m_bin); + DDX_Check(pDX, IDC_CGB, m_cgb); + DDX_Check(pDX, IDC_GB, m_gb); + DDX_Check(pDX, IDC_GBA, m_gba); + DDX_Check(pDX, IDC_GBC, m_gbc); + DDX_Check(pDX, IDC_SGB, m_sgb); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(Associate, CDialog) + //{{AFX_MSG_MAP(Associate) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Associate message handlers + +BOOL Associate::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void Associate::OnCancel() +{ + EndDialog(FALSE); +} + +void Associate::OnOk() +{ + UpdateData(); + + int mask = 0; + if(m_gb) + mask |= 1; + if(m_sgb) + mask |= 2; + if(m_cgb) + mask |= 4; + if(m_gbc) + mask |= 8; + if(m_gba) + mask |= 16; + if(m_agb) + mask |= 32; + if(m_bin) + mask |= 64; + if(mask) { + char applicationPath[2048]; + CString commandPath; + LPCTSTR types[] = { ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" }; + GetModuleFileName(NULL, applicationPath, 2048); + commandPath.Format("\"%s\" \"%%1\"", applicationPath); + regAssociateType("VisualBoyAdvance.Binary", + "Binary", + commandPath); + + for(int i = 0; i < 7; i++) { + if(mask & (1< 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Associate.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// Associate dialog + +class Associate : public CDialog +{ + // Construction + public: + Associate(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(Associate) + enum { IDD = IDD_ASSOCIATIONS }; + BOOL m_agb; + BOOL m_bin; + BOOL m_cgb; + BOOL m_gb; + BOOL m_gba; + BOOL m_gbc; + BOOL m_sgb; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Associate) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(Associate) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_) diff --git a/src/win32/BitmapControl.cpp b/src/win32/BitmapControl.cpp new file mode 100644 index 0000000..0aacc57 --- /dev/null +++ b/src/win32/BitmapControl.cpp @@ -0,0 +1,287 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// BitmapControl.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "BitmapControl.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool BitmapControl::isRegistered = false; + +///////////////////////////////////////////////////////////////////////////// +// BitmapControl + +IMPLEMENT_DYNCREATE(BitmapControl, CScrollView) + + BitmapControl::BitmapControl() +{ + w = 0; + h = 0; + data = NULL; + bmpInfo = NULL; + stretch = false; + registerClass(); + CSize sizeTotal; + sizeTotal.cx = sizeTotal.cy = 0; + SetScrollSizes(MM_TEXT, sizeTotal); +} + +BitmapControl::~BitmapControl() +{ +} + + +BEGIN_MESSAGE_MAP(BitmapControl, CScrollView) + //{{AFX_MSG_MAP(BitmapControl) + ON_WM_ERASEBKGND() + ON_WM_SIZE() + ON_WM_LBUTTONDOWN() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// BitmapControl drawing + +void BitmapControl::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + + CSize sizeTotal; + // TODO: calculate the total size of this view + sizeTotal.cx = sizeTotal.cy = 100; + SetScrollSizes(MM_TEXT, sizeTotal); +} + +void BitmapControl::OnDraw(CDC* dc) +{ + RECT r; + GetClientRect(&r); + int w1 = r.right - r.left; + int h1 = r.bottom - r.top; + CDC memDC; + memDC.CreateCompatibleDC(dc); + if(!stretch) { + if(w > w1) + w1 = w; + if(h > h1) + h1 = h; + } + CBitmap bitmap, *pOldBitmap; + bitmap.CreateCompatibleBitmap(dc, w1, h1); + pOldBitmap = memDC.SelectObject(&bitmap); + if(stretch) { + bmpInfo->bmiHeader.biWidth = w; + bmpInfo->bmiHeader.biHeight = -h; + + StretchDIBits(memDC.GetSafeHdc(), + 0, + 0, + w1, + h1, + 0, + 0, + w, + h, + data, + bmpInfo, + DIB_RGB_COLORS, + SRCCOPY); + } else { + FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE))); + + bmpInfo->bmiHeader.biWidth = w; + bmpInfo->bmiHeader.biHeight = -h; + SetDIBitsToDevice(memDC.GetSafeHdc(), + 0, + 0, + w, + h, + 0, + 0, + 0, + h, + data, + bmpInfo, + DIB_RGB_COLORS); + } + + dc->BitBlt(0,0,w1,h1, + &memDC,0,0,SRCCOPY); + memDC.SelectObject(pOldBitmap); + + bitmap.DeleteObject(); + memDC.DeleteDC(); +} + +///////////////////////////////////////////////////////////////////////////// +// BitmapControl diagnostics + +#ifdef _DEBUG +void BitmapControl::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void BitmapControl::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// BitmapControl message handlers + +BOOL BitmapControl::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + +void BitmapControl::OnSize(UINT nType, int cx, int cy) +{ + if(!stretch) + CScrollView::OnSize(nType, cx, cy); +} + +void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt) +{ + if(!data) + return; + int x = pt.x; + int y = pt.y; + + WPARAM point; + + if(stretch) { + RECT rect; + GetClientRect(&rect); + + int height = rect.bottom - rect.top; + int width = rect.right - rect.left; + + int xx = (x * w) / width; + int yy = (y * h) / height; + + point = xx | (yy<<16); + + int xxx = xx / 8; + int yyy = yy / 8; + + for(int i = 0; i < 8; i++) { + memcpy(&colors[i*3*8], &data[xxx * 8 * 3 + + w * yyy * 8 * 3 + + i * w * 3], 8 * 3); + } + } else { + POINT p; + p.x = GetScrollPos(SB_HORZ); + p.y = GetScrollPos(SB_VERT); + + p.x += x; + p.y += y; + + if(p.x >= w || + p.y >= h) + return; + + point = p.x | (p.y<<16); + + int xxx = p.x / 8; + int yyy = p.y / 8; + + for(int i = 0; i < 8; i++) { + memcpy(&colors[i*3*8], &data[xxx * 8 * 3 + + w * yyy * 8 * 3 + + i * w * 3], 8 * 3); + } + } + + GetParent()->SendMessage(WM_MAPINFO, + point, + (LPARAM)colors); +} + +void BitmapControl::setBmpInfo(BITMAPINFO *info) +{ + bmpInfo = info; +} + +void BitmapControl::setData(u8 *d) +{ + data = d; +} + +void BitmapControl::setSize(int w1, int h1) +{ + if(w != w1 || h != h1) { + w = w1; + h = h1; + SIZE s; + s.cx = w; + s.cy = h; + SetScrollSizes(MM_TEXT, s); + } +} + +void BitmapControl::refresh() +{ + Invalidate(); +} + + +void BitmapControl::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaBitmapControl"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} + +void BitmapControl::setStretch(bool b) +{ + if(b != stretch) { + stretch = b; + Invalidate(); + } +} + +bool BitmapControl::getStretch() +{ + return stretch; +} + +void BitmapControl::PostNcDestroy() +{ +} diff --git a/src/win32/BitmapControl.h b/src/win32/BitmapControl.h new file mode 100644 index 0000000..f2f0c4d --- /dev/null +++ b/src/win32/BitmapControl.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_) +#define AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BitmapControl.h : header file +// +#ifndef WM_MAPINFO +#define WM_MAPINFO WM_APP+101 +#endif + +///////////////////////////////////////////////////////////////////////////// +// BitmapControl view + +class BitmapControl : public CScrollView +{ + public: + BitmapControl(); // protected constructor used by dynamic creation + protected: + DECLARE_DYNCREATE(BitmapControl) + + // Attributes + public: + + // Operations + public: + void setStretch(bool b); + void refresh(); + void setSize(int w1, int h1); + void setData(u8 *d); + void setBmpInfo(BITMAPINFO *info); + static bool isRegistered; + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(BitmapControl) + protected: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual void OnInitialUpdate(); // first time after construct + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + public: + bool getStretch(); + virtual ~BitmapControl(); + protected: +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions + //{{AFX_MSG(BitmapControl) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void registerClass(); + bool stretch; + u8 colors[3*64]; + BITMAPINFO *bmpInfo; + u8 * data; + int h; + int w; +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_) diff --git a/src/win32/BugReport.cpp b/src/win32/BugReport.cpp new file mode 100644 index 0000000..0742b5a --- /dev/null +++ b/src/win32/BugReport.cpp @@ -0,0 +1,249 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// BugReport.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "BugReport.h" + +#include "../agbprint.h" +#include "../AutoBuild.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Port.h" +#include "../RTC.h" +#include "../Sound.h" +#include "../gb/gbCheats.h" +#include "../gb/gbGlobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// BugReport dialog + + +BugReport::BugReport(CWnd* pParent /*=NULL*/) + : CDialog(BugReport::IDD, pParent) +{ + //{{AFX_DATA_INIT(BugReport) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void BugReport::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(BugReport) + DDX_Control(pDX, IDC_BUG_REPORT, m_report); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(BugReport, CDialog) + //{{AFX_MSG_MAP(BugReport) + ON_BN_CLICKED(IDC_COPY, OnCopy) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// BugReport message handlers + +void BugReport::OnCopy() +{ + OpenClipboard(); + + EmptyClipboard(); + CString report; + m_report.GetWindowText(report); + + HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, + (report.GetLength() + 1) * sizeof(CHAR)); + if (hglbCopy == NULL) { + CloseClipboard(); + return; + } + + // Lock the handle and copy the text to the buffer. + + LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy); + memcpy(lptstrCopy, (const char *)report, + report.GetLength() * sizeof(CHAR)); + lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character + GlobalUnlock(hglbCopy); + + // Place the handle on the clipboard. + + SetClipboardData(CF_TEXT, hglbCopy); + CloseClipboard(); + + systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard"); +} + +void BugReport::OnOk() +{ + EndDialog(TRUE); +} + +BOOL BugReport::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CenterWindow(); + + CString report = createReport(); + + m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT))); + + m_report.SetWindowText(report); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + + +static void AppendFormat(CString& report, const char *format, ...) +{ + CString buffer; + va_list valist; + + va_start(valist, format); + buffer.FormatV(format, valist); + va_end(valist); + report += buffer; +} + +CString BugReport::createReport() +{ + theApp.winCheckFullscreen(); + + CString report = ""; + AppendFormat(report, "Emu version : %s\r\n", VERSION); + AppendFormat(report, "Emu Type : %s\r\n", +#ifdef FINAL_VERSION +#ifdef DEV_VERSION + "Development Version" +#else + "Normal Version" +#endif +#else + "Debug Version" +#endif + ); + + if(emulating) { + AppendFormat(report, "File : %s\r\n", theApp.szFile); + + char buffer[20]; + if(theApp.cartridgeType == 0) { + u32 check = 0; + for(int i = 0; i < 0x4000; i += 4) { + check += *((u32 *)&bios[i]); + } + AppendFormat(report, "BIOS Checksum: %08X\r\n", check); + + strncpy(buffer, (const char *)&rom[0xa0], 12); + buffer[12] = 0; + AppendFormat(report, "Internal name: %s\r\n", buffer); + + strncpy(buffer, (const char *)&rom[0xac], 4); + buffer[4] = 0; + AppendFormat(report, "Game code : %s\r\n", buffer); + + CString res = ""; + u32 *p = (u32 *)rom; + u32 *end = (u32 *)((char *)rom+theApp.romSize); + while(p < end) { + u32 d = READ32LE(p); + + if(d == 0x52504545) { + if(memcmp(p, "EEPROM_", 7) == 0) { + res += (const char *)p; + res += ' '; + } + } else if (d == 0x4D415253) { + if(memcmp(p, "SRAM_", 5) == 0) { + res += (const char *)p; + res += ' '; + } + } else if (d == 0x53414C46) { + if(memcmp(p, "FLASH1M_", 8) == 0) { + res += (const char *)p; + res += ' '; + } + } else if(memcmp(p, "FLASH", 5) == 0) { + res += (const char *)p; + res += ' '; + } else if (d == 0x52494953) { + if(memcmp(p, "SIIRTC_V", 8) == 0) { + res += (const char *)p; + res += ' '; + } + } + p++; + } + if(res.GetLength() > 0) + AppendFormat(report, "Cart Save : %s\r\n", res); + } else if(theApp.cartridgeType == 1) { + strncpy(buffer, (const char *)&gbRom[0x134], 15); + buffer[15] = 0; + AppendFormat(report, "Game title : %s\r\n", buffer); + } + } + + AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile); + AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile); + AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx); + AppendFormat(report, "Skip intro : %d\r\n", theApp.removeIntros); + AppendFormat(report, "Throttle : %d\r\n", theApp.throttle); + AppendFormat(report, "Rewind : %d\r\n", theApp.rewindTimer); +/// AppendFormat(report, "Auto frame : %d\r\n", theApp.autoFrameSkip); + AppendFormat(report, "Video option : %d\r\n", theApp.videoOption); + AppendFormat(report, "Render type : %d\r\n", theApp.renderMethod); + AppendFormat(report, "Color depth : %d\r\n", systemColorDepth); + AppendFormat(report, "Red shift : %08x\r\n", systemRedShift); + AppendFormat(report, "Green shift : %08x\r\n", systemGreenShift); + AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift); + AppendFormat(report, "Layer setting: %04X\r\n", layerSettings); + AppendFormat(report, "Save type : %d (%d)\r\n", + theApp.winSaveType, cpuSaveType); + AppendFormat(report, "Flash size : %08X (%08x)\r\n", + theApp.winFlashSize, flashSize); + AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable, + rtcIsEnabled()); + AppendFormat(report, "AGBPrint : %d\r\n", agbPrintIsEnabled()); + AppendFormat(report, "Speed toggle : %d\r\n", theApp.speedupToggle); + AppendFormat(report, "Synchronize : %d\r\n", synchronize); + AppendFormat(report, "Sound OFF : %d\r\n", soundOffFlag); + AppendFormat(report, "Channels : %04x\r\n", soundGetEnable() & 0x30f); + AppendFormat(report, "Old Sync : %d\r\n", theApp.useOldSync); + AppendFormat(report, "Priority : %d\r\n", theApp.threadPriority); + AppendFormat(report, "Filters : %d (%d)\r\n", theApp.filterType, theApp.ifbType); + AppendFormat(report, "Cheats : %d\r\n", cheatsNumber); + AppendFormat(report, "GB Cheats : %d\r\n", gbCheatNumber); + AppendFormat(report, "GB Emu Type : %d\r\n", gbEmulatorType); + + return report; +} diff --git a/src/win32/BugReport.h b/src/win32/BugReport.h new file mode 100644 index 0000000..6d5a0cf --- /dev/null +++ b/src/win32/BugReport.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_) +#define AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BugReport.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// BugReport dialog + +class BugReport : public CDialog +{ + // Construction + public: + BugReport(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(BugReport) + enum { IDD = IDD_BUG_REPORT }; + CEdit m_report; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(BugReport) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + CString createReport(); + + // Generated message map functions + //{{AFX_MSG(BugReport) + afx_msg void OnCopy(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_) diff --git a/src/win32/CmdAccelOb.cpp b/src/win32/CmdAccelOb.cpp new file mode 100644 index 0000000..828b20d --- /dev/null +++ b/src/win32/CmdAccelOb.cpp @@ -0,0 +1,558 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : CmdAccelOb.cpp +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Author : T.Maurel +// Date : 17.08.98 +// +// Remarks : +// +//////////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "CmdAccelOb.h" + +//////////////////////////////////////////////////////////////////////// +// +// +MAPVIRTKEYS mapVirtKeys[] = { + {VK_LBUTTON, "LBUTTON"}, + {VK_RBUTTON, "RBUTTON"}, + {VK_CANCEL, "Cancel"}, + {VK_MBUTTON, "MBUTTON"}, + {VK_BACK, "Backspace"}, + {VK_TAB, "Tab"}, + {VK_CLEAR, "Clear"}, + {VK_RETURN, "Enter"}, + {VK_SHIFT, "Shift"}, + {VK_LSHIFT, "LShift"}, + {VK_RSHIFT, "RShift"}, + {VK_CONTROL, "Control"}, + {VK_LCONTROL, "LControl"}, + {VK_RCONTROL, "RControl"}, + {VK_MENU, "Alt"}, + {VK_LMENU, "LAlt"}, + {VK_RMENU, "RAlt"}, + {VK_PAUSE, "Pause"}, + {VK_CAPITAL, "Caps Lock"}, + {VK_ESCAPE, "Escape"}, + {VK_SPACE, "Space"}, + {VK_PRIOR, "Prior"}, + {VK_NEXT, "Next"}, + {VK_END, "End"}, + {VK_HOME, "Home"}, + {VK_LEFT, "Left"}, + {VK_UP, "Up"}, + {VK_RIGHT, "Right"}, + {VK_DOWN, "Down"}, + {VK_SELECT, "Select"}, + {VK_PRINT, "Print"}, + {VK_EXECUTE, "Execute"}, + {VK_SNAPSHOT, "Snapshot"}, + {VK_INSERT, "Insert"}, + {VK_DELETE, "Delete"}, + {VK_HELP, "Help"}, + {WORD('0'), "0"}, + {WORD('1'), "1"}, + {WORD('2'), "2"}, + {WORD('3'), "3"}, + {WORD('4'), "4"}, + {WORD('5'), "5"}, + {WORD('6'), "6"}, + {WORD('7'), "7"}, + {WORD('8'), "8"}, + {WORD('9'), "9"}, + {WORD('A'), "A"}, + {WORD('B'), "B"}, + {WORD('C'), "C"}, + {WORD('D'), "D"}, + {WORD('E'), "E"}, + {WORD('F'), "F"}, + {WORD('G'), "G"}, + {WORD('H'), "H"}, + {WORD('I'), "I"}, + {WORD('J'), "J"}, + {WORD('K'), "K"}, + {WORD('L'), "L"}, + {WORD('M'), "M"}, + {WORD('N'), "N"}, + {WORD('O'), "O"}, + {WORD('P'), "P"}, + {WORD('Q'), "Q"}, + {WORD('R'), "R"}, + {WORD('S'), "S"}, + {WORD('T'), "T"}, + {WORD('U'), "U"}, + {WORD('V'), "V"}, + {WORD('W'), "W"}, + {WORD('X'), "X"}, + {WORD('Y'), "Y"}, + {WORD('Z'), "Z"}, + {VK_LWIN, "LWIN"}, + {VK_RWIN, "RWIN"}, + {VK_APPS, "APPS"}, + {VK_NUMPAD0, "NumPad0"}, + {VK_NUMPAD1, "NumPad1"}, + {VK_NUMPAD2, "NumPad2"}, + {VK_NUMPAD3, "NumPad3"}, + {VK_NUMPAD4, "NumPad4"}, + {VK_NUMPAD5, "NumPad5"}, + {VK_NUMPAD6, "NumPad6"}, + {VK_NUMPAD7, "NumPad7"}, + {VK_NUMPAD8, "NumPad8"}, + {VK_NUMPAD9, "NumPad9"}, + {VK_MULTIPLY, "NumpadMultiply"}, + {VK_ADD, "NumpadAdd"}, + {VK_SEPARATOR, "Separator"}, + {VK_SUBTRACT, "NumpadSubtract"}, + {VK_DECIMAL, "NumpadDecimal"}, + {VK_DIVIDE, "NumpadDivide"}, + {VK_F1, "F1"}, + {VK_F2, "F2"}, + {VK_F3, "F3"}, + {VK_F4, "F4"}, + {VK_F5, "F5"}, + {VK_F6, "F6"}, + {VK_F7, "F7"}, + {VK_F8, "F8"}, + {VK_F9, "F9"}, + {VK_F10, "F10"}, + {VK_F11, "F11"}, + {VK_F12, "F12"}, + {VK_F13, "F13"}, + {VK_F14, "F14"}, + {VK_F15, "F15"}, + {VK_F16, "F16"}, + {VK_F17, "F17"}, + {VK_F18, "F18"}, + {VK_F19, "F19"}, + {VK_F20, "F20"}, + {VK_F21, "F21"}, + {VK_F22, "F22"}, + {VK_F23, "F23"}, + {VK_F24, "F24"}, + {VK_NUMLOCK, "Num Lock"}, + {VK_SCROLL, "Scroll Lock"}, + {VK_ATTN, "Attention"}, + {VK_CRSEL, "CRSEL"}, + {VK_EXSEL, "EXSEL"}, + {VK_EREOF, "EREOF"}, + {VK_PLAY, "Play"}, + {VK_ZOOM, "Zoom"}, + {VK_NONAME, "No Name"}, + {VK_PA1, "PA1"}, + {VK_OEM_CLEAR, "Clear2"}, + {VK_OEM_1, "Semicolon;"}, + {VK_OEM_2, "Slash/"}, + {VK_OEM_3, "Tilde~"}, + {VK_OEM_4, "LBracket["}, + {VK_OEM_5, "Backslash\\"}, + {VK_OEM_6, "RBracket]"}, + {VK_OEM_7, "Apostrophe'"}, + {VK_OEM_8, "OEM8"}, + {VK_OEM_PLUS, "Plus+"}, + {VK_OEM_MINUS, "Minus-"}, + {VK_OEM_COMMA, "Comma,"}, + {VK_OEM_PERIOD, "Period."}, + {VK_OEM_AX, "Apostrophe`"}, + {VK_OEM_102, "<> or \\|"}, + {VK_ICO_HELP, "ICO Help"}, + {VK_ICO_00, "ICO 00"}, + {VK_OEM_FJ_JISHO, "JISHO"}, + {VK_OEM_FJ_MASSHOU, "MASSHOU"}, + {VK_OEM_FJ_TOUROKU, "TOUROKU"}, + {VK_OEM_FJ_LOYA, "LOYA"}, + {VK_OEM_FJ_ROYA, "ROYA"}, + {VK_OEM_NEC_EQUAL, "Numpad Equals"}, +}; + + +//////////////////////////////////////////////////////////////////////// +// +// +MAPVIRTKEYS mapVirtSysKeys[] = { + {FCONTROL, "Ctrl"}, + {FALT, "Alt"}, + {FSHIFT, "Shift"}, +}; + + +//////////////////////////////////////////////////////////////////////// +// helper fct for external access +//////////////////////////////////////////////////////////////////////// +// +// +TCHAR* mapVirtKeysStringFromWORD(WORD wKey) +{ + for (int index = 0; index < sizeof(mapVirtKeys)/sizeof(mapVirtKeys[0]); index++) { + if (mapVirtKeys[index].wKey == wKey) + return mapVirtKeys[index].szKey; + } + return NULL; +} + + + +//////////////////////////////////////////////////////////////////////// +// +#define DEFAULT_ACCEL 0x01 +#define USER_ACCEL 0x02 + + +//////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////// +// +// +CAccelsOb::CAccelsOb() +{ + m_cVirt = 0; + m_wKey = 0; + m_bLocked = false; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CAccelsOb::CAccelsOb(CAccelsOb* pFrom) +{ + ASSERT(pFrom != NULL); + + m_cVirt = pFrom->m_cVirt; + m_wKey = pFrom->m_wKey; + m_bLocked = pFrom->m_bLocked; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked) +{ + m_cVirt = cVirt; + m_wKey = wKey; + m_bLocked = bLocked; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CAccelsOb::CAccelsOb(LPACCEL pACCEL) +{ + ASSERT(pACCEL != NULL); + + m_cVirt = pACCEL->fVirt; + m_wKey = pACCEL->key; + m_bLocked = false; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from) +{ + m_cVirt = from.m_cVirt; + m_wKey = from.m_wKey; + m_bLocked = from.m_bLocked; + + return *this; +} + + +//////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////// +// +// +void CAccelsOb::GetString(CString& szBuffer) +{ + szBuffer = ""; + + // modifiers part + for (int i = 0; i < sizetable(mapVirtSysKeys); i++) { + if (m_cVirt & mapVirtSysKeys[i].wKey) { + szBuffer += mapVirtSysKeys[i].szKey; + if (m_wKey) + szBuffer += "+"; + } + } + + // in case of the object is not assigned, we avoid error messages + if (m_wKey == 0) + return; + + // and virtual key part + for (int i = 0; i < sizetable(mapVirtKeys); i++) { + if (m_wKey == mapVirtKeys[i].wKey) { + szBuffer += mapVirtKeys[i].szKey; + return; + } + } + + AfxMessageBox("Internal error : (CAccelsOb::GetString) m_wKey invalid"); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift) +{ + // CString szTemp; + // GetString(szTemp); + + + bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false; + bool bRet = (bCtrl == m_bCtrl); + + bool m_bAlt = (m_cVirt & FALT) ? true : false; + bRet &= (bAlt == m_bAlt); + + bool m_bShift = (m_cVirt & FSHIFT) ? true : false; + bRet &= (bShift == m_bShift); + + bRet &= static_cast(m_wKey == wKey); + + return bRet; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +DWORD CAccelsOb::GetData() +{ + BYTE cLocalCodes = 0; + if (m_bLocked) + cLocalCodes = DEFAULT_ACCEL; + else + cLocalCodes = USER_ACCEL; + + WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes); + return MAKELONG(m_wKey, bCodes); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +bool CAccelsOb::SetData(DWORD dwDatas) +{ + m_wKey = LOWORD(dwDatas); + + WORD bCodes = HIWORD(dwDatas); + m_cVirt = LOBYTE(bCodes); + + BYTE cLocalCodes = HIBYTE(bCodes); + m_bLocked = static_cast(cLocalCodes == DEFAULT_ACCEL); + return true; +} + +//////////////////////////////////////////////////////////////////////// +// +#ifdef _DEBUG +//////////////////////////////////////////////////////////////////////// +// +// +void CAccelsOb::AssertValid() const +{ + CObject::AssertValid(); +} + +//////////////////////////////////////////////////////////////////////// +// +// +void CAccelsOb::Dump(CDumpContext& dc) const +{ + dc << "\t\t"; + CObject::Dump(dc); + dc << "\t\tlocked=" << m_bLocked << ", cVirt=" << m_cVirt << ", wKey=" << m_wKey << "\n\n"; + +} +#endif + +//////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////// +// +// +CCmdAccelOb::CCmdAccelOb() +{ +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand) +{ + ASSERT(szCommand != NULL); + + m_wIDCommand = wIDCommand; + m_szCommand = szCommand; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked) +{ + ASSERT(szCommand != NULL); + + m_wIDCommand = wIDCommand; + m_szCommand = szCommand; + + CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked); + ASSERT(pAccel != NULL); + m_Accels.AddTail(pAccel); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CCmdAccelOb::~CCmdAccelOb() +{ + POSITION pos = m_Accels.GetHeadPosition(); + while (pos != NULL) + delete m_Accels.GetNext(pos); + m_Accels.RemoveAll(); +} + + +//////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::Add(BYTE cVirt, WORD wKey, bool bLocked) +{ + CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked); + ASSERT(pAccel != NULL); + m_Accels.AddTail(pAccel); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::Add(CAccelsOb* pAccel) +{ + ASSERT(pAccel != NULL); + m_Accels.AddTail(pAccel); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from) +{ + Reset(); + + m_wIDCommand = from.m_wIDCommand; + m_szCommand = from.m_szCommand; + + CAccelsOb* pAccel; + POSITION pos = from.m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = DEBUG_NEW CAccelsOb(from.m_Accels.GetNext(pos)); + ASSERT(pAccel != NULL); + m_Accels.AddTail(pAccel); + } + return *this; +} + + +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::DeleteUserAccels() +{ + CAccelsOb* pAccel; + POSITION prevPos; + POSITION pos = m_Accels.GetHeadPosition(); + while (pos != NULL) { + prevPos = pos; + pAccel = m_Accels.GetNext(pos); + if (!pAccel->m_bLocked) { + delete pAccel; + m_Accels.RemoveAt(prevPos); + } + } +} + + +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::Reset() +{ + m_wIDCommand = 0; + m_szCommand = "Empty command"; + + CAccelsOb* pAccel; + POSITION pos = m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = m_Accels.GetNext(pos); + delete pAccel; + } +} + +//////////////////////////////////////////////////////////////////////// +// +#ifdef _DEBUG +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::AssertValid() const +{ + // call base class function first + CObject::AssertValid(); +} + + +//////////////////////////////////////////////////////////////////////// +// +// +void CCmdAccelOb::Dump( CDumpContext& dc ) const +{ + // call base class function first + dc << "\t"; + CObject::Dump( dc ); + + // now do the stuff for our specific class + dc << "\tIDCommand = " << m_wIDCommand; + dc << "\n\tszCommand = " << m_szCommand; + dc << "\n\tAccelerators = {\n"; + + CAccelsOb* pAccel; + POSITION pos = m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccel = m_Accels.GetNext(pos); + dc << pAccel; + } + dc << "\t}\n"; +} +#endif diff --git a/src/win32/CmdAccelOb.h b/src/win32/CmdAccelOb.h new file mode 100644 index 0000000..c8e47ac --- /dev/null +++ b/src/win32/CmdAccelOb.h @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : CmdAccelOb.h +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Author : T.Maurel +// Date : 17.08.98 +// +// Remarks : +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef __CMDACCEL_OB_INCLUDE +#define __CMDACCEL_OB_INCLUDE + +#include // MFC Templates extension + +//////////////////////////////////////////////////////////////////////// +// +// +typedef struct tagMAPVIRTKEYS { + WORD wKey; + TCHAR szKey[15]; +} MAPVIRTKEYS, *PMAPVIRTKEYS; + + +//////////////////////////////////////////////////////////////////////// +// +// +#define sizetable(table) (sizeof(table)/sizeof(table[0])) + + +//////////////////////////////////////////////////////////////////////// +// +// +class CAccelsOb : public CObject { + public: + CAccelsOb(); + CAccelsOb(CAccelsOb* pFrom); + CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false); + CAccelsOb(LPACCEL pACCEL); + + public: + CAccelsOb& operator=(const CAccelsOb& from); + + void GetString(CString& szBuffer); + bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift); + DWORD GetData(); + bool SetData(DWORD dwDatas); + + public: +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + public: + BYTE m_cVirt; + WORD m_wKey; + bool m_bLocked; +}; + + +////////////////////////////////////////////////////////////////////// +// +// +class CCmdAccelOb : public CObject { + public: + CCmdAccelOb(); + CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand); + CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked = false); + ~CCmdAccelOb(); + + public: + void Add(CAccelsOb* pAccel); + void Add(BYTE cVirt, WORD wKey, bool bLocked = false); + void Reset(); + void DeleteUserAccels(); + + CCmdAccelOb& operator=(const CCmdAccelOb& from); + public: +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + public: + WORD m_wIDCommand; + CString m_szCommand; + + CList< CAccelsOb*, CAccelsOb*& > m_Accels; +}; + + +//////////////////////////////////////////////////////////////////////// +#endif // __CMDACCEL_OB_INCLUDE + + diff --git a/src/win32/ColorButton.cpp b/src/win32/ColorButton.cpp new file mode 100644 index 0000000..b6de51f --- /dev/null +++ b/src/win32/ColorButton.cpp @@ -0,0 +1,120 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// ColorButton.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "ColorButton.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool ColorButton::isRegistered = false; + +///////////////////////////////////////////////////////////////////////////// +// ColorButton + +ColorButton::ColorButton() +{ + color = 0; + registerClass(); +} + +ColorButton::~ColorButton() +{ +} + + +BEGIN_MESSAGE_MAP(ColorButton, CButton) + //{{AFX_MSG_MAP(ColorButton) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// ColorButton message handlers + +void ColorButton::PreSubclassWindow() +{ + SetWindowLong(m_hWnd, GWL_STYLE, GetStyle() | BS_OWNERDRAW); + CWnd::PreSubclassWindow(); +} + +void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + ASSERT(lpDrawItemStruct); + + int r = (color & 0x1f) << 3; + int g = (color & 0x3e0) >> 2; + int b = (color & 0x7c00) >> 7; + + HDC dc = lpDrawItemStruct->hDC; + UINT state = lpDrawItemStruct->itemState; + RECT rect = lpDrawItemStruct->rcItem; + + SIZE margins; + margins.cx = ::GetSystemMetrics(SM_CXEDGE); + margins.cy = ::GetSystemMetrics(SM_CYEDGE); + + if(GetState() & BST_PUSHED) + DrawEdge(dc, &rect, EDGE_SUNKEN, BF_RECT); + else + DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT); + + InflateRect(&rect, -margins.cx, -margins.cy); + + HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ? + ::GetSysColor(COLOR_3DFACE) : RGB(r,g,b)); + + FillRect(dc, &rect, br); + + if(state & ODS_FOCUS) { + InflateRect(&rect, -1, -1); + DrawFocusRect(dc, &rect); + } + + DeleteObject(br); +} + +void ColorButton::setColor(u16 c) +{ + color = c; + Invalidate(); +} + +void ColorButton::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hIcon = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaColorButton"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} diff --git a/src/win32/ColorButton.h b/src/win32/ColorButton.h new file mode 100644 index 0000000..3d12f74 --- /dev/null +++ b/src/win32/ColorButton.h @@ -0,0 +1,74 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_) +#define AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ColorButton.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// ColorButton window + +class ColorButton : public CButton +{ + // Construction + public: + ColorButton(); + + // Attributes + public: + // Operations + static bool isRegistered; + public: + void PreSubclassWindow(); + void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ColorButton) + //}}AFX_VIRTUAL + + // Implementation + public: + void setColor(u16 c); + u16 color; + virtual ~ColorButton(); + + void registerClass(); + + // Generated message map functions + protected: + //{{AFX_MSG(ColorButton) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_) diff --git a/src/win32/ColorControl.cpp b/src/win32/ColorControl.cpp new file mode 100644 index 0000000..b61d135 --- /dev/null +++ b/src/win32/ColorControl.cpp @@ -0,0 +1,103 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// ColorControl.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "ColorControl.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool ColorControl::isRegistered = false; + +///////////////////////////////////////////////////////////////////////////// +// ColorControl + +ColorControl::ColorControl() +{ + color = 0; + registerClass(); +} + +ColorControl::~ColorControl() +{ +} + + +BEGIN_MESSAGE_MAP(ColorControl, CWnd) + //{{AFX_MSG_MAP(ColorControl) + ON_WM_PAINT() + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// ColorControl message handlers + +void ColorControl::OnPaint() +{ + CPaintDC dc(this); // device context for painting +} + +BOOL ColorControl::OnEraseBkgnd(CDC* pDC) +{ + int r = (color & 0x1f) << 3; + int g = (color & 0x3e0) >> 2; + int b = (color & 0x7c00) >> 7; + + CBrush br; + br.CreateSolidBrush(RGB(r,g,b)); + + RECT rect; + GetClientRect(&rect); + pDC->FillRect(&rect,&br); + pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); + br.DeleteObject(); + return TRUE; +} + +void ColorControl::setColor(u16 c) +{ + color = c; + Invalidate(); +} + +void ColorControl::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaColorControl"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} diff --git a/src/win32/ColorControl.h b/src/win32/ColorControl.h new file mode 100644 index 0000000..e66832c --- /dev/null +++ b/src/win32/ColorControl.h @@ -0,0 +1,74 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_) +#define AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ColorControl.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// ColorControl window + +class ColorControl : public CWnd +{ + // Construction + public: + ColorControl(); + + // Attributes + public: + // Operations + static bool isRegistered; + + // Operations + public: + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ColorControl) + //}}AFX_VIRTUAL + + // Implementation + public: + void setColor(u16 c); + u16 color; + virtual ~ColorControl(); + + // Generated message map functions + protected: + //{{AFX_MSG(ColorControl) + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void registerClass(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_) diff --git a/src/win32/Commands.cpp b/src/win32/Commands.cpp new file mode 100644 index 0000000..d6eb5c9 --- /dev/null +++ b/src/win32/Commands.cpp @@ -0,0 +1,315 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "AcceleratorManager.h" +#include "resource.h" +#include + +#include // MFC Templates extension +#ifndef CMapStringToWord +typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord; +#endif + +static CMapStringToWord winAccelStrings; +static bool initialized = false; + +struct { + const char *command; + WORD id; +} winAccelCommands[] = { + { "OpenRom(!)", ID_FILE_OPEN }, // a (!) puts it in the "common hotkeys" list + { "Load from file...", ID_FILE_LOAD }, + { "Save to file...", ID_FILE_SAVE }, + { "LoadSlot01(!)", ID_FILE_LOADGAME_SLOT1 }, + { "LoadSlot02(!)", ID_FILE_LOADGAME_SLOT2 }, + { "LoadSlot03(!)", ID_FILE_LOADGAME_SLOT3 }, + { "LoadSlot04(!)", ID_FILE_LOADGAME_SLOT4 }, + { "LoadSlot05(!)", ID_FILE_LOADGAME_SLOT5 }, + { "LoadSlot06(!)", ID_FILE_LOADGAME_SLOT6 }, + { "LoadSlot07(!)", ID_FILE_LOADGAME_SLOT7 }, + { "LoadSlot08(!)", ID_FILE_LOADGAME_SLOT8 }, + { "LoadSlot09(!)", ID_FILE_LOADGAME_SLOT9 }, + { "LoadSlot10(!)", ID_FILE_LOADGAME_SLOT10 }, + { "AutoLoadMostRecent", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT }, + { "MakeRecentOnLoad", ID_FILE_LOADGAME_MAKERECENT }, + { "MakeCurrentOnLoad", ID_FILE_LOADGAME_MAKECURRENT }, + { "LoadMostRecent(!)", ID_FILE_LOADGAME_MOSTRECENT }, + { "CurrentSlotLoad(!)", ID_FILE_LOADGAME_CURRENT }, + { "SaveSlot01(!)", ID_FILE_SAVEGAME_SLOT1 }, + { "SaveSlot02(!)", ID_FILE_SAVEGAME_SLOT2 }, + { "SaveSlot03(!)", ID_FILE_SAVEGAME_SLOT3 }, + { "SaveSlot04(!)", ID_FILE_SAVEGAME_SLOT4 }, + { "SaveSlot05(!)", ID_FILE_SAVEGAME_SLOT5 }, + { "SaveSlot06(!)", ID_FILE_SAVEGAME_SLOT6 }, + { "SaveSlot07(!)", ID_FILE_SAVEGAME_SLOT7 }, + { "SaveSlot08(!)", ID_FILE_SAVEGAME_SLOT8 }, + { "SaveSlot09(!)", ID_FILE_SAVEGAME_SLOT9 }, + { "SaveSlot10(!)", ID_FILE_SAVEGAME_SLOT10 }, + { "SaveOldestSlot(!)", ID_FILE_SAVEGAME_OLDESTSLOT }, + { "CurrentSlotSave(!)", ID_FILE_SAVEGAME_CURRENT }, + { "MakeCurrentOnSave", ID_FILE_SAVEGAME_MAKECURRENT }, + { "CurrentSlotNext(!)", ID_FILE_SAVEGAME_INCREMENTSLOT }, + { "CurrentSlotPrev(!)", ID_FILE_SAVEGAME_DECREMENTSLOT }, + { "ClearRecentRomList", ID_FILE_RECENT_RESET }, + { "LockRecentRomList", ID_FILE_RECENT_FREEZE }, + { "SetCurrentSlot01(!)", ID_SELECT_SLOT1 }, + { "SetCurrentSlot02(!)", ID_SELECT_SLOT2 }, + { "SetCurrentSlot03(!)", ID_SELECT_SLOT3 }, + { "SetCurrentSlot04(!)", ID_SELECT_SLOT4 }, + { "SetCurrentSlot05(!)", ID_SELECT_SLOT5 }, + { "SetCurrentSlot06(!)", ID_SELECT_SLOT6 }, + { "SetCurrentSlot07(!)", ID_SELECT_SLOT7 }, + { "SetCurrentSlot08(!)", ID_SELECT_SLOT8 }, + { "SetCurrentSlot09(!)", ID_SELECT_SLOT9 }, + { "SetCurrentSlot10(!)", ID_SELECT_SLOT10 }, + { "RecentRom01", ID_FILE_MRU_FILE1 }, + { "RecentRom02", ID_FILE_MRU_FILE2 }, + { "RecentRom03", ID_FILE_MRU_FILE3 }, + { "RecentRom04", ID_FILE_MRU_FILE4 }, + { "RecentRom05", ID_FILE_MRU_FILE5 }, + { "RecentRom06", ID_FILE_MRU_FILE6 }, + { "RecentRom07", ID_FILE_MRU_FILE7 }, + { "RecentRom08", ID_FILE_MRU_FILE8 }, + { "RecentRom09", ID_FILE_MRU_FILE9 }, + { "RecentRom10", ID_FILE_MRU_FILE10 }, + { "PauseGame(!)", ID_FILE_PAUSE }, + { "ResetGame(!)", ID_FILE_RESET }, + { "ImportBatteryFile", ID_FILE_IMPORT_BATTERYFILE }, + { "ImportGamesharkCodeFile", ID_FILE_IMPORT_GAMESHARKCODEFILE }, + { "ImportGamesharkSnapshot", ID_FILE_IMPORT_GAMESHARKSNAPSHOT }, + { "ExportBatteryFile", ID_FILE_EXPORT_BATTERYFILE }, + { "ExportGamesharkSnapshot", ID_FILE_EXPORT_GAMESHARKSNAPSHOT }, + { "ScreenCapture", ID_FILE_SCREENCAPTURE }, + { "RomInformation", ID_FILE_ROMINFORMATION }, + { "ToggleMenu", ID_FILE_TOGGLEMENU }, + { "Close", ID_FILE_CLOSE }, + { "Exit", ID_FILE_EXIT }, + { "FrameSkip0", ID_OPTIONS_VIDEO_FRAMESKIP_0 }, + { "FrameSkip1", ID_OPTIONS_VIDEO_FRAMESKIP_1 }, + { "FrameSkip2", ID_OPTIONS_VIDEO_FRAMESKIP_2 }, + { "FrameSkip3", ID_OPTIONS_VIDEO_FRAMESKIP_3 }, + { "FrameSkip4", ID_OPTIONS_VIDEO_FRAMESKIP_4 }, + { "FrameSkip5", ID_OPTIONS_VIDEO_FRAMESKIP_5 }, + { "FrameSkip6", ID_OPTIONS_VIDEO_FRAMESKIP_6 }, + { "FrameSkip7", ID_OPTIONS_VIDEO_FRAMESKIP_7 }, + { "FrameSkip8", ID_OPTIONS_VIDEO_FRAMESKIP_8 }, + { "FrameSkip9", ID_OPTIONS_VIDEO_FRAMESKIP_9 }, + { "Speed006%", ID_OPTIONS_FRAMESKIP_THROTTLE_6 }, + { "Speed015%", ID_OPTIONS_FRAMESKIP_THROTTLE_15 }, + { "Speed025%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 }, + { "Speed037%", ID_OPTIONS_FRAMESKIP_THROTTLE_37 }, + { "Speed050%", ID_OPTIONS_FRAMESKIP_THROTTLE_50 }, + { "Speed075%", ID_OPTIONS_FRAMESKIP_THROTTLE_75 }, + { "Speed087%", ID_OPTIONS_FRAMESKIP_THROTTLE_87 }, + { "Speed100%(!)", ID_OPTIONS_FRAMESKIP_THROTTLE_100 }, + { "Speed112%", ID_OPTIONS_FRAMESKIP_THROTTLE_112 }, + { "Speed125%", ID_OPTIONS_FRAMESKIP_THROTTLE_125 }, + { "Speed150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 }, + { "Speed200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200 }, + { "Speed300%", ID_OPTIONS_FRAMESKIP_THROTTLE_300 }, + { "SpeedOther", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER }, + { "SpeedIncrease(!)", ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE }, + { "SpeedDecrease(!)", ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE }, + { "VideoRenderGDI", ID_OPTIONS_VIDEO_RENDERMETHOD_GDI }, + { "VideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW }, + { "VideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D }, + { "VideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL }, + { "VideoRenderSelectSkin", ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN }, + { "VideoRenderSkin", ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN }, + { "VideoVsync", ID_OPTIONS_VIDEO_VSYNC }, + { "VideoX1", ID_OPTIONS_VIDEO_X1 }, + { "VideoX2", ID_OPTIONS_VIDEO_X2 }, + { "VideoX3", ID_OPTIONS_VIDEO_X3 }, + { "VideoX4", ID_OPTIONS_VIDEO_X4 }, + { "Video320x240", ID_OPTIONS_VIDEO_FULLSCREEN320X240 }, + { "Video640x480", ID_OPTIONS_VIDEO_FULLSCREEN640X480 }, + { "Video800x600", ID_OPTIONS_VIDEO_FULLSCREEN800X600 }, + { "VideoFullscreen", ID_OPTIONS_VIDEO_FULLSCREEN }, + { "VideoFullscreenMaxScale", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE }, + { "VideoLayersBg0", ID_OPTIONS_VIDEO_LAYERS_BG0 }, + { "VideoLayersBg1", ID_OPTIONS_VIDEO_LAYERS_BG1 }, + { "VideoLayersBg2", ID_OPTIONS_VIDEO_LAYERS_BG2 }, + { "VideoLayersBg3", ID_OPTIONS_VIDEO_LAYERS_BG3 }, + { "VideoLayersOBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ }, + { "VideoLayersWIN0", ID_OPTIONS_VIDEO_LAYERS_WIN0 }, + { "VideoLayersWIN1", ID_OPTIONS_VIDEO_LAYERS_WIN1 }, + { "VideoLayersOBJWIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN }, + { "EmulatorAssociate", ID_OPTIONS_EMULATOR_ASSOCIATE }, + { "EmulatorDirectories", ID_OPTIONS_EMULATOR_DIRECTORIES }, + { "EmulatorSelectBIOS", ID_OPTIONS_EMULATOR_SELECTBIOSFILE }, + { "EmulatorUseBIOS", ID_OPTIONS_EMULATOR_USEBIOSFILE }, + { "EmulatorUseOldGBTiming", ID_EMULATOR_USEOLDGBTIMING }, + { "EmulatorGBALagging", ID_EMULATOR_GBALAG }, + { "EmulatorSkipBIOS", ID_OPTIONS_EMULATOR_SKIPBIOS }, + { "EmulatorShowSpeedNone", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE }, + { "EmulatorShowSpeedPercentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE }, + { "EmulatorShowSpeedDetailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED }, + { "EmulatorShowSpeedTransparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT }, + { "EmulatorSpeedupToggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE }, + { "EmulatorRemoveIntros", ID_OPTIONS_EMULATOR_REMOVEINTROSGBA }, + { "EmulatorAutoHideMenu", ID_OPTIONS_EMULATOR_AUTOHIDEMENU }, + { "EmulatorSaveAuto", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC }, + { "EmulatorSaveEEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM }, + { "EmulatorSaveSRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM }, + { "EmulatorSaveFLASH", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH }, + { "EmulatorSaveEEPROMSensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR }, + { "EmulatorSaveFlash64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K }, + { "EmulatorSaveFlash128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M }, + { "EmulatorAutoIPSPatch", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH }, + { "EmulatorAGBPrint", ID_OPTIONS_EMULATOR_AGBPRINT }, + { "EmulatorRTC", ID_OPTIONS_EMULATOR_REALTIMECLOCK }, + { "EmulatorRewindSettings", ID_OPTIONS_EMULATOR_REWINDINTERVAL }, + { "SoundOff", ID_OPTIONS_SOUND_OFF }, + { "SoundMute", ID_OPTIONS_SOUND_MUTE }, + { "SoundOn", ID_OPTIONS_SOUND_ON }, + { "SoundChannel1", ID_OPTIONS_SOUND_CHANNEL1 }, + { "SoundChannel2", ID_OPTIONS_SOUND_CHANNEL2 }, + { "SoundChannel3", ID_OPTIONS_SOUND_CHANNEL3 }, + { "SoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 }, + { "SoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA }, + { "SoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB }, + { "Sound11Khz", ID_OPTIONS_SOUND_11KHZ }, + { "Sound22Khz", ID_OPTIONS_SOUND_22KHZ }, + { "Sound44Khz", ID_OPTIONS_SOUND_44KHZ }, + { "SoundEcho", ID_OPTIONS_SOUND_ECHO }, + { "SoundLowPassFilter", ID_OPTIONS_SOUND_LOWPASSFILTER }, + { "SoundReverseStereo", ID_OPTIONS_SOUND_REVERSESTEREO }, + { "SoundMuteFrameAdvance", ID_OPTIONS_SOUND_MUTEFRAMEADVANCE }, + { "SoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X }, + { "SoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X }, + { "SoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X }, + { "SoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X }, + { "GameboyBorder", ID_OPTIONS_GAMEBOY_BORDER }, + { "GameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC }, + { "GameboyColors", ID_OPTIONS_GAMEBOY_COLORS }, + { "FilterNormal", ID_OPTIONS_FILTER_NORMAL }, + { "FilterTVMode", ID_OPTIONS_FILTER_TVMODE }, + { "Filter2xSaI", ID_OPTIONS_FILTER_2XSAI }, + { "FilterSuper2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI }, + { "FilterSuperEagle", ID_OPTIONS_FILTER_SUPEREAGLE }, + { "FilterPixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL }, + { "FilterMotionBlur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL }, + { "FilterAdMameScale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X }, + { "FilterSimple2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X }, + { "FilterBilinear", ID_OPTIONS_FILTER_BILINEAR }, + { "FilterBilinearPlus", ID_OPTIONS_FILTER_BILINEARPLUS }, + { "FilterScanlines", ID_OPTIONS_FILTER_SCANLINES }, + { "FilterHq2x", ID_OPTIONS_FILTER_HQ2X }, + { "FilterHq2x2", ID_OPTIONS_FILTER_HQ2X2 }, + { "FilterLq2x", ID_OPTIONS_FILTER_LQ2X }, + { "FilterHq3x2", ID_OPTIONS_FILTER_HQ3X2 }, + { "FilterIFBNone", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE }, + { "FilterIFBMotionBlur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR }, + { "FilterIFBSmart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART }, + { "FilterDisableMMX", ID_OPTIONS_FILTER_DISABLEMMX }, + { "JoypadConfigure1", ID_OPTIONS_JOYPAD_CONFIGURE_1 }, + { "JoypadConfigure2", ID_OPTIONS_JOYPAD_CONFIGURE_2 }, + { "JoypadConfigure3", ID_OPTIONS_JOYPAD_CONFIGURE_3 }, + { "JoypadConfigure4", ID_OPTIONS_JOYPAD_CONFIGURE_4 }, + { "JoypadMotionConfigure", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE }, + { "JoypadMotionAllowLeftPlusRight", ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT }, + { "JoypadAutofireA(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_A }, + { "JoypadAutofireB(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_B }, + { "JoypadAutofireL(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_L }, + { "JoypadAutofireR(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_R }, + { "JoypadAutofireStart(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_START }, + { "JoypadAutofireSelect(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT }, + { "JoypadAutofireUp(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_UP }, + { "JoypadAutofireDown(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN }, + { "JoypadAutofireLeft(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT }, + { "JoypadAutofireRight(!)", ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT }, + { "JoypadAutofireClearAl(!)l", ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR }, + { "JoypadAutoholdA(!)", ID_STICKY_A }, + { "JoypadAutoholdB(!)", ID_STICKY_B }, + { "JoypadAutoholdL(!)", ID_STICKY_L }, + { "JoypadAutoholdR(!)", ID_STICKY_R }, + { "JoypadAutoholdStart(!)", ID_STICKY_START }, + { "JoypadAutoholdSelect(!)", ID_STICKY_SELECT }, + { "JoypadAutoholdUp(!)", ID_STICKY_UP }, + { "JoypadAutoholdDown(!)", ID_STICKY_DOWN }, + { "JoypadAutoholdLeft(!)", ID_STICKY_LEFT }, + { "JoypadAutoholdRight(!)", ID_STICKY_RIGHT }, + { "JoypadAutoholdClearAll(!)", ID_STICKY_CLEAR }, + { "CheatsSearch", ID_CHEATS_SEARCHFORCHEATS }, + { "CheatsList", ID_CHEATS_CHEATLIST }, + { "CheatsLoad", ID_CHEATS_LOADCHEATLIST }, + { "CheatsSave", ID_CHEATS_SAVECHEATLIST }, + { "CheatsDisable", ID_CHEATS_DISABLECHEATS }, + { "DebugGDB", ID_TOOLS_DEBUG_GDB }, + { "DebugGDBLoad", ID_TOOLS_DEBUG_LOADANDWAIT }, + { "DebugGDBBreak", ID_TOOLS_DEBUG_BREAK }, + { "DebugGDBDisconnect", ID_TOOLS_DEBUG_DISCONNECT }, + { "Disassemble", ID_TOOLS_DISASSEMBLE }, + { "IOViewer", ID_TOOLS_IOVIEWER }, + { "Logging", ID_TOOLS_LOGGING }, + { "MapViewer", ID_TOOLS_MAPVIEW }, + { "MemoryViewer", ID_TOOLS_MEMORYVIEWER }, + { "OAMViewer", ID_TOOLS_OAMVIEWER }, + { "PaletteViewer", ID_TOOLS_PALETTEVIEW }, + { "TileViewer", ID_TOOLS_TILEVIEWER }, + { "FrameAdvance(!)", ID_DEBUG_NEXTFRAME }, + { "FrameSearch(!)", ID_DEBUG_FRAMESEARCH }, + { "FrameSearchRewind(!)", ID_DEBUG_FRAMESEARCHPREV }, + { "FrameSearchEnd(!)", ID_DEBUG_FRAMESEARCHLOAD }, + { "FrameCounter(!)", ID_TOOLS_FRAMECOUNTER }, + { "InputDisplay(!)", ID_TOOLS_INPUTDISPLAY }, + { "SoundStartRecording", ID_OPTIONS_SOUND_STARTRECORDING }, + { "SoundStopRecording", ID_OPTIONS_SOUND_STOPRECORDING }, + { "AVIStartRecording", ID_TOOLS_RECORD_STARTAVIRECORDING }, + { "AVIStopRecording", ID_TOOLS_RECORD_STOPAVIRECORDING }, + { "RecordMovieStart", ID_TOOLS_RECORD_STARTMOVIERECORDING }, + { "RecordMovieStop", ID_TOOLS_RECORD_STOPMOVIERECORDING }, + { "PlayMovieStart", ID_TOOLS_PLAY_STARTMOVIEPLAYING }, + { "PlayMovieStop", ID_TOOLS_PLAY_STOPMOVIEPLAYING }, + { "MovieReadOnly(!)", ID_TOOLS_PLAY_READONLY}, + { "MovieContinueRecording", ID_TOOLS_PLAY_CONTINUE}, + { "MoviePlayFromBeginning", ID_TOOLS_PLAY_RESTART}, + { "Rewind(!)", ID_TOOLS_REWIND }, + { "CustomizeAllCommands", ID_TOOLS_CUSTOMIZE }, + { "CustomizeCommonHotkeys", ID_TOOLS_CUSTOMIZE_COMMON }, + { "HelpBugReport", ID_HELP_BUGREPORT }, + { "HelpFAQ", ID_HELP_FAQ }, + { "HelpAbout", ID_HELP_ABOUT }, + { "Minimize", ID_SYSTEM_MINIMIZE }, +}; + +bool winAccelGetID(const char *command, WORD& id) +{ + if(!initialized) { + int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]); + + for(int i = 0; i < count; i++) { + winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id); + } + initialized = true; + } + + return winAccelStrings.Lookup(command, id) ? true : false; +} + +void winAccelAddCommands(CAcceleratorManager& mgr) +{ + int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]); + + for(int i = 0; i < count; i++) { + if(!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false)) + mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command); + } + +} diff --git a/src/win32/Direct3D.cpp b/src/win32/Direct3D.cpp new file mode 100644 index 0000000..5a45b9a --- /dev/null +++ b/src/win32/Direct3D.cpp @@ -0,0 +1,816 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "vba.h" + +#define DIRECT3D_VERSION 0x0800 +#include "d3d8.h" +#include "d3dx8.h" + +#include "MainWnd.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Text.h" +#include "../gb/gbGlobals.h" + +#include "Reg.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#ifdef MMX +extern "C" bool cpu_mmx; + +extern bool detectMMX(); +#endif + +extern int Init_2xSaI(u32); +extern void winlog(const char *,...); +extern int systemSpeed; + +typedef struct _D3DTLVERTEX { + float sx; /* Screen coordinates */ + float sy; + float sz; + float rhw; /* Reciprocal of homogeneous w */ + D3DCOLOR color; /* Vertex color */ + float tu; /* Texture coordinates */ + float tv; + _D3DTLVERTEX() { } + _D3DTLVERTEX(const D3DVECTOR& v, float _rhw, + D3DCOLOR _color, + float _tu, float _tv) + { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw; + color = _color; + tu = _tu; tv = _tv; + } +} D3DTLVERTEX, *LPD3DTLVERTEX; + +#define D3DFVF_TLVERTEX D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1 + +class Direct3DDisplay : public IDisplay { +private: + HINSTANCE d3dDLL; + LPDIRECT3D8 pD3D; + LPDIRECT3DDEVICE8 pDevice; + LPDIRECT3DTEXTURE8 pTexture; + D3DSURFACE_DESC dsdBackBuffer; + D3DPRESENT_PARAMETERS dpp; + D3DFORMAT screenFormat; + int width; + int height; + bool filterDisabled; + ID3DXFont *pFont; + bool failed; + + void restoreDeviceObjects(); + void invalidateDeviceObjects(); + bool initializeOffscreen(int w, int h); + void updateFiltering(int); +public: + Direct3DDisplay(); + virtual ~Direct3DDisplay(); + + virtual bool initialize(); + virtual void cleanup(); + virtual void render(); + virtual void checkFullScreen(); + virtual void renderMenu(); + virtual void clear(); + virtual bool changeRenderSize(int w, int h); + virtual void resize(int w, int h); + virtual DISPLAY_TYPE getType() { return DIRECT_3D; }; + virtual void setOption(const char *, int); + virtual int selectFullScreenMode(GUID **); +}; + +Direct3DDisplay::Direct3DDisplay() +{ + d3dDLL = NULL; + pD3D = NULL; + pDevice = NULL; + pTexture = NULL; + pFont = NULL; + screenFormat = D3DFMT_R5G6B5; + width = 0; + height = 0; + filterDisabled = false; + failed = false; +} + +Direct3DDisplay::~Direct3DDisplay() +{ + cleanup(); +} + +void Direct3DDisplay::cleanup() +{ + if(pD3D != NULL) { + if(pFont) { + pFont->Release(); + pFont = NULL; + } + + if(pTexture) { + pTexture->Release(); + pTexture = NULL; + } + + if(pDevice) { + pDevice->Release(); + pDevice = NULL; + } + + pD3D->Release(); + pD3D = NULL; + + if(d3dDLL != NULL) { + FreeLibrary(d3dDLL); + d3dDLL = NULL; + } + } +} + +bool Direct3DDisplay::initialize() +{ + theApp.sizeX = 240; + theApp.sizeY = 160; + + switch(theApp.videoOption) { + case VIDEO_1X: + theApp.surfaceSizeX = theApp.sizeX; + theApp.surfaceSizeY = theApp.sizeY; + break; + case VIDEO_2X: + theApp.surfaceSizeX = theApp.sizeX * 2; + theApp.surfaceSizeY = theApp.sizeY * 2; + break; + case VIDEO_3X: + theApp.surfaceSizeX = theApp.sizeX * 3; + theApp.surfaceSizeY = theApp.sizeY * 3; + break; + case VIDEO_4X: + theApp.surfaceSizeX = theApp.sizeX * 4; + theApp.surfaceSizeY = theApp.sizeY * 4; + break; + case VIDEO_320x240: + case VIDEO_640x480: + case VIDEO_800x600: + case VIDEO_OTHER: + { + RECT r; + ::GetWindowRect(GetDesktopWindow(), &r); + theApp.fsWidth = r.right - r.left; + theApp.fsHeight = r.bottom - r.top; + + /* Need to fix this code later. For now, Fullscreen takes the whole + screen. + int scaleX = (theApp.fsWidth / theApp.sizeX); + int scaleY = (theApp.fsHeight / theApp.sizeY); + int min = scaleX < scaleY ? scaleX : scaleY; + theApp.surfaceSizeX = theApp.sizeX * min; + theApp.surfaceSizeY = theApp.sizeY * min; + if(theApp.fullScreenStretch) {*/ + theApp.surfaceSizeX = theApp.fsWidth; + theApp.surfaceSizeY = theApp.fsHeight; +// } + } + break; + } + + theApp.rect.left = 0; + theApp.rect.top = 0; + theApp.rect.right = theApp.sizeX; + theApp.rect.bottom = theApp.sizeY; + + theApp.dest.left = 0; + theApp.dest.top = 0; + theApp.dest.right = theApp.surfaceSizeX; + theApp.dest.bottom = theApp.surfaceSizeY; + + DWORD style = WS_POPUP | WS_VISIBLE; + DWORD styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + style |= WS_OVERLAPPEDWINDOW; + else + styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx); + else + AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx); + + int winSizeX = theApp.dest.right-theApp.dest.left; + int winSizeY = theApp.dest.bottom-theApp.dest.top; + + if(theApp.videoOption > VIDEO_4X) { + winSizeX = theApp.fsWidth; + winSizeY = theApp.fsHeight; + } + + int x = 0; + int y = 0; + + if(theApp.videoOption <= VIDEO_4X) { + x = theApp.windowPositionX; + y = theApp.windowPositionY; + } + + // Create a window + MainWnd *pWnd = new MainWnd; + theApp.m_pMainWnd = pWnd; + + pWnd->CreateEx(styleEx, + theApp.wndClass, + "VisualBoyAdvance", + style, + x,y,winSizeX,winSizeY, + NULL, + 0); + + if (!(HWND)*pWnd) { + winlog("Error creating Window %08x\n", GetLastError()); + return FALSE; + } + + theApp.updateMenuBar(); + + theApp.adjustDestRect(); + + d3dDLL = LoadLibrary("D3D8.DLL"); + LPDIRECT3D8 (WINAPI *D3DCreate)(UINT); + if(d3dDLL != NULL) { + D3DCreate = (LPDIRECT3D8 (WINAPI *)(UINT)) + GetProcAddress(d3dDLL, "Direct3DCreate8"); + + if(D3DCreate == NULL) { + theApp.directXMessage("Direct3DCreate8"); + return FALSE; + } + } else { + theApp.directXMessage("D3D8.DLL"); + return FALSE; + } + + pD3D = D3DCreate(120); + + if(pD3D == NULL) { + winlog("Error creating Direct3D object\n"); + return FALSE; + } + + theApp.mode320Available = FALSE; + theApp.mode640Available = FALSE; + theApp.mode800Available = FALSE; + + D3DDISPLAYMODE mode; + pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode); + + switch(mode.Format) { + case D3DFMT_R8G8B8: + systemColorDepth = 24; + systemRedShift = 19; + systemGreenShift = 11; + systemBlueShift = 3; + break; + case D3DFMT_X8R8G8B8: + systemColorDepth = 32; + systemRedShift = 19; + systemGreenShift = 11; + systemBlueShift = 3; + Init_2xSaI(32); + break; + case D3DFMT_R5G6B5: + systemColorDepth = 16; + systemRedShift = 11; + systemGreenShift = 6; + systemBlueShift = 0; + Init_2xSaI(565); + break; + case D3DFMT_X1R5G5B5: + systemColorDepth = 16; + systemRedShift = 10; + systemGreenShift = 5; + systemBlueShift = 0; + Init_2xSaI(555); + break; + default: + systemMessage(0,"Unsupport D3D format %d", mode.Format); + return false; + } + theApp.fsColorDepth = systemColorDepth; + +#ifdef MMX + if(!theApp.disableMMX) + cpu_mmx = theApp.detectMMX(); + else + cpu_mmx = 0; +#endif + + screenFormat = mode.Format; + + // check for available fullscreen modes + ZeroMemory(&dpp, sizeof(dpp)); + dpp.Windowed = TRUE; + dpp.BackBufferFormat = mode.Format; + dpp.BackBufferCount = 1; + dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + dpp.BackBufferWidth = theApp.surfaceSizeX; + dpp.BackBufferHeight = theApp.surfaceSizeY; + + HRESULT hret = pD3D->CreateDevice(D3DADAPTER_DEFAULT, + D3DDEVTYPE_HAL, + pWnd->GetSafeHwnd(), + D3DCREATE_SOFTWARE_VERTEXPROCESSING, + &dpp, + &pDevice); + if(!SUCCEEDED(hret)) { + winlog("Error creating Direct3DDevice %08x\n", hret); + return false; + } + + restoreDeviceObjects(); + + switch(systemColorDepth) { + case 16: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + case 24: + case 32: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + } + + theApp.updateFilter(); + theApp.updateIFB(); + + if(failed) + return false; + + pWnd->DragAcceptFiles(TRUE); + + return TRUE; +} + +bool Direct3DDisplay::initializeOffscreen(int w, int h) +{ + int size = 256; + if(w > 256 || h > 256) + size = 512; + + UINT ww = size; + UINT hh = size; + D3DFORMAT format = screenFormat; + + if(SUCCEEDED(D3DXCheckTextureRequirements(pDevice, + &ww, + &hh, + NULL, + 0, + &format, + D3DPOOL_MANAGED))) { + if((int)ww < w || (int)hh < h) { + if(theApp.filterFunction) { + filterDisabled = true; + theApp.filterFunction = NULL; + systemMessage(0, "3D card cannot support needed texture size for filter function. Disabling it"); + } + } else + filterDisabled = false; + if(SUCCEEDED(D3DXCreateTexture(pDevice, + ww, + hh, + 0, + 0, + format, + D3DPOOL_MANAGED, + &pTexture))) { + width = w; + height = h; + return true; + } + } + return false; +} + +void Direct3DDisplay::updateFiltering(int filter) +{ + switch(filter) { + default: + case 0: + // point filtering + pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT ); + pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT ); + pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_POINT ); + break; + case 1: + // bilinear + pDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); + pDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); + pDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_POINT ); + break; + } +} + +void Direct3DDisplay::restoreDeviceObjects() +{ + // Store render target surface desc + LPDIRECT3DSURFACE8 pBackBuffer; + HRESULT hr; + if(SUCCEEDED(hr = pDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer ))) { + pBackBuffer->GetDesc( &dsdBackBuffer ); + pBackBuffer->Release(); + } else + systemMessage(0, "Failed GetBackBuffer %08x", hr); + + // Set up the texture + pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); + pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + + int filter = regQueryDwordValue("d3dFilter", 0); + if(filter < 0 || filter > 3) + filter = 0; + updateFiltering(filter); + + // Set miscellaneous render states + pDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE ); + pDevice->SetRenderState( D3DRS_ZENABLE, FALSE ); + + // Set the projection matrix + D3DXMATRIX matProj; + FLOAT fAspect = ((FLOAT)dsdBackBuffer.Width) / dsdBackBuffer.Height; + D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f ); + pDevice->SetTransform( D3DTS_PROJECTION, &matProj ); + + // turn off lighting + pDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); + + if(pFont) { + pFont->Release(); + pFont = NULL; + } + // Create a D3D font using D3DX + HFONT hFont = CreateFont( 14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + ANTIALIASED_QUALITY, FF_DONTCARE, "Arial" ); + D3DXCreateFont( pDevice, hFont, &pFont ); +} + +void Direct3DDisplay::clear() +{ +} + +void Direct3DDisplay::renderMenu() +{ + checkFullScreen(); + if(theApp.m_pMainWnd) + theApp.m_pMainWnd->DrawMenuBar(); +} + +void Direct3DDisplay::checkFullScreen() +{ + // if(tripleBuffering) + // pDirect3D->FlipToGDISurface(); +} + +static void BlitRect(LPDIRECT3DDEVICE8 lpDevice, + LPDIRECT3DTEXTURE8 lpSrc, + float left, float top, + float right, float bottom, + D3DCOLOR col,float z) +{ + // calculate rhw + + float rhw=1.0f/(z*990.0f+10.0f); + + // set up rectangle + + D3DTLVERTEX verts[4]; + verts[0]=D3DTLVERTEX(D3DXVECTOR3(left-0.5f, top-0.5f, z),rhw,col,0.0f,0.0f); + verts[1]=D3DTLVERTEX(D3DXVECTOR3(right-0.5f, top-0.5f, z),rhw,col,1.0f,0.0f); + verts[2]=D3DTLVERTEX(D3DXVECTOR3(right-0.5f, bottom-0.5f, z),rhw,col,1.0f,1.0f); + verts[3]=D3DTLVERTEX(D3DXVECTOR3(left-0.5f, bottom-0.5f, z),rhw,col,0.0f,1.0f); + + // set the texture + + lpDevice->SetTexture(0,lpSrc); + + // configure shader for vertex type + + lpDevice->SetVertexShader(D3DFVF_TLVERTEX); + + // draw the rectangle + + lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,verts,sizeof(D3DTLVERTEX)); +} + +void Direct3DDisplay::render() +{ + if(!pDevice) + return; + + // Test the cooperative level to see if it's okay to render + if( FAILED( pDevice->TestCooperativeLevel() ) ) + { + return; + } + pDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0L ); + + if(SUCCEEDED(pDevice->BeginScene())) { + D3DLOCKED_RECT locked; + if(pTexture && SUCCEEDED(pTexture->LockRect(0, &locked, NULL, 0))) + { + + if(textMethod == 0) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + DrawTextMessages((u8*)pix, copyX*(systemColorDepth/8)+(systemColorDepth==24?0:4), 0, copyY); + } + + + if(theApp.filterFunction) { + if(systemColorDepth == 16) + theApp.filterFunction(pix+theApp.filterWidth*2+4, + theApp.filterWidth*2+4, + (u8*)theApp.delta, + (u8*)locked.pBits, + locked.Pitch, + theApp.filterWidth, + theApp.filterHeight); + else + theApp.filterFunction(pix+theApp.filterWidth*4+4, + theApp.filterWidth*4+4, + (u8*)theApp.delta, + (u8*)locked.pBits, + locked.Pitch, + theApp.filterWidth, + theApp.filterHeight); + } else { + int copyX = 240; + int copyY = 160; + + if(theApp.cartridgeType == 1) { + if(gbBorderOn) { + copyX = 256; + copyY = 224; + } else { + copyX = 160; + copyY = 144; + } + } + // MMX doesn't seem to be faster to copy the data + __asm { + mov eax, copyX; + mov ebx, copyY; + + mov esi, pix; + mov edi, locked.pBits; + mov edx, locked.Pitch; + cmp systemColorDepth, 16; + jnz gbaOtherColor; + sub edx, eax; + sub edx, eax; + lea esi,[esi+2*eax+4]; + shr eax, 1; + gbaLoop16bit: + mov ecx, eax; + repz movsd; + inc esi; + inc esi; + inc esi; + inc esi; + add edi, edx; + dec ebx; + jnz gbaLoop16bit; + jmp gbaLoopEnd; + gbaOtherColor: + cmp systemColorDepth, 32; + jnz gbaOtherColor2; + + sub edx, eax; + sub edx, eax; + sub edx, eax; + sub edx, eax; + lea esi, [esi+4*eax+4]; + gbaLoop32bit: + mov ecx, eax; + repz movsd; + add esi, 4; + add edi, edx; + dec ebx; + jnz gbaLoop32bit; + jmp gbaLoopEnd; + gbaOtherColor2: + lea eax, [eax+2*eax]; + sub edx, eax; + gbaLoop24bit: + mov ecx, eax; + shr ecx, 2; + repz movsd; + add edi, edx; + dec ebx; + jnz gbaLoop24bit; + gbaLoopEnd: + } + } + + if(theApp.videoOption > VIDEO_4X && theApp.showSpeed) { + char buffer[30]; + if(theApp.showSpeed == 1) + sprintf(buffer, "%3d%%", systemSpeed); + else + sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + theApp.showRenderedFrames); + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)locked.pBits, + locked.Pitch, + theApp.rect.left+10, + theApp.rect.bottom-10, + buffer); + else + drawText((u8*)locked.pBits, + locked.Pitch, + theApp.rect.left+10, + theApp.rect.bottom-10, + buffer); + } + + if(textMethod == 1) + { + DrawTextMessages((u8*)locked.pBits, locked.Pitch, theApp.rect.left, theApp.rect.bottom); + } + + pTexture->UnlockRect(0); + + float scaleX = (float)theApp.surfaceSizeX / theApp.sizeX; + float scaleY = (float)theApp.surfaceSizeY / theApp.sizeY; + BlitRect(pDevice, pTexture, 0, 0, scaleX*256, scaleY*256, 0xffffff, 0.1f); + } + + + if(textMethod == 2) + { + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2) && pFont) { + pFont->Begin(); + RECT r; + D3DCOLOR color; + + r.left = 10; + r.top = dpp.BackBufferHeight - 20*(slot+1); + r.right = dpp.BackBufferWidth - 10; + r.bottom = r.top + 20; + + if(outlinedText) + { + color = textColor != 7 ? D3DCOLOR_ARGB(255, 0, 0, 0) : D3DCOLOR_ARGB(255,255,255,255); + + // draw outline + const static int xd [8] = {-1,0,1,1,1,0,-1,-1}; + const static int yd [8] = {-1,-1,-1,0,1,1,1,0}; + for(int i = 0 ; i < 8 ; i++) + { + RECT r2 = r; + r2.left+=xd[i]; r2.right+=xd[i]; + r2.top+=yd[i]; r2.bottom+=yd[i]; + + pFont->DrawText(theApp.screenMessageBuffer[slot], -1, &r2, 0, color); + } + } + + // draw center text + switch(textColor) + { + case 0: color = D3DCOLOR_ARGB(255, 255, 255, 255); break; + case 1: color = D3DCOLOR_ARGB(255, 255, 0, 0); break; + case 2: color = D3DCOLOR_ARGB(255, 255, 255, 0); break; + case 3: color = D3DCOLOR_ARGB(255, 0, 255, 0); break; + case 4: color = D3DCOLOR_ARGB(255, 0, 255, 255); break; + case 5: color = D3DCOLOR_ARGB(255, 0, 0, 255); break; + case 6: color = D3DCOLOR_ARGB(255, 255, 0, 255); break; + case 7: color = D3DCOLOR_ARGB(255, 0, 0, 0); break; + } + pFont->DrawText(theApp.screenMessageBuffer[slot], -1, &r, 0, color); + + pFont->End(); + } else { + theApp.screenMessage[slot] = false; + } + } + } + } + + pDevice->EndScene(); + + pDevice->Present( NULL, NULL, NULL, NULL ); + } +} + +void Direct3DDisplay::invalidateDeviceObjects() +{ + if(pFont) + pFont->Release(); + pFont = NULL; +} + +void Direct3DDisplay::resize(int w, int h) +{ + if(pDevice) { + dpp.BackBufferWidth = w; + dpp.BackBufferHeight = h; + HRESULT hr; + invalidateDeviceObjects(); + if(SUCCEEDED(hr = pDevice->Reset(&dpp))) { + restoreDeviceObjects(); + } else + systemMessage(0, "Failed device reset %08x", hr); + } +} + +bool Direct3DDisplay::changeRenderSize(int w, int h) +{ + if(w != width || h != height) { + if(pTexture) { + pTexture->Release(); + pTexture = NULL; + } + if(!initializeOffscreen(w, h)) { + failed = true; + return false; + } + } + if(filterDisabled && theApp.filterFunction) + theApp.filterFunction = NULL; + + return true; +} + +void Direct3DDisplay::setOption(const char *option, int value) +{ + if(!strcmp(option, "d3dFilter")) + updateFiltering(value); +} + +int Direct3DDisplay::selectFullScreenMode(GUID **) +{ + HWND wnd = GetDesktopWindow(); + RECT r; + GetWindowRect(wnd, &r); + int w = (r.right - r.left) & 4095; + int h = (r.bottom - r.top) & 4095; + HDC dc = GetDC(wnd); + int c = GetDeviceCaps(dc, BITSPIXEL); + ReleaseDC(wnd, dc); + + return (c << 24) | (w << 12) | h; +} + +IDisplay *newDirect3DDisplay() +{ + return new Direct3DDisplay(); +} + diff --git a/src/win32/DirectDraw.cpp b/src/win32/DirectDraw.cpp new file mode 100644 index 0000000..4ff0b70 --- /dev/null +++ b/src/win32/DirectDraw.cpp @@ -0,0 +1,980 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" + +#define DIRECTDRAW_VERSION 0x0700 +#include "ddraw.h" + +#include "../System.h" +#include "../gb/gbGlobals.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Text.h" + +#include "VBA.h" +#include "MainWnd.h" +#include "Reg.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern int Init_2xSaI(u32); +extern int RGB_LOW_BITS_MASK; +extern void winlog(const char *,...); +extern int systemSpeed; +extern int winVideoModeSelect(CWnd *, GUID **); + +class DirectDrawDisplay : public IDisplay { +private: + HINSTANCE ddrawDLL; + LPDIRECTDRAW7 pDirectDraw; + LPDIRECTDRAWSURFACE7 ddsPrimary; + LPDIRECTDRAWSURFACE7 ddsOffscreen; + LPDIRECTDRAWSURFACE7 ddsFlip; + LPDIRECTDRAWCLIPPER ddsClipper; + int width; + int height; + bool failed; + + bool initializeOffscreen(int w, int h); +public: + DirectDrawDisplay(); + virtual ~DirectDrawDisplay(); + + virtual bool initialize(); + virtual void cleanup(); + virtual void render(); + virtual void checkFullScreen(); + virtual void renderMenu(); + virtual void clear(); + virtual bool changeRenderSize(int w, int h); + virtual DISPLAY_TYPE getType() { return DIRECT_DRAW; }; + virtual void setOption(const char *, int) {} + virtual bool isSkinSupported() { return true; } + virtual int selectFullScreenMode(GUID **); +}; + +static HRESULT WINAPI checkModesAvailable(LPDDSURFACEDESC2 surf, LPVOID lpContext) +{ + if(surf->dwWidth == 320 && + surf->dwHeight == 240 && + surf->ddpfPixelFormat.dwRGBBitCount == 16) { + theApp.mode320Available = TRUE; + } + if(surf->dwWidth == 640 && + surf->dwHeight == 480 && + surf->ddpfPixelFormat.dwRGBBitCount == 16) { + theApp.mode640Available = TRUE; + } + if(surf->dwWidth == 800 && + surf->dwHeight == 600 && + surf->ddpfPixelFormat.dwRGBBitCount == 16) { + theApp.mode800Available = TRUE; + } + return DDENUMRET_OK; +} + +static int ffs(UINT mask) +{ + int m = 0; + if (mask) { + while (!(mask & (1 << m))) + m++; + + return (m); + } + + return (0); +} + +DirectDrawDisplay::DirectDrawDisplay() +{ + pDirectDraw = NULL; + ddsPrimary = NULL; + ddsOffscreen = NULL; + ddsFlip = NULL; + ddsClipper = NULL; + ddrawDLL = NULL; + width = 0; + height = 0; + failed = false; +} + +DirectDrawDisplay::~DirectDrawDisplay() +{ + cleanup(); +} + +void DirectDrawDisplay::cleanup() +{ + if(pDirectDraw != NULL) { + if(ddsClipper != NULL) { + ddsClipper->Release(); + ddsClipper = NULL; + } + + if(ddsFlip != NULL) { + ddsFlip->Release(); + ddsFlip = NULL; + } + + if(ddsOffscreen != NULL) { + ddsOffscreen->Release(); + ddsOffscreen = NULL; + } + + if(ddsPrimary != NULL) { + ddsPrimary->Release(); + ddsPrimary = NULL; + } + + pDirectDraw->Release(); + pDirectDraw = NULL; + } + + if(ddrawDLL != NULL) { + /**/AfxFreeLibrary(ddrawDLL); + ddrawDLL = NULL; + } + width = 0; + height = 0; +} + +bool DirectDrawDisplay::initialize() +{ + theApp.sizeX = 240; + theApp.sizeY = 160; + + switch(theApp.videoOption) { + case VIDEO_1X: + theApp.surfaceSizeX = theApp.sizeX; + theApp.surfaceSizeY = theApp.sizeY; + break; + case VIDEO_2X: + theApp.surfaceSizeX = theApp.sizeX * 2; + theApp.surfaceSizeY = theApp.sizeY * 2; + break; + case VIDEO_3X: + theApp.surfaceSizeX = theApp.sizeX * 3; + theApp.surfaceSizeY = theApp.sizeY * 3; + break; + case VIDEO_4X: + theApp.surfaceSizeX = theApp.sizeX * 4; + theApp.surfaceSizeY = theApp.sizeY * 4; + break; + case VIDEO_320x240: + case VIDEO_640x480: + case VIDEO_800x600: + case VIDEO_OTHER: + { + int scaleX = (theApp.fsWidth / theApp.sizeX); + int scaleY = (theApp.fsHeight / theApp.sizeY); + int min = scaleX < scaleY ? scaleX : scaleY; + if(theApp.fsMaxScale) + min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min; + theApp.surfaceSizeX = theApp.sizeX * min; + theApp.surfaceSizeY = theApp.sizeY * min; + if(theApp.fullScreenStretch) { + theApp.surfaceSizeX = theApp.fsWidth; + theApp.surfaceSizeY = theApp.fsHeight; + } + } + break; + } + + theApp.rect.left = 0; + theApp.rect.top = 0; + theApp.rect.right = theApp.sizeX; + theApp.rect.bottom = theApp.sizeY; + + theApp.dest.left = 0; + theApp.dest.top = 0; + theApp.dest.right = theApp.surfaceSizeX; + theApp.dest.bottom = theApp.surfaceSizeY; + + DWORD style = WS_POPUP | WS_VISIBLE; + DWORD styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + style |= WS_OVERLAPPEDWINDOW; + else + styleEx = WS_EX_TOPMOST; + + if(theApp.videoOption <= VIDEO_4X) + AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx); + else + AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx); + + int winSizeX = theApp.dest.right-theApp.dest.left; + int winSizeY = theApp.dest.bottom-theApp.dest.top; + + int x = 0; + int y = 0; + + if(theApp.videoOption <= VIDEO_4X) { + x = theApp.windowPositionX; + y = theApp.windowPositionY; + } + + // Create a window + MainWnd *pWnd = new MainWnd; + theApp.m_pMainWnd = pWnd; + + pWnd->CreateEx(styleEx, + theApp.wndClass, + "VisualBoyAdvance", + style, + x,y,winSizeX,winSizeY, + NULL, + 0); + + if (!(HWND)*pWnd) { + winlog("Error creating Window %08x\n", GetLastError()); + return FALSE; + } + + + theApp.updateMenuBar(); + + theApp.adjustDestRect(); + + GUID *guid = NULL; + if(theApp.ddrawEmulationOnly) + guid = (GUID *)DDCREATE_EMULATIONONLY; + + if(theApp.pVideoDriverGUID) + guid = theApp.pVideoDriverGUID; + + ddrawDLL = /**/AfxLoadLibrary("DDRAW.DLL"); + HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *); + if(ddrawDLL != NULL) { + DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *)) + GetProcAddress(ddrawDLL, "DirectDrawCreateEx"); + + if(DDrawCreateEx == NULL) { + theApp.directXMessage("DirectDrawCreateEx"); + return FALSE; + } + } else { + theApp.directXMessage("DDRAW.DLL"); + return FALSE; + } + + theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly; + + HRESULT hret = DDrawCreateEx(guid, + (void **)&pDirectDraw, + IID_IDirectDraw7, + NULL); + + if(hret != DD_OK) { + winlog("Error creating DirectDraw object %08x\n", hret); + if(theApp.ddrawEmulationOnly) { + // disable emulation only setting in case of failure + regSetDwordValue("ddrawEmulationOnly", 0); + } + // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret); + return FALSE; + } + + if(theApp.ddrawDebug) { + DDCAPS driver; + DDCAPS hel; + ZeroMemory(&driver, sizeof(driver)); + ZeroMemory(&hel, sizeof(hel)); + driver.dwSize = sizeof(driver); + hel.dwSize = sizeof(hel); + pDirectDraw->GetCaps(&driver, &hel); + int i; + DWORD *p = (DWORD *)&driver; + for(i = 0; i < (int)driver.dwSize; i+=4) + winlog("Driver CAPS %2d: %08x\n", i>>2, *p++); + p = (DWORD *)&hel; + for(i = 0; i < (int)hel.dwSize; i+=4) + winlog("HEL CAPS %2d: %08x\n", i>>2, *p++); + } + + theApp.mode320Available = false; + theApp.mode640Available = false; + theApp.mode800Available = false; + // check for available fullscreen modes + pDirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, NULL, + checkModesAvailable); + + DWORD flags = DDSCL_NORMAL; + + if(theApp.videoOption >= VIDEO_320x240) + flags = DDSCL_ALLOWMODEX | + DDSCL_ALLOWREBOOT | + DDSCL_EXCLUSIVE | + DDSCL_FULLSCREEN; + + hret = pDirectDraw->SetCooperativeLevel(pWnd->m_hWnd, + flags); + + if(hret != DD_OK) { + winlog("Error SetCooperativeLevel %08x\n", hret); + // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWLEVEL), hret); + return FALSE; + } + + if(theApp.videoOption > VIDEO_4X) { + hret = pDirectDraw->SetDisplayMode(theApp.fsWidth, + theApp.fsHeight, + theApp.fsColorDepth, + 0, + 0); + if(hret != DD_OK) { + winlog("Error SetDisplayMode %08x\n", hret); + // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSET), hret); + return FALSE; + } + } + + DDSURFACEDESC2 ddsd; + ZeroMemory(&ddsd,sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + if(theApp.videoOption > VIDEO_4X) { + if(theApp.tripleBuffering) { + // setup triple buffering + ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; + ddsd.ddsCaps.dwCaps |= DDSCAPS_COMPLEX | DDSCAPS_FLIP; + ddsd.dwBackBufferCount = 2; + } + } + + hret = pDirectDraw->CreateSurface(&ddsd, &ddsPrimary, NULL); + if(hret != DD_OK) { + winlog("Error primary CreateSurface %08x\n", hret); + // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSURFACE), hret); + return FALSE; + } + + if(theApp.ddrawDebug) { + DDSCAPS2 caps; + ZeroMemory(&caps, sizeof(caps)); + ddsPrimary->GetCaps(&caps); + + winlog("Primary CAPS 1: %08x\n", caps.dwCaps); + winlog("Primary CAPS 2: %08x\n", caps.dwCaps2); + winlog("Primary CAPS 3: %08x\n", caps.dwCaps3); + winlog("Primary CAPS 4: %08x\n", caps.dwCaps4); + } + + if(theApp.videoOption > VIDEO_4X && theApp.tripleBuffering) { + DDSCAPS2 caps; + ZeroMemory(&caps, sizeof(caps)); + // this gets the third surface. The front one is the primary, + // the second is the backbuffer and the third is the flip + // surface + caps.dwCaps = DDSCAPS_BACKBUFFER; + + hret = ddsPrimary->GetAttachedSurface(&caps, &ddsFlip); + if(hret != DD_OK) { + winlog("Failed to get attached surface %08x", hret); + return FALSE; + } + + ddsFlip->AddRef(); + clear(); + } + + // create clipper in all modes to avoid paint problems + // if(videoOption <= VIDEO_4X) { + hret = pDirectDraw->CreateClipper(0, &ddsClipper, NULL); + if(hret == DD_OK) { + ddsClipper->SetHWnd(0, pWnd->m_hWnd); + if(theApp.videoOption > VIDEO_4X) { + if(theApp.tripleBuffering) + ddsFlip->SetClipper(ddsClipper); + else + ddsPrimary->SetClipper(ddsClipper); + } else + ddsPrimary->SetClipper(ddsClipper); + } + // } + + DDPIXELFORMAT px; + + px.dwSize = sizeof(px); + + hret = ddsPrimary->GetPixelFormat(&px); + + switch(px.dwRGBBitCount) { + case 15: + case 16: + systemColorDepth = 16; + break; + case 24: + systemColorDepth = 24; + theApp.filterFunction = NULL; + break; + case 32: + systemColorDepth = 32; + break; + default: + systemMessage(IDS_ERROR_DISP_COLOR, "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode.",px.dwRGBBitCount); + return FALSE; + } + theApp.updateFilter(); + theApp.updateIFB(); + + if(failed) + return false; + + pWnd->DragAcceptFiles(TRUE); + + return true; +} + +bool DirectDrawDisplay::changeRenderSize(int w, int h) +{ + if(w != width || h != height) { + if(ddsOffscreen) { + ddsOffscreen->Release(); + ddsOffscreen = NULL; + } + if(!initializeOffscreen(w, h)) { + failed = true; + return false; + } + } + return true; +} + +bool DirectDrawDisplay::initializeOffscreen(int w, int h) +{ + DDSURFACEDESC2 ddsd; + + ZeroMemory(&ddsd, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + if(theApp.ddrawUseVideoMemory) + ddsd.ddsCaps.dwCaps |= (DDSCAPS_LOCALVIDMEM|DDSCAPS_VIDEOMEMORY); + ddsd.dwWidth = w; + ddsd.dwHeight = h; + + HRESULT hret = pDirectDraw->CreateSurface(&ddsd, &ddsOffscreen, NULL); + + if(hret != DD_OK) { + winlog("Error offscreen CreateSurface %08x\n", hret); + if(theApp.ddrawUseVideoMemory) { + regSetDwordValue("ddrawUseVideoMemory", 0); + } + // errorMessage(myLoadString(IDS_ERROR_DISP_DRAWSURFACE2), hret); + return false; + } + + if(theApp.ddrawDebug) { + DDSCAPS2 caps; + ZeroMemory(&caps, sizeof(caps)); + ddsOffscreen->GetCaps(&caps); + + winlog("Offscreen CAPS 1: %08x\n", caps.dwCaps); + winlog("Offscreen CAPS 2: %08x\n", caps.dwCaps2); + winlog("Offscreen CAPS 3: %08x\n", caps.dwCaps3); + winlog("Offscreen CAPS 4: %08x\n", caps.dwCaps4); + } + + DDPIXELFORMAT px; + + px.dwSize = sizeof(px); + + hret = ddsOffscreen->GetPixelFormat(&px); + + if(theApp.ddrawDebug) { + DWORD *pdword = (DWORD *)&px; + for(int ii = 0; ii < 8; ii++) { + winlog("Pixel format %d %08x\n", ii, pdword[ii]); + } + } + + switch(px.dwRGBBitCount) { + case 15: + case 16: + systemColorDepth = 16; + break; + case 24: + systemColorDepth = 24; + theApp.filterFunction = NULL; + break; + case 32: + systemColorDepth = 32; + break; + default: + systemMessage(IDS_ERROR_DISP_COLOR, "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode.",px.dwRGBBitCount); + return FALSE; + } + if(theApp.ddrawDebug) { + winlog("R Mask: %08x\n", px.dwRBitMask); + winlog("G Mask: %08x\n", px.dwGBitMask); + winlog("B Mask: %08x\n", px.dwBBitMask); + } + + systemRedShift = ffs(px.dwRBitMask); + systemGreenShift = ffs(px.dwGBitMask); + systemBlueShift = ffs(px.dwBBitMask); + +#ifdef MMX + if(!theApp.disableMMX) + cpu_mmx = theApp.detectMMX(); + else + cpu_mmx = 0; +#endif + + if((px.dwFlags&DDPF_RGB) != 0 && + px.dwRBitMask == 0xF800 && + px.dwGBitMask == 0x07E0 && + px.dwBBitMask == 0x001F) { + systemGreenShift++; + Init_2xSaI(565); + RGB_LOW_BITS_MASK=0x821; + } else if((px.dwFlags&DDPF_RGB) != 0 && + px.dwRBitMask == 0x7C00 && + px.dwGBitMask == 0x03E0 && + px.dwBBitMask == 0x001F) { + Init_2xSaI(555); + RGB_LOW_BITS_MASK=0x421; + } else if((px.dwFlags&DDPF_RGB) != 0 && + px.dwRBitMask == 0x001F && + px.dwGBitMask == 0x07E0 && + px.dwBBitMask == 0xF800) { + systemGreenShift++; + Init_2xSaI(565); + RGB_LOW_BITS_MASK=0x821; + } else if((px.dwFlags&DDPF_RGB) != 0 && + px.dwRBitMask == 0x001F && + px.dwGBitMask == 0x03E0 && + px.dwBBitMask == 0x7C00) { + Init_2xSaI(555); + RGB_LOW_BITS_MASK=0x421; + } else { + // 32-bit or 24-bit + if(systemColorDepth == 32 || systemColorDepth == 24) { + systemRedShift += 3; + systemGreenShift += 3; + systemBlueShift += 3; + if(systemColorDepth == 32) + Init_2xSaI(32); + } + } + + if(theApp.ddrawDebug) { + winlog("R shift: %d\n", systemRedShift); + winlog("G shift: %d\n", systemGreenShift); + winlog("B shift: %d\n", systemBlueShift); + } + + switch(systemColorDepth) { + case 16: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + case 24: + case 32: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + } + width = w; + height = h; + return true; +} + +void DirectDrawDisplay::clear() +{ + if(theApp.videoOption <= VIDEO_4X || !theApp.tripleBuffering || ddsFlip == NULL) + return; + + DDBLTFX fx; + ZeroMemory(&fx, sizeof(fx)); + fx.dwSize = sizeof(fx); + fx.dwFillColor = 0; + ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); + ddsPrimary->Flip(NULL, 0); + ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); + ddsPrimary->Flip(NULL, 0); + ddsFlip->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); + ddsPrimary->Flip(NULL, 0); +} + +void DirectDrawDisplay::renderMenu() +{ + checkFullScreen(); + theApp.m_pMainWnd->DrawMenuBar(); +} + +void DirectDrawDisplay::checkFullScreen() +{ + if(theApp.tripleBuffering) + pDirectDraw->FlipToGDISurface(); +} + +void DirectDrawDisplay::render() +{ + HRESULT hret; + + if(pDirectDraw == NULL || + ddsOffscreen == NULL || + ddsPrimary == NULL) + return; + + bool fastForward = speedup; +#if (defined(WIN32) && !defined(SDL)) + if(theApp.frameSearchSkipping) + { + if(theApp.frameSearchFirstStep) + fastForward = true; + else + return; // don't render skipped frame search frames + } +#endif + + if(theApp.vsync && !fastForward) { + hret = pDirectDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); + } + + DDSURFACEDESC2 ddsDesc; + + ZeroMemory(&ddsDesc, sizeof(ddsDesc)); + + ddsDesc.dwSize = sizeof(ddsDesc); + + hret = ddsOffscreen->Lock(NULL, + &ddsDesc, + DDLOCK_WRITEONLY| +#ifndef FINAL_VERSION + DDLOCK_NOSYSLOCK| +#endif + DDLOCK_SURFACEMEMORYPTR, + NULL); + + if(hret == DDERR_SURFACELOST) { + hret = ddsPrimary->Restore(); + if(hret == DD_OK) { + hret = ddsOffscreen->Restore(); + + if(hret == DD_OK) { + hret = ddsOffscreen->Lock(NULL, + &ddsDesc, + DDLOCK_WRITEONLY| +#ifndef FINAL_VERSION + DDLOCK_NOSYSLOCK| +#endif + DDLOCK_SURFACEMEMORYPTR, + NULL); + + } + } + } + + if(hret == DD_OK) { + + //if(textMethod == 0) + //{ + //int copyX = 240, copyY = 160; + //if(theApp.cartridgeType == 1) + // if(gbBorderOn) copyX = 256, copyY = 224; + // else copyX = 160, copyY = 144; + + //DrawTextMessages((u8*)pix, copyX*(systemColorDepth/8)+(systemColorDepth==24?0:4), 0, copyY); + //} + + if(theApp.filterFunction) { + if(systemColorDepth == 16) +/// (*theApp.filterFunction)(pix+theApp.filterWidth*2+4, + (*theApp.filterFunction)(pix+theApp.filterWidth*2+4, + theApp.filterWidth*2+4, + (u8*)theApp.delta, + (u8*)ddsDesc.lpSurface, + ddsDesc.lPitch, + theApp.filterWidth, + theApp.filterHeight); + else +/// (*theApp.filterFunction)(pix+theApp.filterWidth*4+4, + (*theApp.filterFunction)(pix+theApp.filterWidth*4+4, + theApp.filterWidth*4+4, + (u8*)theApp.delta, + (u8*)ddsDesc.lpSurface, + ddsDesc.lPitch, + theApp.filterWidth, + theApp.filterHeight); + + } else { + int copyX = 240; + int copyY = 160; + + if(theApp.cartridgeType == 1) { + if(gbBorderOn) { + copyX = 256; + copyY = 224; + } else { + copyX = 160; + copyY = 144; + } + } + // MMX doesn't seem to be faster to copy the data + __asm { + mov eax, copyX; + mov ebx, copyY; + + mov esi, pix; + mov edi, ddsDesc.lpSurface; + mov edx, ddsDesc.lPitch; + cmp systemColorDepth, 16; + jnz gbaOtherColor; + sub edx, eax; + sub edx, eax; + lea esi,[esi+2*eax+4]; + shr eax, 1; + gbaLoop16bit: + mov ecx, eax; + repz movsd; + inc esi; + inc esi; + inc esi; + inc esi; + add edi, edx; + dec ebx; + jnz gbaLoop16bit; + jmp gbaLoopEnd; + gbaOtherColor: + cmp systemColorDepth, 32; + jnz gbaOtherColor2; + + sub edx, eax; + sub edx, eax; + sub edx, eax; + sub edx, eax; + lea esi, [esi+4*eax+4]; + gbaLoop32bit: + mov ecx, eax; + repz movsd; + add esi, 4; + add edi, edx; + dec ebx; + jnz gbaLoop32bit; + jmp gbaLoopEnd; + gbaOtherColor2: + lea eax, [eax+2*eax]; + sub edx, eax; + gbaLoop24bit: + mov ecx, eax; + shr ecx, 2; + repz movsd; + add edi, edx; + dec ebx; + jnz gbaLoop24bit; + gbaLoopEnd: + } + } + if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) { + char buffer[30]; + if(theApp.showSpeed == 1) + sprintf(buffer, "%3d%%", systemSpeed); + else + sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + theApp.showRenderedFrames); + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)ddsDesc.lpSurface, + ddsDesc.lPitch, + theApp.rect.left+10, + theApp.rect.bottom-10, + buffer); + else + drawText((u8*)ddsDesc.lpSurface, + ddsDesc.lPitch, + theApp.rect.left+10, + theApp.rect.bottom-10, + buffer); + } + + if(textMethod == 1) + { + DrawTextMessages((u8*)ddsDesc.lpSurface, ddsDesc.lPitch, theApp.rect.left, theApp.rect.bottom); + } + + } else if(theApp.ddrawDebug) + winlog("Error during lock: %08x\n", hret); + + hret = ddsOffscreen->Unlock(NULL); + + if(hret == DD_OK) { + ddsOffscreen->PageLock(0); + if(theApp.tripleBuffering && theApp.videoOption > VIDEO_4X) { + hret = ddsFlip->Blt(&theApp.dest, ddsOffscreen, NULL, DDBLT_WAIT, NULL); + if(hret == DD_OK) { + if(theApp.menuToggle || !theApp.active) { + pDirectDraw->FlipToGDISurface(); + ddsPrimary->SetClipper(ddsClipper); + hret = ddsPrimary->Blt(&theApp.dest, ddsFlip, NULL, DDBLT_ASYNC, NULL); + // if using emulation only, then we have to redraw the menu + // everytime. It seems like a bug in DirectDraw to me as we not + // overwritting the menu area at all. + if(theApp.ddrawUsingEmulationOnly) + theApp.m_pMainWnd->DrawMenuBar(); + } else + hret = ddsPrimary->Flip(NULL, 0); + } + } else { + hret = ddsPrimary->Blt(&theApp.dest, ddsOffscreen, NULL,DDBLT_ASYNC,NULL); + + if(hret == DDERR_SURFACELOST) { + hret = ddsPrimary->Restore(); + + if(hret == DD_OK) { + hret = ddsPrimary->Blt(&theApp.dest, ddsOffscreen, NULL, DDBLT_ASYNC, NULL); + } + } + } + ddsOffscreen->PageUnlock(0); + } else if(theApp.ddrawDebug) + winlog("Error during unlock: %08x\n", hret); + + + bool textMessageStarted = false; + + if(textMethod == 2) + { + HDC hdc; + + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2)) + { + + if(!textMessageStarted) + { + textMessageStarted = true; + ddsPrimary->SetClipper(ddsClipper); + ddsPrimary->GetDC(&hdc); + SetBkMode(hdc,TRANSPARENT); + SetTextColor(hdc, textColor != 7 ? RGB(0,0,0) : RGB(255,255,255)); + } + + if(outlinedText) + { + // draw black outline + const static int xd [8] = {-1,0,1,1,1,0,-1,-1}; + const static int yd [8] = {-1,-1,-1,0,1,1,1,0}; + for(int i = 0 ; i < 8 ; i++) + { + TextOut(hdc, theApp.dest.left+10+xd[i], theApp.dest.bottom - 20*(slot+1)+yd[i], theApp.screenMessageBuffer[slot], + strlen(theApp.screenMessageBuffer[slot])); + } + } + } else { + theApp.screenMessage[slot] = false; + } + } + } + + if(textMessageStarted) + { + COLORREF color; + switch(textColor) + { + case 0: color = RGB(255, 255, 255); break; + case 1: color = RGB(255, 0, 0); break; + case 2: color = RGB(255, 255, 0); break; + case 3: color = RGB(0, 255, 0); break; + case 4: color = RGB(0, 255, 255); break; + case 5: color = RGB(0, 0, 255); break; + case 6: color = RGB(255, 0, 255); break; + case 7: color = RGB(0, 0, 0); break; + } + SetTextColor(hdc, color); + + // draw center text + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2)) + { + TextOut(hdc, theApp.dest.left+10, theApp.dest.bottom - 20*(slot+1), theApp.screenMessageBuffer[slot], + strlen(theApp.screenMessageBuffer[slot])); + } + } + } + } + + if(textMessageStarted) + { + ddsPrimary->ReleaseDC(hdc); + } + } + + if(hret != DD_OK) { + if(theApp.ddrawDebug) + winlog("Error on update screen: %08x\n", hret); + } +} + +int DirectDrawDisplay::selectFullScreenMode(GUID **pGUID) +{ + return winVideoModeSelect(theApp.m_pMainWnd, pGUID); +} + +IDisplay *newDirectDrawDisplay() +{ + return new DirectDrawDisplay(); +} + +void DrawTextMessages(u8 * dest, int pitch, int left, int bottom) +{ + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2)) { + + drawText(dest, + pitch, + left, + bottom - 10*(slot+1), + theApp.screenMessageBuffer[slot], + theApp.screenMessageColorBuffer[slot]); + + } else { + theApp.screenMessage[slot] = false; + } + } + } +} diff --git a/src/win32/DirectInput.cpp b/src/win32/DirectInput.cpp new file mode 100644 index 0000000..4eb5de2 --- /dev/null +++ b/src/win32/DirectInput.cpp @@ -0,0 +1,1093 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../movie.h" + +#define DIRECTINPUT_VERSION 0x0500 +#include "dinput.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern void directXMessage(const char *); +extern void winlog(const char *msg,...); + +#define POV_UP 1 +#define POV_DOWN 2 +#define POV_RIGHT 4 +#define POV_LEFT 8 + +class DirectInput : public Input { +private: + HINSTANCE dinputDLL; + +public: + virtual void checkDevices(); + DirectInput(); + virtual ~DirectInput(); + + virtual bool initialize(); + virtual bool readDevices(); + virtual u32 readDevice(int which, bool sensor); + virtual CString getKeyName(int key); + virtual void checkKeys(); + virtual void activate(); + virtual void loadSettings(); + virtual void saveSettings(); +}; + +struct deviceInfo { + LPDIRECTINPUTDEVICE device; + BOOL isPolled; + int nButtons; + int nAxes; + int nPovs; + BOOL first; + struct { + DWORD offset; + LONG center; + LONG negative; + LONG positive; + } axis[8]; + int needed; + union { + UCHAR data[256]; + DIJOYSTATE state; + }; +}; + +static deviceInfo *currentDevice = NULL; +static int numDevices = 1; +static deviceInfo *pDevices = NULL; +static LPDIRECTINPUT pDirectInput = NULL; +static int joyDebug = 0; +static int axisNumber = 0; + +USHORT joypad[4][13] = { + { + DIK_LEFT, DIK_RIGHT, + DIK_UP, DIK_DOWN, + DIK_Z, DIK_X, + DIK_RETURN,DIK_BACK, + DIK_A, DIK_S, + DIK_SPACE, DIK_F12, + DIK_C + }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; + +USHORT motion[4] = { + DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2 +}; + +static int winReadKey(char *name, int num) +{ + char buffer[80]; + + sprintf(buffer, "Joy%d_%s", num, name); + + return regQueryDwordValue(buffer, (DWORD)-1); +} + +void winReadKeys() +{ + int key = -1; + + for(int i = 0; i < 4; i++) { + key = winReadKey("Left", i); + if(key != -1) + joypad[i][KEY_LEFT] = key; + key = winReadKey("Right", i); + if(key != -1) + joypad[i][KEY_RIGHT] = key; + key = winReadKey("Up", i); + if(key != -1) + joypad[i][KEY_UP] = key; + key = winReadKey("Down", i); + if(key != -1) + joypad[i][KEY_DOWN] = key; + key = winReadKey("A", i); + if(key != -1) + joypad[i][KEY_BUTTON_A] = key; + key = winReadKey("B", i); + if(key != -1) + joypad[i][KEY_BUTTON_B] = key; + key = winReadKey("L", i); + if(key != -1) + joypad[i][KEY_BUTTON_L] = key; + key = winReadKey("R", i); + if(key != -1) + joypad[i][KEY_BUTTON_R] = key; + key = winReadKey("Start", i); + if(key != -1) + joypad[i][KEY_BUTTON_START] = key; + key = winReadKey("Select", i); + if(key != -1) + joypad[i][KEY_BUTTON_SELECT] = key; + key = winReadKey("Speed", i); + if(key != -1) + joypad[i][KEY_BUTTON_SPEED] = key; + key = winReadKey("Capture", i); + if(key != -1) + joypad[i][KEY_BUTTON_CAPTURE] = key; + key = winReadKey("GS", i); + if(key != -1) + joypad[i][KEY_BUTTON_GS] = key; + } + key = regQueryDwordValue("Motion_Left", (DWORD)-1); + if(key != -1) + motion[KEY_LEFT] = key; + key = regQueryDwordValue("Motion_Right", (DWORD)-1); + if(key != -1) + motion[KEY_RIGHT] = key; + key = regQueryDwordValue("Motion_Up", (DWORD)-1); + if(key != -1) + motion[KEY_UP] = key; + key = regQueryDwordValue("Motion_Down", (DWORD)-1); + if(key != -1) + motion[KEY_DOWN] = key; +} + +static void winSaveKey(char *name, int num, USHORT value) +{ + char buffer[80]; + + sprintf(buffer, "Joy%d_%s", num, name); + + regSetDwordValue(buffer, value); +} + +void winSaveKeys() +{ + for(int i = 0; i < 4; i++) { + winSaveKey("Left", i, joypad[i][KEY_LEFT]); + winSaveKey("Right", i, joypad[i][KEY_RIGHT]); + winSaveKey("Up", i, joypad[i][KEY_UP]); + winSaveKey("Speed", i, joypad[i][KEY_BUTTON_SPEED]); + winSaveKey("Capture", i, joypad[i][KEY_BUTTON_CAPTURE]); + winSaveKey("GS", i, joypad[i][KEY_BUTTON_GS]); + winSaveKey("Down", i, joypad[i][KEY_DOWN]); + winSaveKey("A", i, joypad[i][KEY_BUTTON_A]); + winSaveKey("B", i, joypad[i][KEY_BUTTON_B]); + winSaveKey("L", i, joypad[i][KEY_BUTTON_L]); + winSaveKey("R", i, joypad[i][KEY_BUTTON_R]); + winSaveKey("Start", i, joypad[i][KEY_BUTTON_START]); + winSaveKey("Select", i, joypad[i][KEY_BUTTON_SELECT]); + } + regSetDwordValue("joyVersion", 1); + + regSetDwordValue("Motion_Left", + motion[KEY_LEFT]); + regSetDwordValue("Motion_Right", + motion[KEY_RIGHT]); + regSetDwordValue("Motion_Up", + motion[KEY_UP]); + regSetDwordValue("Motion_Down", + motion[KEY_DOWN]); +} + +static BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) +{ + DIPROPRANGE diprg; + diprg.diph.dwSize = sizeof(DIPROPRANGE); + diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); + diprg.diph.dwHow = DIPH_BYOFFSET; + diprg.diph.dwObj = pdidoi->dwOfs; // Specify the enumerated axis + + diprg.lMin = -32768; + diprg.lMax = 32767; + // try to set the range + if(FAILED(currentDevice->device->SetProperty(DIPROP_RANGE, &diprg.diph))) { + // Get the range for the axis + if( FAILED(currentDevice->device-> + GetProperty( DIPROP_RANGE, &diprg.diph ) ) ) { + return DIENUM_STOP; + } + } + + DIPROPDWORD didz; + + didz.diph.dwSize = sizeof(didz); + didz.diph.dwHeaderSize = sizeof(DIPROPHEADER); + didz.diph.dwHow = DIPH_BYOFFSET; + didz.diph.dwObj = pdidoi->dwOfs; + + didz.dwData = 5000; + + currentDevice->device->SetProperty(DIPROP_DEADZONE, &didz.diph); + + LONG center = (diprg.lMin + diprg.lMax)/2; + LONG threshold = (diprg.lMax - center)/2; + + // only 8 axis supported + if(axisNumber < 8) { + currentDevice->axis[axisNumber].center = center; + currentDevice->axis[axisNumber].negative = center - threshold; + currentDevice->axis[axisNumber].positive = center + threshold; + currentDevice->axis[axisNumber].offset = pdidoi->dwOfs; + } + axisNumber++; + return DIENUM_CONTINUE; +} + +static BOOL CALLBACK EnumPovsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) +{ + return DIENUM_CONTINUE; +} + +static BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE pInst, + LPVOID lpvContext) +{ + ZeroMemory(&pDevices[numDevices],sizeof(deviceInfo)); + + HRESULT hRet = pDirectInput->CreateDevice(pInst->guidInstance, + &pDevices[numDevices].device, + NULL); + + if(hRet != DI_OK) + return DIENUM_STOP; + + DIDEVCAPS caps; + caps.dwSize=sizeof(DIDEVCAPS); + + hRet = pDevices[numDevices].device->GetCapabilities(&caps); + + if(hRet == DI_OK) { + if(caps.dwFlags & DIDC_POLLEDDATAFORMAT || + caps.dwFlags & DIDC_POLLEDDEVICE) + pDevices[numDevices].isPolled = TRUE; + + pDevices[numDevices].nButtons = caps.dwButtons; + pDevices[numDevices].nAxes = caps.dwAxes; + pDevices[numDevices].nPovs = caps.dwPOVs; + + for(int i = 0; i < 6; i++) { + pDevices[numDevices].axis[i].center = 0x8000; + pDevices[numDevices].axis[i].negative = 0x4000; + pDevices[numDevices].axis[i].positive = 0xc000; + } + } else if(joyDebug) + winlog("Failed to get device capabilities %08x\n", hRet); + + if(joyDebug) { + // don't translate. debug only + winlog("******************************\n"); + winlog("Joystick %2d name : %s\n", numDevices, pInst->tszProductName); + } + + numDevices++; + + + return DIENUM_CONTINUE; +} + +BOOL CALLBACK DIEnumDevicesCallback2(LPCDIDEVICEINSTANCE pInst, + LPVOID lpvContext) +{ + numDevices++; + + return DIENUM_CONTINUE; +} + +static int getPovState(DWORD value) +{ + int state = 0; + if(LOWORD(value) != 0xFFFF) { + if(value < 9000 || value > 27000) + state |= POV_UP; + if(value > 0 && value < 18000) + state |= POV_RIGHT; + if(value > 9000 && value < 27000) + state |= POV_DOWN; + if(value > 18000) + state |= POV_LEFT; + } + return state; +} + +static void checkKeys() +{ + int dev = 0; + int i; + + for(i = 0; i < numDevices; i++) + pDevices[i].needed = 0; + + for(i = 0; i < 4; i++) { + dev = joypad[i][KEY_LEFT] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_LEFT] = DIK_LEFT; + + dev = joypad[i][KEY_RIGHT] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_RIGHT] = DIK_RIGHT; + + dev = joypad[i][KEY_UP] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_UP] = DIK_UP; + + dev = joypad[i][KEY_DOWN] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_DOWN] = DIK_DOWN; + + dev = joypad[i][KEY_BUTTON_A] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_A] = DIK_Z; + + dev = joypad[i][KEY_BUTTON_B] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_B] = DIK_X; + + dev = joypad[i][KEY_BUTTON_L] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_L] = DIK_A; + + dev = joypad[i][KEY_BUTTON_R] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_R] = DIK_S; + + dev = joypad[i][KEY_BUTTON_START] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_START] = DIK_RETURN; + + dev = joypad[i][KEY_BUTTON_SELECT] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_SELECT] = DIK_BACK; + + dev = joypad[i][KEY_BUTTON_SPEED] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_SPEED] = DIK_SPACE; + + dev = joypad[i][KEY_BUTTON_CAPTURE] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_CAPTURE] = DIK_F12; + + dev = joypad[i][KEY_BUTTON_GS] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + joypad[i][KEY_BUTTON_GS] = DIK_C; + } + + dev = motion[KEY_UP] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + motion[KEY_UP] = DIK_NUMPAD8; + + dev = motion[KEY_DOWN] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + motion[KEY_DOWN] = DIK_NUMPAD2; + + dev = motion[KEY_LEFT] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + motion[KEY_LEFT] = DIK_NUMPAD4; + + dev = motion[KEY_RIGHT] >> 8; + if(dev < numDevices && dev >= 0) + pDevices[dev].needed = 1; + else + motion[KEY_RIGHT] = DIK_NUMPAD6; +} + +#define KEYDOWN(buffer,key) (buffer[key] & 0x80) + +static bool readKeyboard() +{ + if(pDevices[0].needed) { + HRESULT hret = pDevices[0].device-> + GetDeviceState(256, + (LPVOID)pDevices[0].data); + + if(hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { + hret = pDevices[0].device->Acquire(); + if(hret != DI_OK) + return false; + hret = pDevices[0].device->GetDeviceState(256,(LPVOID)pDevices[0].data); + } + + return hret == DI_OK; + } + return true; +} + +static bool readJoystick(int joy) +{ + if(pDevices[joy].needed) { + if(pDevices[joy].isPolled) + ((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll(); + + HRESULT hret = pDevices[joy].device-> + GetDeviceState(sizeof(DIJOYSTATE), + (LPVOID)&pDevices[joy].state); + + if(hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { + hret = pDevices[joy].device->Acquire(); + + if(hret == DI_OK) { + + if(pDevices[joy].isPolled) + ((LPDIRECTINPUTDEVICE2)pDevices[joy].device)->Poll(); + + hret = pDevices[joy].device-> + GetDeviceState(sizeof(DIJOYSTATE), + (LPVOID)&pDevices[joy].state); + } + } + + return hret == DI_OK; + } + + return true; +} + +static void checkKeyboard() +{ + HRESULT hret = pDevices[0].device->Acquire(); + hret = pDevices[0].device-> + GetDeviceState(256, + (LPVOID)pDevices[0].data); + + if(hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) { + return; + } + + if(hret == DI_OK) { + for(int i = 0; i < 256; i++) { + if(KEYDOWN(pDevices[0].data, i)) { + SendMessage(GetFocus(), JOYCONFIG_MESSAGE,0,i); + break; + } + } + } +} + +static void checkJoypads() +{ + DIDEVICEOBJECTINSTANCE di; + + ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE)); + + di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE); + + int i =0; + + DIJOYSTATE joystick; + + for(i = 1; i < numDevices; i++) { + HRESULT hret = pDevices[i].device->Acquire(); + + + if(pDevices[i].isPolled) + ((LPDIRECTINPUTDEVICE2)pDevices[i].device)->Poll(); + + hret = pDevices[i].device->GetDeviceState(sizeof(joystick), &joystick); + + int j; + + if(pDevices[i].first) { + memcpy(&pDevices[i].state, &joystick, sizeof(joystick)); + pDevices[i].first = FALSE; + continue; + } + + for(j = 0; j < pDevices[i].nButtons; j++) { + if(((pDevices[i].state.rgbButtons[j] ^ joystick.rgbButtons[j]) + & joystick.rgbButtons[j]) & 0x80) { + HWND focus = GetFocus(); + + SendMessage(focus, JOYCONFIG_MESSAGE, i,j+128); + } + } + + for(j = 0; j < pDevices[i].nAxes && j < 8; j++) { + LONG value = pDevices[i].axis[j].center; + LONG old = 0; + switch(pDevices[i].axis[j].offset) { + case DIJOFS_X: + value = joystick.lX; + old = pDevices[i].state.lX; + break; + case DIJOFS_Y: + value = joystick.lY; + old = pDevices[i].state.lY; + break; + case DIJOFS_Z: + value = joystick.lZ; + old = pDevices[i].state.lZ; + break; + case DIJOFS_RX: + value = joystick.lRx; + old = pDevices[i].state.lRx; + break; + case DIJOFS_RY: + value = joystick.lRy; + old = pDevices[i].state.lRy; + break; + case DIJOFS_RZ: + value = joystick.lRz; + old = pDevices[i].state.lRz; + break; + case DIJOFS_SLIDER(0): + value = joystick.rglSlider[0]; + old = pDevices[i].state.rglSlider[0]; + break; + case DIJOFS_SLIDER(1): + value = joystick.rglSlider[1]; + old = pDevices[i].state.rglSlider[1]; + break; + } + if(value != old) { + if(value < pDevices[i].axis[j].negative) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1)); + else if (value > pDevices[i].axis[j].positive) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<1)+1); + } + } + + for(j = 0;j < 4 && j < pDevices[i].nPovs; j++) { + if(LOWORD(pDevices[i].state.rgdwPOV[j]) != LOWORD(joystick.rgdwPOV[j])) { + int state = getPovState(joystick.rgdwPOV[j]); + + if(state & POV_UP) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x20); + else if(state & POV_DOWN) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x21); + else if(state & POV_RIGHT) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x22); + else if(state & POV_LEFT) + SendMessage(GetFocus(), JOYCONFIG_MESSAGE, i, (j<<2)+0x23); + } + } + + memcpy(&pDevices[i].state, &joystick, sizeof(joystick)); + } +} + +BOOL checkKey(int key) +{ + int dev = (key >> 8); + + int k = (key & 255); + + if(dev == 0) { + return KEYDOWN(pDevices[0].data,k); + } else { + if(k < 16) { + int axis = k >> 1; + LONG value = pDevices[dev].axis[axis].center; + switch(pDevices[dev].axis[axis].offset) { + case DIJOFS_X: + value = pDevices[dev].state.lX; + break; + case DIJOFS_Y: + value = pDevices[dev].state.lY; + break; + case DIJOFS_Z: + value = pDevices[dev].state.lZ; + break; + case DIJOFS_RX: + value = pDevices[dev].state.lRx; + break; + case DIJOFS_RY: + value = pDevices[dev].state.lRy; + break; + case DIJOFS_RZ: + value = pDevices[dev].state.lRz; + break; + case DIJOFS_SLIDER(0): + value = pDevices[dev].state.rglSlider[0]; + break; + case DIJOFS_SLIDER(1): + value = pDevices[dev].state.rglSlider[1]; + break; + } + + if(k & 1) + return value > pDevices[dev].axis[axis].positive; + return value < pDevices[dev].axis[axis].negative; + } else if(k < 48) { + int hat = (k >> 2) & 3; + int state = getPovState(pDevices[dev].state.rgdwPOV[hat]); + BOOL res = FALSE; + switch(k & 3) { + case 0: + res = state & POV_UP; + break; + case 1: + res = state & POV_DOWN; + break; + case 2: + res = state & POV_RIGHT; + break; + case 3: + res = state & POV_LEFT; + break; + } + return res; + } else if(k >= 128) { + return pDevices[dev].state.rgbButtons[k-128] & 0x80; + } + } + + return FALSE; +} + +DirectInput::DirectInput() +{ + dinputDLL = NULL; +} + +DirectInput::~DirectInput() +{ + saveSettings(); + if(pDirectInput != NULL) { + if(pDevices) { + for(int i = 0; i < numDevices ; i++) { + if(pDevices[i].device) { + pDevices[i].device->Unacquire(); + pDevices[i].device->Release(); + pDevices[i].device = NULL; + } + } + free(pDevices); + pDevices = NULL; + } + + pDirectInput->Release(); + pDirectInput = NULL; + } + + if(dinputDLL) { + /**/AfxFreeLibrary(dinputDLL); + dinputDLL = NULL; + } +} + +bool DirectInput::initialize() +{ + joyDebug = GetPrivateProfileInt("config", + "joyDebug", + 0, + "VBA.ini"); + dinputDLL = /**/AfxLoadLibrary("DINPUT.DLL"); + HRESULT (WINAPI *DInputCreate)(HINSTANCE,DWORD,LPDIRECTINPUT *,IUnknown *); + if(dinputDLL != NULL) { + DInputCreate = (HRESULT (WINAPI *)(HINSTANCE,DWORD,LPDIRECTINPUT *,IUnknown *)) + GetProcAddress(dinputDLL, "DirectInputCreateA"); + + if(DInputCreate == NULL) { + directXMessage("DirectInputCreateA"); + return false; + } + } else { + directXMessage("DINPUT.DLL"); + return false; + } + + HRESULT hret = DInputCreate(AfxGetInstanceHandle(), + DIRECTINPUT_VERSION, + &pDirectInput, + NULL); + if(hret != DI_OK) { + // errorMessage(myLoadString(IDS_ERROR_DISP_CREATE), hret); + return false; + } + + hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK, + DIEnumDevicesCallback2, + NULL, + DIEDFL_ATTACHEDONLY); + + + + pDevices = (deviceInfo *)calloc(numDevices, sizeof(deviceInfo)); + + hret = pDirectInput->CreateDevice(GUID_SysKeyboard,&pDevices[0].device,NULL); + pDevices[0].isPolled = false; + pDevices[0].needed = true; + + if(hret != DI_OK) { + // errorMessage(myLoadString(IDS_ERROR_DISP_CREATEDEVICE), hret); + return false; + } + + + numDevices = 1; + + hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK, + DIEnumDevicesCallback, + NULL, + DIEDFL_ATTACHEDONLY); + + // hret = pDevices[0].device->SetCooperativeLevel(hWindow, + // DISCL_FOREGROUND| + // DISCL_NONEXCLUSIVE); + + if(hret != DI_OK) { + // errorMessage(myLoadString(IDS_ERROR_DISP_LEVEL), hret); + return false; + } + + hret = pDevices[0].device->SetDataFormat(&c_dfDIKeyboard); + + if(hret != DI_OK) { + // errorMessage(myLoadString(IDS_ERROR_DISP_DATAFORMAT), hret); + return false; + } + + for(int i = 1; i < numDevices; i++) { + pDevices[i].device->SetDataFormat(&c_dfDIJoystick); + pDevices[i].needed = false; + currentDevice = &pDevices[i]; + axisNumber = 0; + currentDevice->device->EnumObjects(EnumAxesCallback, NULL, DIDFT_AXIS); + currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV); + if(joyDebug) { + // don't translate. debug only + winlog("Joystick %2d polled : %d\n", i, currentDevice->isPolled); + winlog("Joystick %2d buttons : %d\n", i, currentDevice->nButtons); + winlog("Joystick %2d povs : %d\n", i, currentDevice->nPovs); + winlog("Joystick %2d axes : %d\n", i, currentDevice->nAxes); + for(int j = 0; j < currentDevice->nAxes; j++) { + winlog("Axis %2d offset : %08lx\n", j, currentDevice->axis[j]. + offset); + winlog("Axis %2d center : %08lx\n", j, currentDevice->axis[j]. + center); + winlog("Axis %2d negative : %08lx\n", j, currentDevice->axis[j]. + negative); + winlog("Axis %2d positive : %08lx\n", j, currentDevice->axis[j]. + positive); + } + } + + currentDevice = NULL; + } + + for(int i = 0; i < numDevices; i++) + pDevices[i].device->Acquire(); + + return true; +} + +bool DirectInput::readDevices() +{ + bool ok = true; + for(int i = 0; i < numDevices; i++) { + if(pDevices[i].needed) { + if(i) { + ok = readJoystick(i); + } else + ok = readKeyboard(); + } + } + return ok; +} + +u32 currentButtons [4] = {0,0,0,0}; +bool inputActive = true; // used to disable all input when the window is inactive +bool sensorOn = false; + +u32 DirectInput::readDevice(int which, bool sensor) +{ + int i = theApp.joypadDefault; + if(which >= 0 && which <= 3) + i = which; + + sensorOn = sensor; + + currentButtons[i] = 0; + + if(inputActive) + { + if(checkKey(joypad[i][KEY_BUTTON_A])) + currentButtons[i] |= BUTTON_MASK_A; + if(checkKey(joypad[i][KEY_BUTTON_B])) + currentButtons[i] |= BUTTON_MASK_B; + if(checkKey(joypad[i][KEY_BUTTON_SELECT])) + currentButtons[i] |= BUTTON_MASK_SELECT; + if(checkKey(joypad[i][KEY_BUTTON_START])) + currentButtons[i] |= BUTTON_MASK_START; + if(checkKey(joypad[i][KEY_RIGHT])) + currentButtons[i] |= BUTTON_MASK_RIGHT; + if(checkKey(joypad[i][KEY_LEFT])) + currentButtons[i] |= BUTTON_MASK_LEFT; + if(checkKey(joypad[i][KEY_UP])) + currentButtons[i] |= BUTTON_MASK_UP; + if(checkKey(joypad[i][KEY_DOWN])) + currentButtons[i] |= BUTTON_MASK_DOWN; + if(checkKey(joypad[i][KEY_BUTTON_R])) + currentButtons[i] |= BUTTON_MASK_R; + if(checkKey(joypad[i][KEY_BUTTON_L])) + currentButtons[i] |= BUTTON_MASK_L; + + if(sensor) + { + if(checkKey(motion[KEY_LEFT])) + currentButtons[i] |= BUTTON_MASK_LEFT_MOTION; + else if(checkKey(motion[KEY_RIGHT])) + currentButtons[i] |= BUTTON_MASK_RIGHT_MOTION; + if(checkKey(motion[KEY_UP])) + currentButtons[i] |= BUTTON_MASK_UP_MOTION; + else if(checkKey(motion[KEY_DOWN])) + currentButtons[i] |= BUTTON_MASK_DOWN_MOTION; + } + } + + currentButtons[i] |= theApp.skinButtons; + + if(theApp.autoFire || theApp.autoFire2) + { + currentButtons[i] |= (theApp.autoFireToggle ? theApp.autoFire : theApp.autoFire2); + theApp.autoFireToggle = !theApp.autoFireToggle; + } + if(theApp.autoHold) + currentButtons[i] ^= theApp.autoHold; + + extern int gbSgbMode; // from gbSGB.cpp + if(theApp.cartridgeType != 0 && !gbSgbMode) // regular GB has no L/R buttons + { + if(currentButtons[i] & BUTTON_MASK_L) + currentButtons[i] ^= BUTTON_MASK_L; + if(currentButtons[i] & BUTTON_MASK_R) + currentButtons[i] ^= BUTTON_MASK_R; + } + + if(!theApp.allowLeftRight) + { + // disallow L+R or U+D to being pressed at the same time + if((currentButtons[i] & (BUTTON_MASK_RIGHT|BUTTON_MASK_LEFT)) == (BUTTON_MASK_RIGHT|BUTTON_MASK_LEFT)) + currentButtons[i] &= ~BUTTON_MASK_RIGHT; // leave only LEFT on + if((currentButtons[i] & (BUTTON_MASK_DOWN|BUTTON_MASK_UP)) == (BUTTON_MASK_DOWN|BUTTON_MASK_UP)) + currentButtons[i] &= ~BUTTON_MASK_DOWN; // leave only UP on + } + + if(theApp.frameSearchSkipping) + currentButtons[i] = theApp.frameSearchOldInput[i]; + + VBAMovieUpdate(i); + + + if(sensorOn) + { + // handle motion sensor input + if(currentButtons[i] & BUTTON_MASK_LEFT_MOTION) + { + theApp.sensorX += 3; + if(theApp.sensorX > 2197) theApp.sensorX = 2197; + if(theApp.sensorX < 2047) theApp.sensorX = 2057; + } + else if(currentButtons[i] & BUTTON_MASK_RIGHT_MOTION) + { + theApp.sensorX -= 3; + if(theApp.sensorX < 1897) theApp.sensorX = 1897; + if(theApp.sensorX > 2047) theApp.sensorX = 2037; + } + else if(theApp.sensorX > 2047) + { + theApp.sensorX -= 2; + if(theApp.sensorX < 2047) theApp.sensorX = 2047; + } + else + { + theApp.sensorX += 2; + if(theApp.sensorX > 2047) theApp.sensorX = 2047; + } + + if(currentButtons[i] & BUTTON_MASK_UP_MOTION) + { + theApp.sensorY += 3; + if(theApp.sensorY > 2197) theApp.sensorY = 2197; + if(theApp.sensorY < 2047) theApp.sensorY = 2057; + } + else if(currentButtons[i] & BUTTON_MASK_DOWN_MOTION) + { + theApp.sensorY -= 3; + if(theApp.sensorY < 1897) theApp.sensorY = 1897; + if(theApp.sensorY > 2047) theApp.sensorY = 2037; + } + else if(theApp.sensorY > 2047) + { + theApp.sensorY -= 2; + if(theApp.sensorY < 2047) theApp.sensorY = 2047; + } + else + { + theApp.sensorY += 2; + if(theApp.sensorY > 2047) theApp.sensorY = 2047; + } + } + + + uint32 res = currentButtons[i] & BUTTON_REGULAR_MASK; + + if(inputActive) + { + // the "non-button" buttons (what a hack!) + if(checkKey(joypad[i][KEY_BUTTON_SPEED]) || theApp.speedupToggle) + res |= BUTTON_MASK_SPEED; + if(checkKey(joypad[i][KEY_BUTTON_CAPTURE])) + res |= BUTTON_MASK_CAPTURE; + if(checkKey(joypad[i][KEY_BUTTON_GS])) + res |= BUTTON_MASK_GAMESHARK; + } + + return res; +} + +CString DirectInput::getKeyName(int key) +{ + int d = (key >> 8); + int k = key & 255; + + DIDEVICEOBJECTINSTANCE di; + + ZeroMemory(&di,sizeof(DIDEVICEOBJECTINSTANCE)); + + di.dwSize = sizeof(DIDEVICEOBJECTINSTANCE); + + CString winBuffer = winResLoadString(IDS_ERROR); + + if(d == 0) { + pDevices[0].device->GetObjectInfo(&di,key,DIPH_BYOFFSET); + winBuffer = di.tszName; + } else { + if(k < 16) { + if(k < 4) { + switch(k) { + case 0: + winBuffer.Format(winResLoadString(IDS_JOY_LEFT), d); + break; + case 1: + winBuffer.Format(winResLoadString(IDS_JOY_RIGHT), d); + break; + case 2: + winBuffer.Format(winResLoadString(IDS_JOY_UP), d); + break; + case 3: + winBuffer.Format(winResLoadString(IDS_JOY_DOWN), d); + break; + } + } else { + pDevices[d].device->GetObjectInfo(&di, + pDevices[d].axis[k>>1].offset, + DIPH_BYOFFSET); + if(k & 1) + winBuffer.Format("Joy %d %s +", d, di.tszName); + else + winBuffer.Format("Joy %d %s -", d, di.tszName); + } + } else if(k < 48) { + int hat = (k >> 2) & 3; + pDevices[d].device->GetObjectInfo(&di, + DIJOFS_POV(hat), + DIPH_BYOFFSET); + char *dir = "up"; + int dd = k & 3; + if(dd == 1) + dir = "down"; + else if(dd == 2) + dir = "right"; + else if(dd == 3) + dir = "left"; + winBuffer.Format("Joy %d %s %s", d, di.tszName, dir); + } else { + pDevices[d].device->GetObjectInfo(&di, + DIJOFS_BUTTON(k-128), + DIPH_BYOFFSET); + winBuffer.Format(winResLoadString(IDS_JOY_BUTTON),d,di.tszName); + } + } + + return winBuffer; +} + +void DirectInput::checkKeys() +{ + ::checkKeys(); +} + + +Input *newDirectInput() +{ + return new DirectInput; +} + + +void DirectInput::checkDevices() +{ + checkJoypads(); + checkKeyboard(); +} + +void DirectInput::activate() +{ + for(int i = 0; i < numDevices; i++) { + if(pDevices != NULL && pDevices[i].device != NULL) + pDevices[i].device->Acquire(); + } +} + +void DirectInput::loadSettings() +{ + winReadKeys(); +} + +void DirectInput::saveSettings() +{ + winSaveKeys(); +} diff --git a/src/win32/DirectSound.cpp b/src/win32/DirectSound.cpp new file mode 100644 index 0000000..fea5ba3 --- /dev/null +++ b/src/win32/DirectSound.cpp @@ -0,0 +1,474 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "VBA.h" +#include "AVIWrite.h" +#include "Sound.h" +#include "WavWriter.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Sound.h" +#include "../nesvideos-piece.h" + +#include +#include + +class DirectSound : public ISound +{ +private: + HINSTANCE dsoundDLL; + LPDIRECTSOUND pDirectSound; + LPDIRECTSOUNDBUFFER dsbPrimary; + LPDIRECTSOUNDBUFFER dsbSecondary; + LPDIRECTSOUNDNOTIFY dsbNotify; + HANDLE dsbEvent; + WAVEFORMATEX wfx; + float curRate; + +public: + DirectSound(); + virtual ~DirectSound(); + + bool init(); + void pause(); + void reset(); + void resume(); + void write(); + void setSpeed(float rate); + bool isPlaying(); +}; + +DirectSound::DirectSound() +{ + dsoundDLL = NULL; + pDirectSound = NULL; + dsbPrimary = NULL; + dsbSecondary = NULL; + dsbNotify = NULL; + dsbEvent = NULL; +} + +DirectSound::~DirectSound() +{ + if(theApp.aviRecorder != NULL) { + delete theApp.aviRecorder; + theApp.aviRecorder = NULL; + theApp.aviFrameNumber = 0; + theApp.aviRecording = false; + } + + if(theApp.soundRecording) { + if(theApp.soundRecorder != NULL) { + delete theApp.soundRecorder; + theApp.soundRecorder = NULL; + } + theApp.soundRecording = false; + } + + if(dsbNotify != NULL) { + dsbNotify->Release(); + dsbNotify = NULL; + } + + if(dsbEvent != NULL) { + CloseHandle(dsbEvent); + dsbEvent = NULL; + } + + if(pDirectSound != NULL) { + if(dsbPrimary != NULL) { + dsbPrimary->Release(); + dsbPrimary = NULL; + } + + if(dsbSecondary != NULL) { + dsbSecondary->Release(); + dsbSecondary = NULL; + } + + pDirectSound->Release(); + pDirectSound = NULL; + } + + if(dsoundDLL != NULL) { + FreeLibrary(dsoundDLL); + dsoundDLL = NULL; + } +} + +bool DirectSound::init() +{ + HRESULT hr; + + dsoundDLL = LoadLibrary("DSOUND.DLL"); + HRESULT (WINAPI *DSoundCreate)(LPCGUID,LPDIRECTSOUND *,IUnknown *); + if(dsoundDLL != NULL) { + DSoundCreate = (HRESULT (WINAPI *)(LPCGUID,LPDIRECTSOUND *,IUnknown *)) + GetProcAddress(dsoundDLL, "DirectSoundCreate"); + + if(DSoundCreate == NULL) { + theApp.directXMessage("DirectSoundCreate"); + return false; + } + } else { + theApp.directXMessage("DSOUND.DLL"); + return false; + } + + if(FAILED(hr = DSoundCreate(NULL,&pDirectSound,NULL))) + { + // errorMessage(myLoadString(IDS_ERROR_SOUND_CREATE), hr); + systemMessage(IDS_CANNOT_CREATE_DIRECTSOUND, + "Cannot create DirectSound %08x", hr); + pDirectSound = NULL; + dsbSecondary = NULL; + return false; + } + + if(FAILED(hr=pDirectSound->SetCooperativeLevel((HWND)*theApp.m_pMainWnd, DSSCL_EXCLUSIVE))) + { + // errorMessage(myLoadString(IDS_ERROR_SOUND_LEVEL), hr); + systemMessage(IDS_CANNOT_SETCOOPERATIVELEVEL, + "Cannot SetCooperativeLevel %08x", hr); + return false; + } + + DSBUFFERDESC dsbdesc; + ZeroMemory(&dsbdesc,sizeof(DSBUFFERDESC)); + dsbdesc.dwSize=sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; + + if(FAILED(hr=pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbPrimary, NULL))) + { + // errorMessage(myLoadString(IDS_ERROR_SOUND_BUFFER),hr); + systemMessage(IDS_CANNOT_CREATESOUNDBUFFER, + "Cannot CreateSoundBuffer %08x", hr); + return false; + } + + // Set primary buffer format + + memset(&wfx, 0, sizeof(WAVEFORMATEX)); + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 2; + switch(soundQuality) { + case 2: + wfx.nSamplesPerSec = 22050; + soundBufferLen = 736*2; + soundBufferTotalLen = 7360*2; + break; + case 4: + wfx.nSamplesPerSec = 11025; + soundBufferLen = 368*2; + soundBufferTotalLen = 3680*2; + break; + default: + soundQuality = 1; + wfx.nSamplesPerSec = 44100; + soundBufferLen = 1470*2; + soundBufferTotalLen = 14700*2; + } + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + + if(FAILED(hr = dsbPrimary->SetFormat(&wfx))) { + // errorMessage(myLoadString(IDS_ERROR_SOUND_PRIMARY),hr); + systemMessage(IDS_CANNOT_SETFORMAT_PRIMARY, + "Cannot SetFormat for primary %08x", hr); + return false; + } + + ZeroMemory(&dsbdesc,sizeof(DSBUFFERDESC)); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY|DSBCAPS_CTRLFREQUENCY|DSBCAPS_GLOBALFOCUS; + dsbdesc.dwBufferBytes = soundBufferTotalLen; + dsbdesc.lpwfxFormat = &wfx; + + if(FAILED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))) + { + bool ok = false; + while (dsbdesc.dwFlags != DSBCAPS_GETCURRENTPOSITION2) + { + if(dsbdesc.dwFlags & DSBCAPS_CTRLFREQUENCY) dsbdesc.dwFlags ^= DSBCAPS_CTRLFREQUENCY; + else if(dsbdesc.dwFlags & DSBCAPS_GLOBALFOCUS) dsbdesc.dwFlags ^= DSBCAPS_GLOBALFOCUS; + else if(dsbdesc.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY) dsbdesc.dwFlags ^= DSBCAPS_CTRLPOSITIONNOTIFY; + if(SUCCEEDED(hr = pDirectSound->CreateSoundBuffer(&dsbdesc, &dsbSecondary, NULL))) + { + ok = true; + break; + } + } + if(!ok) + { + systemMessage(IDS_CANNOT_CREATESOUNDBUFFER_SEC, "Cannot CreateSoundBuffer secondary %08x", hr); + return false; + } + + dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2; + } + + dsbSecondary->SetCurrentPosition(0); + + if(!theApp.useOldSync) { + hr = dsbSecondary->QueryInterface(IID_IDirectSoundNotify, + (void **)&dsbNotify); + if(!FAILED(hr)) { + dsbEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + + DSBPOSITIONNOTIFY notify[10]; + + for(int i = 0; i < 10; i++) { + notify[i].dwOffset = i*soundBufferLen; + notify[i].hEventNotify = dsbEvent; + } + if(FAILED(dsbNotify->SetNotificationPositions(10, notify))) { + dsbNotify->Release(); + dsbNotify = NULL; + CloseHandle(dsbEvent); + dsbEvent = NULL; + } + } + } + + hr = dsbPrimary->Play(0,0,DSBPLAY_LOOPING); + + if(FAILED(hr)) { + // errorMessage(myLoadString(IDS_ERROR_SOUND_PLAYPRIM), hr); + systemMessage(IDS_CANNOT_PLAY_PRIMARY, "Cannot Play primary %08x", hr); + return false; + } + + systemSoundOn = true; + + return true; +} + +void DirectSound::setSpeed(float rate) +{ + if(dsbSecondary == NULL || wfx.nSamplesPerSec <= 0) + return; + + if(rate != curRate) + { + curRate = rate; + + if(rate > 4.0f) rate = 4.0f; + if(rate < 0.06f) rate = 0.06f; + + dsbSecondary->SetFrequency((DWORD)((float)wfx.nSamplesPerSec * rate)); + } +} + +void DirectSound::pause() +{ + if(dsbSecondary != NULL) { + DWORD status = 0; + dsbSecondary->GetStatus(&status); + + if(status & DSBSTATUS_PLAYING) { + //systemScreenMessage("sound stopped (pause)!", 3); + dsbSecondary->Stop(); + } + } +} + +bool DirectSound::isPlaying() +{ + if(dsbSecondary != NULL) { + DWORD status = 0; + dsbSecondary->GetStatus(&status); + + if(status & DSBSTATUS_PLAYING) { + return true; + } + } + return false; +} + +void DirectSound::reset() +{ + if(dsbSecondary) { + //systemScreenMessage("sound stopped (reset)!", 3); + dsbSecondary->Stop(); + dsbSecondary->SetCurrentPosition(0); + } +} + +void DirectSound::resume() +{ + if(dsbSecondary != NULL) { + dsbSecondary->Play(0,0,DSBPLAY_LOOPING); + } +} + +extern long linearFrameCount; +long linearSoundByteCount = 0; +long linearSoundFrameCount = 0; + +void DirectSound::write() +{ + int len = soundBufferLen; + LPVOID lpvPtr1; + DWORD dwBytes1; + LPVOID lpvPtr2; + DWORD dwBytes2; + + do + { + linearSoundByteCount += len; + if(wfx.nAvgBytesPerSec) + linearSoundFrameCount = 60 * linearSoundByteCount / wfx.nAvgBytesPerSec; + + if(pDirectSound != NULL) + { + if(theApp.soundRecording) { + if(dsbSecondary) { + if(theApp.soundRecorder == NULL) { + theApp.soundRecorder = new WavWriter; + WAVEFORMATEX format; + dsbSecondary->GetFormat(&format, sizeof(format), NULL); + if(theApp.soundRecorder->Open(theApp.soundRecordName)) + theApp.soundRecorder->SetFormat(&format); + } + } + + if(theApp.soundRecorder) { + theApp.soundRecorder->AddSound((u8 *)soundFinalWave, len); + } + } + + if(theApp.nvAudioLog) + { + NESVideoLoggingAudio((u8 *)soundFinalWave, wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels, len/(wfx.nChannels*(wfx.wBitsPerSample/8))); + } + + if(theApp.aviRecording) { + if(theApp.aviRecorder) { + if(dsbSecondary) { + if(!theApp.aviRecorder->IsSoundAdded()) { + WAVEFORMATEX format; + dsbSecondary->GetFormat(&format, sizeof(format), NULL); + theApp.aviRecorder->SetSoundFormat(&format); + } + } + + theApp.aviRecorder->AddSound((const char *)soundFinalWave, len); + } + } + } + } + while(linearSoundFrameCount <= linearFrameCount); + + // arbitrarily wrap counters at 10000 frames to avoid mismatching wrap-around freeze + if(linearSoundFrameCount > 10000 && linearFrameCount > 10000) + { + linearFrameCount -= 10000; + linearSoundByteCount -= wfx.nAvgBytesPerSec*10000/60; + linearSoundFrameCount = 60 * linearSoundByteCount / wfx.nAvgBytesPerSec; + } + + if(!pDirectSound) + return; + + HRESULT hr; + + bool fastForward = speedup; +#if (defined(WIN32) && !defined(SDL)) + fastForward |= theApp.frameSearchSkipping; +#endif + + // slows down emulator to match up with the sound speed + if(!fastForward && synchronize && !(theApp.throttle > 100 && theApp.accuratePitchThrottle) && theApp.throttle>=6) { + DWORD status=0; + hr = dsbSecondary->GetStatus(&status); + if(status & DSBSTATUS_PLAYING) { + if(!soundPaused) { + DWORD play; + while(true) { + dsbSecondary->GetCurrentPosition(&play, NULL); + + if((int)(soundNextPosition+soundBufferLen) < (int)soundBufferTotalLen) + { + if(play < soundNextPosition + || play > soundNextPosition+soundBufferLen) + break; + } + else + { + if(play < soundNextPosition + && play > (soundNextPosition+soundBufferLen)%soundBufferTotalLen) + break; + } + + if(dsbEvent) { + WaitForSingleObject(dsbEvent, 50); + } + } + } + } else { + soundPaused = 1; + } + } + // Obtain memory address of write block. This will be in two parts + // if the block wraps around. + hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen, &lpvPtr1, + &dwBytes1, &lpvPtr2, &dwBytes2, + 0); + + if(FAILED(hr)) + { + char str [256]; + sprintf(str, "Locking secondary failed with %d", hr); + systemScreenMessage(str); + } + + // If DSERR_BUFFERLOST is returned, restore and retry lock. + if (DSERR_BUFFERLOST == hr) { + dsbSecondary->Restore(); + hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen,&lpvPtr1, + &dwBytes1, &lpvPtr2, &dwBytes2, + 0); + } + + soundNextPosition += soundBufferLen; + soundNextPosition = soundNextPosition % soundBufferTotalLen; + + + + if SUCCEEDED(hr) + { + // Write to pointers. + if(NULL != lpvPtr1) + CopyMemory(lpvPtr1, soundFinalWave, dwBytes1); + if(NULL != lpvPtr2) + CopyMemory(lpvPtr2, soundFinalWave+dwBytes1, dwBytes2); + + // Release the data back to DirectSound. + hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2, + dwBytes2); + } +} + +ISound *newDirectSound() +{ + return new DirectSound(); +} diff --git a/src/win32/Directories.cpp b/src/win32/Directories.cpp new file mode 100644 index 0000000..842f176 --- /dev/null +++ b/src/win32/Directories.cpp @@ -0,0 +1,257 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Directories.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Directories.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// Directories dialog + +static int CALLBACK browseCallbackProc(HWND hWnd, UINT msg, + LPARAM l, LPARAM data) +{ + char *buffer = (char *)data; + switch(msg) { + case BFFM_INITIALIZED: + if(buffer[0]) + SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)buffer); + break; + default: + break; + } + return 0; +} + +Directories::Directories(CWnd* pParent /*=NULL*/) + : CDialog(Directories::IDD, pParent) +{ + //{{AFX_DATA_INIT(Directories) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void Directories::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(Directories) + DDX_Control(pDX, IDC_SAVE_PATH, m_savePath); + DDX_Control(pDX, IDC_ROM_PATH, m_romPath); + DDX_Control(pDX, IDC_MOVIES_PATH, m_gbromPath); + DDX_Control(pDX, IDC_CAPTURE_PATH, m_capturePath); + DDX_Control(pDX, IDC_BATTERY_PATH, m_batteryPath); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(Directories, CDialog) + //{{AFX_MSG_MAP(Directories) + ON_BN_CLICKED(IDC_BATTERY_DIR, OnBatteryDir) + ON_BN_CLICKED(IDC_BATTERY_DIR_RESET, OnBatteryDirReset) + ON_BN_CLICKED(IDC_CAPTURE_DIR, OnCaptureDir) + ON_BN_CLICKED(IDC_CAPTURE_DIR_RESET, OnCaptureDirReset) + ON_BN_CLICKED(IDC_MOVIES_DIR, OnMoviesDir) + ON_BN_CLICKED(IDC_MOVIES_DIR_RESET, OnMoviesDirReset) + ON_BN_CLICKED(IDC_ROM_DIR, OnRomDir) + ON_BN_CLICKED(IDC_ROM_DIR_RESET, OnRomDirReset) + ON_BN_CLICKED(IDC_SAVE_DIR, OnSaveDir) + ON_BN_CLICKED(IDC_SAVE_DIR_RESET, OnSaveDirReset) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Directories message handlers + +BOOL Directories::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString p = regQueryStringValue("romdir", NULL); + if(!p.IsEmpty()) { + int len = p.GetLength(); + if(len > 0) + if(p[len-1] == '\\') + p = p.Left(len-1); + GetDlgItem(IDC_ROM_PATH)->SetWindowText(p); + } + + p = regQueryStringValue("moviesdir", NULL); + if(!p.IsEmpty()) { + int len = p.GetLength(); + if(len > 0) + if(p[len-1] == '\\') + p = p.Left(len-1); + GetDlgItem(IDC_MOVIES_PATH)->SetWindowText(p); + } + + p = regQueryStringValue("batteryDir", NULL); + if(!p.IsEmpty()) + GetDlgItem(IDC_BATTERY_PATH)->SetWindowText( p); + p = regQueryStringValue("saveDir", NULL); + if(!p.IsEmpty()) + GetDlgItem(IDC_SAVE_PATH)->SetWindowText(p); + p = regQueryStringValue("captureDir", NULL); + if(!p.IsEmpty()) + GetDlgItem(IDC_CAPTURE_PATH)->SetWindowText(p); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void Directories::OnBatteryDir() +{ + m_batteryPath.GetWindowText(initialFolderDir); + CString p = browseForDir(winResLoadString(IDS_SELECT_BATTERY_DIR)); + if(!p.IsEmpty()) + m_batteryPath.SetWindowText(p); +} + +void Directories::OnBatteryDirReset() +{ + regDeleteValue("batteryDir"); + m_batteryPath.SetWindowText(""); +} + +void Directories::OnCaptureDir() +{ + m_capturePath.GetWindowText(initialFolderDir); + CString p = browseForDir(winResLoadString(IDS_SELECT_CAPTURE_DIR)); + if(!p.IsEmpty()) + m_capturePath.SetWindowText(p); +} + +void Directories::OnCaptureDirReset() +{ + regDeleteValue("captureDir"); + m_capturePath.SetWindowText(""); +} + +void Directories::OnMoviesDir() +{ + m_gbromPath.GetWindowText(initialFolderDir); + CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR)); + if(!p.IsEmpty()) + m_gbromPath.SetWindowText(p); +} + +void Directories::OnMoviesDirReset() +{ + regDeleteValue("moviesdir"); + m_gbromPath.SetWindowText(""); +} + +void Directories::OnRomDir() +{ + m_romPath.GetWindowText(initialFolderDir); + CString p = browseForDir(winResLoadString(IDS_SELECT_ROM_DIR)); + if(!p.IsEmpty()) + m_romPath.SetWindowText(p); +} + +void Directories::OnRomDirReset() +{ + regDeleteValue("romdir"); + m_romPath.SetWindowText(""); +} + +void Directories::OnSaveDir() +{ + m_savePath.GetWindowText(initialFolderDir); + CString p = browseForDir(winResLoadString(IDS_SELECT_SAVE_DIR)); + if(!p.IsEmpty()) + m_savePath.SetWindowText(p); +} + +void Directories::OnSaveDirReset() +{ + regDeleteValue("saveDir"); + m_savePath.SetWindowText(""); +} + +void Directories::OnCancel() +{ + EndDialog(FALSE); +} + +void Directories::OnOK() +{ + CString buffer; + m_romPath.GetWindowText(buffer); + if(!buffer.IsEmpty()) + regSetStringValue("romdir", buffer); + m_gbromPath.GetWindowText(buffer); + if(!buffer.IsEmpty()) + regSetStringValue("moviesdir", buffer); + m_batteryPath.GetWindowText(buffer); + if(!buffer.IsEmpty()) + regSetStringValue("batteryDir", buffer); + m_savePath.GetWindowText(buffer); + if(!buffer.IsEmpty()) + regSetStringValue("saveDir", buffer); + m_capturePath.GetWindowText(buffer); + if(!buffer.IsEmpty()) + regSetStringValue("captureDir", buffer); + EndDialog(TRUE); +} + +CString Directories::browseForDir(CString title) +{ + static char buffer[1024]; + LPMALLOC pMalloc; + LPITEMIDLIST pidl; + + CString res; + + if(SUCCEEDED(SHGetMalloc(&pMalloc))) { + BROWSEINFO bi; + ZeroMemory(&bi, sizeof(bi)); + bi.hwndOwner = m_hWnd; + bi.lpszTitle = title; + bi.pidlRoot = 0; + bi.ulFlags = BIF_RETURNONLYFSDIRS; + bi.lpfn = browseCallbackProc; + bi.lParam = (LPARAM)(LPCTSTR)initialFolderDir; + + pidl = SHBrowseForFolder(&bi); + + if(pidl) { + if(SHGetPathFromIDList(pidl, buffer)) { + res = buffer; + } + pMalloc->Free(pidl); + pMalloc->Release(); + } + } + return res; +} diff --git a/src/win32/Directories.h b/src/win32/Directories.h new file mode 100644 index 0000000..602b53e --- /dev/null +++ b/src/win32/Directories.h @@ -0,0 +1,83 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_) +#define AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Directories.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// Directories dialog + +class Directories : public CDialog +{ + // Construction + public: + CString initialFolderDir; + CString browseForDir(CString title); + Directories(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(Directories) + enum { IDD = IDD_DIRECTORIES }; + CEdit m_savePath; + CEdit m_romPath; + CEdit m_gbromPath; + CEdit m_capturePath; + CEdit m_batteryPath; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Directories) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(Directories) + virtual BOOL OnInitDialog(); + afx_msg void OnBatteryDir(); + afx_msg void OnBatteryDirReset(); + afx_msg void OnCaptureDir(); + afx_msg void OnCaptureDirReset(); + afx_msg void OnMoviesDir(); + afx_msg void OnMoviesDirReset(); + afx_msg void OnRomDir(); + afx_msg void OnRomDirReset(); + afx_msg void OnSaveDir(); + afx_msg void OnSaveDirReset(); + virtual void OnCancel(); + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DIRECTORIES_H__7ADB14C1_3C1B_4294_8D66_A4E87D6FC731__INCLUDED_) diff --git a/src/win32/Disassemble.cpp b/src/win32/Disassemble.cpp new file mode 100644 index 0000000..fab2d53 --- /dev/null +++ b/src/win32/Disassemble.cpp @@ -0,0 +1,349 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Disassemble.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Disassemble.h" + +#include "../System.h" +#include "../armdis.h" +#include "../GBA.h" +#include "../Globals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern int emulating; + +extern void CPUUpdateCPSR(); + + +///////////////////////////////////////////////////////////////////////////// +// Disassemble dialog + + +Disassemble::Disassemble(CWnd* pParent /*=NULL*/) + : ResizeDlg(Disassemble::IDD, pParent) +{ + //{{AFX_DATA_INIT(Disassemble) + m_c = FALSE; + m_f = FALSE; + m_i = FALSE; + m_n = FALSE; + m_t = FALSE; + m_v = FALSE; + m_z = FALSE; + mode = -1; + //}}AFX_DATA_INIT + mode = 0; + address = 0; + autoUpdate = false; + count = 1; +} + + +void Disassemble::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(Disassemble) + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Control(pDX, IDC_DISASSEMBLE, m_list); + DDX_Check(pDX, IDC_C, m_c); + DDX_Check(pDX, IDC_F, m_f); + DDX_Check(pDX, IDC_I, m_i); + DDX_Check(pDX, IDC_N, m_n); + DDX_Check(pDX, IDC_T, m_t); + DDX_Check(pDX, IDC_V, m_v); + DDX_Check(pDX, IDC_Z, m_z); + DDX_Radio(pDX, IDC_AUTOMATIC, mode); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(Disassemble, CDialog) + //{{AFX_MSG_MAP(Disassemble) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_AUTOMATIC, OnAutomatic) + ON_BN_CLICKED(IDC_ARM, OnArm) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_GO, OnGo) + ON_BN_CLICKED(IDC_GOPC, OnGopc) + ON_BN_CLICKED(IDC_NEXT, OnNext) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_THUMB, OnThumb) + ON_WM_VSCROLL() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Disassemble message handlers + +void Disassemble::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void Disassemble::OnAutomatic() +{ + mode = 0; + refresh(); +} + +void Disassemble::OnArm() +{ + mode = 1; + refresh(); +} + +void Disassemble::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +void Disassemble::OnGo() +{ + CString buffer; + m_address.GetWindowText(buffer); + sscanf(buffer, "%x", &address); + refresh(); +} + +void Disassemble::OnGopc() +{ + if(armState) + address = armNextPC - 16; + else + address = armNextPC - 8; + + refresh(); +} + +void Disassemble::OnNext() +{ + CPULoop(1); + if(armState) { + u32 total = address+count*4; + if(armNextPC >= address && armNextPC < total) { + } else { + OnGopc(); + } + } else { + u32 total = address+count*2; + if(armNextPC >= address && armNextPC < total) { + } else { + OnGopc(); + } + } + refresh(); +} + +void Disassemble::OnRefresh() +{ + refresh(); +} + +void Disassemble::OnThumb() +{ + mode = 2; + refresh(); +} + +BOOL Disassemble::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_DISASSEMBLE, DS_SizeY) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_NEXT, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_AUTO_UPDATE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_GOPC, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_VSCROLL, DS_SizeY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\DisassembleView", + NULL); + + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + si.nMin = 0; + si.nMax = 100; + si.nPos = 50; + si.nPage = 0; + GetDlgItem(IDC_VSCROLL)->SetScrollInfo(SB_CTL, &si, TRUE); + + CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)); + + m_list.SetFont(font, FALSE); + for(int i = 0; i < 17; i++) + GetDlgItem(IDC_R0+i)->SetFont(font, FALSE); + + GetDlgItem(IDC_MODE)->SetFont(font, FALSE); + + + m_address.LimitText(8); + refresh(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void Disassemble::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + switch(nSBCode) { + case SB_LINEDOWN: + if(mode == 0) { + if(armState) + address += 4; + else + address += 2; + } else if(mode == 1) + address += 4; + else + address += 2; + break; + case SB_LINEUP: + if(mode == 0) { + if(armState) + address -= 4; + else + address -= 2; + } else if(mode == 1) + address -= 4; + else + address -= 2; + break; + case SB_PAGEDOWN: + if(mode == 0) { + if(armState) + address += count*4; + else + address += count*2; + } else if(mode == 1) + address += count*4; + else + address += count*2; + break; + case SB_PAGEUP: + if(mode == 0) { + if(armState) + address -= count*4; + else + address -= count*2; + } else if(mode == 1) + address -= count*4; + else + address -= count*2; + break; + } + refresh(); + + CDialog::OnVScroll(nSBCode, nPos, pScrollBar); +} + +void Disassemble::refresh() +{ + if(rom == NULL) + return; + + bool arm = armState; + + if(mode != 0) { + if(mode == 1) + arm = true; + else + arm = false; + } + + int h = m_list.GetItemHeight(0); + RECT r; + m_list.GetClientRect(&r); + count = (r.bottom - r.top+1)/h; + + m_list.ResetContent(); + if(!emulating && theApp.cartridgeType == 0) + return; + + char buffer[80]; + u32 addr = address; + int i; + int sel = -1; + for(i = 0; i < count; i++) { + if(addr == armNextPC) + sel = i; + if(arm) { + addr += disArm(addr, buffer, 3); + } else { + addr += disThumb(addr, buffer, 3); + } + m_list.InsertString(-1, buffer); + } + + if(sel != -1) + m_list.SetCurSel(sel); + + CPUUpdateCPSR(); + + for(i = 0; i < 17; i++) { + sprintf(buffer, "%08x", reg[i].I); + GetDlgItem(IDC_R0+i)->SetWindowText(buffer); + } + + m_n = (reg[16].I & 0x80000000) != 0; + m_z = (reg[16].I & 0x40000000) != 0; + m_c = (reg[16].I & 0x20000000) != 0; + m_v = (reg[16].I & 0x10000000) != 0; + m_i = (reg[16].I & 0x80) != 0; + m_f = (reg[16].I & 0x40) != 0; + m_t = (reg[16].I & 0x20) != 0; + + UpdateData(FALSE); + + int v = reg[16].I & 0x1f; + sprintf(buffer, "%02x", v); + GetDlgItem(IDC_MODE)->SetWindowText(buffer); +} + +void Disassemble::update() +{ + OnGopc(); + refresh(); +} + +void Disassemble::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/Disassemble.h b/src/win32/Disassemble.h new file mode 100644 index 0000000..259538d --- /dev/null +++ b/src/win32/Disassemble.h @@ -0,0 +1,94 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_) +#define AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Disassemble.h : header file +// + +#include "IUpdate.h" +#include "ResizeDlg.h" +#include "../System.h" // Added by ClassView + +///////////////////////////////////////////////////////////////////////////// +// Disassemble dialog + +class Disassemble : public ResizeDlg, IUpdateListener +{ + // Construction + public: + virtual void update(); + void refresh(); + int count; + bool autoUpdate; + u32 address; + Disassemble(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(Disassemble) + enum { IDD = IDD_DISASSEMBLE }; + CEdit m_address; + CListBox m_list; + BOOL m_c; + BOOL m_f; + BOOL m_i; + BOOL m_n; + BOOL m_t; + BOOL m_v; + BOOL m_z; + int mode; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Disassemble) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(Disassemble) + afx_msg void OnAutoUpdate(); + afx_msg void OnAutomatic(); + afx_msg void OnArm(); + afx_msg void OnClose(); + afx_msg void OnGo(); + afx_msg void OnGopc(); + afx_msg void OnNext(); + afx_msg void OnRefresh(); + afx_msg void OnThumb(); + virtual BOOL OnInitDialog(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_) diff --git a/src/win32/Display.h b/src/win32/Display.h new file mode 100644 index 0000000..c2cba0b --- /dev/null +++ b/src/win32/Display.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +enum DISPLAY_TYPE { + GDI = 0, + DIRECT_DRAW = 1, + DIRECT_3D = 2, + OPENGL = 3 +}; + +class IDisplay { + public: + IDisplay() {}; + virtual ~IDisplay() {}; + + virtual bool initialize() = 0; + virtual void cleanup() = 0; + virtual void render() = 0; + virtual void checkFullScreen() { }; + virtual void renderMenu() { }; + virtual void clear()=0; + virtual bool changeRenderSize(int w, int h) { return true; }; + virtual void resize(int w, int h) {}; + virtual void setOption(const char *option, int value) = 0; + virtual DISPLAY_TYPE getType() = 0; + virtual bool isSkinSupported() { return false; } + virtual int selectFullScreenMode(GUID **) = 0; +}; diff --git a/src/win32/ExportGSASnapshot.cpp b/src/win32/ExportGSASnapshot.cpp new file mode 100644 index 0000000..c6143d4 --- /dev/null +++ b/src/win32/ExportGSASnapshot.cpp @@ -0,0 +1,117 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// ExportGSASnapshot.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "ExportGSASnapshot.h" + +#include "../GBA.h" +#include "../NLS.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// ExportGSASnapshot dialog + + +ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/) + : CDialog(ExportGSASnapshot::IDD, pParent) +{ + //{{AFX_DATA_INIT(ExportGSASnapshot) + m_desc = _T(""); + m_notes = _T(""); + m_title = _T(""); + //}}AFX_DATA_INIT + m_title = title; + m_filename = filename; + char date[100]; + char time[100]; + + GetDateFormat(LOCALE_USER_DEFAULT, + DATE_SHORTDATE, + NULL, + NULL, + date, + 100); + GetTimeFormat(LOCALE_USER_DEFAULT, + 0, + NULL, + NULL, + time, + 100); + m_desc.Format("%s %s", date, time); +} + + +void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(ExportGSASnapshot) + DDX_Text(pDX, IDC_DESC, m_desc); + DDV_MaxChars(pDX, m_desc, 100); + DDX_Text(pDX, IDC_NOTES, m_notes); + DDV_MaxChars(pDX, m_notes, 512); + DDX_Text(pDX, IDC_TITLE, m_title); + DDV_MaxChars(pDX, m_title, 100); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog) + //{{AFX_MSG_MAP(ExportGSASnapshot) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// ExportGSASnapshot message handlers + +BOOL ExportGSASnapshot::OnInitDialog() +{ + CDialog::OnInitDialog(); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void ExportGSASnapshot::OnCancel() +{ + EndDialog(FALSE); +} + +void ExportGSASnapshot::OnOk() +{ + UpdateData(TRUE); + + bool result = CPUWriteGSASnapshot(m_filename, m_title, m_desc, m_notes); + + if(!result) + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", + m_filename); + + EndDialog(TRUE); +} diff --git a/src/win32/ExportGSASnapshot.h b/src/win32/ExportGSASnapshot.h new file mode 100644 index 0000000..390908f --- /dev/null +++ b/src/win32/ExportGSASnapshot.h @@ -0,0 +1,70 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_) +#define AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ExportGSASnapshot.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// ExportGSASnapshot dialog + +class ExportGSASnapshot : public CDialog +{ + // Construction + public: + ExportGSASnapshot(CString filename, CString title,CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(ExportGSASnapshot) + enum { IDD = IDD_EXPORT_SPS }; + CString m_desc; + CString m_notes; + CString m_title; + //}}AFX_DATA + CString m_filename; + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ExportGSASnapshot) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(ExportGSASnapshot) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_) diff --git a/src/win32/FileDlg.cpp b/src/win32/FileDlg.cpp new file mode 100644 index 0000000..62fcab4 --- /dev/null +++ b/src/win32/FileDlg.cpp @@ -0,0 +1,200 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// FileDlg.cpp: implementation of the FileDlg class. +// +////////////////////////////////////////////////////////////////////// +#define WINVER 0x0410 // windows 98 - just for this 1 file - just in case +#include "stdafx.h" +#include +#include + +#include "VBA.h" +#include "FileDlg.h" +#include "../System.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static FileDlg *instance = NULL; + +static UINT_PTR CALLBACK HookFunc(HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ + if(instance) { + if(msg == WM_NOTIFY) { + OFNOTIFY *notify = (OFNOTIFY *)lParam; + if(notify) { + if(notify->hdr.code == CDN_TYPECHANGE) { + instance->OnTypeChange(hwnd); + return 1; + } + } + } + } + return 0; +} + +static UINT_PTR CALLBACK HookFuncOldStyle(HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ + if(instance) { + if(msg == WM_COMMAND) { + if(HIWORD(wParam) == CBN_SELCHANGE) { + if(LOWORD(wParam) == cmb1) { + // call method with combobox handle to keep + // behaviour there + instance->OnTypeChange((HWND)lParam); + return 1; + } + } + } + } + return 0; +} + +///////////////////////////////////////////////////////////////////////////// +// FileDlg + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +FileDlg::FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter, + int filterIndex, LPCTSTR ext, LPCTSTR *exts, LPCTSTR initialDir, + LPCTSTR title, bool save, bool noReadOnly) +{ + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + m_file = file; + int size = sizeof(OPENFILENAME); + + // avoid problems if OPENFILENAME is already defined with the extended fields + // needed for the enhanced open/save dialog +#if _WIN32_WINNT < 0x0500 + if(info.dwPlatformId == VER_PLATFORM_WIN32_NT) { + if(info.dwMajorVersion >= 5) + size = sizeof(OPENFILENAMEEX); + } +#endif + + ZeroMemory(&m_ofn, sizeof(m_ofn)); + m_ofn.lpstrFile = m_file.GetBuffer(MAX_PATH); + m_ofn.nMaxFile = MAX_PATH; + m_ofn.lStructSize = size; + m_ofn.hwndOwner = parent ? parent->GetSafeHwnd() : NULL; + m_ofn.nFilterIndex = filterIndex; + m_ofn.lpstrInitialDir = initialDir; + m_ofn.lpstrTitle = title; + m_ofn.lpstrDefExt = ext; + m_ofn.lpfnHook = HookFunc; + m_ofn.Flags = OFN_PATHMUSTEXIST | OFN_ENABLESIZING | OFN_ENABLEHOOK; + m_ofn.Flags |= OFN_EXPLORER; + if(noReadOnly) + m_ofn.Flags |= OFN_HIDEREADONLY; + m_filter = filter; + + char *p = m_filter.GetBuffer(0); + + while ((p = strchr(p, '|')) != NULL) + *p++ = 0; + m_ofn.lpstrFilter = m_filter; + + if(theApp.videoOption == VIDEO_320x240) { + m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG); + m_ofn.lpfnHook = HookFuncOldStyle; + m_ofn.Flags |= OFN_ENABLETEMPLATE; + m_ofn.Flags &= ~OFN_EXPLORER; + } + + isSave = save; + extensions = exts; + + instance = this; +} + +FileDlg::~FileDlg() +{ + instance = NULL; +} + +void FileDlg::OnTypeChange(HWND hwnd) +{ + HWND parent = GetParent(hwnd); + + HWND fileNameControl = ::GetDlgItem(parent, cmb13); + + if(fileNameControl == NULL) + fileNameControl = ::GetDlgItem(parent, edt1); + + if(fileNameControl == NULL) + return; + + CString filename; + GetWindowText(fileNameControl, filename.GetBuffer(MAX_PATH), MAX_PATH); + filename.ReleaseBuffer(); + + HWND typeControl = ::GetDlgItem(parent, cmb1); + + ASSERT(typeControl != NULL); + + int sel = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0); + + ASSERT(sel != -1); + + LPCTSTR typeName = extensions[sel]; + + if(filename.GetLength() == 0) { + filename.Format("*%s", typeName); + } else { + int index = filename.Find('.'); + if (index == -1) { + filename = filename + typeName; + } else { + filename = filename.Left(index) + typeName; + } + } + SetWindowText(fileNameControl, filename); +} + +int FileDlg::getFilterIndex() +{ + return m_ofn.nFilterIndex; +} + +int FileDlg::DoModal() +{ + BOOL res = isSave ? GetSaveFileName(&m_ofn) : + GetOpenFileName(&m_ofn); + + return res ? IDOK : IDCANCEL; +} + +LPCTSTR FileDlg::GetPathName() +{ + return (LPCTSTR)m_file; +} diff --git a/src/win32/FileDlg.h b/src/win32/FileDlg.h new file mode 100644 index 0000000..e1c45e0 --- /dev/null +++ b/src/win32/FileDlg.h @@ -0,0 +1,66 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// FileDlg.h: interface for the FileDlg class. +// +////////////////////////////////////////////////////////////////////// +#if !defined(AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_) +#define AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// FileDlg.h : header file +// + +struct OPENFILENAMEEX : public OPENFILENAME { + void * pvReserved; + DWORD dwReserved; + DWORD FlagsEx; +}; + +///////////////////////////////////////////////////////////////////////////// +// FileDlg dialog + +class FileDlg +{ + private: + CString m_file; + CString m_filter; + public: + OPENFILENAMEEX m_ofn; + int DoModal(); + LPCTSTR GetPathName(); + virtual int getFilterIndex(); + virtual void OnTypeChange(HWND hwnd); + FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter, + int filterIndex, LPCTSTR ext, LPCTSTR *exts, LPCTSTR initialDir, + LPCTSTR title, bool save, bool noReadOnly=false); + virtual ~FileDlg(); + + protected: + bool isSave; + LPCTSTR *extensions; + + protected: + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +}; + +#endif // !defined(AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_) diff --git a/src/win32/GBACheats.cpp b/src/win32/GBACheats.cpp new file mode 100644 index 0000000..2d6cab9 --- /dev/null +++ b/src/win32/GBACheats.cpp @@ -0,0 +1,1247 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBACheats.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GBACheats.h" + +#include "../System.h" +#include "../Cheats.h" +#include "../CheatSearch.h" +#include "../GBA.h" +#include "../Globals.h" + +#include "Reg.h" +#include "StringTokenizer.h" +#include "WinResUtil.h" +#include ".\gbacheats.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBACheatSearch dialog + +GBACheatSearch::GBACheatSearch(CWnd* pParent /*=NULL*/) + : CDialog(GBACheatSearch::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBACheatSearch) + valueType = -1; + sizeType = -1; + searchType = -1; + numberType = -1; + updateValues = FALSE; + //}}AFX_DATA_INIT + data = NULL; +} + +GBACheatSearch::~GBACheatSearch() +{ + if(data) + free(data); +} + +void GBACheatSearch::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBACheatSearch) + DDX_Control(pDX, IDC_VALUE, m_value); + DDX_Control(pDX, IDC_CHEAT_LIST, m_list); + DDX_Radio(pDX, IDC_OLD_VALUE, valueType); + DDX_Radio(pDX, IDC_SIZE_8, sizeType); + DDX_Radio(pDX, IDC_EQ, searchType); + DDX_Radio(pDX, IDC_SIGNED, numberType); + DDX_Check(pDX, IDC_UPDATE, updateValues); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBACheatSearch, CDialog) + //{{AFX_MSG_MAP(GBACheatSearch) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(IDC_START, OnStart) + ON_BN_CLICKED(IDC_SEARCH, OnSearch) + ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat) + ON_BN_CLICKED(IDC_UPDATE, OnUpdate) + ON_NOTIFY(LVN_GETDISPINFO, IDC_CHEAT_LIST, OnGetdispinfoCheatList) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList) + ON_CONTROL_RANGE(BN_CLICKED, IDC_OLD_VALUE, IDC_SPECIFIC_VALUE, OnValueType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_EQ, IDC_GE, OnSearchType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType) + //}}AFX_MSG_MAP +ON_WM_CLOSE() +ON_BN_CLICKED(IDC_CHEATREFRESHBUTTON, OnBnClickedCheatrefreshbutton) +//ON_WM_DESTROY() +//ON_WM_NCDESTROY() +//ON_WM_SYSCOMMAND() +//ON_WM_ACTIVATE() +END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBACheatSearch message handlers + +void GBACheatSearch::OnOk() +{ + if(theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = false; + DestroyWindow(); + } + else + { + EndDialog(TRUE); + } +} + +void GBACheatSearch::OnClose() +{ + CDialog::OnClose(); + if(theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = false; + DestroyWindow(); + } + else + { + EndDialog(FALSE); + } +} + +void GBACheatSearch::OnStart() +{ + if(cheatSearchData.count == 0) { + CheatSearchBlock *block = &cheatSearchData.blocks[0]; + block->size = 0x40000; + block->offset = 0x2000000; + block->bits = (u8 *)malloc(0x40000>>3); + block->data = workRAM; + block->saved = (u8 *)malloc(0x40000); + + block = &cheatSearchData.blocks[1]; + block->size = 0x8000; + block->offset = 0x3000000; + block->bits = (u8 *)malloc(0x8000>>3); + block->data = internalRAM; + block->saved = (u8 *)malloc(0x8000); + + cheatSearchData.count = 2; + } + + cheatSearchStart(&cheatSearchData); + GetDlgItem(IDC_SEARCH)->EnableWindow(TRUE); + + if(theApp.modelessCheatDialogIsOpen) + { + GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE); + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE); + } +} + +static void dlgSystemMessage(CWnd * hWnd, int number, const char *defaultMsg, ...) +{ + CString buffer; + va_list valist; + CString msg = defaultMsg; + if(number) + msg = winResLoadString(number); + + va_start(valist, defaultMsg); + buffer.FormatV(msg, valist); + + theApp.winCheckFullscreen(); + + hWnd->MessageBox(buffer, winResLoadString(IDS_ERROR), MB_OK|MB_ICONERROR); + + va_end(valist); +} + +void GBACheatSearch::OnSearch() +{ + CString buffer; + + if(valueType == 0) + cheatSearch(&cheatSearchData, + searchType, + sizeType, + numberType == 0); + else { + m_value.GetWindowText(buffer); + if(buffer.IsEmpty()) { + dlgSystemMessage(this, IDS_NUMBER_CANNOT_BE_EMPTY, "Number cannot be empty"); + return; + } + int value = 0; + switch(numberType) { + case 0: + sscanf(buffer, "%d", &value); + break; + case 1: + sscanf(buffer, "%u", &value); + break; + default: + sscanf(buffer, "%x", &value); + } + cheatSearchValue(&cheatSearchData, + searchType, + sizeType, + numberType == 0, + value); + } + + addChanges(true); + + if(updateValues) + cheatSearchUpdateValues(&cheatSearchData); + + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE); + + if(0 == cheatSearchGetCount(&cheatSearchData, sizeType)) + OnStart(); +} + +void GBACheatSearch::OnAddCheat() +{ + int mark = m_list.GetSelectionMark(); + + if(mark != -1) { + LVITEM item; + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM; + item.iItem = mark; + if(m_list.GetItem(&item)) { + AddCheat dlg((u32)item.lParam); + dlg.DoModal(); + } + } +} + +void GBACheatSearch::OnUpdate() +{ + if(GetDlgItem(IDC_UPDATE)->SendMessage(BM_GETCHECK, + 0, + 0) & BST_CHECKED) + updateValues = true; + else + updateValues = false; + regSetDwordValue("cheatsUpdate", updateValues); +} + +void GBACheatSearch::OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + LV_DISPINFO* info = (LV_DISPINFO*)pNMHDR; + if(info->item.mask & LVIF_TEXT) { + int index = info->item.iItem; + int col = info->item.iSubItem; + + switch(col) { + case 0: + strcpy(info->item.pszText, data[index].address); + break; + case 1: + strcpy(info->item.pszText, data[index].oldValue); + break; + case 2: + strcpy(info->item.pszText, data[index].newValue); + break; + } + } + *pResult = TRUE; + +} + +void GBACheatSearch::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(m_list.GetSelectionMark() != -1); + *pResult = TRUE; +} + +BOOL GBACheatSearch::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString temp = winResLoadString(IDS_ADDRESS); + + m_list.InsertColumn(0, temp, LVCFMT_CENTER, 125, 0); + + temp = winResLoadString(IDS_OLD_VALUE); + m_list.InsertColumn(1, temp, LVCFMT_CENTER, 125, 1); + + temp = winResLoadString(IDS_NEW_VALUE); + m_list.InsertColumn(2, temp, LVCFMT_CENTER, 125, 2); + + m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)), + TRUE); + + m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT); + + if(!cheatSearchData.count) { + GetDlgItem(IDC_SEARCH)->EnableWindow(FALSE); + GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(FALSE); + } + + valueType = regQueryDwordValue("cheatsValueType", 0); + if(valueType < 0 || valueType > 1) + valueType = 0; + + searchType = regQueryDwordValue("cheatsSearchType", SEARCH_EQ); + if(searchType > 5 || searchType < 0) + searchType = 0; + + numberType = regQueryDwordValue("cheatsNumberType", 2); + if(numberType < 0 || numberType > 2) + numberType = 2; + + sizeType = regQueryDwordValue("cheatsSizeType", 0); + if(sizeType < 0 || sizeType > 2) + sizeType = 0; + + updateValues = regQueryDwordValue("cheatsUpdate", 0) ? + true : false; + + UpdateData(FALSE); + + if(valueType == 0) + m_value.EnableWindow(FALSE); + CenterWindow(); + + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE); + + if(cheatSearchData.count) + { + addChanges(false); + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE); + } + else + { + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE); + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBACheatSearch::addChanges(bool showMsgs) +{ + int count = cheatSearchGetCount(&cheatSearchData, sizeType); + + m_list.DeleteAllItems(); + + if(count > 4000) { + if(showMsgs) + dlgSystemMessage(this, IDS_SEARCH_PRODUCED_TOO_MANY, + "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches.", + count); + return; + } + + if(count == 0) { + if(showMsgs) + dlgSystemMessage(this, IDS_SEARCH_PRODUCED_NO_RESULTS, + "Search produced no results."); + return; + } + + m_list.SetItemCount(count); + if(data) + free(data); + + data = (WinCheatsData *)calloc(count,sizeof(WinCheatsData)); + + int inc = 1; + switch(sizeType) { + case 1: + inc = 2; + break; + case 2: + inc = 4; + break; + } + + int index = 0; + if(numberType == 0) { + for(int i = 0; i < cheatSearchData.count; i++) { + CheatSearchBlock *block = &cheatSearchData.blocks[i]; + + for(int j = 0; j < block->size; j+= inc) { + if(IS_BIT_SET(block->bits, j)) { + addChange(index++, + block->offset | j, + cheatSearchSignedRead(block->saved, + j, + sizeType), + cheatSearchSignedRead(block->data, + j, + sizeType)); + } + } + } + } else { + for(int i = 0; i < cheatSearchData.count; i++) { + CheatSearchBlock *block = &cheatSearchData.blocks[i]; + + for(int j = 0; j < block->size; j+= inc) { + if(IS_BIT_SET(block->bits, j)) { + addChange(index++, + block->offset | j, + cheatSearchRead(block->saved, + j, + sizeType), + cheatSearchRead(block->data, + j, + sizeType)); + } + } + } + } + + for(int i = 0; i < count; i++) { + LVITEM item; + + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; + item.iItem = i; + item.iSubItem = 0; + item.lParam = data[i].addr; + item.state = 0; + item.stateMask = 0; + item.pszText = LPSTR_TEXTCALLBACK; + m_list.InsertItem(&item); + + m_list.SetItemText(i, 1, LPSTR_TEXTCALLBACK); + m_list.SetItemText(i, 2, LPSTR_TEXTCALLBACK); + } +} + +void GBACheatSearch::addChange(int index, u32 address, u32 oldValue, u32 newValue) +{ + data[index].addr = address; + sprintf(data[index].address, "%08x",address); + switch(numberType) { + case 0: + sprintf(data[index].oldValue, "%d", oldValue); + sprintf(data[index].newValue, "%d", newValue); + break; + case 1: + sprintf(data[index].oldValue, "%u", oldValue); + sprintf(data[index].newValue, "%u", newValue); + break; + case 2: + switch(sizeType) { + case 0: + sprintf(data[index].oldValue, "%02x", oldValue); + sprintf(data[index].newValue, "%02x", newValue); + break; + case 1: + sprintf(data[index].oldValue, "%04x", oldValue); + sprintf(data[index].newValue, "%04x", newValue); + break; + case 2: + sprintf(data[index].oldValue, "%08x", oldValue); + sprintf(data[index].newValue, "%08x", newValue); + break; + } + } +} + +void GBACheatSearch::OnValueType(UINT id) +{ + switch(id) { + case IDC_OLD_VALUE: + valueType = 0; + m_value.EnableWindow(FALSE); + regSetDwordValue("cheatsValueType", 0); + break; + case IDC_SPECIFIC_VALUE: + valueType = 1; + m_value.EnableWindow(TRUE); + regSetDwordValue("cheatsValueType", 1); + break; + } +} + +void GBACheatSearch::OnSearchType(UINT id) +{ + switch(id) { + case IDC_EQ: + searchType = SEARCH_EQ; + regSetDwordValue("cheatsSearchType", 0); + break; + case IDC_NE: + searchType = SEARCH_NE; + regSetDwordValue("cheatsSearchType", 1); + break; + case IDC_LT: + searchType = SEARCH_LT; + regSetDwordValue("cheatsSearchType", 2); + break; + case IDC_LE: + searchType = SEARCH_LE; + regSetDwordValue("cheatsSearchType", 3); + break; + case IDC_GT: + searchType = SEARCH_GT; + regSetDwordValue("cheatsSearchType", 4); + break; + case IDC_GE: + searchType = SEARCH_GE; + regSetDwordValue("cheatsSearchType", 5); + break; + } +} + +void GBACheatSearch::OnNumberType(UINT id) +{ + switch(id) { + case IDC_SIGNED: + numberType = 0; + regSetDwordValue("cheatsNumberType", 0); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_UNSIGNED: + numberType = 1; + regSetDwordValue("cheatsNumberType", 1); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_HEXADECIMAL: + numberType = 2; + regSetDwordValue("cheatsNumberType", 2); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + } +} + +void GBACheatSearch::OnSizeType(UINT id) +{ + switch(id) { + case IDC_SIZE_8: + sizeType = BITS_8; + regSetDwordValue("cheatsSizeType", 0); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_SIZE_16: + sizeType = BITS_16; + regSetDwordValue("cheatsSizeType", 1); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_SIZE_32: + sizeType = BITS_32; + regSetDwordValue("cheatsSizeType", 2); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + } +} +///////////////////////////////////////////////////////////////////////////// +// AddCheat dialog + + +AddCheat::AddCheat(u32 address, CWnd* pParent /*=NULL*/) + : CDialog(AddCheat::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddCheat) + sizeType = -1; + numberType = -1; + //}}AFX_DATA_INIT + this->address = address; +} + + +void AddCheat::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddCheat) + DDX_Control(pDX, IDC_VALUE, m_value); + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Radio(pDX, IDC_SIZE_8, sizeType); + DDX_Radio(pDX, IDC_SIGNED, numberType); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddCheat, CDialog) + //{{AFX_MSG_MAP(AddCheat) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddCheat message handlers + +void AddCheat::OnOk() +{ + // add cheat + if(addCheat()) { + EndDialog(TRUE); + } +} + +void AddCheat::OnCancel() +{ + EndDialog(FALSE); +} + +BOOL AddCheat::OnInitDialog() +{ + CDialog::OnInitDialog(); + + if(address != 0) { + CString buffer; + buffer.Format("%08x", address); + m_address.SetWindowText(buffer); + m_address.EnableWindow(FALSE); + } + + numberType = regQueryDwordValue("cheatsNumberType", 2); + if(numberType < 0 || numberType > 2) + numberType = 2; + + sizeType = regQueryDwordValue("cheatsSizeType", 0); + if(sizeType < 0 || sizeType > 2) + sizeType = 0; + + UpdateData(FALSE); + + GetDlgItem(IDC_DESC)->SendMessage(EM_LIMITTEXT, + 32, + 0); + if(address != 0) { + GetDlgItem(IDC_SIZE_8)->EnableWindow(FALSE); + GetDlgItem(IDC_SIZE_16)->EnableWindow(FALSE); + GetDlgItem(IDC_SIZE_32)->EnableWindow(FALSE); + GetDlgItem(IDC_HEXADECIMAL)->EnableWindow(FALSE); + GetDlgItem(IDC_UNSIGNED)->EnableWindow(FALSE); + GetDlgItem(IDC_SIGNED)->EnableWindow(FALSE); + } + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void AddCheat::OnNumberType(UINT id) +{ + switch(id) { + case IDC_SIGNED: + numberType = 0; + regSetDwordValue("cheatsNumberType", 0); + break; + case IDC_UNSIGNED: + numberType = 1; + regSetDwordValue("cheatsNumberType", 1); + break; + case IDC_HEXADECIMAL: + numberType = 2; + regSetDwordValue("cheatsNumberType", 2); + break; + } +} + +void AddCheat::OnSizeType(UINT id) +{ + switch(id) { + case IDC_SIZE_8: + sizeType = BITS_8; + regSetDwordValue("cheatsSizeType", 0); + break; + case IDC_SIZE_16: + sizeType = BITS_16; + regSetDwordValue("cheatsSizeType", 1); + break; + case IDC_SIZE_32: + sizeType = BITS_32; + regSetDwordValue("cheatsSizeType", 2); + break; + } +} + +bool AddCheat::addCheat() +{ + CString buffer; + CString code; + + m_address.GetWindowText(buffer); + u32 address = 0; + sscanf(buffer, "%x", &address); + if((address >= 0x02000000 && address < 0x02040000) || + (address >= 0x03000000 && address < 0x03008000)) { + } else { + dlgSystemMessage(this, IDS_INVALID_ADDRESS, "Invalid address: %08x", address); + return false; + } + if(sizeType != 0) { + if(sizeType == 1 && address & 1) { + dlgSystemMessage(this, IDS_MISALIGNED_HALFWORD, + "Misaligned half-word address: %08x", address); + return false; + } + if(sizeType == 2 && address & 3) { + dlgSystemMessage(this, IDS_MISALIGNED_WORD, + "Misaligned word address: %08x", address); + return false; + } + } + u32 value; + m_value.GetWindowText(buffer); + + if(buffer.IsEmpty()) { + dlgSystemMessage(this, IDS_VALUE_CANNOT_BE_EMPTY, "Value cannot be empty"); + return false; + } + + switch(numberType) { + case 0: + sscanf(buffer, "%d", &value); + break; + case 1: + sscanf(buffer, "%u", &value); + break; + default: + sscanf(buffer, "%x", &value); + } + + m_desc.GetWindowText(buffer); + + switch(sizeType) { + case 0: + code.Format("%08x:%02x", address, value); + break; + case 1: + code.Format("%08x:%04x", address, value); + break; + case 2: + code.Format("%08x:%08x", address, value); + break; + } + + cheatsAdd(code, buffer,address, value,-1, sizeType); + return true; +} +///////////////////////////////////////////////////////////////////////////// +// GBACheatList dialog + + +GBACheatList::GBACheatList(CWnd* pParent /*=NULL*/) + : CDialog(GBACheatList::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBACheatList) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + duringRefresh = false; +} + + +void GBACheatList::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBACheatList) + DDX_Control(pDX, IDC_RESTORE, m_restore); + DDX_Control(pDX, IDC_CHEAT_LIST, m_list); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBACheatList, CDialog) + //{{AFX_MSG_MAP(GBACheatList) + ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat) + ON_BN_CLICKED(IDC_ADD_CODE, OnAddCode) + ON_BN_CLICKED(IDC_ADD_CODEBREAKER, OnAddCodebreaker) + ON_BN_CLICKED(IDC_ADD_GAMESHARK, OnAddGameshark) + ON_BN_CLICKED(IDC_ENABLE, OnEnable) + ON_BN_CLICKED(IDC_REMOVE, OnRemove) + ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll) + ON_BN_CLICKED(IDC_RESTORE, OnRestore) + ON_BN_CLICKED(ID_OK, OnOk) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBACheatList message handlers + +void GBACheatList::OnAddCheat() +{ + AddCheat dlg(0); + dlg.DoModal(); + refresh(); +} + +void GBACheatList::OnAddCode() +{ + AddCheatCode dlg; + dlg.DoModal(); + refresh(); +} + +void GBACheatList::OnAddCodebreaker() +{ + AddCBACode dlg; + dlg.DoModal(); + refresh(); +} + +void GBACheatList::OnAddGameshark() +{ + AddGSACode dlg; + dlg.DoModal(); + refresh(); +} + +void GBACheatList::OnEnable() +{ + int mark = m_list.GetSelectionMark(); + int count = m_list.GetItemCount(); + + if(mark != -1) { + LVITEM item; + for(int i = 0; i < count; i++) { + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM|LVIF_STATE; + item.stateMask = LVIS_SELECTED; + item.iItem = i; + if(m_list.GetItem(&item)) { + if(item.state & LVIS_SELECTED) { + if(cheatsList[item.lParam].enabled) + cheatsDisable(item.lParam); + else + cheatsEnable(item.lParam); + } + } + } + refresh(); + } +} + +void GBACheatList::OnRemove() +{ + int mark = m_list.GetSelectionMark(); + int count = m_list.GetItemCount(); + + if(mark != -1) { + for(int i = count - 1; i >= 0; i--) { + LVITEM item; + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM|LVIF_STATE; + item.iItem = i; + item.stateMask = LVIS_SELECTED; + if(m_list.GetItem(&item)) { + if(item.state & LVIS_SELECTED) { + cheatsDelete(item.lParam, restoreValues); + } + } + } + refresh(); + } +} + +void GBACheatList::OnRemoveAll() +{ + cheatsDeleteAll(restoreValues); + refresh(); +} + + +void GBACheatList::OnRestore() +{ + restoreValues = !restoreValues; + regSetDwordValue("cheatsRestore", restoreValues); +} + +void GBACheatList::OnOk() +{ + EndDialog(TRUE); +} + +void GBACheatList::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + if(m_list.GetSelectionMark() != -1) { + GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE); + GetDlgItem(IDC_ENABLE)->EnableWindow(TRUE); + } else { + GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE); + } + + if(!duringRefresh) { + LPNMLISTVIEW l = (LPNMLISTVIEW)pNMHDR; + if(l->uChanged & LVIF_STATE) { + if(((l->uOldState & LVIS_STATEIMAGEMASK)>>12) != + (((l->uNewState & LVIS_STATEIMAGEMASK)>>12))) { + if(m_list.GetCheck(l->iItem)) + cheatsEnable(l->lParam); + else + cheatsDisable(l->lParam); + refresh(); + } + } + } + + *pResult = 0; +} + +BOOL GBACheatList::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString temp = winResLoadString(IDS_CODE); + m_list.InsertColumn(0, temp, LVCFMT_LEFT, 170, 0); + temp = winResLoadString(IDS_DESCRIPTION); + m_list.InsertColumn(1, temp, LVCFMT_LEFT, 150, 1); + temp = winResLoadString(IDS_STATUS); + m_list.InsertColumn(2, temp, LVCFMT_LEFT, 80, 1); + + m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)), + TRUE); + + m_list.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT); + + restoreValues = regQueryDwordValue("cheatsRestore", 0) ? + true : false; + + m_restore.SetCheck(restoreValues); + + refresh(); + GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBACheatList::refresh() +{ + duringRefresh = true; + m_list.DeleteAllItems(); + + CString buffer; + + for(int i = 0; i < cheatsNumber; i++) { + LVITEM item; + + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; + item.iItem = i; + item.iSubItem = 0; + item.lParam = i; + item.state = 0; + item.stateMask = 0; + item.pszText = cheatsList[i].codestring; + m_list.InsertItem(&item); + + m_list.SetCheck(i, (cheatsList[i].enabled) ? TRUE : FALSE); + + m_list.SetItemText(i, 1, cheatsList[i].desc); + + buffer = (cheatsList[i].enabled) ? 'E' : 'D'; + m_list.SetItemText(i, 2, buffer); + } + duringRefresh = false; +} +///////////////////////////////////////////////////////////////////////////// +// AddGSACode dialog + + +AddGSACode::AddGSACode(CWnd* pParent /*=NULL*/) + : CDialog(AddGSACode::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddGSACode) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void AddGSACode::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddGSACode) + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Control(pDX, IDC_CODE, m_code); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddGSACode, CDialog) + //{{AFX_MSG_MAP(AddGSACode) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddGSACode message handlers + +void AddGSACode::OnOk() +{ + CString desc; + CString buffer; + CString part1; + CString code; + CString token; + + m_code.GetWindowText(buffer); + m_desc.GetWindowText(desc); + + StringTokenizer st(buffer, " \t\n\r"); + part1.Empty(); + const char *t = st.next(); + while(t) { + token = t; + token.MakeUpper(); + if(token.GetLength() == 16) + cheatsAddGSACode(token, desc, false); + else if(token.GetLength() == 12) { + code = token.Left(8); + code += " "; + code += token.Right(4); + cheatsAddCBACode(code, desc); + } else if(part1.IsEmpty()) + part1 = token; + else { + if(token.GetLength() == 4) { + code = part1; + code += " "; + code += token; + cheatsAddCBACode(code, desc); + } else { + code = part1 + token; + cheatsAddGSACode(code, desc, true); + } + part1.Empty(); + } + + t = st.next(); + } + EndDialog(TRUE); +} + +void AddGSACode::OnCancel() +{ + EndDialog(FALSE); +} + +BOOL AddGSACode::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_code.LimitText(1024); + m_desc.LimitText(32); + CString title = winResLoadString(IDS_ADD_GSA_CODE); + SetWindowText(title); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +///////////////////////////////////////////////////////////////////////////// +// AddCBACode dialog + + +AddCBACode::AddCBACode(CWnd* pParent /*=NULL*/) + : CDialog(AddCBACode::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddCBACode) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void AddCBACode::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddCBACode) + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Control(pDX, IDC_CODE, m_code); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddCBACode, CDialog) + //{{AFX_MSG_MAP(AddCBACode) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddCBACode message handlers + +void AddCBACode::OnOk() +{ + CString desc; + CString buffer; + CString part1; + CString code; + CString token; + + m_code.GetWindowText(buffer); + m_desc.GetWindowText(desc); + + StringTokenizer st(buffer, " \t\n\r"); + part1.Empty(); + const char *t = st.next(); + while(t) { + token = t; + token.MakeUpper(); + if(token.GetLength() == 16) + cheatsAddGSACode(token, desc, false); + else if(token.GetLength() == 12) { + code = token.Left(8); + code += " "; + code += token.Right(4); + cheatsAddCBACode(code, desc); + } else if(part1.IsEmpty()) + part1 = token; + else { + if(token.GetLength() == 4) { + code = part1; + code += " "; + code += token; + cheatsAddCBACode(code, desc); + } else { + code = part1 + token; + cheatsAddGSACode(code, desc, true); + } + part1.Empty(); + } + + t = st.next(); + } + EndDialog(TRUE); +} + +void AddCBACode::OnCancel() +{ + EndDialog(FALSE); +} + +BOOL AddCBACode::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_code.LimitText(1024); + m_desc.LimitText(32); + CString title = winResLoadString(IDS_ADD_CBA_CODE); + SetWindowText(title); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +///////////////////////////////////////////////////////////////////////////// +// AddCheatCode dialog + + +AddCheatCode::AddCheatCode(CWnd* pParent /*=NULL*/) + : CDialog(AddCheatCode::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddCheatCode) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void AddCheatCode::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddCheatCode) + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Control(pDX, IDC_CODE, m_code); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddCheatCode, CDialog) + //{{AFX_MSG_MAP(AddCheatCode) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddCheatCode message handlers + +void AddCheatCode::OnOk() +{ + CString desc; + CString buffer; + CString token; + + m_code.GetWindowText(buffer); + m_desc.GetWindowText(desc); + + StringTokenizer st(buffer, " \t\n\r"); + const char *t = st.next(); + while(t) { + token = t; + token.MakeUpper(); + cheatsAddCheatCode(token, desc); + t = st.next(); + } + EndDialog(TRUE); +} + +void AddCheatCode::OnCancel() +{ + EndDialog(FALSE); +} + +BOOL AddCheatCode::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_code.LimitText(1024); + m_desc.LimitText(32); + CString title = winResLoadString(IDS_ADD_CHEAT_CODE); + SetWindowText(title); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBACheatSearch::OnBnClickedCheatrefreshbutton() +{ + addChanges(false); +} diff --git a/src/win32/GBACheats.h b/src/win32/GBACheats.h new file mode 100644 index 0000000..1557309 --- /dev/null +++ b/src/win32/GBACheats.h @@ -0,0 +1,294 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_) +#define AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBACheats.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// GBACheatSearch dialog + +struct WinCheatsData { + u32 addr; + char address[9]; + char oldValue[12]; + char newValue[12]; +}; + +class GBACheatSearch : public CDialog +{ + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + afx_msg void OnSearchType(UINT id); + afx_msg void OnValueType(UINT id); + void addChange(int index, u32 address, u32 oldValue, u32 newValue); + GBACheatSearch(CWnd* pParent = NULL); // standard constructor + ~GBACheatSearch(); + + // Dialog Data + //{{AFX_DATA(GBACheatSearch) + enum { IDD = IDD_CHEATS }; + CEdit m_value; + CListCtrl m_list; + int valueType; + int sizeType; + int searchType; + int numberType; + BOOL updateValues; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBACheatSearch) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBACheatSearch) + afx_msg void OnOk(); + afx_msg void OnStart(); + afx_msg void OnSearch(); + afx_msg void OnAddCheat(); + afx_msg void OnUpdate(); + afx_msg void OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void addChanges(bool showMsgs); + WinCheatsData *data; +public: + afx_msg void OnClose(); + afx_msg void OnBnClickedCheatrefreshbutton(); +}; + +///////////////////////////////////////////////////////////////////////////// +// AddCheat dialog + +class AddCheat : public CDialog +{ + // Construction + public: + bool addCheat(); + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + u32 address; + AddCheat(u32 address, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddCheat) + enum { IDD = IDD_ADD_CHEAT }; + CEdit m_value; + CEdit m_desc; + CEdit m_address; + int sizeType; + int numberType; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCheat) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AddCheat) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + ///////////////////////////////////////////////////////////////////////////// +// GBACheatList dialog + +class GBACheatList : public CDialog +{ + // Construction + public: + void refresh(); + bool duringRefresh; + bool restoreValues; + + GBACheatList(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GBACheatList) + enum { IDD = IDD_CHEAT_LIST }; + CButton m_restore; + CListCtrl m_list; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBACheatList) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBACheatList) + afx_msg void OnAddCheat(); + afx_msg void OnAddCode(); + afx_msg void OnAddCodebreaker(); + afx_msg void OnAddGameshark(); + afx_msg void OnEnable(); + afx_msg void OnRemove(); + afx_msg void OnRemoveAll(); + afx_msg void OnRestore(); + afx_msg void OnOk(); + afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + ///////////////////////////////////////////////////////////////////////////// +// AddGSACode dialog + +class AddGSACode : public CDialog +{ + // Construction + public: + AddGSACode(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddGSACode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGSACode) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AddGSACode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// +// AddCBACode dialog + +class AddCBACode : public CDialog +{ + // Construction + public: + AddCBACode(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddCBACode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCBACode) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AddCBACode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// +// AddCheatCode dialog + +class AddCheatCode : public CDialog +{ + // Construction + public: + AddCheatCode(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddCheatCode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCheatCode) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AddCheatCode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_) diff --git a/src/win32/GBCheatsDlg.cpp b/src/win32/GBCheatsDlg.cpp new file mode 100644 index 0000000..99d51e0 --- /dev/null +++ b/src/win32/GBCheatsDlg.cpp @@ -0,0 +1,1080 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBCheats.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GBCheatsDlg.h" +#include "Reg.h" +#include "StringTokenizer.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../CheatSearch.h" +#include "../gb/gbCheats.h" +#include "../gb/gbGlobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static bool winGbCheatAddVerifyGs(const char *code, const char *desc) +{ + gbAddGsCheat(code, desc); + return true; +} + +static bool winGbCheatAddVerifyGg(const char *code, const char *desc) +{ + gbAddGgCheat(code, desc); + return true; +} + +///////////////////////////////////////////////////////////////////////////// +// GBCheatSearch dialog + +GBCheatSearch::GBCheatSearch(CWnd* pParent /*=NULL*/) + : CDialog(GBCheatSearch::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBCheatSearch) + searchType = -1; + numberType = -1; + sizeType = -1; + updateValues = FALSE; + valueType = -1; + //}}AFX_DATA_INIT + data = NULL; +} + +GBCheatSearch::~GBCheatSearch() +{ + if(data) + free(data); +} + +void GBCheatSearch::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBCheatSearch) + DDX_Control(pDX, IDC_VALUE, m_value); + DDX_Control(pDX, IDC_CHEAT_LIST, m_list); + DDX_Radio(pDX, IDC_EQ, searchType); + DDX_Radio(pDX, IDC_SIGNED, numberType); + DDX_Radio(pDX, IDC_SIZE_8, sizeType); + DDX_Check(pDX, IDC_UPDATE, updateValues); + DDX_Radio(pDX, IDC_OLD_VALUE, valueType); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBCheatSearch, CDialog) + //{{AFX_MSG_MAP(GBCheatSearch) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(IDC_ADD_CHEAT, OnAddCheat) + ON_BN_CLICKED(IDC_SEARCH, OnSearch) + ON_BN_CLICKED(IDC_START, OnStart) + ON_BN_CLICKED(IDC_UPDATE, OnUpdate) + ON_NOTIFY(LVN_GETDISPINFO, IDC_CHEAT_LIST, OnGetdispinfoCheatList) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList) + ON_CONTROL_RANGE(BN_CLICKED, IDC_OLD_VALUE, IDC_SPECIFIC_VALUE, OnValueType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_EQ, IDC_GE, OnSearchType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType) + //}}AFX_MSG_MAP +ON_WM_CLOSE() +ON_BN_CLICKED(IDC_CHEATREFRESHBUTTON, OnBnClickedCheatrefreshbutton) +END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBCheatSearch message handlers + +void GBCheatSearch::OnOk() +{ + if(data) + free(data); + data = NULL; + + if(theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = false; + DestroyWindow(); + } + else + { + EndDialog(TRUE); + } +} + +void GBCheatSearch::OnClose() +{ + CDialog::OnClose(); + if(theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = false; + DestroyWindow(); + } + else + { + EndDialog(FALSE); + } +} + +void GBCheatSearch::OnBnClickedCheatrefreshbutton() +{ + addChanges(false); +} + +void GBCheatSearch::OnAddCheat() +{ + int mark = m_list.GetSelectionMark(); + + if(mark != -1) { + LVITEM item; + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM; + item.iItem = mark; + if(m_list.GetItem(&item)) { + AddGBCheat dlg((u32)item.lParam); + dlg.DoModal(); + } + } +} + +static void dlgSystemMessage(CWnd * hWnd, int number, const char *defaultMsg, ...) +{ + CString buffer; + va_list valist; + CString msg = defaultMsg; + if(number) + msg = winResLoadString(number); + + va_start(valist, defaultMsg); + buffer.FormatV(msg, valist); + + theApp.winCheckFullscreen(); + + hWnd->MessageBox(buffer, winResLoadString(IDS_ERROR), MB_OK|MB_ICONERROR); + + va_end(valist); +} + + +void GBCheatSearch::OnSearch() +{ + CString buffer; + if(valueType == 0) + cheatSearch(&cheatSearchData, + searchType, + sizeType, + numberType == 0); + else { + m_value.GetWindowText(buffer); + if(buffer.IsEmpty()) { + dlgSystemMessage(this, IDS_NUMBER_CANNOT_BE_EMPTY, "Number cannot be empty"); + return; + } + int value = 0; + switch(numberType) { + case 0: + sscanf(buffer, "%d", &value); + break; + case 1: + sscanf(buffer, "%u", &value); + break; + default: + sscanf(buffer, "%x", &value); + } + cheatSearchValue(&cheatSearchData, + searchType, + sizeType, + numberType == 0, + value); + } + + addChanges(true); + + if(updateValues) + cheatSearchUpdateValues(&cheatSearchData); + + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE); + + if(0 == cheatSearchGetCount(&cheatSearchData, sizeType)) + OnStart(); +} + +void GBCheatSearch::OnStart() +{ + if(cheatSearchData.count == 0) { + int i = 0; + + CheatSearchBlock *block = &cheatSearchData.blocks[0]; + + if(gbRamSize) { + block->offset = 0xa000; + if(gbRam) + block->data = gbRam; + else + block->data = &gbMemory[0xa000]; + block->saved = (u8*)malloc(gbRamSize); + block->size = gbRamSize; + block->bits = (u8 *)malloc(gbRamSize >> 3); + i++; + } + block = &cheatSearchData.blocks[i]; + if(gbCgbMode) { + block->offset = 0xc000; + block->data = &gbMemory[0xc000]; + block->saved = (u8*)malloc(0x1000); + block->size = 0x1000; + block->bits = (u8 *)malloc(0x1000 >> 3); + i++; + block =&cheatSearchData.blocks[i]; + block->offset = 0xd000; + block->data = gbWram; + block->saved = (u8*)malloc(0x8000); + block->size = 0x8000; + block->bits = (u8 *)malloc(0x8000 >> 3); + i++; + } else { + block->offset = 0xc000; + block->data = &gbMemory[0xc000]; + block->saved = (u8*)malloc(0x2000); + block->size = 0x2000; + block->bits = (u8 *)malloc(0x2000 >> 3); + i++; + } + cheatSearchData.count = i; + } + + cheatSearchStart(&cheatSearchData); + GetDlgItem(IDC_SEARCH)->EnableWindow(TRUE); + + if(theApp.modelessCheatDialogIsOpen) + { + GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE); + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE); + } +} + +void GBCheatSearch::OnUpdate() +{ + if(GetDlgItem(IDC_UPDATE)->SendMessage(BM_GETCHECK, + 0, + 0) & BST_CHECKED) + updateValues = true; + else + updateValues = false; + regSetDwordValue("gbCheatsUpdate", updateValues); +} + +BOOL GBCheatSearch::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString temp = winResLoadString(IDS_ADDRESS); + + m_list.InsertColumn(0, temp, LVCFMT_CENTER, 125, 0); + + temp = winResLoadString(IDS_OLD_VALUE); + m_list.InsertColumn(1, temp, LVCFMT_CENTER, 125, 1); + + temp = winResLoadString(IDS_NEW_VALUE); + m_list.InsertColumn(2, temp, LVCFMT_CENTER, 125, 2); + + m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)), + TRUE); + + m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT); + + if(!cheatSearchData.count) { + GetDlgItem(IDC_SEARCH)->EnableWindow(FALSE); + GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(FALSE); + } + + valueType = regQueryDwordValue("gbCheatsValueType", 0); + if(valueType < 0 || valueType > 1) + valueType = 2; + + searchType = regQueryDwordValue("gbCheatsSearchType", + SEARCH_EQ); + if(searchType < 0 || searchType > 5) + searchType = 0; + + numberType = regQueryDwordValue("gbCheatsNumberType", 2); + if(numberType < 0 || numberType > 2) + numberType = 2; + + sizeType = regQueryDwordValue("gbCheatsSizeType", 0); + if(sizeType < 0 || sizeType > 2) + sizeType = 0; + + updateValues = regQueryDwordValue("gbCheatsUpdate", 0) ? + true : false; + + UpdateData(FALSE); + + if(valueType == 0) + m_value.EnableWindow(FALSE); + + CenterWindow(); + + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->ShowWindow(TRUE); + + if(cheatSearchData.count) + { + addChanges(false); + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(cheatSearchGetCount(&cheatSearchData, sizeType) == 0 ? FALSE : TRUE); + } + else + { + if(theApp.modelessCheatDialogIsOpen) + GetDlgItem(IDC_CHEATREFRESHBUTTON)->EnableWindow(FALSE); + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBCheatSearch::OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + LV_DISPINFO* info = (LV_DISPINFO*)pNMHDR; + if(info->item.mask & LVIF_TEXT) { + int index = info->item.iItem; + int col = info->item.iSubItem; + + switch(col) { + case 0: + strcpy(info->item.pszText, data[index].address); + break; + case 1: + strcpy(info->item.pszText, data[index].oldValue); + break; + case 2: + strcpy(info->item.pszText, data[index].newValue); + break; + } + } + *pResult = TRUE; +} + +void GBCheatSearch::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + GetDlgItem(IDC_ADD_CHEAT)->EnableWindow(m_list.GetSelectionMark() != -1); +} + +int GBCheatSearch::getBank(u16 addr, int j) +{ + switch(addr >> 12) { + case 0x0a: + return j / 0x2000; + case 0x0d: + return j / 0x1000; + } + return 0; +} + +void GBCheatSearch::addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue) +{ + data[index].bank = bank; + if(bank) { + if(address == 0xa000) + address |= offset & 0x1fff; + else + address |= offset & 0xfff; + } else + address |= offset; + data[index].addr = address; + sprintf(data[index].address, "%02x:%04x",bank,address); + switch(numberType) { + case 0: + sprintf(data[index].oldValue, "%d", oldValue); + sprintf(data[index].newValue, "%d", newValue); + break; + case 1: + sprintf(data[index].oldValue, "%u", oldValue); + sprintf(data[index].newValue, "%u", newValue); + break; + case 2: + switch(sizeType) { + case 0: + sprintf(data[index].oldValue, "%02x", oldValue); + sprintf(data[index].newValue, "%02x", newValue); + break; + case 1: + sprintf(data[index].oldValue, "%04x", oldValue); + sprintf(data[index].newValue, "%04x", newValue); + break; + case 2: + sprintf(data[index].oldValue, "%08x", oldValue); + sprintf(data[index].newValue, "%08x", newValue); + break; + } + } +} + +void GBCheatSearch::addChanges(bool showMsg) +{ + int count = cheatSearchGetCount(&cheatSearchData, sizeType); + + m_list.DeleteAllItems(); + + if(count > 4000) { + if(showMsg) + dlgSystemMessage(this, IDS_SEARCH_PRODUCED_TOO_MANY, + "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches.", + count); + return; + } + + if(count == 0) { + if(showMsg) + dlgSystemMessage(this, IDS_SEARCH_PRODUCED_NO_RESULTS, + "Search produced no results"); + return; + } + + m_list.SetItemCount(count); + if(data) + free(data); + + data = (WinGbCheatsData *)calloc(count, sizeof(WinGbCheatsData)); + + int inc = 1; + switch(sizeType) { + case 1: + inc = 2; + break; + case 2: + inc = 4; + break; + } + + int index = 0; + if(numberType == 0) { + for(int i = 0; i < cheatSearchData.count; i++) { + CheatSearchBlock *block = &cheatSearchData.blocks[i]; + + for(int j = 0; j < block->size; j+= inc) { + if(IS_BIT_SET(block->bits, j)) { + addChange(index++, + getBank(block->offset|j, j), + block->offset, + j, + cheatSearchSignedRead(block->saved, + j, + sizeType), + cheatSearchSignedRead(block->data, + j, + sizeType)); + } + } + } + } else { + for(int i = 0; i < cheatSearchData.count; i++) { + CheatSearchBlock *block = &cheatSearchData.blocks[i]; + + for(int j = 0; j < block->size; j+= inc) { + if(IS_BIT_SET(block->bits, j)) { + addChange(index++, + getBank(block->offset|j, j), + block->offset, + j, + cheatSearchRead(block->saved, + j, + sizeType), + cheatSearchRead(block->data, + j, + sizeType)); + } + } + } + } + + for(int i = 0; i < count; i++) { + LVITEM item; + + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; + item.iItem = i; + item.iSubItem = 0; + item.lParam = data[i].addr| + (data[i].bank << 16); + item.state = 0; + item.stateMask = 0; + item.pszText = LPSTR_TEXTCALLBACK; + m_list.InsertItem(&item); + + m_list.SetItemText(i, 1, LPSTR_TEXTCALLBACK); + m_list.SetItemText(i, 2, LPSTR_TEXTCALLBACK); + } +} + +void GBCheatSearch::OnValueType(UINT id) +{ + switch(id) { + case IDC_OLD_VALUE: + valueType = 0; + m_value.EnableWindow(FALSE); + regSetDwordValue("gbCheatsValueType", 0); + break; + case IDC_SPECIFIC_VALUE: + valueType = 1; + m_value.EnableWindow(TRUE); + regSetDwordValue("gbCheatsValueType", 1); + break; + } +} + +void GBCheatSearch::OnSearchType(UINT id) +{ + switch(id) { + case IDC_EQ: + searchType = SEARCH_EQ; + regSetDwordValue("gbCheatsSearchType", 0); + break; + case IDC_NE: + searchType = SEARCH_NE; + regSetDwordValue("gbCheatsSearchType", 1); + break; + case IDC_LT: + searchType = SEARCH_LT; + regSetDwordValue("gbCheatsSearchType", 2); + break; + case IDC_LE: + searchType = SEARCH_LE; + regSetDwordValue("gbCheatsSearchType", 3); + break; + case IDC_GT: + searchType = SEARCH_GT; + regSetDwordValue("gbCheatsSearchType", 4); + break; + case IDC_GE: + searchType = SEARCH_GE; + regSetDwordValue("gbCheatsSearchType", 5); + break; + } +} + +void GBCheatSearch::OnNumberType(UINT id) +{ + switch(id) { + case IDC_SIGNED: + numberType = 0; + regSetDwordValue("gbCheatsNumberType", 0); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_UNSIGNED: + numberType = 1; + regSetDwordValue("gbCheatsNumberType", 1); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_HEXADECIMAL: + numberType = 2; + regSetDwordValue("gbCheatsNumberType", 2); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + } +} + +void GBCheatSearch::OnSizeType(UINT id) +{ + switch(id) { + case IDC_SIZE_8: + sizeType = BITS_8; + regSetDwordValue("gbCheatsSizeType", 0); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_SIZE_16: + sizeType = BITS_16; + regSetDwordValue("gbCheatsSizeType", 1); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + case IDC_SIZE_32: + sizeType = BITS_32; + regSetDwordValue("gbCheatsSizeType", 2); + if(m_list.GetItemCount()) { + addChanges(false); + } + break; + } +} +///////////////////////////////////////////////////////////////////////////// +// AddGBCheat dialog + + +AddGBCheat::AddGBCheat(u32 addr, CWnd* pParent /*=NULL*/) + : CDialog(AddGBCheat::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddGBCheat) + sizeType = -1; + numberType = -1; + //}}AFX_DATA_INIT + address = addr; +} + + +void AddGBCheat::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddGBCheat) + DDX_Control(pDX, IDC_VALUE, m_value); + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Radio(pDX, IDC_SIZE_8, sizeType); + DDX_Radio(pDX, IDC_SIGNED, numberType); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddGBCheat, CDialog) + //{{AFX_MSG_MAP(AddGBCheat) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIGNED, IDC_HEXADECIMAL, OnNumberType) + ON_CONTROL_RANGE(BN_CLICKED, IDC_SIZE_8, IDC_SIZE_32, OnSizeType) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddGBCheat message handlers + +void AddGBCheat::OnCancel() +{ + EndDialog(FALSE); +} + +void AddGBCheat::OnOk() +{ + // add cheat + if(addCheat()) { + EndDialog(TRUE); + } +} + +bool AddGBCheat::addCheat() +{ + CString buffer; + CString code; + + u32 value; + m_value.GetWindowText(buffer); + + if(buffer.IsEmpty()) { + dlgSystemMessage(this, IDS_VALUE_CANNOT_BE_EMPTY, "Value cannot be empty"); + return false; + } + + switch(numberType) { + case 0: + sscanf(buffer, "%d", &value); + break; + case 1: + sscanf(buffer, "%u", &value); + break; + default: + sscanf(buffer, "%x", &value); + } + + m_desc.GetWindowText(buffer); + + int bank = (address >> 16); + address &= 0xFFFF; + + if(address >= 0xd000) + bank += 0x90; + else + bank = 0x01; + + switch(sizeType) { + case 0: + code.Format("%02X%02X%02X%02X", bank, value, address&0xFF, address>>8); + gbAddGsCheat(code, buffer); + break; + case 1: + code.Format("%02X%02X%02X%02X", bank, value&0xFF, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + address++; + code.Format("%02X%02X%02X%02X", bank, value>>8, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + break; + case 2: + code.Format("%02X%02X%02X%02X", bank, value&0xFF, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + address++; + code.Format("%02X%02X%02X%02X", bank, (value>>8) & 0xFF, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + address++; + code.Format("%02X%02X%02X%02X", bank, (value>>16)&0xFF, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + address++; + code.Format("%02X%02X%02X%02X", bank, value>>24, address&0xFF, + address>>8); + gbAddGsCheat(code, buffer); + break; + } + + return true; +} + +BOOL AddGBCheat::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString buffer; + buffer.Format("%02x:%08x", (address>>16), address&0xFFFF); + m_address.SetWindowText(buffer); + m_address.EnableWindow(FALSE); + ::SetWindowLong(m_address, + GWL_USERDATA, + address); + + numberType = regQueryDwordValue("gbCheatsNumberType", 2); + if(numberType < 0 || numberType > 2) + numberType = 2; + + sizeType = regQueryDwordValue("gbCheatsSizeType", 0); + if(sizeType < 0 || sizeType > 2) + sizeType = 0; + + UpdateData(FALSE); + + m_desc.LimitText(32); + + if(address != 0) { + GetDlgItem(IDC_SIZE_8)->EnableWindow(FALSE); + GetDlgItem(IDC_SIZE_16)->EnableWindow(FALSE); + GetDlgItem(IDC_SIZE_32)->EnableWindow(FALSE); + GetDlgItem(IDC_HEXADECIMAL)->EnableWindow(FALSE); + GetDlgItem(IDC_UNSIGNED)->EnableWindow(FALSE); + GetDlgItem(IDC_SIGNED)->EnableWindow(FALSE); + } + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void AddGBCheat::OnNumberType(UINT id) +{ + switch(id) { + case IDC_SIGNED: + numberType = 0; + regSetDwordValue("gbCheatsNumberType", 0); + break; + case IDC_UNSIGNED: + numberType = 1; + regSetDwordValue("gbCheatsNumberType", 1); + break; + case IDC_HEXADECIMAL: + numberType = 2; + regSetDwordValue("gbCheatsNumberType", 2); + break; + } +} + +void AddGBCheat::OnSizeType(UINT id) +{ + switch(id) { + case IDC_SIZE_8: + sizeType = BITS_8; + regSetDwordValue("gbCheatsSizeType", 0); + break; + case IDC_SIZE_16: + sizeType = BITS_16; + regSetDwordValue("gbCheatsSizeType", 1); + break; + case IDC_SIZE_32: + sizeType = BITS_32; + regSetDwordValue("gbCheatsSizeType", 2); + break; + } +} + +///////////////////////////////////////////////////////////////////////////// +// GBCheatList dialog + + +GBCheatList::GBCheatList(CWnd* pParent /*=NULL*/) + : CDialog(GBCheatList::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBCheatList) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + duringRefresh = false; +} + + +void GBCheatList::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBCheatList) + DDX_Control(pDX, IDC_CHEAT_LIST, m_list); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBCheatList, CDialog) + //{{AFX_MSG_MAP(GBCheatList) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(IDC_ADD_GG_CHEAT, OnAddGgCheat) + ON_BN_CLICKED(IDC_ADD_GS_CHEAT, OnAddGsCheat) + ON_BN_CLICKED(IDC_ENABLE, OnEnable) + ON_BN_CLICKED(IDC_REMOVE, OnRemove) + ON_BN_CLICKED(IDC_REMOVE_ALL, OnRemoveAll) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_CHEAT_LIST, OnItemchangedCheatList) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBCheatList message handlers + +void GBCheatList::OnOk() +{ + EndDialog(TRUE); +} + +void GBCheatList::OnAddGgCheat() +{ + CString temp = winResLoadString(IDS_ADD_GG_CODE); + AddGBCode dlg(winGbCheatAddVerifyGg, 11, temp); + dlg.DoModal(); + refresh(); +} + +void GBCheatList::OnAddGsCheat() +{ + CString temp = winResLoadString(IDS_ADD_GS_CODE); + + AddGBCode dlg(winGbCheatAddVerifyGs, 8, temp); + dlg.DoModal(); + refresh(); +} + +void GBCheatList::OnEnable() +{ + int mark = m_list.GetSelectionMark(); + + if(mark != -1) { + LVITEM item; + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM; + item.iItem = mark; + if(m_list.GetItem(&item)) { + if(gbCheatList[item.lParam].enabled) + gbCheatDisable(item.lParam); + else + gbCheatEnable(item.lParam); + refresh(); + } + } +} + +void GBCheatList::OnRemove() +{ + int mark = m_list.GetSelectionMark(); + + if(mark != -1) { + LVITEM item; + memset(&item,0, sizeof(item)); + item.mask = LVIF_PARAM; + item.iItem = mark; + if(m_list.GetItem(&item)) { + gbCheatRemove(item.lParam); + refresh(); + } + } +} + +void GBCheatList::OnRemoveAll() +{ + gbCheatRemoveAll(); + refresh(); +} + +void GBCheatList::OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult) +{ + if(m_list.GetSelectionMark() != -1) { + GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE); + GetDlgItem(IDC_ENABLE)->EnableWindow(TRUE); + } else { + GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE); + } + + if(!duringRefresh) { + LPNMLISTVIEW l = (LPNMLISTVIEW)pNMHDR; + if(l->uChanged & LVIF_STATE) { + if(((l->uOldState & LVIS_STATEIMAGEMASK)>>12) != + (((l->uNewState & LVIS_STATEIMAGEMASK)>>12))) { + if(m_list.GetCheck(l->iItem)) + gbCheatEnable(l->lParam); + else + gbCheatDisable(l->lParam); + refresh(); + } + } + } +} + +BOOL GBCheatList::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString temp = winResLoadString(IDS_CODE); + m_list.InsertColumn(0, temp, LVCFMT_LEFT, 120, 0); + temp = winResLoadString(IDS_DESCRIPTION); + m_list.InsertColumn(1, temp, LVCFMT_LEFT, 200, 1); + temp = winResLoadString(IDS_STATUS); + m_list.InsertColumn(2, temp, LVCFMT_LEFT, 80, 2); + + m_list.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)), + TRUE); + + m_list.SetExtendedStyle(LVS_EX_CHECKBOXES | + LVS_EX_FULLROWSELECT); + + refresh(); + GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE); + GetDlgItem(IDC_ENABLE)->EnableWindow(FALSE); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBCheatList::refresh() +{ + duringRefresh = true; + + m_list.DeleteAllItems(); + + char buffer[2]; + + for(int i = 0; i < gbCheatNumber; i++) { + LVITEM item; + + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; + item.iItem = i; + item.iSubItem = 0; + item.lParam = i; + item.state = 0; + item.stateMask = 0; + item.pszText = gbCheatList[i].cheatCode; + m_list.InsertItem(&item); + + m_list.SetCheck(i, (gbCheatList[i].enabled ? TRUE : FALSE)); + + m_list.SetItemText(i, 1, gbCheatList[i].cheatDesc); + + buffer[0] = (gbCheatList[i].enabled) ? 'E' : 'D'; + buffer[1] = 0; + m_list.SetItemText(i, 2, buffer); + } + duringRefresh = false; +} + +///////////////////////////////////////////////////////////////////////////// +// AddGBCode dialog + + +AddGBCode::AddGBCode(bool (*verify)(const char *,const char*), int len, const char *title, CWnd* pParent /*=NULL*/) + : CDialog(AddGBCode::IDD, pParent) +{ + //{{AFX_DATA_INIT(AddGBCode) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + addVerify = verify; + addLength = len; + addTitle = title; +} + + +void AddGBCode::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(AddGBCode) + DDX_Control(pDX, IDC_DESC, m_desc); + DDX_Control(pDX, IDC_CODE, m_code); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(AddGBCode, CDialog) + //{{AFX_MSG_MAP(AddGBCode) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// AddGBCode message handlers + +void AddGBCode::OnOk() +{ + CString desc; + CString buffer; + m_code.GetWindowText(buffer); + m_desc.GetWindowText(desc); + + StringTokenizer st(buffer, " \t\n\r"); + const char *t = st.next(); + while(t) { + addVerify(t, desc); + t = st.next(); + } + EndDialog(TRUE); +} + +void AddGBCode::OnCancel() +{ + EndDialog(FALSE); +} + +BOOL AddGBCode::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_code.LimitText(1024); + m_desc.LimitText(32); + SetWindowText(addTitle); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/GBCheatsDlg.h b/src/win32/GBCheatsDlg.h new file mode 100644 index 0000000..cf44331 --- /dev/null +++ b/src/win32/GBCheatsDlg.h @@ -0,0 +1,220 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_) +#define AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBCheats.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// GBCheatSearch dialog + +struct WinGbCheatsData { + int bank; + u16 addr; + char address[9]; + char oldValue[12]; + char newValue[12]; +}; + +class GBCheatSearch : public CDialog +{ + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + afx_msg void OnSearchType(UINT id); + afx_msg void OnValueType(UINT id); + void addChanges(bool showMsg); + void addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue); + int getBank(u16 addr, int j); + GBCheatSearch(CWnd* pParent = NULL); // standard constructor + ~GBCheatSearch(); + + // Dialog Data + //{{AFX_DATA(GBCheatSearch) + enum { IDD = IDD_CHEATS }; + CEdit m_value; + CListCtrl m_list; + int searchType; + int numberType; + int sizeType; + BOOL updateValues; + int valueType; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBCheatSearch) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + WinGbCheatsData *data; + + // Generated message map functions + //{{AFX_MSG(GBCheatSearch) + afx_msg void OnOk(); + afx_msg void OnAddCheat(); + afx_msg void OnSearch(); + afx_msg void OnStart(); + afx_msg void OnUpdate(); + virtual BOOL OnInitDialog(); + afx_msg void OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnClose(); + afx_msg void OnBnClickedCheatrefreshbutton(); +}; + +///////////////////////////////////////////////////////////////////////////// +// AddGBCheat dialog + +class AddGBCheat : public CDialog +{ + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + bool addCheat(); + AddGBCheat(u32 addr, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddGBCheat) + enum { IDD = IDD_ADD_CHEAT }; + CEdit m_value; + CEdit m_address; + CEdit m_desc; + int sizeType; + int numberType; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGBCheat) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + u32 address; + + // Generated message map functions + //{{AFX_MSG(AddGBCheat) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + ///////////////////////////////////////////////////////////////////////////// +// GBCheatList dialog + +class GBCheatList : public CDialog +{ + // Construction + public: + void refresh(); + bool duringRefresh; + GBCheatList(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GBCheatList) + enum { IDD = IDD_GB_CHEAT_LIST }; + CListCtrl m_list; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBCheatList) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBCheatList) + afx_msg void OnOk(); + afx_msg void OnAddGgCheat(); + afx_msg void OnAddGsCheat(); + afx_msg void OnEnable(); + afx_msg void OnRemove(); + afx_msg void OnRemoveAll(); + afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// +// AddGBCode dialog + +class AddGBCode : public CDialog +{ + // Construction + public: + AddGBCode(bool (*verify)(const char *, const char *),int, const char *, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(AddGBCode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + + int addLength; + CString addTitle; + bool (*addVerify)(const char *, const char*); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGBCode) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(AddGBCode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_) diff --git a/src/win32/GBColorDlg.cpp b/src/win32/GBColorDlg.cpp new file mode 100644 index 0000000..b4c2784 --- /dev/null +++ b/src/win32/GBColorDlg.cpp @@ -0,0 +1,261 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBColorDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GBColorDlg.h" +#include "../System.h" +#include "Reg.h" + +extern int gbPaletteOption; +extern int emulating; +extern int cartridgeType; +extern u16 gbPalette[128]; + +static u16 defaultPalettes[][24] = { + { + 0x7FFF, 0x56B5, 0x318C, 0x0000, 0x7FFF, 0x56B5, 0x318C, 0x0000, + }, + { + 0x6200, 0x7E10, 0x7C10, 0x5000, 0x6200, 0x7E10, 0x7C10, 0x5000, + }, + { + 0x4008, 0x4000, 0x2000, 0x2008, 0x4008, 0x4000, 0x2000, 0x2008, + }, + { + 0x43F0, 0x03E0, 0x4200, 0x2200, 0x43F0, 0x03E0, 0x4200, 0x2200, + }, + { + 0x43FF, 0x03FF, 0x221F, 0x021F, 0x43FF, 0x03FF, 0x221F, 0x021F, + }, + { + 0x621F, 0x7E1F, 0x7C1F, 0x2010, 0x621F, 0x7E1F, 0x7C1F, 0x2010, + }, + { + 0x621F, 0x401F, 0x001F, 0x2010, 0x621F, 0x401F, 0x001F, 0x2010, + }, + { + 0x1314, 0x0E91, 0x0E0D, 0x2108, 0x1314, 0x0E91, 0x0E0D, 0x2108, + } +}; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBColorDlg dialog + + +GBColorDlg::GBColorDlg(CWnd* pParent /*=NULL*/) + : CDialog(GBColorDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBColorDlg) + which = -1; + //}}AFX_DATA_INIT + which = gbPaletteOption; +} + + +void GBColorDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBColorDlg) + DDX_Control(pDX, IDC_PREDEFINED, m_predefined); + DDX_Radio(pDX, IDC_DEFAULT, which); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBColorDlg, CDialog) + //{{AFX_MSG_MAP(GBColorDlg) + ON_BN_CLICKED(IDC_DEFAULT, OnDefault) + ON_BN_CLICKED(IDC_RESET, OnReset) + ON_BN_CLICKED(IDC_USER1, OnUser1) + ON_BN_CLICKED(IDC_USER2, OnUser2) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_CBN_SELCHANGE(IDC_PREDEFINED, OnSelchangePredefined) + //}}AFX_MSG_MAP + ON_CONTROL_RANGE(BN_CLICKED, IDC_COLOR_BG0, IDC_COLOR_OB3, OnColorClicked) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBColorDlg message handlers + +void GBColorDlg::OnDefault() +{ + setWhich(0); +} + +void GBColorDlg::OnReset() +{ + int s = which * 8; + colors[s++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + colors[s++] = (0x15) | (0x15 << 5) | (0x15 << 10); + colors[s++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + colors[s++] = 0; + + colors[s++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + colors[s++] = (0x15) | (0x15 << 5) | (0x15 << 10); + colors[s++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + colors[s] = 0; + setWhich(which); +} + +void GBColorDlg::OnUser1() +{ + setWhich(1); +} + +void GBColorDlg::OnUser2() +{ + setWhich(2); +} + +void GBColorDlg::OnCancel() +{ + EndDialog(FALSE); +} + +void GBColorDlg::OnOk() +{ + EndDialog(TRUE); +} + +BOOL GBColorDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + colorControls[0].SubclassDlgItem(IDC_COLOR_BG0, this); + colorControls[1].SubclassDlgItem(IDC_COLOR_BG1, this); + colorControls[2].SubclassDlgItem(IDC_COLOR_BG2, this); + colorControls[3].SubclassDlgItem(IDC_COLOR_BG3, this); + colorControls[4].SubclassDlgItem(IDC_COLOR_OB0, this); + colorControls[5].SubclassDlgItem(IDC_COLOR_OB1, this); + colorControls[6].SubclassDlgItem(IDC_COLOR_OB2, this); + colorControls[7].SubclassDlgItem(IDC_COLOR_OB3, this); + + for(int i = 0; i < 24; i++) { + colors[i] = systemGbPalette[i]; + } + + const char *names[] = { + "Standard", + "Blue Sea", + "Dark Night", + "Green Forest", + "Hot Desert", + "Pink Dreams", + "Weird Colors", + "Real Colors" + }; + + for(int j = 0; j < 8; j++) { + int index = m_predefined.AddString(names[j]); + m_predefined.SetItemData(index, j); + } + + RECT cbSize; + int Height; + + m_predefined.GetClientRect(&cbSize); + Height = m_predefined.GetItemHeight(0); + Height += m_predefined.GetItemHeight(0) * (10); + + // Note: The use of SM_CYEDGE assumes that we're using Windows '95 + // Now add on the height of the border of the edit box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // The height of the border of the drop-down box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // now set the size of the window + m_predefined.SetWindowPos(NULL, + 0, 0, + cbSize.right, Height, + SWP_NOMOVE | SWP_NOZORDER); + + + setWhich(which); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBColorDlg::setWhich(int w) +{ + which = w; + + for(int i = 0; i < 8; i++) { + colorControls[i].setColor(colors[which*8+i]); + } +} + +u16 * GBColorDlg::getColors() +{ + return colors; +} + +void GBColorDlg::OnColorClicked(UINT id) +{ + id -= IDC_COLOR_BG0; + + u16 color = colors[which*8+id]; + + COLORREF colorInit = + RGB((color & 0x1f) << 3, ((color >> 5) & 0x1f) << 3, ((color >> 10) & 0x1f) << 3); + + CColorDialog dlg(colorInit, + CC_FULLOPEN | CC_ANYCOLOR, this); + + if(IDOK == dlg.DoModal()) + { + COLORREF c = dlg.GetColor(); + + colors[which*8+id] = (u16)((c >> 3) & 0x1f | ((c >> 11) & 0x1f) << 5 | + ((c >> 19) & 0x1f) << 10); + colorControls[id].setColor(colors[which*8+id]); + } +} + +int GBColorDlg::getWhich() +{ + return which; +} + + +void GBColorDlg::OnSelchangePredefined() +{ + int sel = m_predefined.GetCurSel(); + + if(sel != -1) { + int data = m_predefined.GetItemData(sel); + for(int i = 0; i < 8; i++) { + colorControls[i].setColor(defaultPalettes[data][i]); + colors[which*8+i] = defaultPalettes[data][i]; + } + } +} diff --git a/src/win32/GBColorDlg.h b/src/win32/GBColorDlg.h new file mode 100644 index 0000000..d19c308 --- /dev/null +++ b/src/win32/GBColorDlg.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_) +#define AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_ + +#include "ColorButton.h" // Added by ClassView +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBColorDlg.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// GBColorDlg dialog + +class GBColorDlg : public CDialog +{ + // Construction + public: + int getWhich(); + afx_msg void OnColorClicked(UINT id); + u16 * getColors(); + void setWhich(int w); + u16 colors[24]; + ColorButton colorControls[8]; + GBColorDlg(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GBColorDlg) + enum { IDD = IDD_GB_COLORS }; + CComboBox m_predefined; + int which; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBColorDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBColorDlg) + afx_msg void OnDefault(); + afx_msg void OnReset(); + afx_msg void OnUser1(); + afx_msg void OnUser2(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + afx_msg void OnSelchangePredefined(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_) diff --git a/src/win32/GBDisassemble.cpp b/src/win32/GBDisassemble.cpp new file mode 100644 index 0000000..6eee4ec --- /dev/null +++ b/src/win32/GBDisassemble.cpp @@ -0,0 +1,262 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBDisassemble.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GBDisassemble.h" + +#include "../System.h" +#include "../gb/GB.h" +#include "../gb/gbGlobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern gbRegister AF; +extern gbRegister BC; +extern gbRegister DE; +extern gbRegister HL; +extern gbRegister SP; +extern gbRegister PC; +extern u16 IFF; +extern int gbDis(char *, u16); + +///////////////////////////////////////////////////////////////////////////// +// GBDisassemble dialog + + +GBDisassemble::GBDisassemble(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBDisassemble::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBDisassemble) + m_c = FALSE; + m_h = FALSE; + m_n = FALSE; + m_z = FALSE; + //}}AFX_DATA_INIT + address = 0; + autoUpdate = false; + count = 1; + lastAddress = 0; +} + + +void GBDisassemble::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBDisassemble) + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Control(pDX, IDC_DISASSEMBLE, m_list); + DDX_Check(pDX, IDC_C, m_c); + DDX_Check(pDX, IDC_H, m_h); + DDX_Check(pDX, IDC_N, m_n); + DDX_Check(pDX, IDC_Z, m_z); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBDisassemble, CDialog) + //{{AFX_MSG_MAP(GBDisassemble) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_NEXT, OnNext) + ON_BN_CLICKED(IDC_GO, OnGo) + ON_BN_CLICKED(IDC_GOPC, OnGopc) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_WM_VSCROLL() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBDisassemble message handlers + +void GBDisassemble::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +void GBDisassemble::OnRefresh() +{ + refresh(); +} + +void GBDisassemble::OnNext() +{ + gbEmulate(1); + if(PC.W < address || PC.W >= lastAddress) + OnGopc(); + refresh(); +} + +void GBDisassemble::OnGo() +{ + CString buffer; + m_address.GetWindowText(buffer); + sscanf(buffer, "%x", &address); + refresh(); +} + +void GBDisassemble::OnGopc() +{ + address = PC.W; + + refresh(); +} + +void GBDisassemble::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +BOOL GBDisassemble::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_DISASSEMBLE, DS_SizeY) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_NEXT, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_AUTO_UPDATE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_GOPC, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_VSCROLL, DS_SizeY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBDisassembleView", + NULL); + + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + si.nMin = 0; + si.nMax = 100; + si.nPos = 50; + si.nPage = 0; + GetDlgItem(IDC_VSCROLL)->SetScrollInfo(SB_CTL, &si, TRUE); + CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)); + m_list.SetFont(font); + + for(int i = 0; i < 6; i++) + GetDlgItem(IDC_R0+i)->SetFont(font); + + m_address.LimitText(4); + refresh(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBDisassemble::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + char buffer[80]; + + switch(nSBCode) { + case SB_LINEDOWN: + address += gbDis(buffer, address); + break; + case SB_LINEUP: + address--; + break; + case SB_PAGEDOWN: + address = lastAddress; + break; + case SB_PAGEUP: + address -= count; + break; + } + refresh(); + + CDialog::OnVScroll(nSBCode, nPos, pScrollBar); +} + +void GBDisassemble::refresh() +{ + if(gbRom == NULL) + return; + + int h = m_list.GetItemHeight(0); + RECT r; + m_list.GetClientRect(&r); + count = (r.bottom - r.top+1)/h; + + m_list.ResetContent(); + if(!emulating || theApp.cartridgeType != 1) + return; + + char buffer[80]; + u16 addr = address; + int i; + int sel = -1; + for(i = 0; i < count; i++) { + if(addr == PC.W) + sel = i; + addr += gbDis(buffer, addr); + m_list.InsertString(-1, buffer); + } + lastAddress = addr-1; + if(sel != -1) + m_list.SetCurSel(sel); + + sprintf(buffer, "%04x", AF.W); + GetDlgItem(IDC_R0)->SetWindowText(buffer); + sprintf(buffer, "%04x", BC.W); + GetDlgItem(IDC_R1)->SetWindowText(buffer); + sprintf(buffer, "%04x", DE.W); + GetDlgItem(IDC_R2)->SetWindowText(buffer); + sprintf(buffer, "%04x", HL.W); + GetDlgItem(IDC_R3)->SetWindowText(buffer); + sprintf(buffer, "%04x", SP.W); + GetDlgItem(IDC_R4)->SetWindowText(buffer); + sprintf(buffer, "%04x", PC.W); + GetDlgItem(IDC_R5)->SetWindowText(buffer); + sprintf(buffer, "%04x", IFF); + GetDlgItem(IDC_R6)->SetWindowText(buffer); + + m_z = (AF.B.B0 & 0x80) != 0; + m_n = (AF.B.B0 & 0x40) != 0; + m_h = (AF.B.B0 & 0x20) != 0; + m_c = (AF.B.B0 & 0x10) != 0; + UpdateData(FALSE); +} + +void GBDisassemble::update() +{ + OnGopc(); + refresh(); +} + +void GBDisassemble::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/GBDisassemble.h b/src/win32/GBDisassemble.h new file mode 100644 index 0000000..0a37a6b --- /dev/null +++ b/src/win32/GBDisassemble.h @@ -0,0 +1,89 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_) +#define AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBDisassemble.h : header file +// + +#include "IUpdate.h" +#include "ResizeDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// GBDisassemble dialog + +class GBDisassemble : public ResizeDlg, IUpdateListener +{ + // Construction + public: + void refresh(); + u16 lastAddress; + int count; + bool autoUpdate; + u16 address; + GBDisassemble(CWnd* pParent = NULL); // standard constructor + + virtual void update(); + + // Dialog Data + //{{AFX_DATA(GBDisassemble) + enum { IDD = IDD_GB_DISASSEMBLE }; + CEdit m_address; + CListBox m_list; + BOOL m_c; + BOOL m_h; + BOOL m_n; + BOOL m_z; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBDisassemble) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBDisassemble) + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void OnNext(); + afx_msg void OnGo(); + afx_msg void OnGopc(); + afx_msg void OnAutoUpdate(); + virtual BOOL OnInitDialog(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_) diff --git a/src/win32/GBMapView.cpp b/src/win32/GBMapView.cpp new file mode 100644 index 0000000..c3cd714 --- /dev/null +++ b/src/win32/GBMapView.cpp @@ -0,0 +1,577 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBMapView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBMapView.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../NLS.h" +#include "../Util.h" +#include "../gb/gbGlobals.h" + +extern "C" { +#include +} + +extern u8 gbInvertTab[256]; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBMapView dialog + + +GBMapView::GBMapView(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBMapView::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBMapView) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 1024; + bmpInfo.bmiHeader.biHeight = -1024; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 1024 * 1024); + + mapView.setData(data); + mapView.setBmpInfo(&bmpInfo); + + bg = 0; + bank = 0; +} + + +void GBMapView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBMapView) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_MAP_VIEW, mapView); + DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, mapViewZoom); + DDX_Control(pDX, IDC_COLOR, color); +} + + +BEGIN_MESSAGE_MAP(GBMapView, CDialog) + //{{AFX_MSG_MAP(GBMapView) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_BG0, OnBg0) + ON_BN_CLICKED(IDC_BG1, OnBg1) + ON_BN_CLICKED(IDC_BANK_0, OnBank0) + ON_BN_CLICKED(IDC_BANK_1, OnBank1) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBMapView message handlers + +GBMapView::~GBMapView() +{ + free(data); + data = NULL; +} + +void GBMapView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + +void GBMapView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + +void GBMapView::OnSave() +{ + CString filename; + + if(theApp.captureFormat == 0) + filename = "map.png"; + else + filename = "map.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + + FileDlg dlg(this, + filename, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + if(dlg.getFilterIndex() == 2) + saveBMP(dlg.GetPathName()); + else + savePNG(dlg.GetPathName()); +} + +void GBMapView::render() +{ + u8 * bank0; + u8 * bank1; + if(gbCgbMode) { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } else { + bank0 = &gbMemory[0x8000]; + bank1 = NULL; + } + + int tile_map_address = 0x1800; + if(bg == 1) + tile_map_address = 0x1c00; + + int tile_pattern = 0x0000; + if(bank == 1) + tile_pattern = 0x0800; + + w = 256; + h = 256; + + int tile = 0; + for(int y = 0; y < 32; y++) { + for(int x = 0; x < 32; x++) { + u8 *bmp = &data[y * 8 * 32 * 24 + x*24]; + u8 attrs = 0; + if(bank1 != NULL) + attrs = bank1[tile_map_address]; + u8 tile = bank0[tile_map_address]; + tile_map_address++; + + if(bank == 1) { + if(tile < 128) tile += 128; + else tile -= 128; + } + for(int j = 0; j < 8; j++) { + int tile_pattern_address = attrs & 0x40 ? + tile_pattern + tile*16 + (7-j)*2: + tile_pattern + tile*16+j*2; + + u8 tile_a = 0; + u8 tile_b = 0; + + if(attrs & 0x08) { + tile_a = bank1[tile_pattern_address++]; + tile_b = bank1[tile_pattern_address]; + } else { + tile_a = bank0[tile_pattern_address++]; + tile_b = bank0[tile_pattern_address]; + } + + if(attrs & 0x20) { + tile_a = gbInvertTab[tile_a]; + tile_b = gbInvertTab[tile_b]; + } + + u8 mask = 0x80; + + while(mask > 0) { + u8 c = (tile_a & mask) ? 1 : 0; + c += (tile_b & mask) ? 2 : 0; + + if(gbCgbMode) + c = c + (attrs & 7)*4; + + u16 color = gbPalette[c]; + + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + + mask >>= 1; + } + bmp += 31*24; + } + } + } +} + +void GBMapView::paint() +{ + if(gbRom == NULL) + return; + render(); + + SIZE s; + if(mapView.getStretch()) { + mapView.setSize(w, h); + s.cx = s.cy = 1; + mapView.SetScrollSizes(MM_TEXT, s); + } else { + mapView.setSize(w, h); + s.cx = w; + s.cy = h; + mapView.SetScrollSizes(MM_TEXT, s); + } + + mapView.refresh(); +} + +void GBMapView::OnRefresh() +{ + paint(); +} + +void GBMapView::update() +{ + paint(); +} + +BOOL GBMapView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_MAP_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBMapView", + NULL); + + int s = regQueryDwordValue("mapViewStretch", 0); + if(s) + mapView.setStretch(true); + ((CButton *)GetDlgItem(IDC_STRETCH))->SetCheck(s); + + UINT id = IDC_BANK_0; + if(bank == 1) + id = IDC_BANK_1; + CheckRadioButton(IDC_BANK_0, IDC_BANK_1, id); + id = IDC_BG0; + if(bg == 1) + id = IDC_BG1; + CheckRadioButton(IDC_BG0, IDC_BG1, id); + paint(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBMapView::OnBg0() +{ + bg = 0; + paint(); +} + +void GBMapView::OnBg1() +{ + bg = 1; + paint(); +} + +void GBMapView::OnBank0() +{ + bank = 0; + paint(); +} + +void GBMapView::OnBank1() +{ + bank = 1; + paint(); +} + +void GBMapView::OnStretch() +{ + mapView.setStretch(!mapView.getStretch()); + paint(); + regSetDwordValue("mapViewStretch", mapView.getStretch()); +} + +void GBMapView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void GBMapView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +u32 GBMapView::GetClickAddress(int x, int y) +{ + u32 base = 0x9800; + if(bg == 1) + base = 0x9c00; + + return base + (y >> 3)*32 + (x >> 3); +} + +LRESULT GBMapView::OnMapInfo(WPARAM wParam, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + mapViewZoom.setColors(colors); + + int x = wParam & 0xffff; + int y = (wParam >> 16); + + CString buffer; + buffer.Format("(%d,%d)", x, y); + GetDlgItem(IDC_XY)->SetWindowText(buffer); + + u32 address = GetClickAddress(x,y); + buffer.Format("0x%08X", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + u8 attrs = 0; + + u8 tile = gbMemoryMap[9][address & 0xfff]; + if(gbCgbMode) { + attrs = gbVram[0x2000 + address - 0x8000]; + tile = gbVram[address & 0x1fff]; + } + + if(bank == 1) { + if(tile > 128) tile -= 128; + else tile += 128; + } + + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE_NUM)->SetWindowText(buffer); + + buffer.Empty(); + buffer += attrs & 0x20 ? 'H' : '-'; + buffer += attrs & 0x40 ? 'V' : '-'; + GetDlgItem(IDC_FLIP)->SetWindowText(buffer); + + if(gbCgbMode) { + buffer.Format("%d", (attrs & 7)); + } else + buffer = "---"; + GetDlgItem(IDC_PALETTE_NUM)->SetWindowText(buffer); + + buffer.Empty(); + if(gbCgbMode) + buffer += attrs & 0x80 ? 'P' : '-'; + else + buffer += '-'; + GetDlgItem(IDC_PRIORITY)->SetWindowText(buffer); + + return TRUE; +} + +LRESULT GBMapView::OnColInfo(WPARAM wParam, LPARAM) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + +void GBMapView::PostNcDestroy() +{ + delete this; + CDialog::PostNcDestroy(); +} diff --git a/src/win32/GBMapView.h b/src/win32/GBMapView.h new file mode 100644 index 0000000..2b2b006 --- /dev/null +++ b/src/win32/GBMapView.h @@ -0,0 +1,102 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_) +#define AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBMapView.h : header file +// + +#include "BitmapControl.h" +#include "ColorControl.h" +#include "ZoomControl.h" +#include "ResizeDlg.h" +#include "IUpdate.h" +#include "..\System.h" // Added by ClassView + +///////////////////////////////////////////////////////////////////////////// +// GBMapView dialog + +class GBMapView : public ResizeDlg, IUpdateListener +{ + private: + BITMAPINFO bmpInfo; + u8 *data; + int bank; + int bg; + int w; + int h; + BitmapControl mapView; + ZoomControl mapViewZoom; + ColorControl color; + bool autoUpdate; + // Construction + public: + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + u32 GetClickAddress(int x, int y); + void update(); + void paint(); + void render(); + void savePNG(const char *name); + void saveBMP(const char *name); + ~GBMapView(); + GBMapView(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GBMapView) + enum { IDD = IDD_GB_MAP_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBMapView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBMapView) + afx_msg void OnSave(); + afx_msg void OnRefresh(); + virtual BOOL OnInitDialog(); + afx_msg void OnBg0(); + afx_msg void OnBg1(); + afx_msg void OnBank0(); + afx_msg void OnBank1(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_) diff --git a/src/win32/GBMemoryViewerDlg.cpp b/src/win32/GBMemoryViewerDlg.cpp new file mode 100644 index 0000000..d7b2182 --- /dev/null +++ b/src/win32/GBMemoryViewerDlg.cpp @@ -0,0 +1,442 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBMemoryViewerDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBMemoryViewerDlg.h" +#include "MemoryViewerAddressSize.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../gb/gbGlobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +GBMemoryViewer::GBMemoryViewer() + : MemoryViewer() +{ + setAddressSize(1); +} + +void GBMemoryViewer::readData(u32 address, int len, u8 *data) +{ + u16 addr = address & 0xffff; + if(emulating && gbRom != NULL) { + for(int i = 0; i < len; i++) { + *data++ = gbMemoryMap[addr >> 12][addr & 0xfff]; + addr++; + } + } else { + for(int i = 0; i < len; i++) { + *data++ = 0; + addr++; + } + } +} + +#define GB_READBYTE_QUICK(addr) \ + gbMemoryMap[(addr) >> 12][(addr) & 0xfff] + +#define GB_WRITEBYTE_QUICK(addr,v) \ + gbMemoryMap[(addr) >> 12][(addr) & 0xfff] = (v) + +void GBMemoryViewer::editData(u32 address, int size, int mask, u32 value) +{ + u32 oldValue; + u16 addr = (u16)address & 0xffff; + switch(size) { + case 8: + oldValue = GB_READBYTE_QUICK(addr); + oldValue &= mask; + oldValue |= (u8)value; + GB_WRITEBYTE_QUICK(addr, oldValue); + break; + case 16: + oldValue = GB_READBYTE_QUICK(addr) | + (GB_READBYTE_QUICK(addr + 1) << 8); + oldValue &= mask; + oldValue |= (u16)value; + GB_WRITEBYTE_QUICK(addr, (oldValue & 255)); + GB_WRITEBYTE_QUICK(addr+1, (oldValue >> 8)); + break; + case 32: + oldValue = GB_READBYTE_QUICK(addr) | + (GB_READBYTE_QUICK(addr + 1) << 8) | + (GB_READBYTE_QUICK(addr + 2) << 16) | + (GB_READBYTE_QUICK(addr + 3) << 24); + oldValue &= mask; + oldValue |= (u32)value; + GB_WRITEBYTE_QUICK(addr, (oldValue & 255)); + GB_WRITEBYTE_QUICK(addr+1, (oldValue >> 8)); + GB_WRITEBYTE_QUICK(addr+2, (oldValue >> 16)); + GB_WRITEBYTE_QUICK(addr+3, (oldValue >> 24)); + break; + } +} + +///////////////////////////////////////////////////////////////////////////// +// GBMemoryViewerDlg dialog + + +GBMemoryViewerDlg::GBMemoryViewerDlg(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBMemoryViewerDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBMemoryViewerDlg) + m_size = -1; + //}}AFX_DATA_INIT + autoUpdate = false; + + autoUpdate = !regQueryDwordValue("memViewerAutoUpdate", 1); + OnAutoUpdate(); // inverts and update dialog + + decimalDisplay = !regQueryDwordValue("memViewerDecimalDisplay", 0); + OnDecimalDisplay(); +} + + +void GBMemoryViewerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBMemoryViewerDlg) + DDX_Control(pDX, IDC_CURRENT_ADDRESS, m_current); + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Control(pDX, IDC_ADDRESSES, m_addresses); + DDX_Radio(pDX, IDC_8_BIT, m_size); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_VIEWER, m_viewer); +} + + +BEGIN_MESSAGE_MAP(GBMemoryViewerDlg, CDialog) + //{{AFX_MSG_MAP(GBMemoryViewerDlg) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_8_BIT, On8Bit) + ON_BN_CLICKED(IDC_16_BIT, On16Bit) + ON_BN_CLICKED(IDC_32_BIT, On32Bit) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_DECIMALDISPLAY, OnDecimalDisplay) + ON_BN_CLICKED(IDC_GO, OnGo) + ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_LOAD, OnLoad) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBMemoryViewerDlg message handlers + +BOOL GBMemoryViewerDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_VIEWER, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_LOAD, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_AUTO_UPDATE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_DECIMALDISPLAY, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CURRENT_ADDRESS_LABEL, DS_MoveY | DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_CURRENT_ADDRESS, DS_MoveY | DS_MoveX) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBMemoryView", + NULL); + + m_viewer.setDialog(this); + m_viewer.ShowScrollBar(SB_VERT, TRUE); + m_viewer.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); + + LPCTSTR s[] = { + "0x0000 - ROM", + "0x4000 - ROM", + "0x8000 - VRAM", + "0xA000 - SRAM", + "0xC000 - RAM", + "0xD000 - WRAM", + "0xFF00 - I/O", + "0xFF80 - RAM" + }; + + for(int i = 0; i < 8; i++) + m_addresses.AddString(s[i]); + + m_addresses.SetCurSel(0); + + RECT cbSize; + int Height; + + m_addresses.GetClientRect(&cbSize); + Height = m_addresses.GetItemHeight(-1); + Height += m_addresses.GetItemHeight(0) * (9); + + // Note: The use of SM_CYEDGE assumes that we're using Windows '95 + // Now add on the height of the border of the edit box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // The height of the border of the drop-down box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // now set the size of the window + m_addresses.SetWindowPos(NULL, + 0, 0, + cbSize.right, Height, + SWP_NOMOVE | SWP_NOZORDER); + + m_address.LimitText(8); + + m_size = regQueryDwordValue("memViewerDataSize", 0); + if(m_size < 0 || m_size > 2) + m_size = 0; + m_viewer.setSize(m_size); + UpdateData(FALSE); + + m_current.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT))); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBMemoryViewerDlg::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +void GBMemoryViewerDlg::OnRefresh() +{ + m_viewer.Invalidate(); +} + +void GBMemoryViewerDlg::update() +{ + OnRefresh(); +} + +void GBMemoryViewerDlg::On8Bit() +{ + m_viewer.setSize(0); + regSetDwordValue("memViewerDataSize", 0); +} + +void GBMemoryViewerDlg::On16Bit() +{ + m_viewer.setSize(1); + regSetDwordValue("memViewerDataSize", 1); +} + +void GBMemoryViewerDlg::On32Bit() +{ + m_viewer.setSize(2); + regSetDwordValue("memViewerDataSize", 2); +} + +void GBMemoryViewerDlg::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } + if(GetDlgItem(IDC_AUTO_UPDATE)) + ((CButton *)GetDlgItem(IDC_AUTO_UPDATE))->SetCheck(autoUpdate ? TRUE : FALSE); + regSetDwordValue("memViewerAutoUpdate", autoUpdate); +} + +void GBMemoryViewerDlg::OnDecimalDisplay() +{ + decimalDisplay = !decimalDisplay; + m_viewer.setDecimal(decimalDisplay ? true : false); + if(GetDlgItem(IDC_DECIMAL_DISPLAY)) + ((CButton *)GetDlgItem(IDC_DECIMAL_DISPLAY))->SetCheck(decimalDisplay ? TRUE : FALSE); + + regSetDwordValue("memViewerDecimalDisplay", decimalDisplay); +} + +void GBMemoryViewerDlg::OnGo() +{ + CString buffer; + + m_address.GetWindowText(buffer); + + u32 address; + sscanf(buffer, "%x", &address); + if(m_viewer.getSize() == 1) + address &= ~1; + else if(m_viewer.getSize() == 2) + address &= ~3; + m_viewer.setAddress(address); +} + +void GBMemoryViewerDlg::OnSelchangeAddresses() +{ + int cur = m_addresses.GetCurSel(); + + switch(cur) { + case 0: + m_viewer.setAddress(0x0000); + break; + case 1: + m_viewer.setAddress(0x4000); + break; + case 2: + m_viewer.setAddress(0x8000); + break; + case 3: + m_viewer.setAddress(0xa000); + break; + case 4: + m_viewer.setAddress(0xc000); + break; + case 5: + m_viewer.setAddress(0xd000); + break; + case 6: + m_viewer.setAddress(0xff00); + break; + case 7: + m_viewer.setAddress(0xff80); + break; + } +} + +void GBMemoryViewerDlg::setCurrentAddress(u32 address) +{ + CString buffer; + + buffer.Format("0x%08X", address); + m_current.SetWindowText(buffer); +} + +void GBMemoryViewerDlg::OnSave() +{ + MemoryViewerAddressSize dlg; + CString buffer; + + dlg.setAddress(m_viewer.getCurrentAddress()); + + LPCTSTR exts[] = { ".dmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP); + CString title = winResLoadString(IDS_SELECT_DUMP_FILE); + + if(dlg.DoModal() == IDOK) { + FileDlg file(this, + buffer, + filter, + 0, + "DMP", + exts, + "", + title, + true); + if(file.DoModal() == IDOK) { + buffer = file.GetPathName(); + FILE *f = fopen(buffer, "wb"); + + if(f == NULL) { + systemMessage(IDS_ERROR_CREATING_FILE, buffer); + return; + } + + int size = dlg.getSize(); + u16 addr = dlg.getAddress() & 0xffff; + + for(int i = 0; i < size; i++) { + fputc(gbMemoryMap[addr >> 12][addr & 0xfff], f); + addr++; + } + + fclose(f); + } + } +} + +void GBMemoryViewerDlg::OnLoad() +{ + CString buffer; + LPCTSTR exts[] = { ".dmp" }; + CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP); + CString title = winResLoadString(IDS_SELECT_DUMP_FILE); + + FileDlg file(this, + buffer, + filter, + 0, + "DMP", + exts, + "", + title, + false); + + if(file.DoModal() == IDOK) { + buffer = file.GetPathName(); + FILE *f = fopen(buffer, "rb"); + if(f == NULL) { + systemMessage(IDS_CANNOT_OPEN_FILE, + "Cannot open file %s", + buffer); + return; + } + + MemoryViewerAddressSize dlg; + + fseek(f, 0, SEEK_END); + int size = ftell(f); + + fseek(f, 0, SEEK_SET); + + dlg.setAddress(m_viewer.getCurrentAddress()); + dlg.setSize(size); + + if(dlg.DoModal() == IDOK) { + int size = dlg.getSize(); + u16 addr = dlg.getAddress() & 0xffff; + + for(int i = 0; i < size; i++) { + int c = fgetc(f); + if(c == -1) + break; + gbMemoryMap[addr >> 12][addr & 0xfff] = c; + addr++; + } + OnRefresh(); + } + fclose(f); + } +} + +void GBMemoryViewerDlg::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/GBMemoryViewerDlg.h b/src/win32/GBMemoryViewerDlg.h new file mode 100644 index 0000000..ad2e2d7 --- /dev/null +++ b/src/win32/GBMemoryViewerDlg.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_) +#define AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBMemoryViewerDlg.h : header file +// +#include "MemoryViewer.h" +#include "ResizeDlg.h" +#include "IUpdate.h" + +class GBMemoryViewer : public MemoryViewer { + public: + GBMemoryViewer(); + virtual void readData(u32, int, u8 *); + virtual void editData(u32, int, int, u32); +}; + +///////////////////////////////////////////////////////////////////////////// +// GBMemoryViewerDlg dialog + +class GBMemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg +{ + GBMemoryViewer m_viewer; + bool autoUpdate; + int decimalDisplay; + // Construction + public: + void setCurrentAddress(u32 address); + GBMemoryViewerDlg(CWnd* pParent = NULL); // standard constructor + + virtual void update(); + + // Dialog Data + //{{AFX_DATA(GBMemoryViewerDlg) + enum { IDD = IDD_MEM_VIEWER }; + CEdit m_current; + CEdit m_address; + CComboBox m_addresses; + int m_size; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBMemoryViewerDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBMemoryViewerDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void On8Bit(); + afx_msg void On16Bit(); + afx_msg void On32Bit(); + afx_msg void OnAutoUpdate(); + afx_msg void OnDecimalDisplay(); + afx_msg void OnGo(); + afx_msg void OnSelchangeAddresses(); + afx_msg void OnSave(); + afx_msg void OnLoad(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_) diff --git a/src/win32/GBOamView.cpp b/src/win32/GBOamView.cpp new file mode 100644 index 0000000..7963f0b --- /dev/null +++ b/src/win32/GBOamView.cpp @@ -0,0 +1,599 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBOamView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBOamView.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../NLS.h" +#include "../Util.h" +#include "../gb/gbGlobals.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBOamView dialog + + +GBOamView::GBOamView(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBOamView::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBOamView) + m_stretch = FALSE; + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 8; + bmpInfo.bmiHeader.biHeight = 16; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 8 * 16); + + oamView.setData(data); + oamView.setBmpInfo(&bmpInfo); + + number = 0; +} + + +void GBOamView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBOamView) + DDX_Control(pDX, IDC_SPRITE, m_sprite); + DDX_Check(pDX, IDC_STRETCH, m_stretch); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_COLOR, color); + DDX_Control(pDX, IDC_OAM_VIEW, oamView); + DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom); +} + + +BEGIN_MESSAGE_MAP(GBOamView, CDialog) + //{{AFX_MSG_MAP(GBOamView) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_WM_HSCROLL() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBOamView message handlers + +GBOamView::~GBOamView() +{ + free(data); + data = NULL; +} + + +void GBOamView::paint() +{ + if(gbRom == NULL) + return; + + render(); + oamView.setSize(w,h); + oamView.refresh(); +} + +void GBOamView::update() +{ + paint(); +} + + +void GBOamView::setAttributes(int y, int x, int tile, int flags) +{ + CString buffer; + + int flipH = flags & 0x20; + int flipV = flags & 0x40; + int prio = (flags & 0x80) >> 7; + int pal = flags & 0x7; + int oap = (flags & 0x08) >> 3; + int bank = (flags & 0x10) >> 4; + + buffer.Format("%d,%d", x,y); + GetDlgItem(IDC_POS)->SetWindowText(buffer); + + buffer.Format("%d", pal); + GetDlgItem(IDC_PALETTE)->SetWindowText(buffer); + + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE)->SetWindowText(buffer); + + buffer.Format("%d", prio); + GetDlgItem(IDC_PRIO)->SetWindowText(buffer); + + buffer.Format("%d", bank); + GetDlgItem(IDC_BANK)->SetWindowText(buffer); + + buffer.Empty(); + if(flipH) + buffer += 'H'; + else + buffer += ' '; + if(flipV) + buffer += 'V'; + else + buffer += ' '; + GetDlgItem(IDC_FLAGS)->SetWindowText(buffer); + + buffer.Format("%d", oap); + GetDlgItem(IDC_OAP)->SetWindowText(buffer); +} + +void GBOamView::render() +{ + int m=0; + if(gbRom == NULL) + return; + + u16 addr = number * 4 + 0xfe00; + + int size = register_LCDC & 4; + + u8 y = gbMemory[addr++]; + u8 x = gbMemory[addr++]; + u8 tile = gbMemory[addr++]; + if(size) + tile &= 254; + u8 flags = gbMemory[addr++]; + + u8 *bmp = data; + + w = 8; + h = size ? 16 : 8; + + setAttributes(y, x, tile, flags); + + u8 * bank0; + u8 * bank1; + if(gbCgbMode) { + if(register_VBK & 1) { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } else { + bank0 = &gbVram[0x0000]; + bank1 = &gbVram[0x2000]; + } + } else { + bank0 = &gbMemory[0x8000]; + bank1 = NULL; + } + + int init = 0x0000; + + u8 *pal = gbObp0; + + if((flags & 0x10)) + pal = gbObp1; + + for(int yy = 0; yy < h; yy++) { + int address = init + tile * 16 + 2*yy; + int a = 0; + int b = 0; + + if(gbCgbMode && flags & 0x08) { + a = bank1[address++]; + b = bank1[address++]; + } else { + a = bank0[address++]; + b = bank0[address++]; + } + + for(int xx = 0; xx < 8; xx++) { + u8 mask = 1 << (7-xx); + u8 c = 0; + if( (a & mask)) + c++; + if( (b & mask)) + c+=2; + + // make sure that sprites will work even in CGB mode + if(gbCgbMode) { + c = c + (flags & 0x07)*4 + 32; + } else { + c = pal[c]; + } + + u16 color = gbPalette[c]; + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + } + } +} + +void GBOamView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + +void GBOamView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + + +void GBOamView::save() +{ + CString captureBuffer; + + if(theApp.captureFormat == 0) + captureBuffer = "oam.png"; + else + captureBuffer = "oam.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + captureBuffer, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + captureBuffer = dlg.GetPathName(); + + if(dlg.getFilterIndex() == 2) + saveBMP(captureBuffer); + else + savePNG(captureBuffer); +} + +BOOL GBOamView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_OAM_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_OAM_VIEW_ZOOM, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBOamView", + NULL); + m_sprite.SetWindowText("0"); + + updateScrollInfo(); + + m_stretch = regQueryDwordValue("GBOamViewStretch", 0); + if(m_stretch) + oamView.setStretch(true); + UpdateData(FALSE); + + paint(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBOamView::OnStretch() +{ + oamView.setStretch(!oamView.getStretch()); + paint(); + regSetDwordValue("GBOamViewStretch", oamView.getStretch()); +} + +void GBOamView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + + +void GBOamView::OnChangeSprite() +{ + CString buffer; + m_sprite.GetWindowText(buffer); + int n = atoi(buffer); + if(n < 0 || n > 39) { + buffer.Format("%d", number); + m_sprite.SetWindowText(buffer); + return; + } + number = n; + paint(); + updateScrollInfo(); +} + +void GBOamView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +LRESULT GBOamView::OnMapInfo(WPARAM, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + oamZoom.setColors(colors); + + return TRUE; +} + +LRESULT GBOamView::OnColInfo(WPARAM wParam, LPARAM lParam) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + + +void GBOamView::updateScrollInfo() +{ + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS; + si.nMin = 0; + si.nMax = 39; + si.nPage = 1; + si.nPos = number; + GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL, + &si, + TRUE); +} + + +void GBOamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + switch(nSBCode) { + case SB_BOTTOM: + number = 39; + break; + case SB_LINEDOWN: + number++; + if(number > 39) + number = 39; + break; + case SB_LINEUP: + number--; + if(number < 0) + number = 0; + break; + case SB_PAGEDOWN: + number += 16; + if(number > 39) + number = 39; + break; + case SB_PAGEUP: + number -= 16; + if(number < 0) + number = 0; + break; + case SB_TOP: + number = 0; + break; + case SB_THUMBTRACK: + number = nPos; + if(number < 0) + number = 0; + if(number > 39) + number = 39; + break; + } + + updateScrollInfo(); + + CString buffer; + buffer.Format("%d", number); + m_sprite.SetWindowText(buffer); + paint(); +} + +void GBOamView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/GBOamView.h b/src/win32/GBOamView.h new file mode 100644 index 0000000..663ade0 --- /dev/null +++ b/src/win32/GBOamView.h @@ -0,0 +1,103 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_) +#define AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBOamView.h : header file +// + +#include "BitmapControl.h" +#include "ZoomControl.h" +#include "ColorControl.h" + +#include "IUpdate.h" +#include "ResizeDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// GBOamView dialog + +class GBOamView : public ResizeDlg, IUpdateListener +{ + private: + BITMAPINFO bmpInfo; + u8 *data; + int w; + int h; + int number; + bool autoUpdate; + BitmapControl oamView; + ZoomControl oamZoom; + ColorControl color; + + + // Construction + public: + void updateScrollInfo(); + void save(); + void savePNG(const char *name); + void saveBMP(const char *name); + void render(); + void setAttributes(int y, int x, int tile, int flags); + void paint(); + ~GBOamView(); + GBOamView(CWnd* pParent = NULL); // standard constructor + + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual void update(); + + // Dialog Data + //{{AFX_DATA(GBOamView) + enum { IDD = IDD_GB_OAM_VIEW }; + CEdit m_sprite; + BOOL m_stretch; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBOamView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBOamView) + virtual BOOL OnInitDialog(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnChangeSprite(); + afx_msg void OnClose(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_) diff --git a/src/win32/GBPaletteView.cpp b/src/win32/GBPaletteView.cpp new file mode 100644 index 0000000..522ba15 --- /dev/null +++ b/src/win32/GBPaletteView.cpp @@ -0,0 +1,243 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBPaletteView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBPaletteView.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../gb/gbGlobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +void GBPaletteViewControl::updatePalette() +{ + if(gbRom) { + memcpy(palette, &gbPalette[paletteAddress], 64); + } +} + +///////////////////////////////////////////////////////////////////////////// +// GBPaletteView dialog + + +GBPaletteView::GBPaletteView(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBPaletteView::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBPaletteView) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + autoUpdate = false; +} + +GBPaletteView::~GBPaletteView() +{ +} + +void GBPaletteView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBPaletteView) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_PALETTE_VIEW, paletteView); + DDX_Control(pDX, IDC_PALETTE_VIEW_OBJ, paletteViewOBJ); + DDX_Control(pDX, IDC_COLOR, colorControl); +} + + +BEGIN_MESSAGE_MAP(GBPaletteView, CDialog) + //{{AFX_MSG_MAP(GBPaletteView) + ON_BN_CLICKED(IDC_SAVE_BG, OnSaveBg) + ON_BN_CLICKED(IDC_SAVE_OBJ, OnSaveObj) + ON_BN_CLICKED(IDC_REFRESH2, OnRefresh2) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_PALINFO, OnPalInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBPaletteView message handlers + +BOOL GBPaletteView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_END() + SetData(sz, + FALSE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBPaletteView", + NULL); + + paletteView.init(32, 64, 128); + paletteViewOBJ.init(32, 64, 128); + + paletteView.setPaletteAddress(0); + paletteView.refresh(); + + paletteViewOBJ.setPaletteAddress(32); + paletteViewOBJ.refresh(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBPaletteView::save(int which) +{ + CString captureBuffer; + + if(which == 0) + captureBuffer = "bg.pal"; + else + captureBuffer = "obj.pal"; + + LPCTSTR exts[] = {".pal", ".pal", ".act" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PAL); + CString title = winResLoadString(IDS_SELECT_PALETTE_NAME); + FileDlg dlg(this, + captureBuffer, + filter, + 1, + "PAL", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + PaletteViewControl *p = NULL; + + if(which == 0) + p = &paletteView; + else + p = &paletteViewOBJ; + + switch(dlg.getFilterIndex()) { + case 0: + case 1: + p->saveMSPAL(captureBuffer); + break; + case 2: + p->saveJASCPAL(captureBuffer); + break; + case 3: + p->saveAdobe(captureBuffer); + break; + } +} + + +void GBPaletteView::OnSaveBg() +{ + save(0); +} + +void GBPaletteView::OnSaveObj() +{ + save(1); +} + +void GBPaletteView::OnRefresh2() +{ + paletteView.refresh(); + paletteViewOBJ.refresh(); +} + +void GBPaletteView::update() +{ + OnRefresh2(); +} + + +void GBPaletteView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + + +void GBPaletteView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +LRESULT GBPaletteView::OnPalInfo(WPARAM wParam, LPARAM lParam) +{ + u16 color = (u16)wParam; + u32 address = (u32)lParam; + CString buffer; + + bool isOBJ = address >= 32; + address &= 31; + + buffer.Format("%d", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + int r = (color & 0x1f); + int g = (color & 0x3e0) >> 5; + int b = (color & 0x7c00) >> 10; + + buffer.Format("%d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("%d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("%d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + + buffer.Format("0x%04X", color); + GetDlgItem(IDC_VALUE)->SetWindowText(buffer); + + colorControl.setColor(color); + + if(isOBJ) + paletteView.setSelected(-1); + else + paletteViewOBJ.setSelected(-1); + + return TRUE; +} + +void GBPaletteView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/GBPaletteView.h b/src/win32/GBPaletteView.h new file mode 100644 index 0000000..0d2d71f --- /dev/null +++ b/src/win32/GBPaletteView.h @@ -0,0 +1,90 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_) +#define AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBPaletteView.h : header file +// + +#include "ColorControl.h" +#include "IUpdate.h" +#include "PaletteViewControl.h" +#include "ResizeDlg.h" + +class GBPaletteViewControl : public PaletteViewControl { + public: + virtual void updatePalette(); +}; + +///////////////////////////////////////////////////////////////////////////// +// GBPaletteView dialog + +class GBPaletteView : public ResizeDlg, IUpdateListener +{ + private: + GBPaletteViewControl paletteView; + GBPaletteViewControl paletteViewOBJ; + ColorControl colorControl; + bool autoUpdate; + // Construction + public: + void save(int which); + GBPaletteView(CWnd* pParent = NULL); // standard constructor + virtual ~GBPaletteView(); + + // Dialog Data + //{{AFX_DATA(GBPaletteView) + enum { IDD = IDD_GB_PALETTE_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBPaletteView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + virtual void update(); + + // Implementation + protected: + afx_msg virtual LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); + // Generated message map functions + //{{AFX_MSG(GBPaletteView) + virtual BOOL OnInitDialog(); + afx_msg void OnSaveBg(); + afx_msg void OnSaveObj(); + afx_msg void OnRefresh2(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_) diff --git a/src/win32/GBPrinterDlg.cpp b/src/win32/GBPrinterDlg.cpp new file mode 100644 index 0000000..9f28fdc --- /dev/null +++ b/src/win32/GBPrinterDlg.cpp @@ -0,0 +1,494 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBPrinter.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBPrinterDlg.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../NLS.h" +#include "../Util.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBPrinter dialog + + +GBPrinterDlg::GBPrinterDlg(CWnd* pParent /*=NULL*/) + : CDialog(GBPrinterDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBPrinterDlg) + m_scale = -1; + //}}AFX_DATA_INIT + bitmap = (BITMAPINFO *)bitmapHeader; + + bitmap->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmap->bmiHeader.biWidth = 160; + bitmap->bmiHeader.biHeight = -144; + bitmap->bmiHeader.biPlanes = 1; + bitmap->bmiHeader.biBitCount = 8; + bitmap->bmiHeader.biCompression = BI_RGB; + bitmap->bmiHeader.biSizeImage = 160*144; + bitmap->bmiHeader.biXPelsPerMeter = 0; + bitmap->bmiHeader.biYPelsPerMeter = 0; + bitmap->bmiHeader.biClrUsed = 4; + bitmap->bmiHeader.biClrImportant = 4; + bitmap->bmiColors[0].rgbBlue = + bitmap->bmiColors[0].rgbGreen = + bitmap->bmiColors[0].rgbRed = + 255; + bitmap->bmiColors[0].rgbReserved = 0; + bitmap->bmiColors[1].rgbBlue = + bitmap->bmiColors[1].rgbGreen = + bitmap->bmiColors[1].rgbRed = + 168; + bitmap->bmiColors[1].rgbReserved = 0; + bitmap->bmiColors[2].rgbBlue = + bitmap->bmiColors[2].rgbGreen = + bitmap->bmiColors[2].rgbRed = + 96; + bitmap->bmiColors[2].rgbReserved = 0; + bitmap->bmiColors[3].rgbBlue = + bitmap->bmiColors[3].rgbGreen = + bitmap->bmiColors[3].rgbRed = + 0; + bitmap->bmiColors[3].rgbReserved = 0; +} + + +void GBPrinterDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBPrinterDlg) + DDX_Radio(pDX, IDC_1X, m_scale); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GBPrinterDlg, CDialog) + //{{AFX_MSG_MAP(GBPrinterDlg) + ON_BN_CLICKED(ID_SAVE, OnSave) + ON_BN_CLICKED(ID_PRINT, OnPrint) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(IDC_1X, On1x) + ON_BN_CLICKED(IDC_2X, On2x) + ON_BN_CLICKED(IDC_3X, On3x) + ON_BN_CLICKED(IDC_4X, On4x) + ON_WM_PAINT() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBPrinter message handlers + +void GBPrinterDlg::saveAsBMP(const char *name) +{ + u8 writeBuffer[512 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + 160*144*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, 160); + utilPutDword(bmpheader.height, 144); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 160*144); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + u8 *data = (u8 *)bitmapData; + u8 *p = data + (160*143); + for(int y = 0; y < 144; y++) { + for(int x = 0; x < 160; x++) { + u8 c = *p++; + + *b++ = bitmap->bmiColors[c].rgbBlue; + *b++ = bitmap->bmiColors[c].rgbGreen; + *b++ = bitmap->bmiColors[c].rgbRed; + } + p -= 2*(160); + fwrite(writeBuffer, 1, 3*160, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + +void GBPrinterDlg::saveAsPNG(const char *name) +{ + u8 writeBuffer[160 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", + name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + 160, + 144, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = 160; + int sizeY = 144; + + u8 *pixU8 = (u8 *)bitmapData; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u8 c = *pixU8++; + *b++ = bitmap->bmiColors[c].rgbRed; + *b++ = bitmap->bmiColors[c].rgbGreen; + *b++ = bitmap->bmiColors[c].rgbBlue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + + +void GBPrinterDlg::OnSave() +{ + CString captureBuffer; + + if(theApp.captureFormat == 0) + captureBuffer = "printer.png"; + else + captureBuffer = "printer.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + captureBuffer, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + captureBuffer = dlg.GetPathName(); + + if(dlg.getFilterIndex() == 2) + saveAsBMP(captureBuffer); + else + saveAsPNG(captureBuffer); +} + +void GBPrinterDlg::OnPrint() +{ + CPrintDialog dlg(FALSE); + + dlg.m_pd.nFromPage = 1; + dlg.m_pd.nToPage = 1; + dlg.m_pd.nMinPage = 1; + dlg.m_pd.nMaxPage = 1; + dlg.m_pd.nCopies = 1; + + if(dlg.DoModal() == IDOK) { + DOCINFO di; + float fLogPelsX1 = 0; + float fLogPelsX2 = 0; + float fLogPelsY1 = 0; + float fLogPelsY2 = 0; + float fScaleX = 0, fScaleY = 0; + CDC *winDC = NULL; + memset(&di, 0, sizeof(di)); + di.cbSize = sizeof(DOCINFO); + CString docName = winResLoadString(IDS_POCKET_PRINTER); + di.lpszDocName = docName; + CDC dc; + dc.Attach(dlg.GetPrinterDC()); + int nError = dc.StartDoc(&di); + + if(nError == SP_ERROR) { + systemMessage(IDS_ERROR_ON_STARTDOC,"Error on StartDoc"); + goto error; + } + nError = dc.StartPage(); + if(nError <= 0) { + systemMessage(IDS_ERROR_ON_STARTPAGE, "Error on StartPage"); + goto error; + } + + winDC = GetDC(); + fLogPelsX1 = (float)winDC->GetDeviceCaps(LOGPIXELSX); + fLogPelsY1 = (float)winDC->GetDeviceCaps(LOGPIXELSY); + ReleaseDC(winDC); + + fLogPelsX2 = (float)dc.GetDeviceCaps(LOGPIXELSX); + fLogPelsY2 = (float)dc.GetDeviceCaps(LOGPIXELSY); + + if(fLogPelsX1 > fLogPelsX2) + fScaleX = fLogPelsX1 / fLogPelsX2; + else + fScaleX = fLogPelsX2 / fLogPelsX1; + + if(fLogPelsY1 > fLogPelsY2) + fScaleY = fLogPelsY1 / fLogPelsY2; + else + fScaleY = fLogPelsY2 / fLogPelsY1; + + fScaleX *= (scale+1); + fScaleY *= (scale+1); + + if(StretchDIBits(dc, + 0, + 0, + (int)((float)160*fScaleX), + (int)((float)144*fScaleY), + 0, + 0, + 160, + 144, + bitmapData, + bitmap, + DIB_RGB_COLORS, + SRCCOPY) == GDI_ERROR) { + systemMessage(IDS_ERROR_PRINTING_ON_STRETCH, + "Error printing on StretchDIBits"); + } + + nError = dc.EndPage(); + + if(nError <= 0) { + systemMessage(IDS_ERROR_ON_ENDPAGE, "Error on EndPage"); + goto error; + } + + nError = dc.EndDoc(); + + if(nError <= 0) + systemMessage(IDS_ERROR_ON_ENDDOC, "Error on EndDoc"); + error: + dc.DeleteDC(); + } +} + +void GBPrinterDlg::processData(u8 *data) +{ + for(int y = 0; y < 0x12; y++) { + for(int x = 0; x < 0x14; x++) { + for(int k = 0; k < 8; k++) { + int a = *data++; + int b = *data++; + for(int j = 0; j < 8; j++) { + int mask = 1 << (7-j); + int c = 0; + if(a & mask) + c++; + if(b & mask) + c+=2; + bitmapData[x*8+j + 160*(y*8+k)] = c; + } + } + } + } +} + + +BOOL GBPrinterDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + scale = regQueryDwordValue("printerScale", 0); + if(scale < 0 || scale > 3) + scale = 0; + m_scale = scale; + UpdateData(FALSE); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBPrinterDlg::OnOk() +{ + EndDialog(TRUE); +} + +void GBPrinterDlg::On1x() +{ + regSetDwordValue("printerScale", 0); + scale = 0; +} + +void GBPrinterDlg::On2x() +{ + regSetDwordValue("printerScale", 1); + scale = 1; +} + +void GBPrinterDlg::On3x() +{ + regSetDwordValue("printerScale", 2); + scale = 2; +} + +void GBPrinterDlg::On4x() +{ + regSetDwordValue("printerScale", 3); + scale = 3; +} + +void GBPrinterDlg::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + RECT rect; + CWnd *h = GetDlgItem(IDC_GB_PRINTER); + h->GetWindowRect(&rect); + POINT p; + p.x = rect.left; + p.y = rect.top; + ScreenToClient((POINT *)&p); + rect.left = p.x+1; + rect.top = p.y+1; + p.x = rect.right; + p.y = rect.bottom; + ScreenToClient((POINT *)&p); + rect.right = p.x-1; + rect.bottom = p.y-1; + + StretchDIBits(dc, + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + 0, + 0, + 160, + 144, + bitmapData, + bitmap, + DIB_RGB_COLORS, + SRCCOPY); +} + +void systemGbPrint(u8 *data, + int pages, + int feed, + int palette, + int contrast) +{ + theApp.winCheckFullscreen(); + GBPrinterDlg printer; + printer.processData(data); + printer.DoModal(); +} + diff --git a/src/win32/GBPrinterDlg.h b/src/win32/GBPrinterDlg.h new file mode 100644 index 0000000..506de51 --- /dev/null +++ b/src/win32/GBPrinterDlg.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_) +#define AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBPrinter.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// GBPrinter dialog + +class GBPrinterDlg : public CDialog +{ + private: + u8 bitmapHeader[sizeof(BITMAPINFO)+4*sizeof(RGBQUAD)]; + BITMAPINFO *bitmap; + u8 bitmapData[160*144]; + int scale; + // Construction + public: + void processData(u8 *data); + void saveAsPNG(const char *name); + void saveAsBMP(const char *name); + GBPrinterDlg(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GBPrinterDlg) + enum { IDD = IDD_GB_PRINTER }; + int m_scale; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBPrinterDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GBPrinterDlg) + afx_msg void OnSave(); + afx_msg void OnPrint(); + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void On1x(); + afx_msg void On2x(); + afx_msg void On3x(); + afx_msg void On4x(); + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_) diff --git a/src/win32/GBTileView.cpp b/src/win32/GBTileView.cpp new file mode 100644 index 0000000..69bbe32 --- /dev/null +++ b/src/win32/GBTileView.cpp @@ -0,0 +1,524 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GBTileView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "GBTileView.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../NLS.h" +#include "../Util.h" +#include "../gb/gbGlobals.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GBTileView dialog + + +GBTileView::GBTileView(CWnd* pParent /*=NULL*/) + : ResizeDlg(GBTileView::IDD, pParent) +{ + //{{AFX_DATA_INIT(GBTileView) + m_charBase = -1; + m_bank = -1; + m_stretch = FALSE; + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo, 0, sizeof(bmpInfo)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 32*8; + bmpInfo.bmiHeader.biHeight = 32*8; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 32*32 * 64); + + tileView.setData(data); + tileView.setBmpInfo(&bmpInfo); + + charBase = 0; + palette = 0; + bank = 0; + w = h = 0; +} + +GBTileView::~GBTileView() +{ + free(data); + data = NULL; +} + +void GBTileView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GBTileView) + DDX_Control(pDX, IDC_PALETTE_SLIDER, m_slider); + DDX_Radio(pDX, IDC_CHARBASE_0, m_charBase); + DDX_Radio(pDX, IDC_BANK_0, m_bank); + DDX_Check(pDX, IDC_STRETCH, m_stretch); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_TILE_VIEW, tileView); + DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, zoom); + DDX_Control(pDX, IDC_COLOR, color); +} + + +BEGIN_MESSAGE_MAP(GBTileView, CDialog) + //{{AFX_MSG_MAP(GBTileView) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_CHARBASE_0, OnCharbase0) + ON_BN_CLICKED(IDC_CHARBASE_1, OnCharbase1) + ON_BN_CLICKED(IDC_BANK_0, OnBank0) + ON_BN_CLICKED(IDC_BANK_1, OnBank1) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_WM_HSCROLL() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GBTileView message handlers + +void GBTileView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + +void GBTileView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + + +void GBTileView::OnSave() +{ + CString captureBuffer; + + if(theApp.captureFormat == 0) + captureBuffer = "tiles.png"; + else + captureBuffer = "tiles.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + captureBuffer, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + captureBuffer = dlg.GetPathName(); + + if(theApp.captureFormat) + saveBMP(captureBuffer); + else + savePNG(captureBuffer); +} + +void GBTileView::renderTile(int tile, int x, int y, u8 *charBase) +{ + u8 *bmp = &data[24*x + 8*16*24*y]; + + for(int j = 0; j < 8; j++) { + u8 mask = 0x80; + u8 tile_a = charBase[tile*16+j*2]; + u8 tile_b = charBase[tile*16+j*2+1]; + + for(int i = 0; i < 8; i++) { + u8 c = (tile_a & mask) ? 1 : 0; + c += ((tile_b & mask) ? 2 : 0); + + if(gbCgbMode) { + c = c + palette*4; + } else { + c = gbBgp[c]; + } + + u16 color = gbPalette[c]; + + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + + mask >>= 1; + } + bmp += 15*24; // advance line + } +} + + +void GBTileView::render() +{ + int tiles = 0x0000; + if(charBase) + tiles = 0x0800; + u8 *charBase = (gbVram != NULL) ? + (bank ? &gbVram[0x2000+tiles] : &gbVram[tiles]) : + &gbMemory[0x8000+tiles]; + + int tile = 0; + for(int y = 0; y < 16; y++) { + for(int x = 0; x < 16; x++) { + renderTile(tile, x, y, charBase); + tile++; + } + } + tileView.setSize(16*8, 16*8); + w = 16*8; + h = 16*8; + SIZE s; + s.cx = s.cy = 16*8; + if(tileView.getStretch()) { + s.cx = s.cy = 1; + } + tileView.SetScrollSizes(MM_TEXT, s); +} + +void GBTileView::update() +{ + paint(); +} + + +BOOL GBTileView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_TILE_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\GBTileView", + NULL); + + m_charBase = charBase; + m_bank = bank; + + m_slider.SetRange(0, 7); + m_slider.SetPageSize(2); + m_slider.SetTicFreq(1); + paint(); + + m_stretch = regQueryDwordValue("tileViewStretch", 0); + if(m_stretch) + tileView.setStretch(true); + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GBTileView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + + +void GBTileView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void GBTileView::paint() +{ + if(gbRom != NULL) { + render(); + tileView.refresh(); + } +} + +void GBTileView::OnCharbase0() +{ + charBase = 0; + paint(); +} + +void GBTileView::OnCharbase1() +{ + charBase = 1; + paint(); +} + +void GBTileView::OnBank0() +{ + bank = 0; + paint(); +} + +void GBTileView::OnBank1() +{ + bank = 1; + paint(); +} + + +void GBTileView::OnStretch() +{ + tileView.setStretch(!tileView.getStretch()); + paint(); + regSetDwordValue("tileViewStretch", tileView.getStretch()); +} + +LRESULT GBTileView::OnMapInfo(WPARAM wParam, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + zoom.setColors(colors); + + int x = (wParam & 0xFFFF)/8; + int y = ((wParam >> 16) & 0xFFFF)/8; + + int tiles = 0x0000; + if(charBase) + tiles = 0x0800; + u32 address = 0x8000 + tiles; + int tile = 16 * y + x; + + address += 16 * tile; + + CString buffer; + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE_NUMBER)->SetWindowText(buffer); + + buffer.Format("%04x", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + return TRUE; +} + +LRESULT GBTileView::OnColInfo(WPARAM wParam, LPARAM) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + +void GBTileView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + switch(nSBCode) { + case TB_THUMBPOSITION: + palette = nPos; + break; + default: + palette = m_slider.GetPos(); + break; + } + paint(); +} + + +void GBTileView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/GBTileView.h b/src/win32/GBTileView.h new file mode 100644 index 0000000..7e72c5e --- /dev/null +++ b/src/win32/GBTileView.h @@ -0,0 +1,104 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_) +#define AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GBTileView.h : header file +// +#include "BitmapControl.h" +#include "ColorControl.h" +#include "IUpdate.h" +#include "ResizeDlg.h" +#include "ZoomControl.h" + +///////////////////////////////////////////////////////////////////////////// +// GBTileView dialog + +class GBTileView : public ResizeDlg, IUpdateListener +{ + int charBase; + int palette; + int bank; + BitmapControl tileView; + BITMAPINFO bmpInfo; + u8 *data; + ZoomControl zoom; + ColorControl color; + int w; + int h; + bool autoUpdate; + // Construction + public: + void paint(); + void render(); + void renderTile(int tile, int x, int y, u8 *charBase); + void savePNG(const char *name); + void saveBMP(const char *name); + GBTileView(CWnd* pParent = NULL); // standard constructor + virtual ~GBTileView(); + + virtual void update(); + + // Dialog Data + //{{AFX_DATA(GBTileView) + enum { IDD = IDD_GB_TILE_VIEWER }; + CSliderCtrl m_slider; + int m_charBase; + int m_bank; + BOOL m_stretch; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBTileView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + + // Generated message map functions + //{{AFX_MSG(GBTileView) + afx_msg void OnSave(); + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnAutoUpdate(); + afx_msg void OnCharbase0(); + afx_msg void OnCharbase1(); + afx_msg void OnBank0(); + afx_msg void OnBank1(); + afx_msg void OnStretch(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_) diff --git a/src/win32/GDBConnection.cpp b/src/win32/GDBConnection.cpp new file mode 100644 index 0000000..af03869 --- /dev/null +++ b/src/win32/GDBConnection.cpp @@ -0,0 +1,261 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GDBConnection.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GDBConnection.h" + +#include + +#define SOCKET_MESSAGE WM_APP+1 + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static bool initialized = false; + +///////////////////////////////////////////////////////////////////////////// +// GDBPortDlg dialog + + +GDBPortDlg::GDBPortDlg(CWnd* pParent /*=NULL*/) + : CDialog(GDBPortDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(GDBPortDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + port = 55555; + sock = INVALID_SOCKET; + + if(!initialized) { + WSADATA wsaData; + + int error = WSAStartup(MAKEWORD(1,1), &wsaData); + + initialized = true; + } +} + + +void GDBPortDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GDBPortDlg) + DDX_Control(pDX, IDC_PORT, m_port); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GDBPortDlg, CDialog) + //{{AFX_MSG_MAP(GDBPortDlg) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_WM_CLOSE() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GDBPortDlg message handlers + +int GDBPortDlg::getPort() +{ + return port; +} + + +SOCKET GDBPortDlg::getSocket() +{ + return sock; +} + + +BOOL GDBPortDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString buffer; + + buffer.Format("%d", port); + + m_port.SetWindowText(buffer); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void GDBPortDlg::OnOk() +{ + CString buffer; + + m_port.GetWindowText(buffer); + + sockaddr_in address; + address.sin_family = AF_INET; + address.sin_addr.s_addr = inet_addr("0.0.0.0"); + address.sin_port = htons(atoi(buffer)); + port = ntohs(address.sin_port); + + SOCKET s = socket(AF_INET, SOCK_STREAM, 0); + + if(s != INVALID_SOCKET) { + int error = bind(s, (sockaddr *)&address, sizeof(address)); + + if(error) { + systemMessage(IDS_ERROR_BINDING, "Error binding socket. Port probably in use."); + error = closesocket(s); + EndDialog(FALSE); + } else { + error = listen(s, 1); + if(!error) { + sock = s; + EndDialog(TRUE); + } else { + systemMessage(IDS_ERROR_LISTENING, "Error listening on socket."); + closesocket(s); + EndDialog(FALSE); + } + } + } else { + systemMessage(IDS_ERROR_CREATING_SOCKET, "Error creating socket."); + EndDialog(FALSE); + } +} + +void GDBPortDlg::OnCancel() +{ + OnClose(); +} + +void GDBPortDlg::OnClose() +{ + EndDialog(FALSE); +} +///////////////////////////////////////////////////////////////////////////// +// GDBWaitingDlg dialog + + +GDBWaitingDlg::GDBWaitingDlg(SOCKET s, int p, CWnd* pParent /*=NULL*/) + : CDialog(GDBWaitingDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(GDBWaitingDlg) + //}}AFX_DATA_INIT + port = p & 65535; + listenSocket = s; +} + + +void GDBWaitingDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GDBWaitingDlg) + DDX_Control(pDX, IDC_PORT, m_port); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GDBWaitingDlg, CDialog) + //{{AFX_MSG_MAP(GDBWaitingDlg) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_WM_CLOSE() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GDBWaitingDlg message handlers + +BOOL GDBWaitingDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString buffer; + + buffer.Format("%d", port); + + m_port.SetWindowText(buffer); + + CenterWindow(); + + int error = WSAAsyncSelect(listenSocket, + (HWND )*this, + SOCKET_MESSAGE, + FD_ACCEPT); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +LRESULT GDBWaitingDlg::OnSocketAccept(WPARAM wParam, LPARAM lParam) +{ + if(LOWORD(lParam) == FD_ACCEPT) { + WSAAsyncSelect(listenSocket, (HWND)*this, 0, 0); + + int flag = 0; + ioctlsocket(listenSocket, FIONBIO, (unsigned long *)&flag); + + SOCKET s = accept(listenSocket, NULL, NULL); + if(s != INVALID_SOCKET) { + char dummy; + recv(s, &dummy, 1, 0); + if(dummy != '+') { + systemMessage(IDS_ACK_NOT_RECEIVED, "ACK not received from GDB."); + OnClose(); // calls EndDialog + } else { + sock = s; + EndDialog(TRUE); + } + } + } + + return TRUE; +} + +void GDBWaitingDlg::OnCancel() +{ + OnClose(); +} + +void GDBWaitingDlg::OnClose() +{ + if(sock != INVALID_SOCKET) { + closesocket(sock); + sock = INVALID_SOCKET; + } + if(listenSocket != INVALID_SOCKET) { + closesocket(listenSocket); + listenSocket = INVALID_SOCKET; + } + EndDialog(FALSE); +} + +SOCKET GDBWaitingDlg::getListenSocket() +{ + return listenSocket; +} + +SOCKET GDBWaitingDlg::getSocket() +{ + return sock; +} diff --git a/src/win32/GDBConnection.h b/src/win32/GDBConnection.h new file mode 100644 index 0000000..f82ac0e --- /dev/null +++ b/src/win32/GDBConnection.h @@ -0,0 +1,114 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_) +#define AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GDBConnection.h : header file +// + +#include + +///////////////////////////////////////////////////////////////////////////// +// GDBPortDlg dialog + +class GDBPortDlg : public CDialog +{ + int port; + SOCKET sock; + // Construction + public: + SOCKET getSocket(); + int getPort(); + GDBPortDlg(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GDBPortDlg) + enum { IDD = IDD_GDB_PORT }; + CEdit m_port; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GDBPortDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GDBPortDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void OnCancel(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// +// GDBWaitingDlg dialog + +class GDBWaitingDlg : public CDialog +{ + int port; + SOCKET listenSocket; + SOCKET sock; + // Construction + public: + SOCKET getSocket(); + SOCKET getListenSocket(); + afx_msg LRESULT OnSocketAccept(WPARAM wParam, LPARAM lParam); + GDBWaitingDlg(SOCKET s,int p, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GDBWaitingDlg) + enum { IDD = IDD_GDB_WAITING }; + CStatic m_port; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GDBWaitingDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GDBWaitingDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_) diff --git a/src/win32/GDIDisplay.cpp b/src/win32/GDIDisplay.cpp new file mode 100644 index 0000000..8a6f93a --- /dev/null +++ b/src/win32/GDIDisplay.cpp @@ -0,0 +1,490 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include + +#include "../System.h" +#include "../gb/gbGlobals.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Text.h" + +#include "VBA.h" +#include "MainWnd.h" +#include "Reg.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern void winlog(const char *,...); +extern int RGB_LOW_BITS_MASK; +extern int Init_2xSaI(u32); +extern int systemSpeed; + +class GDIDisplay : public IDisplay { +private: + u8 *filterData; + u8 info[sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD)]; + +public: + GDIDisplay(); + virtual ~GDIDisplay(); + + virtual bool initialize(); + virtual void cleanup(); + virtual void render(); + virtual void checkFullScreen(); + virtual void renderMenu(); + virtual void clear(); + virtual DISPLAY_TYPE getType() { return GDI; }; + virtual void setOption(const char *, int) {} + virtual bool isSkinSupported() { return true; } + virtual int selectFullScreenMode(GUID **); +}; + +static int calculateShift(u32 mask) +{ + int m = 0; + + while(mask) { + m++; + mask >>= 1; + } + + return m-5; +} + +GDIDisplay::GDIDisplay() +{ + filterData = (u8 *)malloc(4*4*256*240); +} + +GDIDisplay::~GDIDisplay() +{ + cleanup(); +} + +void GDIDisplay::cleanup() +{ + if(filterData) { + free(filterData); + filterData = NULL; + } +} + +bool GDIDisplay::initialize() +{ + theApp.sizeX = 240; + theApp.sizeY = 160; + switch(theApp.videoOption) { + case VIDEO_1X: + theApp.surfaceSizeX = theApp.sizeX; + theApp.surfaceSizeY = theApp.sizeY; + break; + case VIDEO_2X: + theApp.surfaceSizeX = theApp.sizeX * 2; + theApp.surfaceSizeY = theApp.sizeY * 2; + break; + case VIDEO_3X: + theApp.surfaceSizeX = theApp.sizeX * 3; + theApp.surfaceSizeY = theApp.sizeY * 3; + break; + case VIDEO_4X: + theApp.surfaceSizeX = theApp.sizeX * 4; + theApp.surfaceSizeY = theApp.sizeY * 4; + break; + case VIDEO_320x240: + case VIDEO_640x480: + case VIDEO_800x600: + case VIDEO_OTHER: + { + int scaleX = (theApp.fsWidth / theApp.sizeX); + int scaleY = (theApp.fsHeight / theApp.sizeY); + int min = scaleX < scaleY ? scaleX : scaleY; + if(theApp.fsMaxScale) + min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min; + theApp.surfaceSizeX = theApp.sizeX * min; + theApp.surfaceSizeY = theApp.sizeY * min; + if(theApp.fullScreenStretch) { + theApp.surfaceSizeX = theApp.fsWidth; + theApp.surfaceSizeY = theApp.fsHeight; + } + } + break; + } + + theApp.rect.left = 0; + theApp.rect.top = 0; + theApp.rect.right = theApp.sizeX; + theApp.rect.bottom = theApp.sizeY; + + theApp.dest.left = 0; + theApp.dest.top = 0; + theApp.dest.right = theApp.surfaceSizeX; + theApp.dest.bottom = theApp.surfaceSizeY; + + DWORD style = WS_POPUP | WS_VISIBLE; + DWORD styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + style |= WS_OVERLAPPEDWINDOW; + else + styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx); + else + AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx); + + int winSizeX = theApp.dest.right-theApp.dest.left; + int winSizeY = theApp.dest.bottom-theApp.dest.top; + + if(theApp.videoOption > VIDEO_4X) { + winSizeX = theApp.fsWidth; + winSizeY = theApp.fsHeight; + } + + int x = 0; + int y = 0; + + if(theApp.videoOption <= VIDEO_4X) { + x = theApp.windowPositionX; + y = theApp.windowPositionY; + } + + // Create a window + MainWnd *pWnd = new MainWnd; + theApp.m_pMainWnd = pWnd; + + pWnd->CreateEx(styleEx, + theApp.wndClass, + "VisualBoyAdvance", + style, + x,y,winSizeX,winSizeY, + NULL, + 0); + + if (!(HWND)*pWnd) { + winlog("Error creating Window %08x\n", GetLastError()); + return FALSE; + } + + theApp.updateMenuBar(); + + theApp.adjustDestRect(); + + theApp.mode320Available = false; + theApp.mode640Available = false; + theApp.mode800Available = false; + + HDC dc = GetDC(NULL); + HBITMAP hbm = CreateCompatibleBitmap(dc, 1, 1); + BITMAPINFO *bi = (BITMAPINFO *)info; + ZeroMemory(bi, sizeof(info)); + bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS); + GetDIBits(dc, hbm, 0, 1, NULL, (LPBITMAPINFO)info, DIB_RGB_COLORS); + DeleteObject(hbm); + ReleaseDC(NULL, dc); + + if(bi->bmiHeader.biCompression == BI_BITFIELDS) { + systemColorDepth = bi->bmiHeader.biBitCount; + if(systemColorDepth == 15) + systemColorDepth = 16; + systemRedShift = calculateShift(*((DWORD *)&bi->bmiColors[0])); + systemGreenShift = calculateShift(*((DWORD *)&bi->bmiColors[1])); + systemBlueShift = calculateShift(*((DWORD *)&bi->bmiColors[2])); + if(systemColorDepth == 16) { + if(systemGreenShift == 6) { + Init_2xSaI(565); + RGB_LOW_BITS_MASK=0x821; + } else { + Init_2xSaI(555); + RGB_LOW_BITS_MASK=0x421; + } + } else if(systemColorDepth == 32) + Init_2xSaI(32); + } else { + systemColorDepth = 32; + systemRedShift = 19; + systemGreenShift = 11; + systemBlueShift = 3; + + Init_2xSaI(32); + } + theApp.fsColorDepth = systemColorDepth; + if(systemColorDepth == 24) + theApp.filterFunction = NULL; +#ifdef MMX + if(!theApp.disableMMX) + cpu_mmx = theApp.detectMMX(); + else + cpu_mmx = 0; +#endif + + switch(systemColorDepth) { + case 16: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + case 24: + case 32: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + } + theApp.updateFilter(); + theApp.updateIFB(); + + pWnd->DragAcceptFiles(TRUE); + + return TRUE; +} + +void GDIDisplay::clear() +{ +} + +void GDIDisplay::renderMenu() +{ + checkFullScreen(); + theApp.m_pMainWnd->DrawMenuBar(); +} + +void GDIDisplay::checkFullScreen() +{ +} + +void GDIDisplay::render() +{ + void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = theApp.filterFunction; + int filterWidth = theApp.filterWidth, filterHeight = theApp.filterHeight; +/* + if(textMethod == 1) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + extern void Simple1x(u8*,u32,u8*,u8*,u32,int,int); + filterFunction = Simple1x; + filterWidth = copyX*2; + filterHeight = copyY*2; + } +*/ + BITMAPINFO *bi = (BITMAPINFO *)info; + bi->bmiHeader.biWidth = filterWidth+1; + bi->bmiHeader.biHeight = -filterHeight; + + int pitch = filterWidth * 2 + 4; + if(systemColorDepth == 24) + pitch = filterWidth * 3; + else if(systemColorDepth == 32) + pitch = filterWidth * 4 + 4; + + if(textMethod == 1 && !filterFunction) + { + textMethod = 0; // must not be after systemMessage! + systemMessage(0,"The \"On Game\" text display mode does not work with this combination of renderers and filters.\nThe display mode is automatically being changed to \"In Game\" instead,\nbut this may cause message text to go into AVI recordings and screenshots.\nThis can be reconfigured by choosing \"Options->Video->Text Display Options...\""); + } + + if(textMethod == 0) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + DrawTextMessages((u8*)pix, copyX*(systemColorDepth/8)+(systemColorDepth==24?0:4), 0, copyY); + } + + if(filterFunction) { + bi->bmiHeader.biWidth = filterWidth * 2; + bi->bmiHeader.biHeight = -filterHeight * 2; + + if(systemColorDepth == 16) + (*filterFunction)(pix+pitch, + pitch, + (u8*)theApp.delta, + (u8*)filterData, + filterWidth*2*2, + filterWidth, + filterHeight); + else + (*filterFunction)(pix+pitch, + pitch, + (u8*)theApp.delta, + (u8*)filterData, + filterWidth*4*2, + filterWidth, + filterHeight); + } + + if(theApp.showSpeed && (theApp.videoOption > VIDEO_4X || theApp.skin != NULL)) { + char buffer[30]; + if(theApp.showSpeed == 1) + sprintf(buffer, "%3d%%", systemSpeed); + else + sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + theApp.showRenderedFrames); + + if(filterFunction) { + int p = filterWidth * 4; + if(systemColorDepth == 24) + p = filterWidth * 6; + else if(systemColorDepth == 32) + p = filterWidth * 8; + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)filterData, + p, + 10, + filterHeight*2-10, + buffer); + else + drawText((u8*)filterData, + p, + 10, + filterHeight*2-10, + buffer); + } else { + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)pix, + pitch, + 10, + filterHeight-10, + buffer); + else + drawText((u8*)pix, + pitch, + 10, + filterHeight-10, + buffer); + } + } + if(textMethod == 1 && filterFunction) + DrawTextMessages((u8*)filterData, filterWidth*systemColorDepth/4, 0, filterHeight*2); + + POINT p; + p.x = theApp.dest.left; + p.y = theApp.dest.top; + CWnd *pWnd = theApp.m_pMainWnd; + pWnd->ScreenToClient(&p); + POINT p2; + p2.x = theApp.dest.right; + p2.y = theApp.dest.bottom; + pWnd->ScreenToClient(&p2); + + CDC *dc = pWnd->GetDC(); + + StretchDIBits((HDC)*dc, + p.x, + p.y, + p2.x - p.x, + p2.y - p.y, + 0, + 0, + theApp.rect.right, + theApp.rect.bottom, + filterFunction ? filterData : pix+pitch, + bi, + DIB_RGB_COLORS, + SRCCOPY); + + if(textMethod == 2) + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2)) { + dc->SetBkMode(TRANSPARENT); + + if(outlinedText) + { + dc->SetTextColor(textColor != 7 ? RGB(0,0,0) : RGB(255,255,255)); + + // draw black outline + const static int xd [8] = {-1,0,1,1,1,0,-1,-1}; + const static int yd [8] = {-1,-1,-1,0,1,1,1,0}; + for(int i = 0 ; i < 8 ; i++) + { + dc->TextOut(p.x+10+xd[i], p2.y - 20*(slot+1)+yd[i], theApp.screenMessageBuffer[slot]); + } + } + + COLORREF color; + switch(textColor) + { + case 0: color = RGB(255, 255, 255); break; + case 1: color = RGB(255, 0, 0); break; + case 2: color = RGB(255, 255, 0); break; + case 3: color = RGB(0, 255, 0); break; + case 4: color = RGB(0, 255, 255); break; + case 5: color = RGB(0, 0, 255); break; + case 6: color = RGB(255, 0, 255); break; + case 7: color = RGB(0, 0, 0); break; + } + dc->SetTextColor(color); + + // draw center text + dc->TextOut(p.x+10, p2.y - 20*(slot+1), theApp.screenMessageBuffer[slot]); + } else { + theApp.screenMessage[slot] = false; + } + } + } + + + pWnd->ReleaseDC(dc); +} + +int GDIDisplay::selectFullScreenMode(GUID **) +{ + HWND wnd = GetDesktopWindow(); + RECT r; + GetWindowRect(wnd, &r); + int w = (r.right - r.left) & 4095; + int h = (r.bottom - r.top) & 4095; + HDC dc = GetDC(wnd); + int c = GetDeviceCaps(dc, BITSPIXEL); + ReleaseDC(wnd, dc); + + return (c << 24) | (w << 12) | h; +} + +IDisplay *newGDIDisplay() +{ + return new GDIDisplay(); +} + diff --git a/src/win32/GSACodeSelect.cpp b/src/win32/GSACodeSelect.cpp new file mode 100644 index 0000000..78e3b60 --- /dev/null +++ b/src/win32/GSACodeSelect.cpp @@ -0,0 +1,120 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// GSACodeSelect.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "GSACodeSelect.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// GSACodeSelect dialog + + +GSACodeSelect::GSACodeSelect(FILE *file, CWnd* pParent /*=NULL*/) + : CDialog(GSACodeSelect::IDD, pParent) +{ + //{{AFX_DATA_INIT(GSACodeSelect) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_file = file; +} + + +void GSACodeSelect::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(GSACodeSelect) + DDX_Control(pDX, IDC_GAME_LIST, m_games); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(GSACodeSelect, CDialog) + //{{AFX_MSG_MAP(GSACodeSelect) + ON_BN_CLICKED(ID_OK, OnOk) + ON_LBN_SELCHANGE(IDC_GAME_LIST, OnSelchangeGameList) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// GSACodeSelect message handlers + +void GSACodeSelect::OnCancel() +{ + EndDialog(-1); +} + +void GSACodeSelect::OnOk() +{ + EndDialog(m_games.GetCurSel()); +} + +void GSACodeSelect::OnSelchangeGameList() +{ + int item = m_games.GetCurSel(); + CWnd *ok = GetDlgItem(ID_OK); + + ok->EnableWindow(item != -1); +} + +BOOL GSACodeSelect::OnInitDialog() +{ + CDialog::OnInitDialog(); + + char buffer[1024]; + + FILE *f = m_file; + int games = 0; + int len = 0; + fseek(f, -4, SEEK_CUR); + fread(&games, 1, 4, f); + while(games > 0) { + fread(&len, 1, 4, f); + fread(buffer, 1, len, f); + buffer[len] = 0; + m_games.AddString(buffer); + int codes = 0; + fread(&codes, 1, 4, f); + + while(codes > 0) { + fread(&len, 1, 4, f); + fseek(f, len, SEEK_CUR); + fread(&len, 1, 4, f); + fseek(f, len, SEEK_CUR); + fseek(f, 4, SEEK_CUR); + fread(&len, 1, 4, f); + fseek(f, len*12, SEEK_CUR); + codes--; + } + games--; + } + GetDlgItem(ID_OK)->EnableWindow(FALSE); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/GSACodeSelect.h b/src/win32/GSACodeSelect.h new file mode 100644 index 0000000..8eeafa0 --- /dev/null +++ b/src/win32/GSACodeSelect.h @@ -0,0 +1,69 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_) +#define AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// GSACodeSelect.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// GSACodeSelect dialog + +class GSACodeSelect : public CDialog +{ + // Construction + public: + GSACodeSelect(FILE *file, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(GSACodeSelect) + enum { IDD = IDD_CODE_SELECT }; + CListBox m_games; + //}}AFX_DATA + FILE *m_file; + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GSACodeSelect) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(GSACodeSelect) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnSelchangeGameList(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_) diff --git a/src/win32/Hyperlink.cpp b/src/win32/Hyperlink.cpp new file mode 100644 index 0000000..05770d6 --- /dev/null +++ b/src/win32/Hyperlink.cpp @@ -0,0 +1,118 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Hyperlink.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Hyperlink.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// Hyperlink + +Hyperlink::Hyperlink() +{ + m_over = false; +} + +Hyperlink::~Hyperlink() +{ + m_underlineFont.DeleteObject(); +} + + +BEGIN_MESSAGE_MAP(Hyperlink, CStatic) + //{{AFX_MSG_MAP(Hyperlink) + ON_WM_CTLCOLOR_REFLECT() + ON_WM_ERASEBKGND() + ON_WM_MOUSEMOVE() + //}}AFX_MSG_MAP + ON_CONTROL_REFLECT(STN_CLICKED, OnClicked) +END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Hyperlink message handlers + +void Hyperlink::PreSubclassWindow() +{ + DWORD dwStyle = GetStyle(); + ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); + + // 32649 is the hand cursor + m_cursor = LoadCursor(NULL, MAKEINTRESOURCE(32649)); + + CFont *font = GetFont(); + + LOGFONT lg; + font->GetLogFont(&lg); + + lg.lfUnderline = TRUE; + + m_underlineFont.CreateFontIndirect(&lg); + SetFont(&m_underlineFont); + + CStatic::PreSubclassWindow(); +} + +void Hyperlink::OnClicked() +{ + CString url; + GetWindowText(url); + ::ShellExecute(0, _T("open"), url, + 0, 0, SW_SHOWNORMAL); +} + +HBRUSH Hyperlink::CtlColor(CDC* pDC, UINT nCtlColor) +{ + pDC->SetTextColor(RGB(0,0,240)); + + return (HBRUSH)GetStockObject(NULL_BRUSH); +} + +BOOL Hyperlink::OnEraseBkgnd(CDC* pDC) +{ + CRect rect; + GetClientRect(rect); + pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE)); + + return TRUE; +} + +void Hyperlink::OnMouseMove(UINT nFlags, CPoint point) +{ + if(!m_over) { + m_over = true; + SetCapture(); + ::SetCursor(m_cursor); + } else { + CRect r; + GetClientRect(&r); + + if(!r.PtInRect(point)) { + m_over = false; + ReleaseCapture(); + } + } +} diff --git a/src/win32/Hyperlink.h b/src/win32/Hyperlink.h new file mode 100644 index 0000000..4afe28e --- /dev/null +++ b/src/win32/Hyperlink.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_) +#define AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Hyperlink.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// Hyperlink window + +class Hyperlink : public CStatic +{ +// Construction +public: + Hyperlink(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Hyperlink) + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +public: + bool m_over; + HCURSOR m_cursor; + afx_msg void OnClicked(); + CFont m_underlineFont; + virtual ~Hyperlink(); + + // Generated message map functions +protected: + //{{AFX_MSG(Hyperlink) + afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HYPERLINK_H__BECEAB7D_31FB_4727_A42B_8732162EEBCC__INCLUDED_) diff --git a/src/win32/IOViewer.cpp b/src/win32/IOViewer.cpp new file mode 100644 index 0000000..4d2b2c7 --- /dev/null +++ b/src/win32/IOViewer.cpp @@ -0,0 +1,201 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// IOViewer.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "IOViewer.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" + +#include "IOViewerRegs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// IOViewer dialog + + +IOViewer::IOViewer(CWnd* pParent /*=NULL*/) + : ResizeDlg(IOViewer::IDD, pParent) +{ + //{{AFX_DATA_INIT(IOViewer) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + selected = 0; + autoUpdate = false; +} + + +void IOViewer::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(IOViewer) + DDX_Control(pDX, IDC_VALUE, m_value); + DDX_Control(pDX, IDC_ADDRESSES, m_address); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(IOViewer, CDialog) + //{{AFX_MSG_MAP(IOViewer) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses) + ON_BN_CLICKED(IDC_APPLY, OnApply) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// IOViewer message handlers + +void IOViewer::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +void IOViewer::OnRefresh() +{ + // TODO: Add your control notification handler code here + +} + +void IOViewer::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void IOViewer::OnSelchangeAddresses() +{ + selected = m_address.GetCurSel(); + + update(); +} + +void IOViewer::PostNcDestroy() +{ + delete this; +} + +BOOL IOViewer::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // winCenterWindow(getHandle()); + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\IOView", + NULL); + + CFont *font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)); + int i; + for(i = 0; i < sizeof(ioViewRegisters)/sizeof(IOData); i++) { + m_address.AddString(ioViewRegisters[i].name); + } + m_address.SetFont(font); + for(i = 0; i < 16; i++) { + GetDlgItem(IDC_BIT_0+i)->SetFont(font); + } + + RECT cbSize; + int Height; + + m_address.GetClientRect(&cbSize); + Height = m_address.GetItemHeight(0); + Height += m_address.GetItemHeight(0) * (10); + + // Note: The use of SM_CYEDGE assumes that we're using Windows '95 + // Now add on the height of the border of the edit box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // The height of the border of the drop-down box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // now set the size of the window + m_address.SetWindowPos(NULL, + 0, 0, + cbSize.right, Height, + SWP_NOMOVE | SWP_NOZORDER); + + m_address.SetCurSel(0); + update(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void IOViewer::update() +{ + CString buffer; + + const IOData *sel = &ioViewRegisters[selected]; + u16 data = sel->address ? *sel->address : + (ioMem ? *((u16 *)&ioMem[sel->offset]) : 0); + + for(int i = 0; i < 16; i++) { + CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i); + + if(pWnd) { + if(!(sel->write & (1 << i))) + pWnd->EnableWindow(FALSE); + else + pWnd->EnableWindow(TRUE); + pWnd->SetCheck(((data & (1 << i)) >> i)); + buffer.Format("%2d %s", i, sel->bits[i]); + pWnd->SetWindowText(buffer); + } + } + + buffer.Format("%04X", data); + m_value.SetWindowText(buffer); +} + +void IOViewer::OnApply() +{ + const IOData *sel = &ioViewRegisters[selected]; + u16 res = 0; + for(int i = 0; i < 16; i++) { + CButton *pWnd = (CButton *)GetDlgItem(IDC_BIT_0 + i); + + if(pWnd) { + if(pWnd->GetCheck()) + res |= (1 << i); + } + } + CPUWriteHalfWord(0x4000000+sel->offset, res); + update(); +} diff --git a/src/win32/IOViewer.h b/src/win32/IOViewer.h new file mode 100644 index 0000000..d768b01 --- /dev/null +++ b/src/win32/IOViewer.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_) +#define AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// IOViewer.h : header file +// + +#include "ResizeDlg.h" +#include "IUpdate.h" + +///////////////////////////////////////////////////////////////////////////// +// IOViewer dialog + +class IOViewer : public ResizeDlg, IUpdateListener +{ + // Construction + public: + void update(); + bool autoUpdate; + int selected; + IOViewer(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(IOViewer) + enum { IDD = IDD_IO_VIEWER }; + CStatic m_value; + CComboBox m_address; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(IOViewer) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(IOViewer) + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void OnAutoUpdate(); + afx_msg void OnSelchangeAddresses(); + virtual BOOL OnInitDialog(); + afx_msg void OnApply(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_) diff --git a/src/win32/IOViewerRegs.h b/src/win32/IOViewerRegs.h new file mode 100644 index 0000000..9d28a6e --- /dev/null +++ b/src/win32/IOViewerRegs.h @@ -0,0 +1,2087 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +struct IOData { + u16 *address; + u16 offset; + char *name; + u16 write; + char *bits[16]; +}; + +const IOData ioViewRegisters[] = { + { + &DISPCNT, 0, "0x4000000-DISPCNT", 0xFFF7, + { + "", + "", + "BG Mode (3 bits)", + "CGB Mode", + "Display Frame", + "H-Blank Interval OBJ processing", + "OBJ Character mapping", + "Forced blank", + "BG0", + "BG1", + "BG2", + "BG3", + "OBJ", + "WIN0", + "WIN1", + "OBJWIN" + } + }, + { + &DISPSTAT, 4, "0x4000004-DISPSTAT", 0xFF38, + { + "V-Blank Status", + "H-Blank Status", + "VCOUNT Evaluation", + "V-Blank Interrupt Enable", + "H-Blank Interrupt Enable", + "VCOUNT Match Interrupt Enable", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "VCOUNT setting (8 bits)" + } + }, + { + &VCOUNT, 6, "0x4000006-VCOUNT", 0x0000, + { + "", + "", + "", + "", + "", + "", + "", + "VCOUNT (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG0CNT, 8, "0x4000008-BG0CNT", 0xDFCF, + { + "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "", + "", + "Size (2 bits)" + } + }, + { + &BG1CNT, 0xA, "0x400000A-BG1CNT", 0xDFCF, + { + "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "", + "", + "Size (2 bits)" + } + }, + { + &BG2CNT, 0xC, "0x400000C-BG2CNT", 0xFFCF, + { + "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "Area Overflow", + "", + "Size (2 bits)" + } + }, + { + &BG3CNT, 0xE, "0x400000E-BG3CNT", 0xFFCF, + { + "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "Area Overflow", + "", + "Size (2 bits)" + } + }, + { + &BG0HOFS, 0x10, "0x4000010-BG0HOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG0VOFS, 0x12, "0x4000012-BG0VOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG1HOFS, 0x14, "0x4000014-BG1HOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG1VOFS, 0x16, "0x4000016-BG1VOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG2HOFS, 0x18, "0x4000018-BG8HOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG2VOFS, 0x1A, "0x400001A-BG2VOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG3HOFS, 0x1C, "0x400001C-BG3HOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits,W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG3VOFS, 0x1E, "0x400001E-BG3VOFS", 0x01FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits,W)", + "", + "", + "", + "", + "", + "", + "" + } + }, + { + &BG2PA, 0x20, "0x4000020-BG2PA", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dx (16 bits,W)" + } + }, + { + &BG2PB, 0x22, "0x4000022-BG2PB", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dmx (16 bits,W)" + } + }, + { + &BG2PC, 0x24, "0x4000024-BG2PC", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dy (16 bits,W)" + } + }, + { + &BG2PD, 0x26, "0x4000026-BG2PD", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dmy (16 bits,W)" + } + }, + { + &BG2X_L, 0x28, "0x4000028-BG2X_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "X low bits (16 bits,W)" + } + }, + { + &BG2X_H, 0x2A, "0x400002A-BG2X_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "X high bits (12 bits,W)", + "", + "", + "", + "", + } + }, + { + &BG2Y_L, 0x2C, "0x400002C-BG2Y_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Y low bits (16 bits,W)" + } + }, + { + &BG2Y_H, 0x2E, "0x400002E-BG2Y_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Y hight bits (12 bits,W)", + "", + "", + "", + "", + } + }, + { + &BG3PA, 0x30, "0x4000030-BG3PA", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dx (16 bits,W)" + } + }, + { + &BG3PB, 0x32, "0x4000032-BG3PB", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dmx (16 bits,W)" + } + }, + { + &BG3PC, 0x34, "0x4000034-BG3PC", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dy (16 bits,W)" + } + }, + { + &BG3PD, 0x36, "0x4000036-BG3PD", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "dmy (16 bits,W)" + } + }, + { + &BG3X_L, 0x38, "0x4000038-BG3X_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "X low bits (16 bits,W)" + } + }, + { + &BG3X_H, 0x3A, "0x400003A-BG3X_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "X hight bits (12 bits,W)", + "", + "", + "", + "", + } + }, + { + &BG3Y_L, 0x3C, "0x400003C-BG3Y_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Y low bits (16 bits,W)" + } + }, + { + &BG3Y_H, 0x3E, "0x400003E-BG3Y_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Y hight bits (12 bits,W)", + "", + "", + "", + "", + } + }, + { + &WIN0H, 0x40, "0x4000040-WIN0H", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 0 lower-right X (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 0 upper-left X (8 bits,W)", + } + }, + { + &WIN1H, 0x42, "0x4000042-WIN1H", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 1 lower-right X (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 1 upper-left (8 bits,W)", + } + }, + { + &WIN0V, 0x44, "0x4000044-WIN0V", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 0 lower-right Y (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 0 upper-left Y (8 bits,W)", + } + }, + { + &WIN1V, 0x46, "0x4000046-WIN1V", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 1 lower-right Y (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 1 upper-left Y (8 bits,W)", + } + }, + { + &WININ, 0x48, "0x4000048-WININ", 0x3F3F, + { + "WIN0 BG0", + "WIN0 BG1", + "WIN0 BG2", + "WIN0 BG3", + "WIN0 OBJ", + "WIN0 Special FX", + "", + "", + "WIN1 BG0", + "WIN1 BG1", + "WIN1 BG2", + "WIN1 BG3", + "WIN1 OBJ", + "WIN1 Special FX", + "", + "", + } + }, + { + &WINOUT, 0x4A, "0x400004A-WINOUT", 0x3F3F, + { + "WIN0/1 BG0", + "WIN0/1 BG1", + "WIN0/1 BG2", + "WIN0/1 BG3", + "WIN0/1 OBJ", + "WIN0/1 Special FX", + "", + "", + "OBJWIN BG0", + "OBJWIN BG1", + "OBJWIN BG2", + "OBJWIN BG3", + "OBJWIN OBJ", + "OBJWIN Special FX", + "", + "", + } + }, + { + &MOSAIC, 0x4C, "0x400004C-MOSAIC", 0xFFFF, + { + "", + "", + "", + "BG H Size (4 bits,W)", + "", + "", + "", + "BG V Size (4 bits,W)", + "", + "", + "", + "OBJ H Size (4 bits,W)", + "", + "", + "", + "OBJ V Size (4 bits,W)", + } + }, + { + &BLDMOD, 0x50, "0x4000050-BLDMOD", 0x3FFF, + { + "1st BG0", + "1st BG1", + "1st BG2", + "1st BG3", + "1st OBJ", + "1st BD", + "", + "FX Type (2 bits)", + "2nd BG0", + "2nd BG1", + "2nd BG2", + "2nd BG3", + "2nd OBJ", + "2nd BD", + "", + "", + } + }, + { + &COLEV, 0x52, "0x4000052-COLEV", 0x1F1F, + { + "", + "", + "", + "", + "Coefficient EVA (5 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Coefficient EVB (5 bits,W)", + "", + "", + "", + } + }, + { + &COLY, 0x54, "0x4000054-COLEY", 0x001F, + { + "", + "", + "", + "", + "Coefficient EVY (5 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x60, "0x4000060-SG10_L", 0x007F, + { + "", + "", + "Sweep Shifts (3 bits)", + "Sweep addition/decrease", + "", + "", + "Sweep Time (3 bits)", + "", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x62, "0x4000062-SG10_H", 0xFFFF, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "Waveform Type (2 bits)", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } + }, + { + NULL, 0x64, "0x4000064-SG11", 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } + }, + { + NULL, 0x68, "0x4000068-SG20", 0xFFFF, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "Waveform Type (2 bits)", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } + }, + { + NULL, 0x6C, "0x400006C-SG21", 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } + }, + { + NULL, 0x70, "0x4000070-SG30_L", 0x00E0, + { + "", + "", + "", + "", + "", + "Waveform 32/64 Steps", + "Waveform Bank 0/1", + "Sound Output", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x72, "0x4000072-SG30_H", 0xE0FF, + { + "", + "", + "", + "", + "", + "", + "", + "Sound Length (8 bits,W)", + "", + "", + "", + "", + "", + "", + "Output Level (2 bits)", + "Forced 3/4 Output Level", + } + }, + { + NULL, 0x74, "0x4000074-SG31", 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } + }, + { + NULL, 0x78, "0x4000078-SG40", 0xFF3F, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } + }, + { + NULL, 0x7C, "0x400007C-SG41", 0xC0FF, + { + "", + "", + "Dividing Ratio Freq. (3 bits)", + "Counter 15/7 Steps", + "", + "", + "", + "Counter Shift Clock (4 bits)", + "", + "", + "", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } + }, + { + NULL, 0x80, "0x4000080-SGCNT0_L", 0xFF77, + { + "", + "", + "Right Volume (3 bits)", + "", + "", + "", + "Left Volume (3 bits)", + "", + "Channel 1->Right", + "Channel 2->Right", + "Channel 3->Right", + "Channel 4->Right", + "Channel 1->Left", + "Channel 2->Left", + "Channel 3->Left", + "Channel 4->Left", + } + }, + { + NULL, 0x82, "0x4000082-SGCNT0_H", 0xFF1F, + { + "", + "Sound 1-4 Volume (2 bits)", + "DMA Sound A Volume", + "DMA Sound B Volume", + "", + "", + "", + "", + "DMA Sound A->Right", + "DMA Sound A->Left", + "DMA Sound A Timer", + "DMA Sound A Reset FIFO", + "DMA Sound B->Right", + "DMA Sound B->Left", + "DMA Sound B Timer", + "DMA Sound B Reset FIFO", + } + }, + { + NULL, 0x84, "0x4000084-SGCNT1", 0x0080, + { + "Sound 1 On", + "Sound 2 On", + "Sound 3 On", + "Sound 4 On", + "", + "", + "", + "Master Sound Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x88, "0x4000088-SGBIAS", 0xC3FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Bias Level (10 bits)", + "", + "", + "", + "", + "", + "Sampling Rate (2 bits)", + } + }, + { + NULL, 0xA0, "0x40000A0-SIGFIFOA_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 0 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 1 (8 bits)", + } + }, + { + NULL, 0xA2, "0x40000A2-SIGFIFOA_H", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 2 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 3 (8 bits)", + } + }, + { + NULL, 0xA4, "0x40000A4-SIGFIFOB_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 0 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 1 (8 bits)", + } + }, + { + NULL, 0xA6, "0x40000A6-SIGFIFOB_H", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 2 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 3 (8 bits)", + } + }, + { + &DM0SAD_L, 0xB0, "0x40000B0-DM0SAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } + }, + { + &DM0SAD_H, 0xB2, "0x40000B2-DM0SAD_H", 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 11 bits)", + "", + "", + "", + "", + "", + } + }, + { + &DM0DAD_L, 0xB4, "0x40000B4-DM0DAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } + }, + { + &DM0DAD_H, 0xB6, "0x40000B6-DM0DAD_H", 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } + }, + { + &DM0CNT_L, 0xB8, "0x40000B8-DM0CNT_L", 0x3FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Count (14 bits)", + "", + "", + } + }, + { + &DM0CNT_H, 0xBA, "0x40000BA-DM0CNT_H", 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } + }, + { + &DM1SAD_L, 0xBC, "0x40000BC-DM1SAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } + }, + { + &DM1SAD_H, 0xBE, "0x40000BE-DM1SAD_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } + }, + { + &DM1DAD_L, 0xC0, "0x40000C0-DM1DAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } + }, + { + &DM1DAD_H, 0xC2, "0x40000C2-DM1DAD_H", 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } + }, + { + &DM1CNT_L, 0xC4, "0x40000C4-DM1CNT_L", 0x3FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Count (14 bits)", + "", + "", + } + }, + { + &DM1CNT_H, 0xC6, "0x40000C6-DM1CNT_H", 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } + }, + { + &DM2SAD_L, 0xC8, "0x40000C8-DM2SAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } + }, + { + &DM2SAD_H, 0xCA, "0x40000CA-DM2SAD_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } + }, + { + &DM2DAD_L, 0xCC, "0x40000CC-DM2DAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } + }, + { + &DM2DAD_H, 0xCE, "0x40000CE-DM2DAD_H", 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } + }, + { + &DM2CNT_L, 0xD0, "0x40000D0-DM2CNT_L", 0x3FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Count (14 bits)", + "", + "", + } + }, + { + &DM2CNT_H, 0xD2, "0x40000D2-DM2CNT_H", 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } + }, + { + &DM3SAD_L, 0xD4, "0x40000D4-DM3SAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } + }, + { + &DM3SAD_H, 0xD6, "0x40000D6-DM3SAD_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } + }, + { + &DM3DAD_L, 0xD8, "0x40000D8-DM3DAD_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } + }, + { + &DM3DAD_H, 0xDA, "0x40000DA-DM3DAD_H", 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 12 bits)", + "", + "", + "", + "", + } + }, + { + &DM3CNT_L, 0xDC, "0x40000DC-DM3CNT_L", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Count (16 bits)", + } + }, + { + &DM3CNT_H, 0xDE, "0x40000DE-DM3CNT_H", 0xFFE0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "Game Pak Data Request", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } + }, + { + &TM0D, 0x100, "0x4000100-TM0D", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Timer Counter (16 bits)", + } + }, + { + &TM0CNT, 0x102, "0x4000102-TM0CNT", 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + &TM1D, 0x104, "0x4000104-TM1D", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Timer Counter (16 bits)", + } + }, + { + &TM1CNT, 0x106, "0x4000106-TM1CNT", 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + &TM2D, 0x108, "0x4000108-TM2D", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Timer Counter (16 bits)", + } + }, + { + &TM2CNT, 0x10A, "0x400010A-TM2CNT", 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + &TM3D, 0x10C, "0x400010C-TM3D", 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Timer Counter (16 bits)", + } + }, + { + &TM3CNT, 0x10E, "0x400010E-TM3CNT", 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + &P1, 0x130, "0x4000130-P1", 0x03FF, + { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "Shoulder Right", + "Shoulder Left", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x132, "0x4000132-P1CNT", 0xC3FF, + { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "Shoulder Right", + "Shoulder Left", + "", + "", + "", + "", + "Interrupt Request", + "Interrupt Condition", + } + }, + { + &IE, 0x200, "0x4000200-IE", 0x3FFF, + { + "VBlank", + "HBlank", + "VCount", + "Timer 0", + "Timer 1", + "Timer 2", + "Timer 3", + "Serial", + "DMA 0", + "DMA 1", + "DMA 2", + "DMA 3", + "Keypad", + "Game Pak", + "", + "", + } + }, + { + &IF, 0x202, "0x4000202-IF", 0x0000, + { + "VBlank", + "HBlank", + "VCount", + "Timer 0", + "Timer 1", + "Timer 2", + "Timer 3", + "Serial", + "DMA 0", + "DMA 1", + "DMA 2", + "DMA 3", + "Keypad", + "Game Pak", + "", + "", + } + }, + { + NULL, 0x204, "0x4000204-WAITCNT", 0x5FFF, + { + "", + "SRAM Wait Control (2 bits)", + "", + "Wait State 0 First Access (2 bits)", + "Wait State 0 Second Access", + "", + "Wait State 1 First Access (2 bits)", + "Wait State 1 Second Access", + "", + "Wait State 2 First Access (2 bits)", + "Wait State 2 Second Access", + "", + "PHI Terminal Output (2 bits)", + "", + "Game Pak Prefetch Buffer", + "Game Pak Type Flag", + } + }, + { + &IME, 0x208, "0x4000208-IME", 0x0001, + { + "Master Interrupt Enable", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + } + }, + { + NULL, 0x300, "0x4000300-HALTCNT", 0x8001, + { + "First Boot", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Power Down", + } + }, +}; diff --git a/src/win32/IUpdate.h b/src/win32/IUpdate.h new file mode 100644 index 0000000..a409cb4 --- /dev/null +++ b/src/win32/IUpdate.h @@ -0,0 +1,27 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_WIN32_IUPDATE_H +#define VBA_WIN32_IUPDATE_H + +class IUpdateListener { + public: + virtual void update()=0; +}; +#endif diff --git a/src/win32/Input.h b/src/win32/Input.h new file mode 100644 index 0000000..ec271ce --- /dev/null +++ b/src/win32/Input.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_WIN32_INPUT_H +#define VBA_WIN32_INPUT_H +#include "../System.h" + +#define JOYCONFIG_MESSAGE (WM_USER + 1000) + + +#include "../inputGlobal.h" + +class Input { + + public: + Input() {}; + virtual ~Input() {}; + + virtual bool initialize() = 0; + + virtual bool readDevices() = 0; + virtual u32 readDevice(int which, bool sensor) = 0; + virtual CString getKeyName(int key) = 0; + virtual void checkKeys() = 0; + virtual void checkDevices() = 0; + virtual void activate() = 0; + virtual void loadSettings() = 0; + virtual void saveSettings() = 0; +}; + +#endif diff --git a/src/win32/Joypad.cpp b/src/win32/Joypad.cpp new file mode 100644 index 0000000..193313c --- /dev/null +++ b/src/win32/Joypad.cpp @@ -0,0 +1,435 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Joypad.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Joypad.h" +#include "Input.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern USHORT joypad[4][13]; +extern USHORT motion[4]; + +///////////////////////////////////////////////////////////////////////////// +// JoypadEditControl + +JoypadEditControl::JoypadEditControl() +{ +} + +JoypadEditControl::~JoypadEditControl() +{ +} + + +BEGIN_MESSAGE_MAP(JoypadEditControl, CEdit) + //{{AFX_MSG_MAP(JoypadEditControl) + ON_WM_CHAR() + //}}AFX_MSG_MAP + ON_MESSAGE(JOYCONFIG_MESSAGE, OnJoyConfig) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// JoypadEditControl message handlers + +void JoypadEditControl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +} + +LRESULT JoypadEditControl::OnJoyConfig(WPARAM wParam, LPARAM lParam) +{ + SetWindowLong(GetSafeHwnd(), GWL_USERDATA,((wParam<<8)|lParam)); + SetWindowText(theApp.input->getKeyName((wParam<<8)|lParam)); + GetParent()->GetNextDlgTabItem(this, FALSE)->SetFocus(); + return TRUE; +} + +BOOL JoypadEditControl::PreTranslateMessage(MSG *pMsg) +{ + if(pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN)) + return TRUE; + + return CEdit::PreTranslateMessage(pMsg); +} + +///////////////////////////////////////////////////////////////////////////// +// JoypadConfig dialog + + +JoypadConfig::JoypadConfig(int w, CWnd* pParent /*=NULL*/) + : CDialog(JoypadConfig::IDD, pParent) +{ + //{{AFX_DATA_INIT(JoypadConfig) + //}}AFX_DATA_INIT + timerId = 0; + which = w; + if(which < 0 || which > 3) + which = 0; +} + +void JoypadConfig::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(JoypadConfig) + DDX_Control(pDX, IDC_EDIT_UP, up); + DDX_Control(pDX, IDC_EDIT_SPEED, speed); + DDX_Control(pDX, IDC_EDIT_RIGHT, right); + DDX_Control(pDX, IDC_EDIT_LEFT, left); + DDX_Control(pDX, IDC_EDIT_DOWN, down); + DDX_Control(pDX, IDC_EDIT_CAPTURE, capture); + DDX_Control(pDX, IDC_EDIT_BUTTON_START, buttonStart); + DDX_Control(pDX, IDC_EDIT_BUTTON_SELECT, buttonSelect); + DDX_Control(pDX, IDC_EDIT_BUTTON_R, buttonR); + DDX_Control(pDX, IDC_EDIT_BUTTON_L, buttonL); + DDX_Control(pDX, IDC_EDIT_BUTTON_GS, buttonGS); + DDX_Control(pDX, IDC_EDIT_BUTTON_B, buttonB); + DDX_Control(pDX, IDC_EDIT_BUTTON_A, buttonA); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(JoypadConfig, CDialog) + //{{AFX_MSG_MAP(JoypadConfig) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + ON_WM_CHAR() + ON_WM_DESTROY() + ON_WM_TIMER() + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// JoypadConfig message handlers + +void JoypadConfig::OnCancel() +{ + EndDialog(FALSE); +} + +void JoypadConfig::OnOk() +{ + assignKeys(); + theApp.input->checkKeys(); + EndDialog(TRUE); +} + +void JoypadConfig::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +} + +void JoypadConfig::OnDestroy() +{ + CDialog::OnDestroy(); + + KillTimer(timerId); +} + +void JoypadConfig::OnTimer(UINT nIDEvent) +{ + theApp.input->checkDevices(); + + CDialog::OnTimer(nIDEvent); +} + +void JoypadConfig::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +} + +BOOL JoypadConfig::OnInitDialog() +{ + CDialog::OnInitDialog(); + + timerId = SetTimer(0,200,NULL); + + SetWindowLong(up, GWL_USERDATA,joypad[which][KEY_UP]); + up.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_UP])); + + SetWindowLong(down, GWL_USERDATA,joypad[which][KEY_DOWN]); + down.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_DOWN])); + + SetWindowLong(left, GWL_USERDATA,joypad[which][KEY_LEFT]); + left.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_LEFT])); + + SetWindowLong(right, GWL_USERDATA,joypad[which][KEY_RIGHT]); + right.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_RIGHT])); + + SetWindowLong(buttonA, GWL_USERDATA,joypad[which][KEY_BUTTON_A]); + buttonA.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_A])); + + SetWindowLong(buttonB, GWL_USERDATA,joypad[which][KEY_BUTTON_B]); + buttonB.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_B])); + + SetWindowLong(buttonL, GWL_USERDATA,joypad[which][KEY_BUTTON_L]); + buttonL.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_L])); + + SetWindowLong(buttonR, GWL_USERDATA,joypad[which][KEY_BUTTON_R]); + buttonR.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_R])); + + SetWindowLong(buttonSelect, GWL_USERDATA,joypad[which][KEY_BUTTON_SELECT]); + buttonSelect.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SELECT])); + + SetWindowLong(buttonStart, GWL_USERDATA,joypad[which][KEY_BUTTON_START]); + buttonStart.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_START])); + + SetWindowLong(speed, GWL_USERDATA,joypad[which][KEY_BUTTON_SPEED]); + speed.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SPEED])); + + SetWindowLong(capture, GWL_USERDATA,joypad[which][KEY_BUTTON_CAPTURE]); + capture.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_CAPTURE])); + + SetWindowLong(buttonGS, GWL_USERDATA,joypad[which][KEY_BUTTON_GS]); + buttonGS.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_GS])); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void JoypadConfig::assignKey(int id, int key) +{ + switch(id) { + case IDC_EDIT_LEFT: + joypad[which][KEY_LEFT] = key; + break; + case IDC_EDIT_RIGHT: + joypad[which][KEY_RIGHT] = key; + break; + case IDC_EDIT_UP: + joypad[which][KEY_UP] = key; + break; + case IDC_EDIT_SPEED: + joypad[which][KEY_BUTTON_SPEED] = key; + break; + case IDC_EDIT_CAPTURE: + joypad[which][KEY_BUTTON_CAPTURE] = key; + break; + case IDC_EDIT_DOWN: + joypad[which][KEY_DOWN] = key; + break; + case IDC_EDIT_BUTTON_A: + joypad[which][KEY_BUTTON_A] = key; + break; + case IDC_EDIT_BUTTON_B: + joypad[which][KEY_BUTTON_B] = key; + break; + case IDC_EDIT_BUTTON_L: + joypad[which][KEY_BUTTON_L] = key; + break; + case IDC_EDIT_BUTTON_R: + joypad[which][KEY_BUTTON_R] = key; + break; + case IDC_EDIT_BUTTON_START: + joypad[which][KEY_BUTTON_START] = key; + break; + case IDC_EDIT_BUTTON_SELECT: + joypad[which][KEY_BUTTON_SELECT] = key; + break; + case IDC_EDIT_BUTTON_GS: + joypad[which][KEY_BUTTON_GS] = key; + break; + } +} + +void JoypadConfig::assignKeys() +{ + int id; + + id = IDC_EDIT_UP; + assignKey(id, GetWindowLong(up, GWL_USERDATA)); + + id = IDC_EDIT_DOWN; + assignKey(id, GetWindowLong(down, GWL_USERDATA)); + + id = IDC_EDIT_LEFT; + assignKey(id, GetWindowLong(left, GWL_USERDATA)); + + id = IDC_EDIT_RIGHT; + assignKey(id, GetWindowLong(right, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_A; + assignKey(id, GetWindowLong(buttonA, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_B; + assignKey(id, GetWindowLong(buttonB, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_L; + assignKey(id, GetWindowLong(buttonL, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_R; + assignKey(id, GetWindowLong(buttonR, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_SELECT; + assignKey(id, GetWindowLong(buttonSelect, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_START; + assignKey(id, GetWindowLong(buttonStart, GWL_USERDATA)); + + id = IDC_EDIT_SPEED; + assignKey(id, GetWindowLong(speed, GWL_USERDATA)); + + id = IDC_EDIT_CAPTURE; + assignKey(id, GetWindowLong(capture, GWL_USERDATA)); + + id = IDC_EDIT_BUTTON_GS; + assignKey(id, GetWindowLong(buttonGS, GWL_USERDATA)); + + // winSaveKeys(); +} + +///////////////////////////////////////////////////////////////////////////// +// MotionConfig dialog + + +MotionConfig::MotionConfig(CWnd* pParent /*=NULL*/) + : CDialog(MotionConfig::IDD, pParent) +{ + //{{AFX_DATA_INIT(MotionConfig) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + timerId = 0; +} + + +void MotionConfig::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MotionConfig) + DDX_Control(pDX, IDC_EDIT_UP, up); + DDX_Control(pDX, IDC_EDIT_RIGHT, right); + DDX_Control(pDX, IDC_EDIT_LEFT, left); + DDX_Control(pDX, IDC_EDIT_DOWN, down); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(MotionConfig, CDialog) + //{{AFX_MSG_MAP(MotionConfig) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + ON_WM_CHAR() + ON_WM_DESTROY() + ON_WM_KEYDOWN() + ON_WM_TIMER() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// MotionConfig message handlers + +void MotionConfig::OnCancel() +{ + EndDialog(FALSE); +} + +void MotionConfig::OnOk() +{ + assignKeys(); + theApp.input->checkKeys(); + EndDialog( TRUE); +} + +void MotionConfig::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +} + +void MotionConfig::OnDestroy() +{ + CDialog::OnDestroy(); + + KillTimer(timerId); +} + +BOOL MotionConfig::OnInitDialog() +{ + CDialog::OnInitDialog(); + + timerId = SetTimer(0,200,NULL); + + SetWindowLong(up, GWL_USERDATA,motion[KEY_UP]); + up.SetWindowText(theApp.input->getKeyName(motion[KEY_UP])); + + SetWindowLong(down, GWL_USERDATA,motion[KEY_DOWN]); + down.SetWindowText(theApp.input->getKeyName(motion[KEY_DOWN])); + + SetWindowLong(left, GWL_USERDATA,motion[KEY_LEFT]); + left.SetWindowText(theApp.input->getKeyName(motion[KEY_LEFT])); + + SetWindowLong(right, GWL_USERDATA,motion[KEY_RIGHT]); + right.SetWindowText(theApp.input->getKeyName(motion[KEY_RIGHT])); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MotionConfig::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ +} + +void MotionConfig::OnTimer(UINT nIDEvent) +{ + theApp.input->checkDevices(); + + CDialog::OnTimer(nIDEvent); +} + +void MotionConfig::assignKey(int id, int key) +{ + switch(id) { + case IDC_EDIT_LEFT: + motion[KEY_LEFT] = key; + break; + case IDC_EDIT_RIGHT: + motion[KEY_RIGHT] = key; + break; + case IDC_EDIT_UP: + motion[KEY_UP] = key; + break; + case IDC_EDIT_DOWN: + motion[KEY_DOWN] = key; + break; + } +} + +void MotionConfig::assignKeys() +{ + int id; + + id = IDC_EDIT_UP; + assignKey(id, GetWindowLong(up, GWL_USERDATA)); + + id = IDC_EDIT_DOWN; + assignKey(id, GetWindowLong(down, GWL_USERDATA)); + + id = IDC_EDIT_LEFT; + assignKey(id, GetWindowLong(left, GWL_USERDATA)); + + id = IDC_EDIT_RIGHT; + assignKey(id, GetWindowLong(right, GWL_USERDATA)); +} diff --git a/src/win32/Joypad.h b/src/win32/Joypad.h new file mode 100644 index 0000000..4e39f09 --- /dev/null +++ b/src/win32/Joypad.h @@ -0,0 +1,168 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_) +#define AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Joypad.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// JoypadEditControl window + +class JoypadEditControl : public CEdit +{ + // Construction + public: + JoypadEditControl(); + + // Attributes + public: + + // Operations + public: + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(JoypadEditControl) + //}}AFX_VIRTUAL + + // Implementation + public: + virtual BOOL PreTranslateMessage(MSG *pMsg); + afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam); + virtual ~JoypadEditControl(); + + // Generated message map functions + protected: + //{{AFX_MSG(JoypadEditControl) + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// JoypadConfig dialog + +class JoypadConfig : public CDialog +{ + // Construction + public: + void assignKeys(); + void assignKey(int id, int key); + JoypadConfig(int w, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(JoypadConfig) + enum { IDD = IDD_CONFIG }; + JoypadEditControl up; + JoypadEditControl speed; + JoypadEditControl right; + JoypadEditControl left; + JoypadEditControl down; + JoypadEditControl capture; + JoypadEditControl buttonStart; + JoypadEditControl buttonSelect; + JoypadEditControl buttonR; + JoypadEditControl buttonL; + JoypadEditControl buttonGS; + JoypadEditControl buttonB; + JoypadEditControl buttonA; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(JoypadConfig) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + UINT timerId; + int which; + + // Generated message map functions + //{{AFX_MSG(JoypadConfig) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnDestroy(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + ///////////////////////////////////////////////////////////////////////////// +// MotionConfig dialog + +class MotionConfig : public CDialog +{ + // Construction + public: + void assignKeys(); + void assignKey(int id, int key); + MotionConfig(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(MotionConfig) + enum { IDD = IDD_MOTION_CONFIG }; + JoypadEditControl up; + JoypadEditControl right; + JoypadEditControl left; + JoypadEditControl down; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MotionConfig) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(MotionConfig) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnDestroy(); + virtual BOOL OnInitDialog(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + UINT timerId; +}; +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_JOYPAD_H__FFFB2470_9EEC_4D2D_A5F0_3BF31579999A__INCLUDED_) diff --git a/src/win32/KeyboardEdit.cpp b/src/win32/KeyboardEdit.cpp new file mode 100644 index 0000000..be8d1a8 --- /dev/null +++ b/src/win32/KeyboardEdit.cpp @@ -0,0 +1,172 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : KeyboardEdit.cpp +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Authors : A.Lebatard + T.Maurel +// Date : 17.08.98 +// +// Remarks : implementation file +// +//////////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "KeyboardEdit.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern TCHAR* mapVirtKeysStringFromWORD(WORD wKey); + +///////////////////////////////////////////////////////////////////////////// +// CKeyboardEdit + +CKeyboardEdit::CKeyboardEdit() +{ + m_bKeyDefined = false; + ResetKey (); +} + +CKeyboardEdit::~CKeyboardEdit() +{ +} + + +BEGIN_MESSAGE_MAP(CKeyboardEdit, CEdit) + //{{AFX_MSG_MAP(CKeyboardEdit) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + +#pragma warning( disable : 4706 ) + ///////////////////////////////////////////////////////////////////////////// +// CKeyboardEdit message handlers +BOOL CKeyboardEdit::PreTranslateMessage (MSG* pMsg) +{ + bool bPressed; + if ((bPressed = (pMsg->message == WM_KEYDOWN)) || pMsg->message == WM_KEYUP || (bPressed = (pMsg->message == WM_SYSKEYDOWN)) || pMsg->message == WM_SYSKEYUP) { + bool bReset = false; + if (bPressed && m_bKeyDefined && !((1 << 30) & pMsg->lParam)) { + ResetKey (); + bReset = true; + } + bool syncShift = true, syncCtrl = true, syncAlt = true; + if (pMsg->wParam == VK_SHIFT && !m_bKeyDefined) { + if(bPressed) + m_bShiftPressed = bPressed; + syncShift = false; + } + else if (pMsg->wParam == VK_CONTROL &&!m_bKeyDefined) { + if(bPressed) + m_bCtrlPressed = bPressed; + syncCtrl = false; + } + else if (pMsg->wParam == VK_MENU && !m_bKeyDefined) { + if(bPressed) + m_bAltPressed = bPressed; + syncAlt = false; + } + else { + if (!m_bKeyDefined) { + m_wVirtKey = (WORD)pMsg->wParam; + if (bPressed) + m_bKeyDefined = true; + } + } + if (!m_bKeyDefined || bReset) { + if (syncShift) + m_bShiftPressed = ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0); + if (syncCtrl) + m_bCtrlPressed = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0); + if (syncAlt) + m_bAltPressed = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); + } + + DisplayKeyboardString (); + return TRUE; + } + + return CEdit::PreTranslateMessage(pMsg); +} +#pragma warning( default : 4706 ) + +//////////////////////////////////////////////////////////////////////// +// +void CKeyboardEdit::DisplayKeyboardString() +{ + CString strKbd; + + // modifiers + if (m_bCtrlPressed) + strKbd = "Ctrl"; + if (m_bAltPressed) { + if (strKbd.GetLength () > 0) + strKbd += '+'; + strKbd += "Alt"; + } + if (m_bShiftPressed) { + if (strKbd.GetLength () > 0) + strKbd += '+'; + strKbd += "Shift"; + } + // virtual key + LPCTSTR szVirtKey = mapVirtKeysStringFromWORD(m_wVirtKey); + if (szVirtKey != NULL) { + if (strKbd.GetLength () > 0) + strKbd += '+'; + strKbd += szVirtKey; + } + SetWindowText (strKbd); +} + + +//////////////////////////////////////////////////////////////////////// +// +void CKeyboardEdit::ResetKey () +{ + m_wVirtKey = 0; + m_bCtrlPressed = false; + m_bAltPressed = false; + m_bShiftPressed = false; + + m_bKeyDefined = false; + if(m_hWnd != NULL) + SetWindowText(_T("")); +} + + +//////////////////////////////////////////////////////////////////////// +// +bool CKeyboardEdit::GetAccelKey(WORD& wVirtKey, bool& bCtrl, bool& bAlt, bool& bShift) +{ + if (!m_bKeyDefined) + { + if(!m_bAltPressed && !m_bCtrlPressed && !m_bShiftPressed) + return false; + } + + wVirtKey = m_wVirtKey; + bAlt = m_bAltPressed; + bCtrl = m_bCtrlPressed; + bShift = m_bShiftPressed; + return true; +} + diff --git a/src/win32/KeyboardEdit.h b/src/win32/KeyboardEdit.h new file mode 100644 index 0000000..c72da1d --- /dev/null +++ b/src/win32/KeyboardEdit.h @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 1998 by Thierry Maurel +// All rights reserved +// +// Distribute freely, except: don't remove my name from the source or +// documentation (don't take credit for my work), mark your changes (don't +// get me blamed for your possible bugs), don't alter or remove this +// notice. +// No warrantee of any kind, express or implied, is included with this +// software; use at your own risk, responsibility for damages (if any) to +// anyone resulting from the use of this software rests entirely with the +// user. +// +// Send bug reports, bug fixes, enhancements, requests, flames, etc., and +// I'll try to keep a version up to date. I can be reached as follows: +// tmaurel@caramail.com (or tmaurel@hol.fr) +// +//////////////////////////////////////////////////////////////////////////////// +// File : KeyboardEdit.h +// Project : AccelsEditor +//////////////////////////////////////////////////////////////////////////////// +// Version : 1.0 * Authors : A.Lebatard + T.Maurel +// Date : 17.08.98 +// +// Remarks : +// +//////////////////////////////////////////////////////////////////////////////// +#if !defined(AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_) +#define AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// KeyboardEdit.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CKeyboardEdit window + +class CKeyboardEdit : public CEdit +{ + // Construction + public: + CKeyboardEdit(); + + // Attributes + public: + bool m_bKeyDefined; + + WORD m_wVirtKey; + bool m_bCtrlPressed; + bool m_bAltPressed; + bool m_bShiftPressed; + + // Operations + public: + bool GetAccelKey(WORD& wVirtKey, bool& bCtrl, bool& bAlt, bool& bShift); + void ResetKey (); + + protected: + void DisplayKeyboardString (); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CKeyboardEdit) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + + // Implementation + public: + virtual ~CKeyboardEdit(); + + // Generated message map functions + protected: + //{{AFX_MSG(CKeyboardEdit) + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_) diff --git a/src/win32/LangSelect.cpp b/src/win32/LangSelect.cpp new file mode 100644 index 0000000..4dcabe6 --- /dev/null +++ b/src/win32/LangSelect.cpp @@ -0,0 +1,97 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// LangSelect.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "LangSelect.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// LangSelect dialog + + +LangSelect::LangSelect(CWnd* pParent /*=NULL*/) + : CDialog(LangSelect::IDD, pParent) +{ + //{{AFX_DATA_INIT(LangSelect) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void LangSelect::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(LangSelect) + DDX_Control(pDX, IDC_LANG_STRING, m_langString); + DDX_Control(pDX, IDC_LANG_NAME, m_langName); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(LangSelect, CDialog) + //{{AFX_MSG_MAP(LangSelect) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// LangSelect message handlers + +void LangSelect::OnCancel() +{ + EndDialog(FALSE); +} + +void LangSelect::OnOk() +{ + m_langString.GetWindowText(theApp.languageName); + EndDialog(TRUE); +} + +BOOL LangSelect::OnInitDialog() +{ + CDialog::OnInitDialog(); + + char lbuffer[10]; + if(GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, + lbuffer, 10)) { + m_langName.SetWindowText(lbuffer); + } else { + m_langName.SetWindowText("???"); + } + + if(!theApp.languageName.IsEmpty()) + m_langString.SetWindowText(theApp.languageName); + + m_langString.LimitText(3); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/LangSelect.h b/src/win32/LangSelect.h new file mode 100644 index 0000000..d8b2239 --- /dev/null +++ b/src/win32/LangSelect.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_) +#define AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// LangSelect.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// LangSelect dialog + +class LangSelect : public CDialog +{ + // Construction + public: + LangSelect(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(LangSelect) + enum { IDD = IDD_LANG_SELECT }; + CEdit m_langString; + CStatic m_langName; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(LangSelect) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(LangSelect) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_) diff --git a/src/win32/Logging.cpp b/src/win32/Logging.cpp new file mode 100644 index 0000000..697b6d4 --- /dev/null +++ b/src/win32/Logging.cpp @@ -0,0 +1,287 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Logging.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" + +#include "FileDlg.h" +#include "Logging.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// Logging dialog + +Logging *Logging::instance = NULL; +CString Logging::text; + +Logging::Logging(CWnd* pParent /*=NULL*/) + : ResizeDlg(Logging::IDD, pParent) +{ + //{{AFX_DATA_INIT(Logging) + m_swi = FALSE; + m_unaligned_access = FALSE; + m_illegal_write = FALSE; + m_illegal_read = FALSE; + m_dma0 = FALSE; + m_dma1 = FALSE; + m_dma2 = FALSE; + m_dma3 = FALSE; + m_agbprint = FALSE; + m_undefined = FALSE; + //}}AFX_DATA_INIT +} + + +void Logging::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(Logging) + DDX_Control(pDX, IDC_LOG, m_log); + DDX_Check(pDX, IDC_VERBOSE_SWI, m_swi); + DDX_Check(pDX, IDC_VERBOSE_UNALIGNED_ACCESS, m_unaligned_access); + DDX_Check(pDX, IDC_VERBOSE_ILLEGAL_WRITE, m_illegal_write); + DDX_Check(pDX, IDC_VERBOSE_ILLEGAL_READ, m_illegal_read); + DDX_Check(pDX, IDC_VERBOSE_DMA0, m_dma0); + DDX_Check(pDX, IDC_VERBOSE_DMA1, m_dma1); + DDX_Check(pDX, IDC_VERBOSE_DMA2, m_dma2); + DDX_Check(pDX, IDC_VERBOSE_DMA3, m_dma3); + DDX_Check(pDX, IDC_VERBOSE_AGBPRINT, m_agbprint); + DDX_Check(pDX, IDC_VERBOSE_UNDEFINED, m_undefined); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(Logging, CDialog) + //{{AFX_MSG_MAP(Logging) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(IDC_CLEAR, OnClear) + ON_BN_CLICKED(IDC_VERBOSE_AGBPRINT, OnVerboseAgbprint) + ON_BN_CLICKED(IDC_VERBOSE_DMA0, OnVerboseDma0) + ON_BN_CLICKED(IDC_VERBOSE_DMA1, OnVerboseDma1) + ON_BN_CLICKED(IDC_VERBOSE_DMA2, OnVerboseDma2) + ON_BN_CLICKED(IDC_VERBOSE_DMA3, OnVerboseDma3) + ON_BN_CLICKED(IDC_VERBOSE_ILLEGAL_READ, OnVerboseIllegalRead) + ON_BN_CLICKED(IDC_VERBOSE_ILLEGAL_WRITE, OnVerboseIllegalWrite) + ON_BN_CLICKED(IDC_VERBOSE_SWI, OnVerboseSwi) + ON_BN_CLICKED(IDC_VERBOSE_UNALIGNED_ACCESS, OnVerboseUnalignedAccess) + ON_BN_CLICKED(IDC_VERBOSE_UNDEFINED, OnVerboseUndefined) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_EN_ERRSPACE(IDC_LOG, OnErrspaceLog) + ON_EN_MAXTEXT(IDC_LOG, OnMaxtextLog) + ON_WM_CLOSE() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Logging message handlers + +void Logging::OnOk() +{ + EndDialog(TRUE); + + instance = NULL; +} + +void Logging::OnClear() +{ + text = ""; + m_log.SetWindowText(""); +} + +void Logging::OnVerboseAgbprint() +{ + systemVerbose ^= 512; +} + +void Logging::OnVerboseDma0() +{ + systemVerbose ^= 16; +} + +void Logging::OnVerboseDma1() +{ + systemVerbose ^= 32; +} + +void Logging::OnVerboseDma2() +{ + systemVerbose ^= 64; +} + +void Logging::OnVerboseDma3() +{ + systemVerbose ^= 128; +} + +void Logging::OnVerboseIllegalRead() +{ + systemVerbose ^= 8; +} + +void Logging::OnVerboseIllegalWrite() +{ + systemVerbose ^= 4; +} + +void Logging::OnVerboseSwi() +{ + systemVerbose ^= 1; +} + +void Logging::OnVerboseUnalignedAccess() +{ + systemVerbose ^= 2; +} + +void Logging::OnVerboseUndefined() +{ + systemVerbose ^= 256; +} + +void Logging::OnSave() +{ + int len = m_log.GetWindowTextLength(); + + char *mem = (char *)malloc(len); + + if(mem) { + LPCTSTR exts[] = { ".txt" }; + m_log.GetWindowText(mem, len); + CString filter = "All Files|*.*||"; + FileDlg dlg(this, "", filter, 0, + NULL, exts, NULL, "Save output", true); + + if(dlg.DoModal() == IDOK) { + FILE *f = fopen(dlg.GetPathName(), "w"); + if(f) { + fwrite(mem, 1, len, f); + fclose(f); + } + } + } + + free(mem); +} + +void Logging::OnErrspaceLog() +{ + systemMessage(0, "Error allocating space"); +} + +void Logging::OnMaxtextLog() +{ + systemMessage(0, "Max text length reached %d", m_log.GetLimitText()); +} + +void Logging::PostNcDestroy() +{ + delete this; +} + +BOOL Logging::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_LOG, DS_SizeY|DS_SizeX) + DIALOG_SIZER_ENTRY( ID_OK, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLEAR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\LogView", + NULL); + m_swi = (systemVerbose & 1) != 0; + m_unaligned_access = (systemVerbose & 2) != 0; + m_illegal_write = (systemVerbose & 4) != 0; + m_illegal_read = (systemVerbose & 8) != 0; + m_dma0 = (systemVerbose & 16) != 0; + m_dma1 = (systemVerbose & 32) != 0; + m_dma2 = (systemVerbose & 64) != 0; + m_dma3 = (systemVerbose & 128) != 0; + m_undefined = (systemVerbose & 256) != 0; + m_agbprint = (systemVerbose & 256) != 0; + UpdateData(FALSE); + + m_log.LimitText(-1); + m_log.SetWindowText(text); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void Logging::log(const char *s) +{ + int size = ::SendMessage(m_log, WM_GETTEXTLENGTH, 0, 0); + m_log.SetSel(size, size); + m_log.ReplaceSel(s); +} + +void Logging::OnClose() +{ + EndDialog(FALSE); + + instance = NULL; + + CDialog::OnClose(); +} + +void toolsLogging() +{ + if(Logging::instance == NULL) { + Logging::instance = new Logging(); + Logging::instance->Create(IDD_LOGGING, AfxGetApp()->m_pMainWnd); + Logging::instance->ShowWindow(SW_SHOW); + } else { + Logging::instance->SetForegroundWindow(); + } +} + +void toolsLog(const char *s) +{ + CString str; + int state = 0; + if(s) { + char c = *s++; + while(c) { + if(c == '\n' && state == 0) + str += '\r'; + else if(c == '\r') + state = 1; + else + state = 0; + str += c; + c = *s++; + } + } + + Logging::text += str; + if(Logging::instance != NULL) { + Logging::instance->log(str); + } +} diff --git a/src/win32/Logging.h b/src/win32/Logging.h new file mode 100644 index 0000000..01514f6 --- /dev/null +++ b/src/win32/Logging.h @@ -0,0 +1,98 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_) +#define AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Logging.h : header file +// + +#include "ResizeDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// Logging dialog + +class Logging : public ResizeDlg +{ + // Construction + public: + void log(const char *); + Logging(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(Logging) + enum { IDD = IDD_LOGGING }; + CEdit m_log; + BOOL m_swi; + BOOL m_unaligned_access; + BOOL m_illegal_write; + BOOL m_illegal_read; + BOOL m_dma0; + BOOL m_dma1; + BOOL m_dma2; + BOOL m_dma3; + BOOL m_agbprint; + BOOL m_undefined; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Logging) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(Logging) + afx_msg void OnOk(); + afx_msg void OnClear(); + afx_msg void OnVerboseAgbprint(); + afx_msg void OnVerboseDma0(); + afx_msg void OnVerboseDma1(); + afx_msg void OnVerboseDma2(); + afx_msg void OnVerboseDma3(); + afx_msg void OnVerboseIllegalRead(); + afx_msg void OnVerboseIllegalWrite(); + afx_msg void OnVerboseSwi(); + afx_msg void OnVerboseUnalignedAccess(); + afx_msg void OnVerboseUndefined(); + afx_msg void OnSave(); + afx_msg void OnErrspaceLog(); + afx_msg void OnMaxtextLog(); + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + static Logging *instance; + static CString text; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LOGGING_H__222FC21A_D40D_450D_8A1C_D33305E47B85__INCLUDED_) diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp new file mode 100644 index 0000000..75b825b --- /dev/null +++ b/src/win32/MainWnd.cpp @@ -0,0 +1,1345 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MainWnd.cpp : implementation file +// + +#include "stdafx.h" +#include "VBA.h" +#include "MainWnd.h" + +#include + +#include "FileDlg.h" +#include "Reg.h" +#include "WinResUtil.h" +#include "GBACheats.h" +#include "GBCheatsDlg.h" + +#include "../System.h" +#include "../AutoBuild.h" +#include "../cheatSearch.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Flash.h" +#include "../Globals.h" +#include "../gb/GB.h" +#include "../gb/gbCheats.h" +#include "../gb/gbGlobals.h" +#include "../RTC.h" +#include "../Sound.h" +#include "../Util.h" +#include "../movie.h" +#include ".\mainwnd.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define VBA_CONFIRM_MODE WM_APP + 100 + +extern void remoteCleanUp(); + +///////////////////////////////////////////////////////////////////////////// +// MainWnd + +MainWnd::MainWnd() +{ + m_hAccelTable = NULL; + arrow = LoadCursor(NULL, IDC_ARROW); +} + +MainWnd::~MainWnd() +{ +} + + +BEGIN_MESSAGE_MAP(MainWnd, CWnd) + //{{AFX_MSG_MAP(MainWnd) + ON_WM_CLOSE() + ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout) + ON_COMMAND(ID_HELP_FAQ, OnHelpFaq) + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) + ON_WM_INITMENUPOPUP() + ON_COMMAND(ID_FILE_PAUSE, OnFilePause) + ON_UPDATE_COMMAND_UI(ID_FILE_PAUSE, OnUpdateFilePause) + ON_COMMAND(ID_FILE_RESET, OnFileReset) + ON_UPDATE_COMMAND_UI(ID_FILE_RESET, OnUpdateFileReset) + ON_UPDATE_COMMAND_UI(ID_FILE_RECENT_FREEZE, OnUpdateFileRecentFreeze) + ON_COMMAND(ID_FILE_RECENT_RESET, OnFileRecentReset) + ON_COMMAND(ID_FILE_RECENT_FREEZE, OnFileRecentFreeze) + ON_COMMAND(ID_FILE_EXIT, OnFileExit) + ON_COMMAND(ID_FILE_CLOSE, OnFileClose) + ON_UPDATE_COMMAND_UI(ID_FILE_CLOSE, OnUpdateFileClose) + ON_COMMAND(ID_FILE_LOAD, OnFileLoad) + ON_UPDATE_COMMAND_UI(ID_FILE_LOAD, OnUpdateFileLoad) + ON_COMMAND(ID_FILE_SAVE, OnFileSave) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave) + ON_COMMAND(ID_FILE_IMPORT_BATTERYFILE, OnFileImportBatteryfile) + ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_BATTERYFILE, OnUpdateFileImportBatteryfile) + ON_COMMAND(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnFileImportGamesharkcodefile) + ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKCODEFILE, OnUpdateFileImportGamesharkcodefile) + ON_COMMAND(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnFileImportGamesharksnapshot) + ON_UPDATE_COMMAND_UI(ID_FILE_IMPORT_GAMESHARKSNAPSHOT, OnUpdateFileImportGamesharksnapshot) + ON_COMMAND(ID_FILE_EXPORT_BATTERYFILE, OnFileExportBatteryfile) + ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_BATTERYFILE, OnUpdateFileExportBatteryfile) + ON_COMMAND(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnFileExportGamesharksnapshot) + ON_UPDATE_COMMAND_UI(ID_FILE_EXPORT_GAMESHARKSNAPSHOT, OnUpdateFileExportGamesharksnapshot) + ON_COMMAND(ID_FILE_SCREENCAPTURE, OnFileScreencapture) + ON_UPDATE_COMMAND_UI(ID_FILE_SCREENCAPTURE, OnUpdateFileScreencapture) + ON_COMMAND(ID_FILE_ROMINFORMATION, OnFileRominformation) + ON_UPDATE_COMMAND_UI(ID_FILE_ROMINFORMATION, OnUpdateFileRominformation) + ON_COMMAND(ID_FILE_TOGGLEMENU, OnFileTogglemenu) + ON_UPDATE_COMMAND_UI(ID_FILE_TOGGLEMENU, OnUpdateFileTogglemenu) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnUpdateOptionsFrameskipThrottle6) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnUpdateOptionsFrameskipThrottle15) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnUpdateOptionsFrameskipThrottle25) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_37, OnUpdateOptionsFrameskipThrottle37) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnUpdateOptionsFrameskipThrottle50) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnUpdateOptionsFrameskipThrottle75) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_87, OnUpdateOptionsFrameskipThrottle87) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnUpdateOptionsFrameskipThrottle100) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_112, OnUpdateOptionsFrameskipThrottle112) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnUpdateOptionsFrameskipThrottle125) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnUpdateOptionsFrameskipThrottle150) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnUpdateOptionsFrameskipThrottle200) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnUpdateOptionsFrameskipThrottle300) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnUpdateOptionsFrameskipThrottleOther) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnUpdateOptionsFrameskipThrottleIncrease) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnUpdateOptionsFrameskipThrottleDecrease) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_6, OnOptionsFrameskipThrottle6) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_15, OnOptionsFrameskipThrottle15) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_25, OnOptionsFrameskipThrottle25) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_37, OnOptionsFrameskipThrottle37) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_50, OnOptionsFrameskipThrottle50) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_75, OnOptionsFrameskipThrottle75) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_87, OnOptionsFrameskipThrottle87) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_100, OnOptionsFrameskipThrottle100) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_112, OnOptionsFrameskipThrottle112) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_125, OnOptionsFrameskipThrottle125) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnOptionsFrameskipThrottle150) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnOptionsFrameskipThrottle200) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_300, OnOptionsFrameskipThrottle300) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnOptionsFrameskipThrottleOther) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, OnOptionsFrameskipThrottleIncrease) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, OnOptionsFrameskipThrottleDecrease) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnOptionsFrameskipAccuratePitch) + ON_COMMAND(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnOptionsFrameskipAccurateSpeed) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATEPITCH, OnUpdateOptionsFrameskipAccuratePitch) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_ACCURATESPEED, OnUpdateOptionsFrameskipAccurateSpeed) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_0, OnUpdateOptionsVideoFrameskip0) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_1, OnUpdateOptionsVideoFrameskip1) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_2, OnUpdateOptionsVideoFrameskip2) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_3, OnUpdateOptionsVideoFrameskip3) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_4, OnUpdateOptionsVideoFrameskip4) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_5, OnUpdateOptionsVideoFrameskip5) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_6, OnUpdateOptionsVideoFrameskip6) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_7, OnUpdateOptionsVideoFrameskip7) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_8, OnUpdateOptionsVideoFrameskip8) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_9, OnUpdateOptionsVideoFrameskip9) + ON_COMMAND(ID_OPTIONS_VIDEO_VSYNC, OnOptionsVideoVsync) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_VSYNC, OnUpdateOptionsVideoVsync) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X1, OnUpdateOptionsVideoX1) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X2, OnUpdateOptionsVideoX2) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X3, OnUpdateOptionsVideoX3) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_X4, OnUpdateOptionsVideoX4) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnUpdateOptionsVideoFullscreen320x240) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnUpdateOptionsVideoFullscreen640x480) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnUpdateOptionsVideoFullscreen800x600) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN320X240, OnOptionsVideoFullscreen320x240) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN640X480, OnOptionsVideoFullscreen640x480) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN800X600, OnOptionsVideoFullscreen800x600) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREEN, OnOptionsVideoFullscreen) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREEN, OnUpdateOptionsVideoFullscreen) + ON_WM_MOVE() + ON_WM_SIZE() + ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESFX, OnOptionsVideoDisablesfx) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESFX, OnUpdateOptionsVideoDisablesfx) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnOptionsVideoFullscreenstretchtofit) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT, OnUpdateOptionsVideoFullscreenstretchtofit) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnOptionsVideoRendermethodGdi) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_GDI, OnUpdateOptionsVideoRendermethodGdi) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnOptionsVideoRendermethodDirectdraw) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW, OnUpdateOptionsVideoRendermethodDirectdraw) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnOptionsVideoRendermethodDirect3d) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D, OnUpdateOptionsVideoRendermethodDirect3d) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnOptionsVideoRendermethodOpengl) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL, OnUpdateOptionsVideoRendermethodOpengl) + ON_COMMAND(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnOptionsVideoTriplebuffering) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TRIPLEBUFFERING, OnUpdateOptionsVideoTriplebuffering) + ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnOptionsVideoDdrawemulationonly) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY, OnUpdateOptionsVideoDdrawemulationonly) + ON_COMMAND(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnOptionsVideoDdrawusevideomemory) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY, OnUpdateOptionsVideoDdrawusevideomemory) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnOptionsVideoRenderoptionsD3dnofilter) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER, OnUpdateOptionsVideoRenderoptionsD3dnofilter) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnOptionsVideoRenderoptionsD3dbilinear) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR, OnUpdateOptionsVideoRenderoptionsD3dbilinear) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnOptionsVideoRenderoptionsGlnearest) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST, OnUpdateOptionsVideoRenderoptionsGlnearest) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnOptionsVideoRenderoptionsGlbilinear) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR, OnUpdateOptionsVideoRenderoptionsGlbilinear) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnOptionsVideoRenderoptionsGltriangle) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnUpdateOptionsVideoRenderoptionsGltriangle) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnOptionsVideoRenderoptionsGlquads) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnUpdateOptionsVideoRenderoptionsGlquads) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnOptionsVideoRenderoptionsSelectskin) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnUpdateOptionsVideoRenderoptionsSelectskin) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnOptionsVideoRenderoptionsSkin) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnUpdateOptionsVideoRenderoptionsSkin) + ON_WM_CONTEXTMENU() + ON_COMMAND(ID_OPTIONS_EMULATOR_ASSOCIATE, OnOptionsEmulatorAssociate) + ON_COMMAND(ID_OPTIONS_EMULATOR_DIRECTORIES, OnOptionsEmulatorDirectories) + ON_COMMAND(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnOptionsVideoDisablestatusmessages) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES, OnUpdateOptionsVideoDisablestatusmessages) + ON_COMMAND(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnOptionsEmulatorSynchronize) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SYNCHRONIZE, OnUpdateOptionsEmulatorSynchronize) + ON_COMMAND(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnOptionsEmulatorPausewheninactive) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE, OnUpdateOptionsEmulatorPausewheninactive) + ON_COMMAND(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnOptionsEmulatorSpeeduptoggle) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE, OnUpdateOptionsEmulatorSpeeduptoggle) + ON_COMMAND(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnOptionsEmulatorRemoveintrosgba) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REMOVEINTROSGBA, OnUpdateOptionsEmulatorRemoveintrosgba) + ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnOptionsEmulatorAutomaticallyipspatch) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH, OnUpdateOptionsEmulatorAutomaticallyipspatch) + ON_COMMAND(ID_OPTIONS_EMULATOR_AGBPRINT, OnOptionsEmulatorAgbprint) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AGBPRINT, OnUpdateOptionsEmulatorAgbprint) + ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnUpdateOptionsEmulatorRealtimeclock) + ON_COMMAND(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnOptionsEmulatorAutohidemenu) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_AUTOHIDEMENU, OnUpdateOptionsEmulatorAutohidemenu) + ON_COMMAND(ID_OPTIONS_EMULATOR_REWINDINTERVAL, OnOptionsEmulatorRewindinterval) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnOptionsEmulatorSavetypeAutomatic) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnUpdateOptionsEmulatorSavetypeAutomatic) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnOptionsEmulatorSavetypeEeprom) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnUpdateOptionsEmulatorSavetypeEeprom) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnOptionsEmulatorSavetypeSram) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_SRAM, OnUpdateOptionsEmulatorSavetypeSram) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnOptionsEmulatorSavetypeFlash) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH, OnUpdateOptionsEmulatorSavetypeFlash) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnOptionsEmulatorSavetypeEepromsensor) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR, OnUpdateOptionsEmulatorSavetypeEepromsensor) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnOptionsEmulatorSavetypeNone) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_NONE, OnUpdateOptionsEmulatorSavetypeNone) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnOptionsEmulatorSavetypeFlash512k) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnUpdateOptionsEmulatorSavetypeFlash512k) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnOptionsEmulatorSavetypeFlash1m) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnUpdateOptionsEmulatorSavetypeFlash1m) + ON_COMMAND(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnOptionsEmulatorUsebiosfile) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_USEBIOSFILE, OnUpdateOptionsEmulatorUsebiosfile) + ON_COMMAND(ID_OPTIONS_EMULATOR_SKIPBIOS, OnOptionsEmulatorSkipbios) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SKIPBIOS, OnUpdateOptionsEmulatorSkipbios) + ON_COMMAND(ID_OPTIONS_EMULATOR_SELECTBIOSFILE, OnOptionsEmulatorSelectbiosfile) + ON_COMMAND(ID_EMULATOR_USEOLDGBTIMING, OnOptionsEmulatorUseOldGBTiming) + ON_UPDATE_COMMAND_UI(ID_EMULATOR_USEOLDGBTIMING, OnUpdateOptionsEmulatorUseOldGBTiming) + ON_COMMAND(ID_EMULATOR_GBALAG, OnOptionsEmulatorGBALag) + ON_UPDATE_COMMAND_UI(ID_EMULATOR_GBALAG, OnUpdateOptionsEmulatorGBALag) + ON_COMMAND(ID_OPTIONS_EMULATOR_PNGFORMAT, OnOptionsEmulatorPngformat) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PNGFORMAT, OnUpdateOptionsEmulatorPngformat) + ON_COMMAND(ID_OPTIONS_EMULATOR_BMPFORMAT, OnOptionsEmulatorBmpformat) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BMPFORMAT, OnUpdateOptionsEmulatorBmpformat) + ON_COMMAND(ID_OPTIONS_SOUND_OFF, OnOptionsSoundOff) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_OFF, OnUpdateOptionsSoundOff) + ON_COMMAND(ID_OPTIONS_SOUND_MUTE, OnOptionsSoundMute) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTE, OnUpdateOptionsSoundMute) + ON_COMMAND(ID_OPTIONS_SOUND_ON, OnOptionsSoundOn) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ON, OnUpdateOptionsSoundOn) + ON_COMMAND(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnOptionsSoundUseoldsynchronization) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION, OnUpdateOptionsSoundUseoldsynchronization) + ON_COMMAND(ID_OPTIONS_SOUND_ECHO, OnOptionsSoundEcho) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_ECHO, OnUpdateOptionsSoundEcho) + ON_COMMAND(ID_OPTIONS_SOUND_LOWPASSFILTER, OnOptionsSoundLowpassfilter) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_LOWPASSFILTER, OnUpdateOptionsSoundLowpassfilter) + ON_COMMAND(ID_OPTIONS_SOUND_REVERSESTEREO, OnOptionsSoundReversestereo) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_REVERSESTEREO, OnUpdateOptionsSoundReversestereo) + ON_COMMAND(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnOptionsSoundMuteFrameAdvance) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_MUTEFRAMEADVANCE, OnUpdateOptionsSoundMuteFrameAdvance) + ON_COMMAND(ID_OPTIONS_SOUND_11KHZ, OnOptionsSound11khz) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_11KHZ, OnUpdateOptionsSound11khz) + ON_COMMAND(ID_OPTIONS_SOUND_22KHZ, OnOptionsSound22khz) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_22KHZ, OnUpdateOptionsSound22khz) + ON_COMMAND(ID_OPTIONS_SOUND_44KHZ, OnOptionsSound44khz) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_44KHZ, OnUpdateOptionsSound44khz) + ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL1, OnOptionsSoundChannel1) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL1, OnUpdateOptionsSoundChannel1) + ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL2, OnOptionsSoundChannel2) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL2, OnUpdateOptionsSoundChannel2) + ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL3, OnOptionsSoundChannel3) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL3, OnUpdateOptionsSoundChannel3) + ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL4, OnOptionsSoundChannel4) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL4, OnUpdateOptionsSoundChannel4) + ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnOptionsSoundDirectsounda) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDA, OnUpdateOptionsSoundDirectsounda) + ON_COMMAND(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnOptionsSoundDirectsoundb) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_DIRECTSOUNDB, OnUpdateOptionsSoundDirectsoundb) + ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDER, OnOptionsGameboyBorder) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDER, OnUpdateOptionsGameboyBorder) + ON_COMMAND(ID_OPTIONS_GAMEBOY_PRINTER, OnOptionsGameboyPrinter) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_PRINTER, OnUpdateOptionsGameboyPrinter) + ON_COMMAND(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnOptionsGameboyBorderAutomatic) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC, OnUpdateOptionsGameboyBorderAutomatic) + ON_COMMAND(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnOptionsGameboyAutomatic) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_AUTOMATIC, OnUpdateOptionsGameboyAutomatic) + ON_COMMAND(ID_OPTIONS_GAMEBOY_GBA, OnOptionsGameboyGba) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GBA, OnUpdateOptionsGameboyGba) + ON_COMMAND(ID_OPTIONS_GAMEBOY_CGB, OnOptionsGameboyCgb) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_CGB, OnUpdateOptionsGameboyCgb) + ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB, OnOptionsGameboySgb) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB, OnUpdateOptionsGameboySgb) + ON_COMMAND(ID_OPTIONS_GAMEBOY_SGB2, OnOptionsGameboySgb2) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_SGB2, OnUpdateOptionsGameboySgb2) + ON_COMMAND(ID_OPTIONS_GAMEBOY_GB, OnOptionsGameboyGb) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GB, OnUpdateOptionsGameboyGb) + ON_COMMAND(ID_OPTIONS_GAMEBOY_REALCOLORS, OnOptionsGameboyRealcolors) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_REALCOLORS, OnUpdateOptionsGameboyRealcolors) + ON_COMMAND(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnOptionsGameboyGameboycolors) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS, OnUpdateOptionsGameboyGameboycolors) + ON_COMMAND(ID_OPTIONS_GAMEBOY_COLORS, OnOptionsGameboyColors) + ON_COMMAND(ID_OPTIONS_FILTER_DISABLEMMX, OnOptionsFilterDisablemmx) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_FILTER_DISABLEMMX, OnUpdateOptionsFilterDisablemmx) + ON_COMMAND(ID_OPTIONS_LANGUAGE_SYSTEM, OnOptionsLanguageSystem) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_SYSTEM, OnUpdateOptionsLanguageSystem) + ON_COMMAND(ID_OPTIONS_LANGUAGE_ENGLISH, OnOptionsLanguageEnglish) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_ENGLISH, OnUpdateOptionsLanguageEnglish) + ON_COMMAND(ID_OPTIONS_LANGUAGE_OTHER, OnOptionsLanguageOther) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_LANGUAGE_OTHER, OnUpdateOptionsLanguageOther) + ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnOptionsJoypadConfigure1) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_1, OnUpdateOptionsJoypadConfigure1) + ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnOptionsJoypadConfigure2) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_2, OnUpdateOptionsJoypadConfigure2) + ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnOptionsJoypadConfigure3) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_3, OnUpdateOptionsJoypadConfigure3) + ON_COMMAND(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnOptionsJoypadConfigure4) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_CONFIGURE_4, OnUpdateOptionsJoypadConfigure4) + ON_COMMAND(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnOptionsJoypadMotionconfigure) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_MOTIONCONFIGURE, OnUpdateOptionsJoypadMotionconfigure) + ON_COMMAND(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnOptionsJoypadAllowLeftRight) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT, OnUpdateOptionsJoypadAllowLeftRight) + ON_COMMAND(ID_CHEATS_SEARCHFORCHEATS, OnCheatsSearchforcheats) + ON_UPDATE_COMMAND_UI(ID_CHEATS_SEARCHFORCHEATS, OnUpdateCheatsSearchforcheats) + ON_COMMAND(ID_CHEATS_CHEATLIST, OnCheatsCheatlist) + ON_UPDATE_COMMAND_UI(ID_CHEATS_CHEATLIST, OnUpdateCheatsCheatlist) + ON_COMMAND(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnCheatsAutomaticsaveloadcheats) + ON_COMMAND(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnCheatsPauseDuringCheatSearch) + ON_COMMAND(ID_CHEATS_LOADCHEATLIST, OnCheatsLoadcheatlist) + ON_UPDATE_COMMAND_UI(ID_CHEATS_LOADCHEATLIST, OnUpdateCheatsLoadcheatlist) + ON_COMMAND(ID_CHEATS_SAVECHEATLIST, OnCheatsSavecheatlist) + ON_UPDATE_COMMAND_UI(ID_CHEATS_SAVECHEATLIST, OnUpdateCheatsSavecheatlist) + ON_COMMAND(ID_TOOLS_DISASSEMBLE, OnToolsDisassemble) + ON_UPDATE_COMMAND_UI(ID_TOOLS_DISASSEMBLE, OnUpdateToolsDisassemble) + ON_COMMAND(ID_TOOLS_LOGGING, OnToolsLogging) + ON_UPDATE_COMMAND_UI(ID_TOOLS_LOGGING, OnUpdateToolsLogging) + ON_COMMAND(ID_TOOLS_IOVIEWER, OnToolsIoviewer) + ON_UPDATE_COMMAND_UI(ID_TOOLS_IOVIEWER, OnUpdateToolsIoviewer) + ON_COMMAND(ID_TOOLS_MAPVIEW, OnToolsMapview) + ON_UPDATE_COMMAND_UI(ID_TOOLS_MAPVIEW, OnUpdateToolsMapview) + ON_COMMAND(ID_TOOLS_MEMORYVIEWER, OnToolsMemoryviewer) + ON_UPDATE_COMMAND_UI(ID_TOOLS_MEMORYVIEWER, OnUpdateToolsMemoryviewer) + ON_COMMAND(ID_TOOLS_OAMVIEWER, OnToolsOamviewer) + ON_UPDATE_COMMAND_UI(ID_TOOLS_OAMVIEWER, OnUpdateToolsOamviewer) + ON_COMMAND(ID_TOOLS_PALETTEVIEW, OnToolsPaletteview) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PALETTEVIEW, OnUpdateToolsPaletteview) + ON_COMMAND(ID_TOOLS_TILEVIEWER, OnToolsTileviewer) + ON_UPDATE_COMMAND_UI(ID_TOOLS_TILEVIEWER, OnUpdateToolsTileviewer) + ON_COMMAND(ID_DEBUG_NEXTFRAME, OnDebugNextframe) + ON_UPDATE_COMMAND_UI(ID_DEBUG_NEXTFRAME, OnUpdateDebugNextframe) + ON_COMMAND(ID_DEBUG_FRAMESEARCH, OnDebugFramesearch) + ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCH, OnUpdateDebugFramesearch) + ON_COMMAND(ID_DEBUG_FRAMESEARCHPREV, OnDebugFramesearchPrev) + ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHPREV, OnUpdateDebugFramesearchPrev) + ON_COMMAND(ID_DEBUG_FRAMESEARCHLOAD, OnDebugFramesearchLoad) + ON_UPDATE_COMMAND_UI(ID_DEBUG_FRAMESEARCHLOAD, OnUpdateDebugFramesearchLoad) + ON_UPDATE_COMMAND_UI(ID_CHEATS_AUTOMATICSAVELOADCHEATS, OnUpdateCheatsAutomaticsaveloadcheats) + ON_UPDATE_COMMAND_UI(ID_CHEATS_PAUSEDURINGCHEATSEARCH, OnUpdateCheatsPauseDuringCheatSearch) + ON_COMMAND(ID_TOOLS_FRAMECOUNTER, OnToolsFrameCounter) + ON_UPDATE_COMMAND_UI(ID_TOOLS_FRAMECOUNTER, OnUpdateToolsFrameCounter) + ON_COMMAND(ID_TOOLS_INPUTDISPLAY, OnToolsInputDisplay) + ON_UPDATE_COMMAND_UI(ID_TOOLS_INPUTDISPLAY, OnUpdateToolsInputDisplay) + ON_COMMAND(ID_TOOLS_DEBUG_GDB, OnToolsDebugGdb) + ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_GDB, OnUpdateToolsDebugGdb) + ON_COMMAND(ID_TOOLS_DEBUG_LOADANDWAIT, OnToolsDebugLoadandwait) + ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_LOADANDWAIT, OnUpdateToolsDebugLoadandwait) + ON_COMMAND(ID_TOOLS_DEBUG_BREAK, OnToolsDebugBreak) + ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_BREAK, OnUpdateToolsDebugBreak) + ON_COMMAND(ID_TOOLS_DEBUG_DISCONNECT, OnToolsDebugDisconnect) + ON_UPDATE_COMMAND_UI(ID_TOOLS_DEBUG_DISCONNECT, OnUpdateToolsDebugDisconnect) + ON_COMMAND(ID_OPTIONS_SOUND_STARTRECORDING, OnOptionsSoundStartrecording) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_STARTRECORDING, OnUpdateOptionsSoundStartrecording) + ON_COMMAND(ID_OPTIONS_SOUND_STOPRECORDING, OnOptionsSoundStoprecording) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_STOPRECORDING, OnUpdateOptionsSoundStoprecording) + ON_COMMAND(ID_TOOLS_RECORD_STARTAVIRECORDING, OnToolsRecordStartavirecording) + ON_UPDATE_COMMAND_UI(ID_TOOLS_RECORD_STARTAVIRECORDING, OnUpdateToolsRecordStartavirecording) + ON_COMMAND(ID_TOOLS_RECORD_STOPAVIRECORDING, OnToolsRecordStopavirecording) + ON_UPDATE_COMMAND_UI(ID_TOOLS_RECORD_STOPAVIRECORDING, OnUpdateToolsRecordStopavirecording) + ON_WM_PAINT() + ON_COMMAND(ID_TOOLS_RECORD_STARTMOVIERECORDING, OnToolsRecordStartmovierecording) + ON_UPDATE_COMMAND_UI(ID_TOOLS_RECORD_STARTMOVIERECORDING, OnUpdateToolsRecordStartmovierecording) + ON_COMMAND(ID_TOOLS_RECORD_STOPMOVIERECORDING, OnToolsRecordStopmovierecording) + ON_UPDATE_COMMAND_UI(ID_TOOLS_RECORD_STOPMOVIERECORDING, OnUpdateToolsRecordStopmovierecording) + ON_COMMAND(ID_TOOLS_PLAY_STARTMOVIEPLAYING, OnToolsPlayStartmovieplaying) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PLAY_STARTMOVIEPLAYING, OnUpdateToolsPlayStartmovieplaying) + ON_COMMAND(ID_TOOLS_PLAY_STOPMOVIEPLAYING, OnToolsPlayStopmovieplaying) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PLAY_STOPMOVIEPLAYING, OnUpdateToolsPlayStopmovieplaying) + ON_COMMAND(ID_TOOLS_PLAY_READONLY, OnToolsPlayReadOnly) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PLAY_READONLY, OnUpdateToolsPlayReadOnly) + ON_COMMAND(ID_TOOLS_PLAY_CONTINUE, OnToolsPlayContinue) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PLAY_CONTINUE, OnUpdateToolsPlayContinue) + ON_COMMAND(ID_TOOLS_PLAY_RESTART, OnToolsPlayRestart) + ON_UPDATE_COMMAND_UI(ID_TOOLS_PLAY_RESTART, OnUpdateToolsPlayRestart) + ON_COMMAND(ID_TOOLS_REWIND, OnToolsRewind) + ON_UPDATE_COMMAND_UI(ID_TOOLS_REWIND, OnUpdateToolsRewind) + ON_COMMAND(ID_TOOLS_CUSTOMIZE, OnToolsCustomize) + ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE, OnUpdateToolsCustomize) + ON_COMMAND(ID_TOOLS_CUSTOMIZE_COMMON, OnToolsCustomizeCommon) + ON_UPDATE_COMMAND_UI(ID_TOOLS_CUSTOMIZE_COMMON, OnUpdateToolsCustomizeCommon) + ON_COMMAND(ID_HELP_BUGREPORT, OnHelpBugreport) + ON_WM_MOUSEMOVE() + ON_WM_INITMENU() + ON_WM_ACTIVATE() + ON_WM_ACTIVATEAPP() + ON_WM_DROPFILES() + ON_COMMAND(ID_FILE_SAVEGAME_OLDESTSLOT, OnFileSavegameOldestslot) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_OLDESTSLOT, OnUpdateFileSavegameOldestslot) + ON_COMMAND(ID_FILE_LOADGAME_MOSTRECENT, OnFileLoadgameMostrecent) + ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MOSTRECENT, OnUpdateFileLoadgameMostrecent) + + ON_COMMAND(ID_FILE_SAVEGAME_CURRENT, OnFileSavegameCurrent) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_CURRENT, OnUpdateFileSavegameCurrent) + ON_COMMAND(ID_FILE_LOADGAME_CURRENT, OnFileLoadgameCurrent) + ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_CURRENT, OnUpdateFileLoadgameCurrent) + ON_COMMAND(ID_FILE_LOADGAME_MAKECURRENT, OnFileLoadgameMakeCurrent) + ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKECURRENT, OnUpdateFileLoadgameMakeCurrent) + ON_COMMAND(ID_FILE_SAVEGAME_MAKECURRENT, OnFileSavegameMakeCurrent) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_MAKECURRENT, OnUpdateFileSavegameMakeCurrent) + ON_COMMAND(ID_FILE_SAVEGAME_INCREMENTSLOT, OnFileSavegameIncrementSlot) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_INCREMENTSLOT, OnUpdateFileSavegameIncrementSlot) + ON_COMMAND(ID_FILE_SAVEGAME_DECREMENTSLOT, OnFileSavegameDecrementSlot) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVEGAME_DECREMENTSLOT, OnUpdateFileSavegameDecrementSlot) + + ON_COMMAND(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnFileLoadgameAutoloadmostrecent) + ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_AUTOLOADMOSTRECENT, OnUpdateFileLoadgameAutoloadmostrecent) + ON_COMMAND(ID_FILE_LOADGAME_MAKERECENT, OnFileLoadgameMakeRecent) + ON_UPDATE_COMMAND_UI(ID_FILE_LOADGAME_MAKERECENT, OnUpdateFileLoadgameMakeRecent) + ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_25X, OnOptionsSoundVolume25x) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_25X, OnUpdateOptionsSoundVolume25x) + ON_COMMAND(ID_OPTIONS_SOUND_VOLUME_5X, OnOptionsSoundVolume5x) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_VOLUME_5X, OnUpdateOptionsSoundVolume5x) + ON_COMMAND(ID_CHEATS_DISABLECHEATS, OnCheatsDisablecheats) + ON_UPDATE_COMMAND_UI(ID_CHEATS_DISABLECHEATS, OnUpdateCheatsDisablecheats) + ON_COMMAND(ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE, OnOptionsVideoFullscreenmaxscale) + //}}AFX_MSG_MAP + ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE10, OnFileRecentFile) + ON_COMMAND_EX_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnFileLoadSlot) + ON_COMMAND_EX_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnFileSaveSlot) + ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_LOADGAME_SLOT1, ID_FILE_LOADGAME_SLOT10, OnUpdateFileLoadGameSlot) + ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_SAVEGAME_SLOT1, ID_FILE_SAVEGAME_SLOT10, OnUpdateFileSaveGameSlot) + + ON_COMMAND_EX_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnSelectSlot) + ON_UPDATE_COMMAND_UI_RANGE(ID_SELECT_SLOT1, ID_SELECT_SLOT10, OnUpdateSelectSlot) + + ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_FRAMESKIP_0, ID_OPTIONS_VIDEO_FRAMESKIP_5, OnOptionsFrameskip) + ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_FRAMESKIP_6, ID_OPTIONS_VIDEO_FRAMESKIP_9, OnOptionsFrameskip) + ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_X1, ID_OPTIONS_VIDEO_X4, OnOptionVideoSize) + ON_COMMAND_EX_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnVideoLayer) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_VIDEO_LAYERS_BG0, ID_OPTIONS_VIDEO_LAYERS_OBJWIN, OnUpdateVideoLayer) + ON_COMMAND(ID_SYSTEM_MINIMIZE, OnSystemMinimize) + ON_COMMAND_EX_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE, ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT, OnOptionsEmulatorShowSpeed) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_EMULATOR_SHOWSPEED_NONE, ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT, OnUpdateOptionsEmulatorShowSpeed) + ON_COMMAND_EX_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnOptionsSoundVolume) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_SOUND_VOLUME_1X, ID_OPTIONS_SOUND_VOLUME_4X, OnUpdateOptionsSoundVolume) + ON_COMMAND_EX_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnOptionsPriority) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_PRIORITY_HIGHEST, ID_OPTIONS_PRIORITY_BELOWNORMAL, OnUpdateOptionsPriority) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_NORMAL, ID_OPTIONS_FILTER_TVMODE, OnUpdateOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL, ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL, OnUpdateOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X, ID_OPTIONS_FILTER16BIT_SIMPLE2X, OnUpdateOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_BILINEAR, ID_OPTIONS_FILTER_BILINEARPLUS, OnUpdateOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_SCANLINES, ID_OPTIONS_FILTER_SCANLINES, OnUpdateOptionsFilter) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_LQ2X, ID_OPTIONS_FILTER_HQ3X2, OnUpdateOptionsFilter) + ON_COMMAND_EX_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE, ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART, OnOptionsFilterIFB) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE, ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART, OnUpdateOptionsFilterIFB) + ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnOptionsJoypadDefault) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1, ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4, OnUpdateOptionsJoypadDefault) + ON_COMMAND_EX_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnOptionsJoypadAutofire) + ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_JOYPAD_AUTOFIRE_A, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, OnUpdateOptionsJoypadAutofire) + ON_COMMAND_EX_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnOptionsJoypadSticky) + ON_UPDATE_COMMAND_UI_RANGE(ID_STICKY_A, ID_STICKY_CLEAR, OnUpdateOptionsJoypadSticky) + ON_MESSAGE(VBA_CONFIRM_MODE, OnConfirmMode) + ON_MESSAGE(WM_SYSCOMMAND, OnMySysCommand) + ON_COMMAND(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnOptionsVideoTextdisplayoptions) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS, OnUpdateOptionsVideoTextdisplayoptions) + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// MainWnd message handlers + +bool vbaShuttingDown = false; + +void MainWnd::OnClose() +{ + vbaShuttingDown = true; // HACK to fix crash on exit while memory viewer is open + + CWnd::OnClose(); + + delete this; +} + +bool MainWnd::FileRun() +{ + int prevCartridgeType = theApp.cartridgeType; + + // save battery file before we change the filename... + if(rom != NULL || gbRom != NULL) { + if(theApp.autoSaveLoadCheatList) + winSaveCheatListDefault(); + writeBatteryFile(); + cheatSearchCleanup(&cheatSearchData); + theApp.emulator.emuCleanUp(); + remoteCleanUp(); + if(VBAMovieActive()) + VBAMovieStop(false); // will only get here on user selecting to open a ROM, canceling movie + emulating = false; + theApp.frameSearching = false; + theApp.frameSearchSkipping = false; + } + char tempName[2048]; + char file[2048]; + + utilGetBaseName(theApp.szFile, tempName); + + _fullpath(file, tempName, 1024); + theApp.filename = file; + + int index = theApp.filename.ReverseFind('.'); + if(index != -1) + theApp.filename = theApp.filename.Left(index); + + CString ipsname; + ipsname.Format("%s.ips", theApp.filename); + + if(!theApp.dir.GetLength()) { + int index = theApp.filename.ReverseFind('\\'); + if(index != -1) { + theApp.dir = theApp.filename.Left(index-1); + } + } + + IMAGE_TYPE type = utilFindType(theApp.szFile); + + if(type == IMAGE_UNKNOWN) { + systemMessage(IDS_UNSUPPORTED_FILE_TYPE, + "The file \"%s\" is an unsupported type.", theApp.szFile); + return false; + } + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + theApp.cartridgeType = (int)type; + if(type == IMAGE_GB) { + if(!gbLoadRom(theApp.szFile)) + return false; + theApp.emulator = GBSystem; + gbBorderOn = theApp.winGbBorderOn; + theApp.romSize = gbRomSize; + if(theApp.autoIPS) { + int size = gbRomSize; + utilApplyIPS(ipsname, &gbRom, &size); + if(size != gbRomSize) { + extern bool gbUpdateSizes(); + gbUpdateSizes(); + gbReset(); + theApp.romSize = size; + } + } + } else { + int size = CPULoadRom(theApp.szFile); + if(!size) + return false; + + theApp.romSize = size; + + flashSetSize(theApp.winFlashSize); + rtcEnable(theApp.winRtcEnable); + cpuSaveType = theApp.winSaveType; + + // if(cpuEnhancedDetection && winSaveType == 0) { + // utilGBAFindSave(rom, size); + // } + GetModuleFileName(NULL, tempName, 2048); + + char *p = strrchr(tempName, '\\'); + if(p) + *p = 0; + + char buffer[5]; + strncpy(buffer, (const char *)&rom[0xac], 4); + buffer[4] = 0; + + strcat(tempName, "\\vba-over.ini"); + + UINT i = GetPrivateProfileInt(buffer, + "rtcEnabled", + -1, + tempName); + if(i != (UINT)-1) + rtcEnable(i == 0 ? false : true); + + i = GetPrivateProfileInt(buffer, + "flashSize", + -1, + tempName); + if(i != (UINT)-1 && (i == 0x10000 || i == 0x20000)) + flashSetSize((int)i); + + i = GetPrivateProfileInt(buffer, + "saveType", + -1, + tempName); + if(i != (UINT)-1 && (i <= 5)) + cpuSaveType = (int)i; + + theApp.emulator = GBASystem; + /* disabled due to problems + if(theApp.removeIntros && rom != NULL) { + *((u32 *)rom)= 0xea00002e; + } + */ + + if(theApp.autoIPS) { + int size = 0x2000000; + utilApplyIPS(ipsname, &rom, &size); + if(size != 0x2000000) { + CPUReset(); + } + } + } + + if(theApp.soundInitialized) { + if(theApp.cartridgeType == 1) + gbSoundReset(); + else + soundReset(); + } else { + if(!soundOffFlag) + soundInit(); + theApp.soundInitialized = true; + } + + if(type == IMAGE_GBA) { + skipBios = theApp.skipBiosFile ? true : false; + CPUInit((char *)(LPCTSTR)theApp.biosFileName, theApp.useBiosFile ? true : false); + CPUReset(); + } + + readBatteryFile(); + + if(theApp.autoSaveLoadCheatList) + winLoadCheatListDefault(); + + theApp.addRecentFile(theApp.szFile); + + theApp.updateWindowSize(theApp.videoOption); + + theApp.updateFrameSkip(); + + if(theApp.autoHideMenu && theApp.videoOption > VIDEO_4X && theApp.menuToggle) + OnFileTogglemenu(); + + emulating = true; + + if(theApp.autoLoadMostRecent && !VBAMovieActive() && !VBAMovieLoading()) // would cause desync in movies... + OnFileLoadgameMostrecent(); + + theApp.frameskipadjust = 0; + theApp.renderedFrames = 0; + + theApp.rewindCount = 0; + theApp.rewindCounter = 0; + theApp.rewindSaveNeeded = false; + + { + extern bool playMovieFile, playMovieFileReadOnly, outputWavFile, outputAVIFile, flagHideMenu; // from VBA.cpp + extern char movieFileToPlay [1024], wavFileToOutput [1024]; // from VBA.cpp + extern int pauseAfterTime; // from VBA.cpp + if(playMovieFile) + { + playMovieFile = false; + VBAMovieOpen(movieFileToPlay, playMovieFileReadOnly); + } + if(outputWavFile) + { + outputWavFile = false; + theApp.soundRecordName = wavFileToOutput; + theApp.soundRecording = true; + } + if(outputAVIFile) + { + outputAVIFile = false; + OnToolsRecordStartavirecording(); + } + if(pauseAfterTime >= 0) + { + VBAMovieSetPauseAt(pauseAfterTime); + } + if(flagHideMenu) + { + OnFileTogglemenu(); + theApp.updateWindowSize(theApp.videoOption); + } + } + + if(theApp.cartridgeType != prevCartridgeType) + { + extern GBACheatSearch gbaDlg; + extern GBCheatSearch gbDlg; + if(!theApp.pauseDuringCheatSearch && theApp.modelessCheatDialogIsOpen) + { + gbaDlg.DestroyWindow(); + gbDlg.DestroyWindow(); + theApp.modelessCheatDialogIsOpen = false; + } + } + + return true; +} + +void MainWnd::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu) +{ + ASSERT(pMenu != NULL); + + CCmdUI state; + state.m_pMenu = pMenu; + ASSERT(state.m_pOther == NULL); + ASSERT(state.m_pParentMenu == NULL); + + // determine if menu is popup in top-level menu and set m_pOther to + // it if so (m_pParentMenu == NULL indicates that it is secondary popup) + HMENU hParentMenu; + if (AfxGetThreadState()->m_hTrackingMenu == pMenu->m_hMenu) + state.m_pParentMenu = pMenu; // parent == child for tracking popup + else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL) { + CWnd* pParent = GetTopLevelParent(); + // child windows don't have menus -- need to go to the top! + if (pParent != NULL && + (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL) { + int nIndexMax = ::GetMenuItemCount(hParentMenu); + for (int nIndex = 0; nIndex < nIndexMax; nIndex++) { + if (::GetSubMenu(hParentMenu, nIndex) == pMenu->m_hMenu) { + // when popup is found, m_pParentMenu is containing menu + state.m_pParentMenu = CMenu::FromHandle(hParentMenu); + break; + } + } + } + } + + state.m_nIndexMax = pMenu->GetMenuItemCount(); + for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax; + state.m_nIndex++) { + state.m_nID = pMenu->GetMenuItemID(state.m_nIndex); + if (state.m_nID == 0) + continue; // menu separator or invalid cmd - ignore it + + ASSERT(state.m_pOther == NULL); + ASSERT(state.m_pMenu != NULL); + if (state.m_nID == (UINT)-1) { + // possibly a popup menu, route to first item of that popup + state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex); + if (state.m_pSubMenu == NULL || + (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 || + state.m_nID == (UINT)-1) { + continue; // first item of popup can't be routed to + } + state.DoUpdate(this, FALSE); // popups are never auto disabled + } else { + // normal menu item + // Auto enable/disable if frame window has 'm_bAutoMenuEnable' + // set and command is _not_ a system command. + state.m_pSubMenu = NULL; + state.DoUpdate(this, state.m_nID < 0xF000); + } + + // adjust for menu deletions and additions + UINT nCount = pMenu->GetMenuItemCount(); + if (nCount < state.m_nIndexMax) { + state.m_nIndex -= (state.m_nIndexMax - nCount); + while (state.m_nIndex < nCount && + pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID) { + state.m_nIndex++; + } + } + state.m_nIndexMax = nCount; + } +} + +void MainWnd::OnMove(int x, int y) +{ + CWnd::OnMove(x, y); + + if(!theApp.changingVideoSize) { + if(this) { + if(!IsIconic()) { + RECT r; + + GetWindowRect(&r); + theApp.windowPositionX = r.left; + theApp.windowPositionY = r.top; + theApp.adjustDestRect(); + regSetDwordValue("windowX", theApp.windowPositionX); + regSetDwordValue("windowY", theApp.windowPositionY); + } + } + } +} + +static bool wasPaused = false; +static int lastType = -1; + +void MainWnd::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + // hack to re-maximize window after it auto-unmaximizes while loading a ROM + if(nType == SIZE_MAXIMIZED && lastType == SIZE_MAXIMIZED) + { + lastType = -1; + ShowWindow(SW_SHOWMAXIMIZED); + MoveWindow(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN)); + return; + } + else + lastType = nType; + + if(!theApp.changingVideoSize) { + if(this) { + if(!IsIconic()) { + if(theApp.iconic) { + if(emulating) { + if(!wasPaused) + { + soundResume(); + theApp.paused = false; + } + } + } + if(theApp.videoOption <= VIDEO_4X) { + theApp.surfaceSizeX = cx; + theApp.surfaceSizeY = cy; + theApp.adjustDestRect(); + if(theApp.display) + theApp.display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top); + } + } else { + if(emulating) { + if(!theApp.paused) { + wasPaused = theApp.paused; + theApp.paused = true; + soundPause(); + } + } + theApp.iconic = true; + } + } + } +} + +void MainWnd::winSaveCheatListDefault() +{ + CString name; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + CString dir = regQueryStringValue("saveDir", NULL); + + if(!dir.GetLength()) + dir = getDirFromFile(filename); + + if(isDriveRoot(dir)) + filename.Format("%s%s.clt", dir, name); + else + filename.Format("%s\\%s.clt", dir, name); + + winSaveCheatList(filename); +} + +void MainWnd::winSaveCheatList(const char *name) +{ + if(theApp.cartridgeType == 0) + cheatsSaveCheatList(name); + else + gbCheatsSaveCheatList(name); +} + +void MainWnd::winLoadCheatListDefault() +{ + CString name; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + CString dir = regQueryStringValue("saveDir", NULL); + + if(!dir.GetLength()) + dir = getDirFromFile(filename); + + if(isDriveRoot(dir)) + filename.Format("%s%s.clt", dir, name); + else + filename.Format("%s\\%s.clt", dir, name); + + winLoadCheatList(filename); +} + +void MainWnd::winLoadCheatList(const char *name) +{ + bool res = false; + + if(theApp.cartridgeType == 0) + res = cheatsLoadCheatList(name); + else + res = gbCheatsLoadCheatList(name); + + if(res) + systemScreenMessage(winResLoadString(IDS_LOADED_CHEATS)); +} + +CString MainWnd::getDirFromFile(CString& file) +{ + CString temp = file; + int index = temp.ReverseFind('\\'); + + if(index != -1) { + temp = temp.Left(index); + if(temp.GetLength() == 2 && temp[1] == ':') + temp += "\\"; + } else { + temp = ""; + } + return temp; +} + +bool MainWnd::isDriveRoot(CString& file) +{ + if(file.GetLength() == 3) { + if(file[1] == ':' && file[2] == '\\') + return true; + } + return false; +} + +void MainWnd::writeBatteryFile() +{ + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("batteryDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.sav", saveDir, buffer); + else + filename.Format("%s\\%s.sav", saveDir, buffer); + + if(theApp.emulator.emuWriteBattery) + theApp.emulator.emuWriteBattery(filename); +} + + +void MainWnd::readBatteryFile() +{ + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("batteryDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.sav", saveDir, buffer); + else + filename.Format("%s\\%s.sav", saveDir, buffer); + + bool res = false; + + if(theApp.emulator.emuReadBattery) + res = theApp.emulator.emuReadBattery(filename); + + if(res) + systemScreenMessage(winResLoadString(IDS_LOADED_BATTERY)); +} + +CString MainWnd::winLoadFilter(UINT id) +{ + CString res = winResLoadString(id); + res.Replace('_','|'); + + return res; +} + +bool MainWnd::loadSaveGame(const char *name) +{ + if(theApp.emulator.emuReadState) + return theApp.emulator.emuReadState(name); + return false; +} + +bool MainWnd::writeSaveGame(const char *name) +{ + if(theApp.emulator.emuWriteState) + return theApp.emulator.emuWriteState(name); + return false; +} + +void MainWnd::OnContextMenu(CWnd* pWnd, CPoint point) +{ + winMouseOn(); + if(theApp.skin) { + if(theApp.popup == NULL) { + theApp.winAccelMgr.UpdateMenu(theApp.menu); + theApp.popup = CreatePopupMenu(); + if(theApp.menu != NULL) { + int count = GetMenuItemCount(theApp.menu); + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + + if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + for(int i = 0; i < count; i++) { + char buffer[256]; + MENUITEMINFO info; + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info) - sizeof(HBITMAP); + info.fMask = MIIM_STRING | MIIM_SUBMENU; + info.dwTypeData = buffer; + info.cch = 256; + if(!GetMenuItemInfo(theApp.menu, i, MF_BYPOSITION, &info)) { + } + if(!AppendMenu(theApp.popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) { + } + } + } else { + for(int i = 0; i < count; i++) { + wchar_t buffer[256]; + MENUITEMINFOW info; + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info) - sizeof(HBITMAP); + info.fMask = MIIM_STRING | MIIM_SUBMENU; + info.dwTypeData = buffer; + info.cch = 256; + if(!GetMenuItemInfoW(theApp.menu, i, MF_BYPOSITION, &info)) { + } + if(!AppendMenuW(theApp.popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) { + } + } + } + } + } + int x = point.x; + int y = point.y; + if(x == -1 && y == -1) { + x = (theApp.dest.left + theApp.dest.right) / 2; + y = (theApp.dest.top + theApp.dest.bottom) / 2; + } + if(!TrackPopupMenu(theApp.popup, 0, x, y, 0, m_hWnd, NULL)) { + } + } +} + +void MainWnd::OnSystemMinimize() +{ + ShowWindow(SW_SHOWMINIMIZED); +} + +bool MainWnd::fileOpenSelect() +{ + theApp.dir = ""; + CString initialDir = regQueryStringValue("romdir","."); + if(!initialDir.IsEmpty()) + theApp.dir = initialDir; + + int selectedFilter = regQueryDwordValue("selectedFilter", 0); + if(selectedFilter < 0 || selectedFilter > 2) + selectedFilter = 0; + + theApp.szFile = ""; + + LPCTSTR exts[] = { "" }; + CString filter = winLoadFilter(IDS_FILTER_ROM); + CString title = winResLoadString(IDS_SELECT_ROM); + + FileDlg dlg(this, "", filter, selectedFilter, "", exts, theApp.dir, title, false, true); + + if(dlg.DoModal() == IDOK) { + regSetDwordValue("selectedFilter", dlg.m_ofn.nFilterIndex); + theApp.szFile = dlg.GetPathName(); + theApp.dir = theApp.szFile.Left(dlg.m_ofn.nFileOffset); + if(theApp.dir.GetLength() > 3 && theApp.dir[theApp.dir.GetLength()-1] == '\\') + theApp.dir = theApp.dir.Left(theApp.dir.GetLength()-1); + regSetStringValue("romdir", theApp.dir); + return true; + } + return false; +} + +void MainWnd::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + if(emulating) { + theApp.painting = true; + systemDrawScreen(); + theApp.painting = false; + theApp.renderedFrames--; + } +} + +static bool translatingAccelerator = false; + +BOOL MainWnd::PreTranslateMessage(MSG* pMsg) +{ + translatingAccelerator = true; + if (CWnd::PreTranslateMessage(pMsg)) + { + translatingAccelerator = false; + return TRUE; + } + + if(pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) { + bool bHit = theApp.hAccel != NULL && ::TranslateAccelerator(m_hWnd, theApp.hAccel, pMsg); + + // HACK to get around the fact that TranslateAccelerator can't handle modifier-only accelerators + // (it would be better to fix TranslateAccelerator, but its code is in a Microsoft library...) + if(!bHit) { + if(pMsg->wParam == VK_SHIFT || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_MENU) { + + // do a linear loop through all accelerators to find modifier-only ones... + CCmdAccelOb* pCmdAccel; + WORD wKey; + CAccelsOb* pAccelOb; + POSITION pos = theApp.winAccelMgr.m_mapAccelTable.GetStartPosition(); + const int modifiers = ((pMsg->wParam == VK_SHIFT) ? FSHIFT : ((pMsg->wParam == VK_CONTROL) ? FCONTROL : FALT)); + while (pos != NULL) { + theApp.winAccelMgr.m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); + POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); + while (pos != NULL) { + pAccelOb = pCmdAccel->m_Accels.GetNext(pos); + + if(pAccelOb->m_wKey == 0) // if accelerator-only + { + if((pAccelOb->m_cVirt & modifiers) == modifiers) // if modifier matches + { + SendMessage(WM_COMMAND, pCmdAccel->m_wIDCommand, 0); // tell Windows to call the right function + } + } + } + } + } + } + + translatingAccelerator = false; + return bHit; + } + + translatingAccelerator = false; + return FALSE; +} + +void MainWnd::screenCapture(int captureNumber) +{ + CString buffer; + + CString captureDir = regQueryStringValue("captureDir", ""); + int index = theApp.filename.ReverseFind('\\'); + + CString name; + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + + if(captureDir.IsEmpty()) + captureDir = getDirFromFile(theApp.filename); + + LPCTSTR ext = "png"; + if(theApp.captureFormat != 0) + ext = "bmp"; + + if(isDriveRoot(captureDir)) + buffer.Format("%s%s_%02d.%s", + captureDir, + name, + captureNumber, + ext); + else + buffer.Format("%s\\%s_%02d.%s", + captureDir, + name, + captureNumber, + ext); + + if(theApp.captureFormat == 0) + theApp.emulator.emuWritePNG(buffer); + else + theApp.emulator.emuWriteBMP(buffer); + + CString msg = winResLoadString(IDS_SCREEN_CAPTURE); + systemScreenMessage(msg); +} + +void MainWnd::winMouseOn() +{ + SetCursor(arrow); + if(theApp.videoOption > VIDEO_4X) { + theApp.mouseCounter = 120; + } else + theApp.mouseCounter = 0; +} + +void MainWnd::OnMouseMove(UINT nFlags, CPoint point) +{ + winMouseOn(); + + CWnd::OnMouseMove(nFlags, point); +} + +void MainWnd::OnInitMenu(CMenu* pMenu) +{ + CWnd::OnInitMenu(pMenu); + + // HACK: we only want to call this if the user is pulling down the menu, + // but TranslateAccelerator also causes OnInitMenu to be called, so ignore that + if(!translatingAccelerator) + { + soundPause(); + } +} + +void MainWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) +{ + CWnd::OnActivate(nState, pWndOther, bMinimized); + + bool a = (nState == WA_ACTIVE) || (nState == WA_CLICKACTIVE); + + extern bool inputActive; + inputActive = a; + + if(a && theApp.input) { + theApp.active = a; + theApp.input->activate(); + if(!theApp.paused) { + if(emulating) { + soundResume(); + } + } + } else { + wasPaused = theApp.paused; + theApp.wasPaused = true; + if(theApp.pauseWhenInactive) { + if(emulating) { + soundPause(); + } + theApp.active = a; + } + + memset(theApp.delta,255,sizeof(theApp.delta)); + } + + if(theApp.paused && emulating) + { + theApp.painting = true; + systemDrawScreen(); + theApp.painting = false; + } +} + +#if _MSC_VER <= 1200 +void MainWnd::OnActivateApp(BOOL bActive, HTASK hTask) +#else +void MainWnd::OnActivateApp(BOOL bActive, DWORD hTask) +#endif +{ + CWnd::OnActivateApp(bActive, hTask); + + if(theApp.tripleBuffering && theApp.videoOption > VIDEO_4X) { + if(bActive) { + if(theApp.display) + theApp.display->clear(); + } + } +} + +void MainWnd::OnDropFiles(HDROP hDropInfo) +{ + char szFile[1024]; + + if(DragQueryFile(hDropInfo, + 0, + szFile, + 1024)) { + theApp.szFile = szFile; + if(FileRun()) { + SetForegroundWindow(); + emulating = TRUE; + } else { + emulating = FALSE; + soundPause(); + } + } + DragFinish(hDropInfo); +} + +LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam) +{ + if(emulating && !theApp.paused) { + if((wParam&0xFFF0) == SC_SCREENSAVE || (wParam&0xFFF0) == SC_MONITORPOWER) + return 0; + } + return Default(); +} diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h new file mode 100644 index 0000000..f272f00 --- /dev/null +++ b/src/win32/MainWnd.h @@ -0,0 +1,497 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_) +#define AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MainWnd.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// MainWnd window + +class MainWnd : public CWnd +{ + // Construction + public: + MainWnd(); + + // Attributes + public: + + // Operations + public: + bool FileRun(); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MainWnd) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + + // Implementation + public: + HCURSOR arrow; + void winMouseOn(); + void screenCapture(int captureNumber); + HACCEL m_hAccelTable; + bool fileOpenSelect(); + afx_msg LRESULT OnConfirmMode(WPARAM, LPARAM); + afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM); + afx_msg void OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI); + afx_msg void OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI); + afx_msg void OnUpdateSelectSlot(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsJoypadAutofire(UINT nID); + afx_msg void OnUpdateOptionsJoypadSticky(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsJoypadSticky(UINT nID); + afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsJoypadDefault(UINT nID); + afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsFilterIFB(UINT nID); + afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsFilter(UINT nID); + afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsPriority(UINT nID); + void updateSoundChannels(UINT nID); + afx_msg void OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsSoundVolume(UINT nID); + afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID); + afx_msg void OnSystemMinimize(); + afx_msg void OnUpdateVideoLayer(CCmdUI* pCmdUI); + afx_msg BOOL OnVideoLayer(UINT nID); + void winConfirmMode(); + afx_msg BOOL OnOptionVideoSize(UINT nID); + afx_msg BOOL OnOptionsFrameskip(UINT nID); + afx_msg void OnOptionsSound44khz(); + afx_msg void OnOptionsEmulatorSelectbiosfile(); + afx_msg void OnFileTogglemenu(); + bool fileImportGSACodeFile(CString& fileName); + bool writeSaveGame(const char *name); + bool loadSaveGame(const char *name); + CString winLoadFilter(UINT id); + void winLoadCheatList(const char *name); + void winLoadCheatListDefault(); + void readBatteryFile(); + void writeBatteryFile(); + bool isDriveRoot(CString& file); + CString getDirFromFile(CString& file); + void winSaveCheatList(const char *name); + void winSaveCheatListDefault(); + virtual ~MainWnd(); + + // Generated message map functions + protected: + //{{AFX_MSG(MainWnd) + afx_msg void OnClose(); + afx_msg void OnHelpAbout(); + afx_msg void OnHelpFaq(); + afx_msg void OnFileOpen(); + afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); + afx_msg void OnFilePause(); + afx_msg void OnUpdateFilePause(CCmdUI* pCmdUI); + afx_msg void OnFileReset(); + afx_msg void OnUpdateFileReset(CCmdUI* pCmdUI); + afx_msg void OnUpdateFileRecentFreeze(CCmdUI* pCmdUI); + afx_msg void OnFileRecentReset(); + afx_msg void OnFileRecentFreeze(); + afx_msg void OnFileExit(); + afx_msg void OnFileClose(); + afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI); + afx_msg void OnFileLoad(); + afx_msg void OnUpdateFileLoad(CCmdUI* pCmdUI); + afx_msg void OnFileSave(); + afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI); + afx_msg void OnFileImportBatteryfile(); + afx_msg void OnUpdateFileImportBatteryfile(CCmdUI* pCmdUI); + afx_msg void OnFileImportGamesharkcodefile(); + afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI* pCmdUI); + afx_msg void OnFileImportGamesharksnapshot(); + afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI* pCmdUI); + afx_msg void OnFileExportBatteryfile(); + afx_msg void OnUpdateFileExportBatteryfile(CCmdUI* pCmdUI); + afx_msg void OnFileExportGamesharksnapshot(); + afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI* pCmdUI); + afx_msg void OnFileScreencapture(); + afx_msg void OnUpdateFileScreencapture(CCmdUI* pCmdUI); + afx_msg void OnFileRominformation(); + afx_msg void OnUpdateFileRominformation(CCmdUI* pCmdUI); + afx_msg void OnUpdateFileTogglemenu(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle6(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle15(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle37(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle75(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle87(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle112(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle125(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle300(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleIncrease(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleDecrease(CCmdUI* pCmdUI); + afx_msg void OnOptionsFrameskipThrottleNothrottle(); + afx_msg void OnOptionsFrameskipThrottle6(); + afx_msg void OnOptionsFrameskipThrottle15(); + afx_msg void OnOptionsFrameskipThrottle25(); + afx_msg void OnOptionsFrameskipThrottle37(); + afx_msg void OnOptionsFrameskipThrottle50(); + afx_msg void OnOptionsFrameskipThrottle75(); + afx_msg void OnOptionsFrameskipThrottle87(); + afx_msg void OnOptionsFrameskipThrottle100(); + afx_msg void OnOptionsFrameskipThrottle112(); + afx_msg void OnOptionsFrameskipThrottle125(); + afx_msg void OnOptionsFrameskipThrottle150(); + afx_msg void OnOptionsFrameskipThrottle200(); + afx_msg void OnOptionsFrameskipThrottle300(); + afx_msg void OnOptionsFrameskipThrottleOther(); + afx_msg void OnOptionsFrameskipThrottleIncrease(); + afx_msg void OnOptionsFrameskipThrottleDecrease(); + afx_msg void OnOptionsFrameskipAccuratePitch(); + afx_msg void OnOptionsFrameskipAccurateSpeed(); + afx_msg void OnUpdateOptionsFrameskipAccuratePitch(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsFrameskipAccurateSpeed(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoVsync(); + afx_msg void OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoX1(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoX2(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoX3(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoX4(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFullscreen320x240(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFullscreen640x480(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsVideoFullscreen800x600(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoFullscreen320x240(); + afx_msg void OnOptionsVideoFullscreen640x480(); + afx_msg void OnOptionsVideoFullscreen800x600(); + afx_msg void OnOptionsVideoFullscreen(); + afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI); + afx_msg void OnMove(int x, int y); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnOptionsVideoDisablesfx(); + afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoFullscreenstretchtofit(); + afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRendermethodGdi(); + afx_msg void OnUpdateOptionsVideoRendermethodGdi(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRendermethodDirectdraw(); + afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRendermethodDirect3d(); + afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRendermethodOpengl(); + afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoTriplebuffering(); + afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoDdrawemulationonly(); + afx_msg void OnUpdateOptionsVideoDdrawemulationonly(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoDdrawusevideomemory(); + afx_msg void OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsD3dnofilter(); + afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsD3dbilinear(); + afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlnearest(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlbilinear(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGltriangle(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlquads(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsSelectskin(); + afx_msg void OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsSkin(); + afx_msg void OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI* pCmdUI); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnOptionsEmulatorAssociate(); + afx_msg void OnOptionsEmulatorDirectories(); + afx_msg void OnOptionsVideoDisablestatusmessages(); + afx_msg void OnUpdateOptionsVideoDisablestatusmessages(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSynchronize(); + afx_msg void OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorPausewheninactive(); + afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSpeeduptoggle(); + afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorRemoveintrosgba(); + afx_msg void OnUpdateOptionsEmulatorRemoveintrosgba(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorAutomaticallyipspatch(); + afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorAgbprint(); + afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorRealtimeclock(); + afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorAutohidemenu(); + afx_msg void OnUpdateOptionsEmulatorAutohidemenu(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorRewindinterval(); + afx_msg void OnOptionsEmulatorSavetypeAutomatic(); + afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeEeprom(); + afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeSram(); + afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeEepromsensor(); + afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeNone(); + afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash512k(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash1m(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorUsebiosfile(); + afx_msg void OnUpdateOptionsEmulatorUsebiosfile(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorUseOldGBTiming(); + afx_msg void OnUpdateOptionsEmulatorUseOldGBTiming(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorGBALag(); + afx_msg void OnUpdateOptionsEmulatorGBALag(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSkipbios(); + afx_msg void OnUpdateOptionsEmulatorSkipbios(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorPngformat(); + afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorBmpformat(); + afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundOff(); + afx_msg void OnUpdateOptionsSoundOff(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundMute(); + afx_msg void OnUpdateOptionsSoundMute(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundOn(); + afx_msg void OnUpdateOptionsSoundOn(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundUseoldsynchronization(); + afx_msg void OnUpdateOptionsSoundUseoldsynchronization(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundEcho(); + afx_msg void OnUpdateOptionsSoundEcho(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundLowpassfilter(); + afx_msg void OnUpdateOptionsSoundLowpassfilter(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundReversestereo(); + afx_msg void OnUpdateOptionsSoundReversestereo(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundMuteFrameAdvance(); + afx_msg void OnUpdateOptionsSoundMuteFrameAdvance(CCmdUI* pCmdUI); + afx_msg void OnOptionsSound11khz(); + afx_msg void OnUpdateOptionsSound11khz(CCmdUI* pCmdUI); + afx_msg void OnOptionsSound22khz(); + afx_msg void OnUpdateOptionsSound22khz(CCmdUI* pCmdUI); + afx_msg void OnUpdateOptionsSound44khz(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundChannel1(); + afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundChannel2(); + afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundChannel3(); + afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundChannel4(); + afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundDirectsounda(); + afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundDirectsoundb(); + afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyBorder(); + afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyPrinter(); + afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyBorderAutomatic(); + afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyAutomatic(); + afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyGba(); + afx_msg void OnUpdateOptionsGameboyGba(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyCgb(); + afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboySgb(); + afx_msg void OnUpdateOptionsGameboySgb(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboySgb2(); + afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyGb(); + afx_msg void OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyRealcolors(); + afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyGameboycolors(); + afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI); + afx_msg void OnOptionsGameboyColors(); + afx_msg void OnOptionsFilterDisablemmx(); + afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI); + afx_msg void OnOptionsLanguageSystem(); + afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI); + afx_msg void OnOptionsLanguageEnglish(); + afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI); + afx_msg void OnOptionsLanguageOther(); + afx_msg void OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadConfigure1(); + afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadConfigure2(); + afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadConfigure3(); + afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadConfigure4(); + afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadMotionconfigure(); + afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI); + afx_msg void OnOptionsJoypadAllowLeftRight(); + afx_msg void OnUpdateOptionsJoypadAllowLeftRight(CCmdUI* pCmdUI); + afx_msg void OnCheatsSearchforcheats(); + afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI); + afx_msg void OnCheatsCheatlist(); + afx_msg void OnUpdateCheatsCheatlist(CCmdUI* pCmdUI); + afx_msg void OnCheatsAutomaticsaveloadcheats(); + afx_msg void OnCheatsPauseDuringCheatSearch(); + afx_msg void OnCheatsLoadcheatlist(); + afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI); + afx_msg void OnCheatsSavecheatlist(); + afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI); + afx_msg void OnToolsDisassemble(); + afx_msg void OnUpdateToolsDisassemble(CCmdUI* pCmdUI); + afx_msg void OnToolsLogging(); + afx_msg void OnUpdateToolsLogging(CCmdUI* pCmdUI); + afx_msg void OnToolsIoviewer(); + afx_msg void OnUpdateToolsIoviewer(CCmdUI* pCmdUI); + afx_msg void OnToolsMapview(); + afx_msg void OnUpdateToolsMapview(CCmdUI* pCmdUI); + afx_msg void OnToolsMemoryviewer(); + afx_msg void OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI); + afx_msg void OnToolsOamviewer(); + afx_msg void OnUpdateToolsOamviewer(CCmdUI* pCmdUI); + afx_msg void OnToolsPaletteview(); + afx_msg void OnUpdateToolsPaletteview(CCmdUI* pCmdUI); + afx_msg void OnToolsTileviewer(); + afx_msg void OnUpdateToolsTileviewer(CCmdUI* pCmdUI); + afx_msg void OnDebugNextframe(); + afx_msg void OnUpdateDebugNextframe(CCmdUI* pCmdUI); + afx_msg void OnDebugFramesearch(); + afx_msg void OnUpdateDebugFramesearch(CCmdUI* pCmdUI); + afx_msg void OnDebugFramesearchPrev(); + afx_msg void OnUpdateDebugFramesearchPrev(CCmdUI* pCmdUI); + afx_msg void OnDebugFramesearchLoad(); + afx_msg void OnUpdateDebugFramesearchLoad(CCmdUI* pCmdUI); + afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI); + afx_msg void OnUpdateCheatsPauseDuringCheatSearch(CCmdUI* pCmdUI); + afx_msg void OnToolsFrameCounter(); + afx_msg void OnUpdateToolsFrameCounter(CCmdUI* pCmdUI); + afx_msg void OnToolsInputDisplay(); + afx_msg void OnUpdateToolsInputDisplay(CCmdUI* pCmdUI); + afx_msg void OnToolsDebugGdb(); + afx_msg void OnUpdateToolsDebugGdb(CCmdUI* pCmdUI); + afx_msg void OnToolsDebugLoadandwait(); + afx_msg void OnUpdateToolsDebugLoadandwait(CCmdUI* pCmdUI); + afx_msg void OnToolsDebugBreak(); + afx_msg void OnUpdateToolsDebugBreak(CCmdUI* pCmdUI); + afx_msg void OnToolsDebugDisconnect(); + afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundStartrecording(); + afx_msg void OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundStoprecording(); + afx_msg void OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI); + afx_msg void OnToolsRecordStartavirecording(); + afx_msg void OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI); + afx_msg void OnToolsRecordStopavirecording(); + afx_msg void OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI); + afx_msg void OnPaint(); + afx_msg void OnToolsRecordStartmovierecording(); + afx_msg void OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI); + afx_msg void OnToolsRecordStopmovierecording(); + afx_msg void OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI); + afx_msg void OnToolsPlayStartmovieplaying(); + afx_msg void OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI); + afx_msg void OnToolsPlayStopmovieplaying(); + afx_msg void OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI); + afx_msg void OnToolsPlayReadOnly(); + afx_msg void OnUpdateToolsPlayReadOnly(CCmdUI* pCmdUI); + afx_msg void OnToolsPlayContinue(); + afx_msg void OnUpdateToolsPlayContinue(CCmdUI* pCmdUI); + afx_msg void OnToolsPlayRestart(); + afx_msg void OnUpdateToolsPlayRestart(CCmdUI* pCmdUI); + afx_msg void OnToolsRewind(); + afx_msg void OnUpdateToolsRewind(CCmdUI* pCmdUI); + afx_msg void OnToolsCustomize(); + afx_msg void OnUpdateToolsCustomize(CCmdUI* pCmdUI); + afx_msg void OnToolsCustomizeCommon(); + afx_msg void OnUpdateToolsCustomizeCommon(CCmdUI* pCmdUI); + afx_msg void OnHelpBugreport(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnInitMenu(CMenu* pMenu); + afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); +#if _MSC_VER <= 1200 + afx_msg void OnActivateApp(BOOL bActive, HTASK hTask); +#else + afx_msg void OnActivateApp(BOOL bActive, DWORD hTask); +#endif + afx_msg void OnDropFiles(HDROP hDropInfo); + afx_msg void OnFileSavegameOldestslot(); + afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI); + afx_msg void OnFileLoadgameMostrecent(); + afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI); + afx_msg void OnFileLoadgameAutoloadmostrecent(); + afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI); + afx_msg void OnFileLoadgameMakeRecent(); + afx_msg void OnUpdateFileLoadgameMakeRecent(CCmdUI* pCmdUI); + + afx_msg void OnFileSavegameCurrent(); + afx_msg void OnUpdateFileSavegameCurrent(CCmdUI* pCmdUI); + afx_msg void OnFileLoadgameCurrent(); + afx_msg void OnUpdateFileLoadgameCurrent(CCmdUI* pCmdUI); + afx_msg void OnFileLoadgameMakeCurrent(); + afx_msg void OnUpdateFileLoadgameMakeCurrent(CCmdUI* pCmdUI); + afx_msg void OnFileSavegameMakeCurrent(); + afx_msg void OnUpdateFileSavegameMakeCurrent(CCmdUI* pCmdUI); + afx_msg void OnFileSavegameIncrementSlot(); + afx_msg void OnUpdateFileSavegameIncrementSlot(CCmdUI* pCmdUI); + afx_msg void OnFileSavegameDecrementSlot(); + afx_msg void OnUpdateFileSavegameDecrementSlot(CCmdUI* pCmdUI); + + afx_msg void OnOptionsSoundVolume25x(); + afx_msg void OnUpdateOptionsSoundVolume25x(CCmdUI* pCmdUI); + afx_msg void OnOptionsSoundVolume5x(); + afx_msg void OnUpdateOptionsSoundVolume5x(CCmdUI* pCmdUI); + afx_msg void OnCheatsDisablecheats(); + afx_msg void OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoFullscreenmaxscale(); + afx_msg void OnOptionsVideoTextdisplayoptions(); + afx_msg void OnUpdateOptionsVideoTextdisplayoptions(CCmdUI *pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + afx_msg BOOL OnFileRecentFile(UINT nID); + afx_msg BOOL OnFileLoadSlot(UINT nID); + afx_msg BOOL OnFileSaveSlot(UINT nID); + afx_msg BOOL OnSelectSlot(UINT nID); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINWND_H__E8AD28B9_C9FB_4EC2_A2DC_DD1BBA55A275__INCLUDED_) diff --git a/src/win32/MainWndCheats.cpp b/src/win32/MainWndCheats.cpp new file mode 100644 index 0000000..f769330 --- /dev/null +++ b/src/win32/MainWndCheats.cpp @@ -0,0 +1,209 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" + +#include "FileDlg.h" +#include "GBACheats.h" +#include "GBCheatsDlg.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../GBA.h" +#include "../Globals.h" +#include "../gb/gbCheats.h" + +extern int emulating; + +GBACheatSearch gbaDlg; +GBCheatSearch gbDlg; + +void MainWnd::OnCheatsSearchforcheats() +{ + theApp.winCheckFullscreen(); + + if(!theApp.pauseDuringCheatSearch && theApp.modelessCheatDialogIsOpen) + { + gbaDlg.DestroyWindow(); + gbDlg.DestroyWindow(); + theApp.modelessCheatDialogIsOpen = false; + } + + if(theApp.cartridgeType == 0) + { + if(theApp.pauseDuringCheatSearch) + { + gbaDlg.DoModal(); + } + else + { + if(!theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = true; + gbaDlg.Create(GBACheatSearch::IDD, theApp.m_pMainWnd); + } + } + } + else + { + if(theApp.pauseDuringCheatSearch) + { + gbDlg.DoModal(); + } + else + { + if(!theApp.modelessCheatDialogIsOpen) + { + theApp.modelessCheatDialogIsOpen = true; + gbDlg.Create(GBACheatSearch::IDD, theApp.m_pMainWnd); + } + } + } +} + +void MainWnd::OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnCheatsCheatlist() +{ + theApp.winCheckFullscreen(); + if(theApp.cartridgeType == 0) { + GBACheatList dlg; + dlg.DoModal(); + } else { + GBCheatList dlg; + dlg.DoModal(); + } +} + +void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnCheatsAutomaticsaveloadcheats() +{ + theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList; +} + +void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.autoSaveLoadCheatList); +} + +void MainWnd::OnCheatsPauseDuringCheatSearch() +{ + theApp.pauseDuringCheatSearch = !theApp.pauseDuringCheatSearch; +} + +void MainWnd::OnUpdateCheatsPauseDuringCheatSearch(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.pauseDuringCheatSearch); +} + +void MainWnd::OnCheatsLoadcheatlist() +{ + theApp.winCheckFullscreen(); + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.clt", saveDir, buffer); + else + filename.Format("%s\\%s.clt", saveDir, buffer); + + LPCTSTR exts[] = { ".clt" }; + CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST); + CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME); + + FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, false); + + if(dlg.DoModal() == IDOK) { + winLoadCheatList(dlg.GetPathName()); + } +} + +void MainWnd::OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnCheatsSavecheatlist() +{ + theApp.winCheckFullscreen(); + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.clt", saveDir, buffer); + else + filename.Format("%s\\%s.clt", saveDir, buffer); + + LPCTSTR exts[] = { ".clt" }; + CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST); + CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME); + + FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, true); + + if(dlg.DoModal() == IDOK) { + winSaveCheatList(dlg.GetPathName()); + } +} + +void MainWnd::OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnCheatsDisablecheats() +{ + cheatsEnabled = !cheatsEnabled; +} + +void MainWnd::OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(!cheatsEnabled); +} + diff --git a/src/win32/MainWndFile.cpp b/src/win32/MainWndFile.cpp new file mode 100644 index 0000000..4e579d8 --- /dev/null +++ b/src/win32/MainWndFile.cpp @@ -0,0 +1,1133 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" + +#include "ExportGSASnapshot.h" +#include "FileDlg.h" +#include "GSACodeSelect.h" +#include "RomInfo.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../GBA.h" +#include "../Globals.h" +#include "../NLS.h" +#include "../Sound.h" +#include "../gb/GB.h" +#include "../gb/gbCheats.h" +#include "../gb/gbGlobals.h" +#include "../movie.h" + +extern int emulating; + +extern void remoteCleanUp(); + +void MainWnd::OnFileOpen() +{ + theApp.winCheckFullscreen(); + if(fileOpenSelect()) { + if(VBAMovieActive()) + VBAMovieStop(false); // will only get here on user selecting to play a ROM, canceling movie + FileRun(); + } +} + +void MainWnd::OnFilePause() +{ + if(!theApp.paused) + { + if(theApp.throttle > 25) + { + // less immediate response, better update + OnDebugNextframe(); + } + else + { + // more immediate response, worse update + theApp.paused = !theApp.paused; + theApp.painting = true; + systemDrawScreen(); + theApp.painting = false; + } + theApp.wasPaused = true; + soundPause(); + } + else + { + theApp.paused = !theApp.paused; + soundResume(); + } +} + +void MainWnd::OnUpdateFilePause(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.paused); +} + +void MainWnd::OnFileReset() +{ + if(emulating) { + if(VBAMovieGetState() == MOVIE_STATE_PLAY) + { + VBAMovieRestart(); + systemScreenMessage("movie play restart"); + } + else + { + theApp.emulator.emuReset(); + systemScreenMessage(winResLoadString(IDS_RESET)); + } + } +} + +void MainWnd::OnUpdateFileReset(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnUpdateFileRecentFreeze(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.recentFreeze); + + if(pCmdUI->m_pMenu == NULL) + return; + + CMenu *pMenu = pCmdUI->m_pMenu; + + int i; + for(i = 0; i < 10; i++) { + if(!pMenu->RemoveMenu(ID_FILE_MRU_FILE1+i, MF_BYCOMMAND)) + break; + } + + for(i = 0; i < 10; i++) { + CString p = theApp.recentFiles[i]; + if(p.GetLength() == 0) + break; + int index = p.ReverseFind('\\'); + + if(index != -1) + p = p.Right(p.GetLength()-index-1); + + pMenu->AppendMenu(MF_STRING, ID_FILE_MRU_FILE1+i, p); + } + theApp.winAccelMgr.UpdateMenu((HMENU)*pMenu); +} + +BOOL MainWnd::OnFileRecentFile(UINT nID) +{ + if(theApp.recentFiles[(nID&0xFFFF)-ID_FILE_MRU_FILE1].GetLength()) { + + if(VBAMovieActive()) + VBAMovieStop(false); // will only get here on user selecting to play a ROM, canceling movie + + theApp.szFile = theApp.recentFiles[(nID&0xFFFF)-ID_FILE_MRU_FILE1]; + if(FileRun()) + emulating = true; + else { + emulating = false; + soundPause(); + } + } + return TRUE; +} + +void MainWnd::OnFileRecentReset() +{ + CString str1 = "Really clear your recent ROMs list?";//winResLoadString(IDS_REALLY_CLEAR); + CString str2 = winResLoadString(IDS_CONFIRM_ACTION); + + if(MessageBox(str1, + str2, + MB_YESNO) == IDNO) + return; + + int i = 0; + for(i = 0; i < 10; i++) + theApp.recentFiles[i] = ""; +} + +void MainWnd::OnFileRecentFreeze() +{ + theApp.recentFreeze = !theApp.recentFreeze; +} + +void MainWnd::OnFileExit() +{ + SendMessage(WM_CLOSE); +} + +void MainWnd::OnFileClose() +{ + // save battery file before we change the filename... + if(rom != NULL || gbRom != NULL) { + if(theApp.autoSaveLoadCheatList) + winSaveCheatListDefault(); + writeBatteryFile(); + soundPause(); + theApp.emulator.emuCleanUp(); + remoteCleanUp(); + if(VBAMovieActive()) + VBAMovieStop(false); // will only get here on user selecting to stop playing the ROM, canceling movie + } + emulating = 0; + RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); + systemSetTitle("VisualBoyAdvance"); +} + +void MainWnd::OnUpdateFileClose(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileLoad() +{ + theApp.winCheckFullscreen(); + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.sgm", saveDir, buffer); + else + filename.Format("%s\\%s.sgm", saveDir, buffer); + + LPCTSTR exts[] = { ".sgm" }; + CString filter = winLoadFilter(IDS_FILTER_SGM); + CString title = winResLoadString(IDS_SELECT_SAVE_GAME_NAME); + + FileDlg dlg(this, filename, filter, 0, "", exts, saveDir, title, false, true); + + if(dlg.DoModal() == IDOK) { + bool res = loadSaveGame(dlg.GetPathName()); + + theApp.rewindCount = 0; + theApp.rewindCounter = 0; + theApp.rewindSaveNeeded = false; + + if(res) + systemScreenMessage(winResLoadString(IDS_LOADED_STATE)); + } +} + +void MainWnd::OnUpdateFileLoad(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +bool8 loadedMovieSnapshot = 0; +BOOL MainWnd::OnFileLoadSlot(UINT nID) +{ + nID = nID + 1 - ID_FILE_LOADGAME_SLOT1; + + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s%d.sgm", saveDir, buffer, nID); + else + filename.Format("%s\\%s%d.sgm", saveDir, buffer, nID); + + bool res = loadSaveGame(filename); + + // deleting rewinds because you loaded a save state is stupid +/// theApp.rewindCount = 0; +/// theApp.rewindCounter = 0; +/// theApp.rewindSaveNeeded = false; + + if(res) + { + CString format; + if(VBAMovieActive()) + if(VBAMovieReadOnly()) + format = winResLoadString(IDS_REPLAYED_STATE_N); + else + format = winResLoadString(IDS_RERECORDED_STATE_N); + else + format = winResLoadString(IDS_LOADED_STATE_N); + buffer.Format(format, nID); + systemScreenMessage(buffer); + + int lastSlot = theApp.currentSlot; + + if(theApp.loadMakesRecent && VBAMovieActive() == loadedMovieSnapshot) + { + OnFileSaveSlot(nID - 1 + ID_FILE_SAVEGAME_SLOT1); // to update the file's modification date + } + + if(theApp.loadMakesCurrent) + theApp.currentSlot = nID - 1; + else + theApp.currentSlot = lastSlot; // restore value in case the call to OnFileSaveSlot changed it + + theApp.frameSearching = false; + theApp.frameSearchSkipping = false; + + } + + return res; +} + +void MainWnd::OnFileSave() +{ + theApp.winCheckFullscreen(); + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s.sgm", saveDir, buffer); + else + filename.Format("%s\\%s.sgm", saveDir, buffer); + + LPCTSTR exts[] = { ".sgm" }; + CString filter = winLoadFilter(IDS_FILTER_SGM); + CString title = winResLoadString(IDS_SELECT_SAVE_GAME_NAME); + + FileDlg dlg(this, filename, filter, 0, "", exts, saveDir, title, true); + + if(dlg.DoModal() == IDOK) { + bool res = writeSaveGame(dlg.GetPathName()); + if(res) + systemScreenMessage(winResLoadString(IDS_WROTE_STATE)); + } +} + +void MainWnd::OnUpdateFileSave(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +BOOL MainWnd::OnFileSaveSlot(UINT nID) +{ + nID = nID + 1 - ID_FILE_SAVEGAME_SLOT1; + + if(theApp.saveMakesCurrent) + theApp.currentSlot = nID - 1; + + CString buffer; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + buffer = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(isDriveRoot(saveDir)) + filename.Format("%s%s%d.sgm", saveDir, buffer, nID); + else + filename.Format("%s\\%s%d.sgm", saveDir, buffer, nID); + + bool res = writeSaveGame(filename); + + CString format = winResLoadString(IDS_WROTE_STATE_N); + buffer.Format(format, nID); + + systemScreenMessage(buffer); + + return res; +} + +BOOL MainWnd::OnSelectSlot(UINT nID) +{ + nID = nID + 1 - ID_SELECT_SLOT1; + theApp.currentSlot = nID - 1; + + CString buffer; + buffer.Format("Slot %d selected", nID); + systemScreenMessage(buffer, 0, 600); + + return true; +} + +void MainWnd::OnFileImportBatteryfile() +{ + theApp.winCheckFullscreen(); + LPCTSTR exts[] = { ".sav" }; + CString filter = winLoadFilter(IDS_FILTER_SAV); + CString title = winResLoadString(IDS_SELECT_BATTERY_FILE); + + CString saveDir = regQueryStringValue("batteryDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + FileDlg dlg(this, "", filter, 0, "", exts, saveDir, title, false, true); + + if(dlg.DoModal() == IDCANCEL) + return; + + CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST); + CString str2 = winResLoadString(IDS_CONFIRM_ACTION); + + if(MessageBox(str1, + str2, + MB_OKCANCEL) == IDCANCEL) + return; + + bool res = false; + + res = theApp.emulator.emuReadBattery(dlg.GetPathName()); + + if(!res) + systemMessage(MSG_CANNOT_OPEN_FILE, "Cannot open file %s", dlg.GetPathName()); + else { + theApp.emulator.emuReset(); + } +} + +void MainWnd::OnUpdateFileImportBatteryfile(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileImportGamesharkcodefile() +{ + theApp.winCheckFullscreen(); + LPCTSTR exts[] = { "" }; + CString filter = theApp.cartridgeType == 0 ? winLoadFilter(IDS_FILTER_SPC) : winLoadFilter(IDS_FILTER_GCF); + CString title = winResLoadString(IDS_SELECT_CODE_FILE); + + FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true); + + if(dlg.DoModal() == IDCANCEL) + return; + + CString str1 = winResLoadString(IDS_CODES_WILL_BE_LOST); + CString str2 = winResLoadString(IDS_CONFIRM_ACTION); + + if(MessageBox(str1, + str2, + MB_OKCANCEL) == IDCANCEL) + return; + + bool res = false; + CString file = dlg.GetPathName(); + if(theApp.cartridgeType == 1) + res = gbCheatReadGSCodeFile(file); + else { + res = fileImportGSACodeFile(file); + } +} + +void MainWnd::OnUpdateFileImportGamesharkcodefile(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileImportGamesharksnapshot() +{ + theApp.winCheckFullscreen(); + LPCTSTR exts[] = { "" }; + CString filter = theApp.cartridgeType == 1 ? winLoadFilter(IDS_FILTER_GBS) : winLoadFilter(IDS_FILTER_SPS); + CString title = winResLoadString(IDS_SELECT_SNAPSHOT_FILE); + + FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true); + + if(dlg.DoModal() == IDCANCEL) + return; + + CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST); + CString str2 = winResLoadString(IDS_CONFIRM_ACTION); + + if(MessageBox(str1, + str2, + MB_OKCANCEL) == IDCANCEL) + return; + + if(theApp.cartridgeType == 1) + gbReadGSASnapshot(dlg.GetPathName()); + else + CPUReadGSASnapshot(dlg.GetPathName()); +} + +void MainWnd::OnUpdateFileImportGamesharksnapshot(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileExportBatteryfile() +{ + theApp.winCheckFullscreen(); + CString name; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + + LPCTSTR exts[] = {".sav", ".dat" }; + + CString filter = winLoadFilter(IDS_FILTER_SAV); + CString title = winResLoadString(IDS_SELECT_BATTERY_FILE); + + CString saveDir = regQueryStringValue("batteryDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + FileDlg dlg(this, + name, + filter, + 1, + "SAV", + exts, + saveDir, + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + bool result = false; + + if(theApp.cartridgeType == 1) { + result = gbWriteBatteryFile(dlg.GetPathName(), false); + } else + result = theApp.emulator.emuWriteBattery(dlg.GetPathName()); + + if(!result) + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", + dlg.GetPathName()); +} + +void MainWnd::OnUpdateFileExportBatteryfile(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileExportGamesharksnapshot() +{ + theApp.winCheckFullscreen(); + if(eepromInUse) { + systemMessage(IDS_EEPROM_NOT_SUPPORTED, "EEPROM saves cannot be exported"); + return; + } + + CString name; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + + LPCTSTR exts[] = {".sps" }; + + CString filter = winLoadFilter(IDS_FILTER_SPS); + CString title = winResLoadString(IDS_SELECT_SNAPSHOT_FILE); + + FileDlg dlg(this, + name, + filter, + 1, + "SPS", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) + return; + + char buffer[16]; + strncpy(buffer, (const char *)&rom[0xa0], 12); + buffer[12] = 0; + + ExportGSASnapshot dlg2(dlg.GetPathName(), buffer, this); + dlg2.DoModal(); +} + +void MainWnd::OnUpdateFileExportGamesharksnapshot(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && theApp.cartridgeType == 0); +} + +void MainWnd::OnFileScreencapture() +{ + theApp.winCheckFullscreen(); + CString name; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + name = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + name = theApp.filename; + + CString capdir = regQueryStringValue("captureDir", ""); + if(capdir.IsEmpty()) + capdir = getDirFromFile(name); + + CString ext = "png"; + + if(theApp.captureFormat != 0) + ext = "bmp"; + + if(isDriveRoot(capdir)) + filename.Format("%s%s.%s", capdir, name, ext); + else + filename.Format("%s\\%s.%s", capdir, name, ext); + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + filename, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + capdir, + title, + true); + + if(dlg.DoModal() == IDCANCEL) + return; + + if(dlg.getFilterIndex() == 2) + theApp.emulator.emuWriteBMP(dlg.GetPathName()); + else + theApp.emulator.emuWritePNG(dlg.GetPathName()); + + systemScreenMessage(winResLoadString(IDS_SCREEN_CAPTURE)); +} + +void MainWnd::OnUpdateFileScreencapture(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileRominformation() +{ + theApp.winCheckFullscreen(); + if(theApp.cartridgeType == 0) { + RomInfoGBA dlg(rom); + dlg.DoModal(); + } else { + RomInfoGB dlg(gbRom); + dlg.DoModal(); + } +} + +void MainWnd::OnUpdateFileRominformation(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnFileTogglemenu() +{ +/// if(theApp.videoOption <= VIDEO_4X) +/// return; + + theApp.menuToggle = !theApp.menuToggle; + + if(theApp.menuToggle) { + theApp.updateMenuBar(); + if(theApp.tripleBuffering) { + if(theApp.display) + theApp.display->checkFullScreen(); + DrawMenuBar(); + } + } else { + SetMenu(NULL); + DestroyMenu(theApp.menu); + } + + theApp.adjustDestRect(); +} + +void MainWnd::OnUpdateFileTogglemenu(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption > VIDEO_4X); +} + +bool MainWnd::fileImportGSACodeFile(CString& fileName) +{ + FILE *f = fopen(fileName, "rb"); + + if(f == NULL) { + systemMessage(MSG_CANNOT_OPEN_FILE, "Cannot open file %s", fileName); + return false; + } + + u32 len; + fread(&len, 1, 4, f); + if(len != 14) { + fclose(f); + systemMessage(MSG_UNSUPPORTED_CODE_FILE, "Unsupported code file %s", + fileName); + return false; + } + char buffer[16]; + fread(buffer, 1, 14, f); + buffer[14] = 0; + if(memcmp(buffer, "SharkPortCODES", 14)) { + fclose(f); + systemMessage(MSG_UNSUPPORTED_CODE_FILE, "Unsupported code file %s", + fileName); + return false; + } + fseek(f, 0x1e, SEEK_SET); + fread(&len, 1, 4, f); + int game = 0; + if(len > 1) { + GSACodeSelect dlg(f); + game = dlg.DoModal(); + } + fclose(f); + + bool v3 = false; + + int index = fileName.ReverseFind('.'); + + if(index != -1) { + if(fileName.Right(3).CompareNoCase("XPC") == 0) + v3 = true; + } + + if(game != -1) { + return cheatsImportGSACodeFile(fileName, game, v3); + } + + return true; +} + +void MainWnd::OnFileSavegameOldestslot() +{ + if(!emulating) + return; + + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + filename = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + filename = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(!isDriveRoot(saveDir)) + saveDir += "\\"; + + CString name; + CFileStatus status; + CString str; + time_t time = -1; + int found = 0; + + for(int i = 0; i < 10; i++) { + name.Format("%s%s%d.sgm", saveDir, filename, i+1); + + if(emulating && CFile::GetStatus(name, status)) { + if(time - status.m_mtime.GetTime() > 0 || time == -1) { + time = status.m_mtime.GetTime(); + found = i; + } + } else { + found = i; + break; + } + } + OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1+found); +} + +void MainWnd::OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); + if(pCmdUI->m_pSubMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pSubMenu; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + filename = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + filename = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(!isDriveRoot(saveDir)) + saveDir += "\\"; + + CString name; + CFileStatus status; + CString str; + time_t time = -1; + int found = 0; + bool foundEmpty = false; + + for(int i = 0; i < 10; i++) { + name.Format("%s%s%d.sgm", saveDir, filename, i+1); + + if(emulating && CFile::GetStatus(name, status)) { + CString timestamp = status.m_mtime.Format("%Y/%m/%d %H:%M:%S"); + str.Format("%d %s", i+1, timestamp); + if(!foundEmpty && (time - status.m_mtime.GetTime() > 0 || time == -1)) { + time = status.m_mtime.GetTime(); + found = i; + } + } else { + if(!foundEmpty) + { + found = i; + foundEmpty = true; + } + str.Format("%d ----/--/-- --:--:--", i+1); + } + pMenu->ModifyMenu(ID_FILE_SAVEGAME_SLOT1+i, MF_STRING|MF_BYCOMMAND, ID_FILE_SAVEGAME_SLOT1+i, str); + } + + if(found != -1 && emulating) + str.Format("Oldest slot (#%d)", found+1); + else + str.Format("Oldest slot", found+1); + pMenu->ModifyMenu(ID_FILE_SAVEGAME_OLDESTSLOT, MF_STRING|MF_BYCOMMAND, ID_FILE_SAVEGAME_OLDESTSLOT, str); + + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } +} + +void MainWnd::OnFileLoadgameMostrecent() +{ + if(!emulating) + return; + + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + filename = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + filename = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(!isDriveRoot(saveDir)) + saveDir += "\\"; + + CString name; + CFileStatus status; + CString str; + time_t time = 0; + int found = -1; + + for(int i = 0; i < 10; i++) { + name.Format("%s%s%d.sgm", saveDir, filename, i+1); + + if(emulating && CFile::GetStatus(name, status)) { + if(status.m_mtime.GetTime() > time) { + time = status.m_mtime.GetTime(); + found = i; + } + } + } + if(found != -1) { + OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1+found); + } +} + +void MainWnd::OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); + + if(pCmdUI->m_pSubMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pSubMenu; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + filename = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + filename = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(!isDriveRoot(saveDir)) + saveDir += "\\"; + + CString name; + CFileStatus status; + CString str; + + time_t time = 0; + int found = -1; + for(int i = 0; i < 10; i++) { + name.Format("%s%s%d.sgm", saveDir, filename, i+1); + + if(emulating && CFile::GetStatus(name, status)) { + CString timestamp = status.m_mtime.Format("%Y/%m/%d %H:%M:%S"); + str.Format("%d %s", i+1, timestamp); + + if(status.m_mtime.GetTime() > time) { + time = status.m_mtime.GetTime(); + found = i; + } + } else { + str.Format("%d ----/--/-- --:--:--", i+1); + } + pMenu->ModifyMenu(ID_FILE_LOADGAME_SLOT1+i, MF_STRING|MF_BYCOMMAND, ID_FILE_LOADGAME_SLOT1+i, str); + } + + if(found != -1 && emulating) + str.Format("Most recent slot (#%d)", found+1); + else + str.Format("Most recent slot", found+1); + pMenu->ModifyMenu(ID_FILE_LOADGAME_MOSTRECENT, MF_STRING|MF_BYCOMMAND, ID_FILE_LOADGAME_MOSTRECENT, str); + + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } +} + +void MainWnd::OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnUpdateSelectSlot(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(true); +} + +void MainWnd::OnFileLoadgameAutoloadmostrecent() +{ + theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent; +} +void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.autoLoadMostRecent); +} + +void MainWnd::OnFileLoadgameMakeRecent() +{ + theApp.loadMakesRecent = !theApp.loadMakesRecent; +} +void MainWnd::OnUpdateFileLoadgameMakeRecent(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.loadMakesRecent); +} + + +void MainWnd::OnFileSavegameCurrent() +{ + OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1 + theApp.currentSlot); +} +void MainWnd::OnUpdateFileSavegameCurrent(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); + + if(pCmdUI->m_pMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pMenu; + CString str; + + str.Format("Current slot (#%d)", theApp.currentSlot+1); + pMenu->ModifyMenu(ID_FILE_SAVEGAME_CURRENT, MF_STRING|MF_BYCOMMAND, ID_FILE_SAVEGAME_CURRENT, str); + + pCmdUI->Enable(emulating); + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } +} + +void MainWnd::OnFileLoadgameCurrent() +{ + OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1 + theApp.currentSlot); +} +void MainWnd::OnUpdateFileLoadgameCurrent(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); + + if(pCmdUI->m_pMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pMenu; + CString filename; + + int index = theApp.filename.ReverseFind('\\'); + + if(index != -1) + filename = theApp.filename.Right(theApp.filename.GetLength()-index-1); + else + filename = theApp.filename; + + CString saveDir = regQueryStringValue("saveDir", NULL); + + if(saveDir.IsEmpty()) + saveDir = getDirFromFile(theApp.filename); + + if(!isDriveRoot(saveDir)) + saveDir += "\\"; + + CString name; + CFileStatus status; + CString str; + + bool found = false; + int i = theApp.currentSlot; + { + name.Format("%s%s%d.sgm", saveDir, filename, i+1); + + if(emulating && CFile::GetStatus(name, status)) { + found = true; + } + } + + str.Format("Current slot (#%d)", theApp.currentSlot+1); + pMenu->ModifyMenu(ID_FILE_LOADGAME_CURRENT, MF_STRING|MF_BYCOMMAND, ID_FILE_LOADGAME_CURRENT, str); + + pCmdUI->Enable(found && emulating); + + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } + +} + +void MainWnd::OnFileLoadgameMakeCurrent() +{ + theApp.loadMakesCurrent = !theApp.loadMakesCurrent; +} +void MainWnd::OnUpdateFileLoadgameMakeCurrent(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.loadMakesCurrent); +} + +void MainWnd::OnFileSavegameMakeCurrent() +{ + theApp.saveMakesCurrent = !theApp.saveMakesCurrent; +} +void MainWnd::OnUpdateFileSavegameMakeCurrent(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.saveMakesCurrent); +} + +void MainWnd::OnFileSavegameIncrementSlot() +{ + theApp.currentSlot = (theApp.currentSlot + 1) % 10; + + char str [32]; + sprintf(str, "Current Slot: %d", theApp.currentSlot+1); + systemScreenMessage(str, 0, 600); +} +void MainWnd::OnUpdateFileSavegameIncrementSlot(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(true); + + if(pCmdUI->m_pMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pMenu; + CString str; + + str.Format("Increase current slot (#%d -> #%d)", 1+(theApp.currentSlot), 1+((theApp.currentSlot + 1) % 10)); + pMenu->ModifyMenu(ID_FILE_SAVEGAME_INCREMENTSLOT, MF_STRING|MF_BYCOMMAND, ID_FILE_SAVEGAME_INCREMENTSLOT, str); + + pCmdUI->Enable(true); + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } +} + +void MainWnd::OnFileSavegameDecrementSlot() +{ + theApp.currentSlot = (10 + theApp.currentSlot - 1) % 10; + + char str [32]; + sprintf(str, "Current Slot: %d", theApp.currentSlot+1); + systemScreenMessage(str, 0, 600); +} +void MainWnd::OnUpdateFileSavegameDecrementSlot(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(true); + + if(pCmdUI->m_pMenu != NULL) { + CMenu *pMenu = pCmdUI->m_pMenu; + CString str; + + str.Format("Decrease current slot (#%d -> #%d)", 1+(theApp.currentSlot), 1+((10 + theApp.currentSlot - 1) % 10)); + pMenu->ModifyMenu(ID_FILE_SAVEGAME_DECREMENTSLOT, MF_STRING|MF_BYCOMMAND, ID_FILE_SAVEGAME_DECREMENTSLOT, str); + + pCmdUI->Enable(true); + theApp.winAccelMgr.UpdateMenu(pMenu->GetSafeHmenu()); + } +} diff --git a/src/win32/MainWndHelp.cpp b/src/win32/MainWndHelp.cpp new file mode 100644 index 0000000..bbecc0b --- /dev/null +++ b/src/win32/MainWndHelp.cpp @@ -0,0 +1,46 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" + +#include "AboutDialog.h" +#include "BugReport.h" + +extern int emulating; + +void MainWnd::OnHelpAbout() +{ + theApp.winCheckFullscreen(); + AboutDialog dlg; + + dlg.DoModal(); +} + +void MainWnd::OnHelpFaq() +{ + ::ShellExecute(0, _T("open"), "http://vba.ngemu.com/faq.shtml", + 0, 0, SW_SHOWNORMAL); +} + +void MainWnd::OnHelpBugreport() +{ + BugReport dlg(theApp.m_pMainWnd); + + dlg.DoModal(); +} diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp new file mode 100644 index 0000000..f1efd9c --- /dev/null +++ b/src/win32/MainWndOptions.cpp @@ -0,0 +1,2219 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" + +#include "Associate.h" +#include "Directories.h" +#include "FileDlg.h" +#include "GBColorDlg.h" +#include "Joypad.h" +#include "MaxScale.h" +#include "ModeConfirm.h" +#include "Reg.h" +#include "RewindInterval.h" +#include "skin.h" +#include "Throttle.h" +#include "TextOptions.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../agbprint.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../Sound.h" +#include "../gb/GB.h" +#include "../gb/gbGlobals.h" +#include "../gb/gbPrinter.h" +#include "../movie.h" + +extern int emulating; + +#define VBA_CONFIRM_MODE WM_APP + 100 + +extern void CPUUpdateRenderBuffers(bool force); + +void MainWnd::OnOptionsFrameskipThrottleNothrottle() +{ + theApp.throttle = 0; +} + +void MainWnd::OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 0); +} + +void MainWnd::OnOptionsFrameskipThrottle6() +{ + theApp.throttle = 6; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle6(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 6); +} + +void MainWnd::OnOptionsFrameskipThrottle15() +{ + theApp.throttle = 15; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle15(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 15); +} + +void MainWnd::OnOptionsFrameskipThrottle25() +{ + theApp.throttle = 25; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 25); +} + +void MainWnd::OnOptionsFrameskipThrottle37() +{ + theApp.throttle = 37; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle37(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 37); +} + +void MainWnd::OnOptionsFrameskipThrottle50() +{ + theApp.throttle = 50; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 50); +} + +void MainWnd::OnOptionsFrameskipThrottle75() +{ + theApp.throttle = 75; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle75(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 75); +} + +void MainWnd::OnOptionsFrameskipThrottle87() +{ + theApp.throttle = 87; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle87(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 87); +} + +void MainWnd::OnOptionsFrameskipThrottle100() +{ + theApp.throttle = 100; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 100); +} + +void MainWnd::OnOptionsFrameskipThrottle112() +{ + theApp.throttle = 112; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle112(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 112); +} + +void MainWnd::OnOptionsFrameskipThrottle125() +{ + theApp.throttle = 125; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle125(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 125); +} + +void MainWnd::OnOptionsFrameskipThrottle150() +{ + theApp.throttle = 150; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 150); +} + +void MainWnd::OnOptionsFrameskipThrottle200() +{ + theApp.throttle = 200; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 200); +} + +void MainWnd::OnOptionsFrameskipThrottle300() +{ + theApp.throttle = 300; +} +void MainWnd::OnUpdateOptionsFrameskipThrottle300(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.throttle == 300); +} + +static bool isMenuItemThrottleValue(int throttle) +{ + return throttle == 6 || throttle == 15 || throttle == 25 || throttle == 37 || + throttle == 50 || throttle == 75 || throttle == 87 || throttle == 100 || throttle == 112 || + throttle == 125 || throttle == 150 || throttle == 200 || throttle == 300; +} + +void MainWnd::OnOptionsFrameskipThrottleOther() +{ + Throttle dlg; + int v = dlg.DoModal(); + if(v) + theApp.throttle = v; +} +void MainWnd::OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(!isMenuItemThrottleValue(theApp.throttle)); +} + +void MainWnd::OnOptionsFrameskipThrottleIncrease() +{ + if(theApp.throttle < 6) + theApp.throttle++; + else if(theApp.throttle < 300) + { + do { + theApp.throttle++; + } while (!isMenuItemThrottleValue(theApp.throttle)); + } + char str [256]; + sprintf(str, "%d%% throttle speed", theApp.throttle); + systemScreenMessage(str); +} +void MainWnd::OnUpdateOptionsFrameskipThrottleIncrease(CCmdUI* pCmdUI) +{ +} + +void MainWnd::OnOptionsFrameskipThrottleDecrease() +{ + if(theApp.throttle > 6) + { + do { + theApp.throttle--; + } while (!isMenuItemThrottleValue(theApp.throttle)); + } + else if(theApp.throttle > 1) + theApp.throttle--; + char str [256]; + sprintf(str, "%d%% throttle speed", theApp.throttle); + systemScreenMessage(str); +} +void MainWnd::OnUpdateOptionsFrameskipThrottleDecrease(CCmdUI* pCmdUI) +{ +} + + +/* +void MainWnd::OnOptionsFrameskipAutomatic() +{ + theApp.autoFrameSkip = !theApp.autoFrameSkip; + if(!theApp.autoFrameSkip && emulating) + theApp.updateFrameSkip(); +} + +void MainWnd::OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.autoFrameSkip); +} +*/ + +void MainWnd::OnOptionsFrameskipAccuratePitch() +{ + theApp.accuratePitchThrottle = true; +} +void MainWnd::OnUpdateOptionsFrameskipAccuratePitch(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.accuratePitchThrottle || soundOffFlag || !synchronize); + pCmdUI->Enable(!soundOffFlag && synchronize); +} + +void MainWnd::OnOptionsFrameskipAccurateSpeed() +{ + theApp.accuratePitchThrottle = false; +} +void MainWnd::OnUpdateOptionsFrameskipAccurateSpeed(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(!theApp.accuratePitchThrottle && !soundOffFlag && synchronize); + pCmdUI->Enable(!soundOffFlag && synchronize); +} + +BOOL MainWnd::OnOptionsFrameskip(UINT nID) +{ + switch(nID) { + case ID_OPTIONS_VIDEO_FRAMESKIP_0: + case ID_OPTIONS_VIDEO_FRAMESKIP_1: + case ID_OPTIONS_VIDEO_FRAMESKIP_2: + case ID_OPTIONS_VIDEO_FRAMESKIP_3: + case ID_OPTIONS_VIDEO_FRAMESKIP_4: + case ID_OPTIONS_VIDEO_FRAMESKIP_5: + if(theApp.cartridgeType == 0) { + frameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0; + } else { + gbFrameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0; + } + if(emulating) + theApp.updateFrameSkip(); + return TRUE; + break; + case ID_OPTIONS_VIDEO_FRAMESKIP_6: + case ID_OPTIONS_VIDEO_FRAMESKIP_7: + case ID_OPTIONS_VIDEO_FRAMESKIP_8: + case ID_OPTIONS_VIDEO_FRAMESKIP_9: + if(theApp.cartridgeType == 0) { + frameSkip = 6 + nID - ID_OPTIONS_VIDEO_FRAMESKIP_6; + } else { + gbFrameSkip = 6 + nID - ID_OPTIONS_VIDEO_FRAMESKIP_6; + } + if(emulating) + theApp.updateFrameSkip(); + return TRUE; + break; + } + return FALSE; +} + +void MainWnd::OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 0 : gbFrameSkip == 0); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 1 : gbFrameSkip == 1); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 2 : gbFrameSkip == 2); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 3 : gbFrameSkip == 3); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 4 : gbFrameSkip == 4); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 5 : gbFrameSkip == 5); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 6 : gbFrameSkip == 6); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 7 : gbFrameSkip == 7); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 8 : gbFrameSkip == 8); +} + +void MainWnd::OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 9 : gbFrameSkip == 9); +} + +void MainWnd::OnOptionsVideoVsync() +{ + theApp.vsync = !theApp.vsync; +} + +void MainWnd::OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.vsync); +} + +void MainWnd::OnUpdateOptionsVideoX1(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.videoOption == VIDEO_1X); +} + +void MainWnd::OnUpdateOptionsVideoX2(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.videoOption == VIDEO_2X); +} + +void MainWnd::OnUpdateOptionsVideoX3(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.videoOption == VIDEO_3X); +} + +void MainWnd::OnUpdateOptionsVideoX4(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.videoOption == VIDEO_4X); +} + +void MainWnd::OnUpdateOptionsVideoFullscreen320x240(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.mode320Available); + pCmdUI->SetCheck(theApp.videoOption == VIDEO_320x240); +} + +void MainWnd::OnUpdateOptionsVideoFullscreen640x480(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.mode640Available); + pCmdUI->SetCheck(theApp.videoOption == VIDEO_640x480); +} + +void MainWnd::OnUpdateOptionsVideoFullscreen800x600(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.mode800Available); + pCmdUI->SetCheck(theApp.videoOption == VIDEO_800x600); +} + +BOOL MainWnd::OnOptionVideoSize(UINT nID) +{ + theApp.updateVideoSize(nID); + theApp.m_pMainWnd->PostMessage(VBA_CONFIRM_MODE); + return TRUE; +} + +void MainWnd::OnOptionsVideoFullscreen320x240() +{ + OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN320X240); +} + +void MainWnd::OnOptionsVideoFullscreen640x480() +{ + OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN640X480); +} + +void MainWnd::OnOptionsVideoFullscreen800x600() +{ + OnOptionVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN800X600); +} + +void MainWnd::OnOptionsVideoFullscreen() +{ + theApp.winCheckFullscreen(); + GUID *pGUID = NULL; + int size = theApp.display->selectFullScreenMode(&pGUID); + if(size != -1) { + int width = (size >> 12) & 4095; + int height = (size & 4095); + int colorDepth = (size >> 24); + if(width != theApp.fsWidth || + height != theApp.fsHeight || + colorDepth != theApp.fsColorDepth || + pGUID != theApp.pVideoDriverGUID || + theApp.videoOption != VIDEO_OTHER) { + theApp.fsForceChange = true; + theApp.fsWidth = width; + theApp.fsHeight = height; + theApp.fsColorDepth = colorDepth; + theApp.pVideoDriverGUID = pGUID; + if(pGUID) { + theApp.videoDriverGUID = *pGUID; + regSetDwordValue("defaultVideoDriver", FALSE); + regSetBinaryValue("videoDriverGUID", + (char *)pGUID, sizeof(GUID)); + } else { + regSetDwordValue("defaultVideoDriver", TRUE); + } + theApp.updateVideoSize(ID_OPTIONS_VIDEO_FULLSCREEN); + theApp.m_pMainWnd->PostMessage(VBA_CONFIRM_MODE); + } + } + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.videoOption == VIDEO_OTHER); +} + +void MainWnd::OnOptionsVideoDisablesfx() +{ + cpuDisableSfx = !cpuDisableSfx; + if(emulating && theApp.cartridgeType == 0) + CPUUpdateRender(); +} + +void MainWnd::OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(cpuDisableSfx); +} + +void MainWnd::OnOptionsVideoFullscreenstretchtofit() +{ + theApp.fullScreenStretch = !theApp.fullScreenStretch; + theApp.updateWindowSize(theApp.videoOption); + if(theApp.display) + theApp.display->clear(); +} + +void MainWnd::OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.fullScreenStretch); +} + +BOOL MainWnd::OnVideoLayer(UINT nID) +{ + layerSettings ^= 0x0100 << + ((nID & 0xFFFF) - ID_OPTIONS_VIDEO_LAYERS_BG0); + layerEnable = DISPCNT & layerSettings; + CPUUpdateRenderBuffers(false); + return TRUE; +} + +void MainWnd::OnUpdateVideoLayer(CCmdUI *pCmdUI) +{ + pCmdUI->SetCheck((layerSettings >> (8 + pCmdUI->m_nID - ID_OPTIONS_VIDEO_LAYERS_BG0)) & 1); + switch(pCmdUI->m_nID) { + case ID_OPTIONS_VIDEO_LAYERS_BG1: + case ID_OPTIONS_VIDEO_LAYERS_BG2: + case ID_OPTIONS_VIDEO_LAYERS_BG3: + case ID_OPTIONS_VIDEO_LAYERS_WIN1: + case ID_OPTIONS_VIDEO_LAYERS_OBJWIN: + pCmdUI->Enable(theApp.cartridgeType == 0); + break; + } +} + +void MainWnd::OnOptionsVideoRendermethodGdi() +{ + theApp.renderMethod = GDI; + theApp.updateRenderMethod(false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRendermethodGdi(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.renderMethod == GDI); +} + +void MainWnd::OnOptionsVideoRendermethodDirectdraw() +{ + theApp.renderMethod = DIRECT_DRAW; + theApp.updateRenderMethod(false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.renderMethod == DIRECT_DRAW); +} + +void MainWnd::OnOptionsVideoRendermethodDirect3d() +{ + theApp.renderMethod = DIRECT_3D; + theApp.updateRenderMethod(false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.renderMethod == DIRECT_3D); +} + +void MainWnd::OnOptionsVideoRendermethodOpengl() +{ + theApp.renderMethod = OPENGL; + theApp.updateRenderMethod(false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.renderMethod == OPENGL); +} + +void MainWnd::OnOptionsVideoTriplebuffering() +{ + theApp.tripleBuffering = !theApp.tripleBuffering; +} + +void MainWnd::OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.tripleBuffering); +} + +void MainWnd::OnOptionsVideoDdrawemulationonly() +{ + theApp.ddrawEmulationOnly = !theApp.ddrawEmulationOnly; +} + +void MainWnd::OnUpdateOptionsVideoDdrawemulationonly(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.ddrawEmulationOnly); +} + +void MainWnd::OnOptionsVideoDdrawusevideomemory() +{ + theApp.ddrawUseVideoMemory = !theApp.ddrawUseVideoMemory; +} + +void MainWnd::OnUpdateOptionsVideoDdrawusevideomemory(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.ddrawUseVideoMemory); +} + +void MainWnd::OnOptionsVideoRenderoptionsD3dnofilter() +{ + theApp.d3dFilter = 0; + if(theApp.display) + theApp.display->setOption("d3dFilter", 0); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.d3dFilter == 0); +} + +void MainWnd::OnOptionsVideoRenderoptionsD3dbilinear() +{ + theApp.d3dFilter = 1; + if(theApp.display) + theApp.display->setOption("d3dFilter", 1); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.d3dFilter == 1); +} + +void MainWnd::OnOptionsVideoRenderoptionsGlnearest() +{ + theApp.glFilter = 0; + if(theApp.display) + theApp.display->setOption("glFilter", 0); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.glFilter == 0); +} + +void MainWnd::OnOptionsVideoRenderoptionsGlbilinear() +{ + theApp.glFilter = 1; + if(theApp.display) + theApp.display->setOption("glFilter", 1); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.glFilter == 1); +} + +void MainWnd::OnOptionsVideoRenderoptionsGltriangle() +{ + theApp.glType = 0; + if(theApp.display) + theApp.display->setOption("glType", 0); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.glType == 0); +} + +void MainWnd::OnOptionsVideoRenderoptionsGlquads() +{ + theApp.glType = 1; + if(theApp.display) + theApp.display->setOption("glType", 1); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.glType == 1); +} + +void MainWnd::OnOptionsVideoRenderoptionsSelectskin() +{ + LPCTSTR exts[] = {".ini" }; + CString filter = winLoadFilter(IDS_FILTER_INI); + CString title = winResLoadString(IDS_SELECT_SKIN_FILE); + + FileDlg dlg(this, + theApp.skinName, + filter, + 0, + "INI", + exts, + "", + title, + false); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + bool result = false; + if(!theApp.skinEnabled) { + theApp.skinEnabled = !theApp.skinEnabled; + regSetDwordValue("skinEnabled", theApp.skinEnabled); + } + + if(theApp.skin && theApp.skinEnabled) { + delete theApp.skin; + theApp.skin = NULL; + } + + theApp.skinName = dlg.GetPathName(); + + theApp.winUpdateSkin(); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.display && theApp.display->isSkinSupported() && + theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnOptionsVideoRenderoptionsSkin() +{ + theApp.skinEnabled = !theApp.skinEnabled; + theApp.updateRenderMethod(true); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.skinEnabled); + pCmdUI->Enable(theApp.display && theApp.display->isSkinSupported() && theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnOptionsEmulatorAssociate() +{ + theApp.winCheckFullscreen(); + Associate dlg; + dlg.DoModal(); +} + +void MainWnd::OnOptionsEmulatorDirectories() +{ + theApp.winCheckFullscreen(); + Directories dlg; + dlg.DoModal(); +} + +void MainWnd::OnOptionsVideoDisablestatusmessages() +{ + theApp.disableStatusMessage = !theApp.disableStatusMessage; +} + +void MainWnd::OnUpdateOptionsVideoDisablestatusmessages(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.disableStatusMessage); +} + +void MainWnd::OnOptionsEmulatorSynchronize() +{ + synchronize = !synchronize; +} + +void MainWnd::OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(synchronize); +} + +void MainWnd::OnOptionsEmulatorPausewheninactive() +{ + theApp.pauseWhenInactive = !theApp.pauseWhenInactive; +} + +void MainWnd::OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.pauseWhenInactive); +} + +void MainWnd::OnOptionsEmulatorSpeeduptoggle() +{ + theApp.speedupToggle = !theApp.speedupToggle; +} + +void MainWnd::OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.speedupToggle); +} + +void MainWnd::OnOptionsEmulatorRemoveintrosgba() +{ + // theApp.removeIntros = !theApp.removeIntros; +} + +void MainWnd::OnUpdateOptionsEmulatorRemoveintrosgba(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(false); + // pCmdUI->SetCheck(theApp.removeIntros); +} + +void MainWnd::OnOptionsEmulatorAutomaticallyipspatch() +{ + theApp.autoIPS = !theApp.autoIPS; +} + +void MainWnd::OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.autoIPS); +} + +void MainWnd::OnOptionsEmulatorAgbprint() +{ + agbPrintEnable(!agbPrintIsEnabled()); +} + +void MainWnd::OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(agbPrintIsEnabled()); +} + +void MainWnd::OnOptionsEmulatorRealtimeclock() +{ + theApp.winRtcEnable = !theApp.winRtcEnable; +} + +void MainWnd::OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winRtcEnable); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorAutohidemenu() +{ + theApp.autoHideMenu = !theApp.autoHideMenu; +} + +void MainWnd::OnUpdateOptionsEmulatorAutohidemenu(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.autoHideMenu); +} + +void MainWnd::OnOptionsEmulatorRewindinterval() +{ + RewindInterval dlg((float)theApp.rewindTimer/6.0f, theApp.rewindSlots); + int v = dlg.DoModal(); + + if(v >= 0) { + + int interval = v & 0x0000ffff; + int slots = (v & 0xffff0000) >> 16; + + int prevSlots = theApp.rewindSlots; + + theApp.rewindTimer = interval; // already converted to a multiple of 10 frames + theApp.rewindSlots = slots; + if(interval == 0 || slots == 0) { + theApp.rewindTimer = theApp.rewindSlots = 0; + regSetDwordValue("rewindTimer", interval); + regSetDwordValue("rewindSlots", slots); + if(theApp.rewindMemory) + free(theApp.rewindMemory); + theApp.rewindMemory = NULL; + theApp.rewindCount = 0; + theApp.rewindCounter = 0; + theApp.rewindSaveNeeded = false; + } else { + regSetDwordValue("rewindTimer", interval); + regSetDwordValue("rewindSlots", slots); + if(slots != prevSlots) { + if(theApp.rewindMemory) + free(theApp.rewindMemory); + theApp.rewindMemory = NULL; + theApp.rewindPos = 0; + } + if(theApp.rewindMemory == NULL) + theApp.rewindMemory = (char *)malloc(theApp.rewindSlots*REWIND_SIZE); + theApp.rewindCount = 0; + theApp.rewindSaveNeeded = true; + } + } +} + +BOOL MainWnd::OnOptionsEmulatorShowSpeed(UINT nID) +{ + switch(nID) { + case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE: + theApp.showSpeed = 0; + systemSetTitle("VisualBoyAdvance"); + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE: + theApp.showSpeed = 1; + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED: + theApp.showSpeed = 2; + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT: + theApp.showSpeedTransparent = !theApp.showSpeedTransparent; + break; + default: + return FALSE; + } + return TRUE; +} + +void MainWnd::OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI) +{ + switch(pCmdUI->m_nID) { + case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE: + pCmdUI->SetCheck(theApp.showSpeed == 0); + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE: + pCmdUI->SetCheck(theApp.showSpeed == 1); + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED: + pCmdUI->SetCheck(theApp.showSpeed == 2); + break; + case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT: + pCmdUI->SetCheck(theApp.showSpeedTransparent); + break; + } +} + +void MainWnd::OnOptionsEmulatorSavetypeAutomatic() +{ + theApp.winSaveType = 0; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 0); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeEeprom() +{ + theApp.winSaveType = 1; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 1); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeSram() +{ + theApp.winSaveType = 2; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 2); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeFlash() +{ + theApp.winSaveType = 3; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 3); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeEepromsensor() +{ + theApp.winSaveType = 4; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 4); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeNone() +{ + theApp.winSaveType = 5; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winSaveType == 5); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeFlash512k() +{ + flashSetSize(0x10000); + theApp.winFlashSize = 0x10000; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winFlashSize == 0x10000); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSavetypeFlash1m() +{ + flashSetSize(0x20000); + theApp.winFlashSize = 0x20000; +} +void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winFlashSize == 0x20000); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorUsebiosfile() +{ + if(!theApp.biosFileName.IsEmpty()) + theApp.useBiosFile = !theApp.useBiosFile; +} +void MainWnd::OnUpdateOptionsEmulatorUsebiosfile(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.useBiosFile); + pCmdUI->Enable(!theApp.biosFileName.IsEmpty() && (!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL))); +} + +void MainWnd::OnOptionsEmulatorSkipbios() +{ + theApp.skipBiosFile = !theApp.skipBiosFile; +} +void MainWnd::OnUpdateOptionsEmulatorSkipbios(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.skipBiosFile); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorUseOldGBTiming() +{ + theApp.useOldGBTiming = !theApp.useOldGBTiming; +} +void MainWnd::OnUpdateOptionsEmulatorUseOldGBTiming(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.useOldGBTiming); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + + + +void MainWnd::OnOptionsEmulatorGBALag() +{ + extern void TogglePrefetchHack(); + TogglePrefetchHack(); + memLagEnabled = memLagTempEnabled; // memLagEnabled is only to hold the last value that the user chose, so temporary changes don't get into the registry +} +void MainWnd::OnUpdateOptionsEmulatorGBALag(CCmdUI* pCmdUI) +{ +/// extern bool prefetchActive, prefetchPrevActive, prefetchApplies; +/// pCmdUI->SetCheck((prefetchApplies||(VBAMovieGetState()==MOVIE_STATE_PLAY)) ? prefetchActive : !memLagTempEnabled); + pCmdUI->SetCheck(!memLagTempEnabled); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsEmulatorSelectbiosfile() +{ + theApp.winCheckFullscreen(); + LPCTSTR exts[] = { "" }; + CString filter = winLoadFilter(IDS_FILTER_BIOS); + CString title = winResLoadString(IDS_SELECT_BIOS_FILE); + + FileDlg dlg(this, + theApp.biosFileName, + filter, + 0, + "BIOS", + exts, + "", + title, + false); + + if(dlg.DoModal() == IDOK) { + theApp.biosFileName = dlg.GetPathName(); + } +} + +void MainWnd::OnOptionsEmulatorPngformat() +{ + theApp.captureFormat = 0; +} + +void MainWnd::OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.captureFormat == 0); +} + +void MainWnd::OnOptionsEmulatorBmpformat() +{ + theApp.captureFormat = 1; +} + +void MainWnd::OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.captureFormat == 1); +} + +void MainWnd::OnOptionsSoundOff() +{ + soundOffFlag = true; + soundShutdown(); +} + +void MainWnd::OnUpdateOptionsSoundOff(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundOffFlag); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsSoundMute() +{ + soundDisable(0x30f); +} + +void MainWnd::OnUpdateOptionsSoundMute(CCmdUI* pCmdUI) +{ + int active = soundGetEnable() & 0x30f; + pCmdUI->SetCheck(active == 0); +} + +void MainWnd::OnOptionsSoundOn() +{ + if(soundOffFlag) { + soundOffFlag = false; + soundInit(); + } + soundEnable(0x30f); +} + +void MainWnd::OnUpdateOptionsSoundOn(CCmdUI* pCmdUI) +{ + int active = soundGetEnable() & 0x30f; + pCmdUI->SetCheck(active != 0 && !soundOffFlag); +} + +void MainWnd::OnOptionsSoundUseoldsynchronization() +{ + theApp.useOldSync = !theApp.useOldSync; + systemMessage(IDS_SETTING_WILL_BE_EFFECTIVE, + "Setting will be effective the next time you start the emulator"); +} + +void MainWnd::OnUpdateOptionsSoundUseoldsynchronization(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.useOldSync); +} + +void MainWnd::OnOptionsSoundEcho() +{ + soundEcho = !soundEcho; +} + +void MainWnd::OnUpdateOptionsSoundEcho(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundEcho); +} + +void MainWnd::OnOptionsSoundLowpassfilter() +{ + soundLowPass = !soundLowPass; +} + +void MainWnd::OnUpdateOptionsSoundLowpassfilter(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundLowPass); +} + +void MainWnd::OnOptionsSoundReversestereo() +{ + soundReverse = !soundReverse; +} +void MainWnd::OnUpdateOptionsSoundReversestereo(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundReverse); +} + +void MainWnd::OnOptionsSoundMuteFrameAdvance() +{ + theApp.muteFrameAdvance = !theApp.muteFrameAdvance; + if(!theApp.muteFrameAdvance) + theApp.frameAdvanceMuteNow = false; +} +void MainWnd::OnUpdateOptionsSoundMuteFrameAdvance(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.muteFrameAdvance); +} + +void MainWnd::OnOptionsSound11khz() +{ + if(theApp.cartridgeType == 0) + soundSetQuality(4); + else + gbSoundSetQuality(4); +} + +void MainWnd::OnUpdateOptionsSound11khz(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundQuality == 4); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsSound22khz() +{ + if(theApp.cartridgeType == 0) + soundSetQuality(2); + else + gbSoundSetQuality(2); +} + +void MainWnd::OnUpdateOptionsSound22khz(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundQuality == 2); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsSound44khz() +{ + if(theApp.cartridgeType == 0) + soundSetQuality(1); + else + gbSoundSetQuality(1); +} + +void MainWnd::OnUpdateOptionsSound44khz(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundQuality == 1); +} + +BOOL MainWnd::OnOptionsSoundVolume(UINT nID) +{ + soundVolume = nID - ID_OPTIONS_SOUND_VOLUME_1X; + return TRUE; +} + +void MainWnd::OnUpdateOptionsSoundVolume(CCmdUI *pCmdUI) +{ + pCmdUI->SetCheck(soundVolume == (int)(pCmdUI->m_nID - ID_OPTIONS_SOUND_VOLUME_1X)); +} + + +void MainWnd::OnOptionsSoundVolume25x() +{ + soundVolume = 4; +} + +void MainWnd::OnUpdateOptionsSoundVolume25x(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundVolume == 4); +} + +void MainWnd::OnOptionsSoundVolume5x() +{ + soundVolume = 5; +} + +void MainWnd::OnUpdateOptionsSoundVolume5x(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundVolume == 5); +} + +void MainWnd::updateSoundChannels(UINT id) +{ + int flag = 0; + + if(id == ID_OPTIONS_SOUND_CHANNEL1) + flag = 1; + + if(id == ID_OPTIONS_SOUND_CHANNEL2) + flag = 2; + + if(id == ID_OPTIONS_SOUND_CHANNEL3) + flag = 4; + + if(id == ID_OPTIONS_SOUND_CHANNEL4) + flag = 8; + + if(id == ID_OPTIONS_SOUND_DIRECTSOUNDA) + flag = 256; + + if(id == ID_OPTIONS_SOUND_DIRECTSOUNDB) + flag = 512; + + int active = soundGetEnable() & 0x30f; + + if(active & flag) + active &= (~flag); + else + active |= flag; + + soundEnable(active); + soundDisable((~active)&0x30f); +} + +void MainWnd::OnOptionsSoundChannel1() +{ + updateSoundChannels(ID_OPTIONS_SOUND_CHANNEL1); +} + +void MainWnd::OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 1); +} + +void MainWnd::OnOptionsSoundChannel2() +{ + updateSoundChannels(ID_OPTIONS_SOUND_CHANNEL2); +} + +void MainWnd::OnUpdateOptionsSoundChannel2(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 2); +} + +void MainWnd::OnOptionsSoundChannel3() +{ + updateSoundChannels(ID_OPTIONS_SOUND_CHANNEL3); +} + +void MainWnd::OnUpdateOptionsSoundChannel3(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 4); +} + +void MainWnd::OnOptionsSoundChannel4() +{ + updateSoundChannels(ID_OPTIONS_SOUND_CHANNEL4); +} + +void MainWnd::OnUpdateOptionsSoundChannel4(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 8); +} + +void MainWnd::OnOptionsSoundDirectsounda() +{ + updateSoundChannels(ID_OPTIONS_SOUND_DIRECTSOUNDA); +} + +void MainWnd::OnUpdateOptionsSoundDirectsounda(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 256); + pCmdUI->Enable(theApp.cartridgeType == 0); +} + +void MainWnd::OnOptionsSoundDirectsoundb() +{ + updateSoundChannels(ID_OPTIONS_SOUND_DIRECTSOUNDB); +} + +void MainWnd::OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(soundGetEnable() & 512); + pCmdUI->Enable(theApp.cartridgeType == 0); +} + +void MainWnd::OnOptionsGameboyBorder() +{ + theApp.winGbBorderOn = !theApp.winGbBorderOn; + gbBorderOn = theApp.winGbBorderOn; + if(emulating && theApp.cartridgeType == 1 && gbBorderOn) { + gbSgbRenderBorder(); + } + theApp.updateWindowSize(theApp.videoOption); +} + +void MainWnd::OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.winGbBorderOn); +} + +void MainWnd::OnOptionsGameboyPrinter() +{ + theApp.winGbPrinterEnabled = !theApp.winGbPrinterEnabled; + if(theApp.winGbPrinterEnabled) + gbSerialFunction = gbPrinterSend; + else + gbSerialFunction = NULL; +} + +void MainWnd::OnUpdateOptionsGameboyPrinter(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbSerialFunction == gbPrinterSend); +} + +void MainWnd::OnOptionsGameboyBorderAutomatic() +{ + gbBorderAutomatic = !gbBorderAutomatic; + if(emulating && theApp.cartridgeType == 1 && gbBorderOn) { + gbSgbRenderBorder(); + theApp.updateWindowSize(theApp.videoOption); + } +} + +void MainWnd::OnUpdateOptionsGameboyBorderAutomatic(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbBorderAutomatic); +} + +void MainWnd::OnOptionsGameboyAutomatic() +{ + gbEmulatorType = 0; +} + +void MainWnd::OnUpdateOptionsGameboyAutomatic(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 0); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboyGba() +{ + gbEmulatorType = 4; +} + +void MainWnd::OnUpdateOptionsGameboyGba(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 4); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboyCgb() +{ + gbEmulatorType = 1; +} + +void MainWnd::OnUpdateOptionsGameboyCgb(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 1); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboySgb() +{ + gbEmulatorType = 2; +} + +void MainWnd::OnUpdateOptionsGameboySgb(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 2); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboySgb2() +{ + gbEmulatorType = 5; +} + +void MainWnd::OnUpdateOptionsGameboySgb2(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 5); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboyGb() +{ + gbEmulatorType = 3; +} + +void MainWnd::OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbEmulatorType == 3); + pCmdUI->Enable(!VBAMovieActive() || GetAsyncKeyState(VK_CONTROL)); +} + +void MainWnd::OnOptionsGameboyRealcolors() +{ + gbColorOption = 0; +} + +void MainWnd::OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbColorOption == 0); +} + +void MainWnd::OnOptionsGameboyGameboycolors() +{ + gbColorOption = 1; +} + +void MainWnd::OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(gbColorOption == 1); +} + + +void MainWnd::OnOptionsGameboyColors() +{ + theApp.winCheckFullscreen(); + GBColorDlg dlg; + if(dlg.DoModal()) { + gbPaletteOption = dlg.getWhich(); + memcpy(systemGbPalette, dlg.getColors(), 24*sizeof(u16)); + if(emulating && theApp.cartridgeType == 1) { + memcpy(gbPalette, &systemGbPalette[dlg.getWhich()*8], 8*sizeof(u16)); + } + } +} + +BOOL MainWnd::OnOptionsPriority(UINT nID) +{ + switch(nID) { + case ID_OPTIONS_PRIORITY_HIGHEST: + theApp.threadPriority = 0; + break; + case ID_OPTIONS_PRIORITY_ABOVENORMAL: + theApp.threadPriority = 1; + break; + case ID_OPTIONS_PRIORITY_NORMAL: + theApp.threadPriority = 2; + break; + case ID_OPTIONS_PRIORITY_BELOWNORMAL: + theApp.threadPriority = 3; + break; + default: + return FALSE; + } + theApp.updatePriority(); + + return TRUE; +} + +void MainWnd::OnUpdateOptionsPriority(CCmdUI *pCmdUI) +{ + switch(pCmdUI->m_nID) { + case ID_OPTIONS_PRIORITY_HIGHEST: + pCmdUI->SetCheck(theApp.threadPriority == 0); + break; + case ID_OPTIONS_PRIORITY_ABOVENORMAL: + pCmdUI->SetCheck(theApp.threadPriority == 1); + break; + case ID_OPTIONS_PRIORITY_NORMAL: + pCmdUI->SetCheck(theApp.threadPriority == 2); + break; + case ID_OPTIONS_PRIORITY_BELOWNORMAL: + pCmdUI->SetCheck(theApp.threadPriority == 3); + break; + } +} + +BOOL MainWnd::OnOptionsFilter(UINT nID) +{ + switch(nID) { + case ID_OPTIONS_FILTER_NORMAL: + theApp.filterType = 0; + break; + case ID_OPTIONS_FILTER_TVMODE: + theApp.filterType = 1; + break; + case ID_OPTIONS_FILTER_2XSAI: + theApp.filterType = 2; + break; + case ID_OPTIONS_FILTER_SUPER2XSAI: + theApp.filterType = 3; + break; + case ID_OPTIONS_FILTER_SUPEREAGLE: + theApp.filterType = 4; + break; + case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL: + theApp.filterType = 5; + break; + case ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL: + theApp.filterType = 6; + break; + case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X: + theApp.filterType = 7; + break; + case ID_OPTIONS_FILTER16BIT_SIMPLE2X: + theApp.filterType = 8; + break; + case ID_OPTIONS_FILTER_BILINEAR: + theApp.filterType = 9; + break; + case ID_OPTIONS_FILTER_BILINEARPLUS: + theApp.filterType = 10; + break; + case ID_OPTIONS_FILTER_SCANLINES: + theApp.filterType = 11; + break; + case ID_OPTIONS_FILTER_HQ2X2: + theApp.filterType = 12; + break; + case ID_OPTIONS_FILTER_HQ2X: + theApp.filterType = 13; + break; + case ID_OPTIONS_FILTER_LQ2X: + theApp.filterType = 14; + break; + case ID_OPTIONS_FILTER_HQ3X2: + theApp.filterType = 15; + break; + case ID_OPTIONS_FILTER_HQ3X: + theApp.filterType = 16; + break; + default: + return FALSE; + } + theApp.updateFilter(); + return TRUE; +} + +void MainWnd::OnUpdateOptionsFilter(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(systemColorDepth == 16 || systemColorDepth == 32); + switch(pCmdUI->m_nID) { + case ID_OPTIONS_FILTER_NORMAL: + pCmdUI->SetCheck(theApp.filterType == 0); + break; + case ID_OPTIONS_FILTER_TVMODE: + pCmdUI->SetCheck(theApp.filterType == 1); + break; + case ID_OPTIONS_FILTER_2XSAI: + pCmdUI->SetCheck(theApp.filterType == 2); + break; + case ID_OPTIONS_FILTER_SUPER2XSAI: + pCmdUI->SetCheck(theApp.filterType == 3); + break; + case ID_OPTIONS_FILTER_SUPEREAGLE: + pCmdUI->SetCheck(theApp.filterType == 4); + break; + case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL: + pCmdUI->SetCheck(theApp.filterType == 5); + break; + case ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL: + pCmdUI->SetCheck(theApp.filterType == 6); + break; + case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X: + pCmdUI->SetCheck(theApp.filterType == 7); + break; + case ID_OPTIONS_FILTER16BIT_SIMPLE2X: + pCmdUI->SetCheck(theApp.filterType == 8); + break; + case ID_OPTIONS_FILTER_BILINEAR: + pCmdUI->SetCheck(theApp.filterType == 9); + break; + case ID_OPTIONS_FILTER_BILINEARPLUS: + pCmdUI->SetCheck(theApp.filterType == 10); + break; + case ID_OPTIONS_FILTER_SCANLINES: + pCmdUI->SetCheck(theApp.filterType == 11); + break; + case ID_OPTIONS_FILTER_HQ2X2: + pCmdUI->SetCheck(theApp.filterType == 12); + break; + case ID_OPTIONS_FILTER_HQ2X: + pCmdUI->SetCheck(theApp.filterType == 13); + break; + case ID_OPTIONS_FILTER_LQ2X: + pCmdUI->SetCheck(theApp.filterType == 14); + break; + case ID_OPTIONS_FILTER_HQ3X2: + pCmdUI->SetCheck(theApp.filterType == 15); + break; + case ID_OPTIONS_FILTER_HQ3X: + pCmdUI->SetCheck(theApp.filterType == 16); + break; + } +} + +BOOL MainWnd::OnOptionsFilterIFB(UINT nID) +{ + switch(nID) { + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE: + theApp.ifbType = 0; + break; + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR: + theApp.ifbType = 1; + break; + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART: + theApp.ifbType = 2; + break; + default: + return FALSE; + } + theApp.updateIFB(); + return TRUE; +} + +void MainWnd::OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI) +{ + switch(pCmdUI->m_nID) { + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE: + pCmdUI->SetCheck(theApp.ifbType == 0); + break; + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR: + pCmdUI->SetCheck(theApp.ifbType == 1); + break; + case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART: + pCmdUI->SetCheck(theApp.ifbType == 2); + break; + } +} + +void MainWnd::OnOptionsFilterDisablemmx() +{ + theApp.disableMMX = !theApp.disableMMX; + if(!theApp.disableMMX) + cpu_mmx = theApp.detectMMX(); + else + cpu_mmx = 0; +} + +void MainWnd::OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.disableMMX); +} + + +void MainWnd::OnOptionsLanguageSystem() +{ + theApp.winSetLanguageOption(0, false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.languageOption == 0); +} + +void MainWnd::OnOptionsLanguageEnglish() +{ + theApp.winSetLanguageOption(1, false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.languageOption == 1); +} + +void MainWnd::OnOptionsLanguageOther() +{ + theApp.winCheckFullscreen(); + theApp.winSetLanguageOption(2, false); + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.languageOption == 2); +} + + +void MainWnd::OnOptionsJoypadConfigure1() +{ + theApp.winCheckFullscreen(); + JoypadConfig dlg(0); + dlg.DoModal(); +} + +void MainWnd::OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + +void MainWnd::OnOptionsJoypadConfigure2() +{ + theApp.winCheckFullscreen(); + JoypadConfig dlg(1); + dlg.DoModal(); +} + +void MainWnd::OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + +void MainWnd::OnOptionsJoypadConfigure3() +{ + theApp.winCheckFullscreen(); + JoypadConfig dlg(2); + dlg.DoModal(); +} + +void MainWnd::OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + +void MainWnd::OnOptionsJoypadConfigure4() +{ + theApp.winCheckFullscreen(); + JoypadConfig dlg(3); + dlg.DoModal(); +} + +void MainWnd::OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + +BOOL MainWnd::OnOptionsJoypadDefault(UINT nID) +{ + theApp.joypadDefault = nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1; + return TRUE; +} + +void MainWnd::OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI) +{ + pCmdUI->SetCheck(theApp.joypadDefault == (int)(pCmdUI->m_nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1)); +} + +void MainWnd::OnOptionsJoypadMotionconfigure() +{ + theApp.winCheckFullscreen(); + MotionConfig dlg; + dlg.DoModal(); +} +void MainWnd::OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + +void MainWnd::OnOptionsJoypadAllowLeftRight() +{ + theApp.allowLeftRight = !theApp.allowLeftRight; +} +void MainWnd::OnUpdateOptionsJoypadAllowLeftRight(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.allowLeftRight); +} + +BOOL MainWnd::OnOptionsJoypadAutofire(UINT nID) +{ + int & autoFire = (theApp.autoFireToggle ? theApp.autoFire : theApp.autoFire2); + int & autoFire2 = (theApp.autoFireToggle ? theApp.autoFire2 : theApp.autoFire); + int autoFires = (theApp.autoFire | theApp.autoFire2); + + switch(nID) { + case ID_OPTIONS_JOYPAD_AUTOFIRE_A: + if(autoFires & BUTTON_MASK_A) { + autoFire &= ~BUTTON_MASK_A; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A_DISABLED)); + } else { + autoFire |= BUTTON_MASK_A; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A)); + } + autoFire2 &= ~BUTTON_MASK_A; + theApp.autoHold &= ~BUTTON_MASK_A; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_B: + if(autoFires & BUTTON_MASK_B) { + autoFire &= ~BUTTON_MASK_B; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B_DISABLED)); + } else { + autoFire |= BUTTON_MASK_B; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B)); + } + autoFire2 &= ~BUTTON_MASK_B; + theApp.autoHold &= ~BUTTON_MASK_B; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_L: + if(autoFires & BUTTON_MASK_L) { + autoFire &= ~BUTTON_MASK_L; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L_DISABLED)); + } else { + autoFire |= BUTTON_MASK_L; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L)); + } + autoFire2 &= ~BUTTON_MASK_L; + theApp.autoHold &= ~BUTTON_MASK_L; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_R: + if(autoFires & BUTTON_MASK_R) { + autoFire &= ~BUTTON_MASK_R; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R_DISABLED)); + } else { + autoFire |= BUTTON_MASK_R; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R)); + } + autoFire2 &= ~BUTTON_MASK_R; + theApp.autoHold &= ~BUTTON_MASK_R; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_START: + if(autoFires & BUTTON_MASK_START) { + autoFire &= ~BUTTON_MASK_START; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_START_DISABLED)); + } else { + autoFire |= BUTTON_MASK_START; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_START)); + } + autoFire2 &= ~BUTTON_MASK_START; + theApp.autoHold &= ~BUTTON_MASK_START; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT: + if(autoFires & BUTTON_MASK_SELECT) { + autoFire &= ~BUTTON_MASK_SELECT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_SELECT_DISABLED)); + } else { + autoFire |= BUTTON_MASK_SELECT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_SELECT)); + } + autoFire2 &= ~BUTTON_MASK_SELECT; + theApp.autoHold &= ~BUTTON_MASK_SELECT; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_UP: + if(autoFires & BUTTON_MASK_UP) { + autoFire &= ~BUTTON_MASK_UP; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_UP_DISABLED)); + } else { + autoFire |= BUTTON_MASK_UP; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_UP)); + } + autoFire2 &= ~BUTTON_MASK_UP; + theApp.autoHold &= ~BUTTON_MASK_UP; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN: + if(autoFires & BUTTON_MASK_DOWN) { + autoFire &= ~BUTTON_MASK_DOWN; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DOWN_DISABLED)); + } else { + autoFire |= BUTTON_MASK_DOWN; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DOWN)); + } + autoFire2 &= ~BUTTON_MASK_DOWN; + theApp.autoHold &= ~BUTTON_MASK_DOWN; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT: + if(autoFires & BUTTON_MASK_LEFT) { + autoFire &= ~BUTTON_MASK_LEFT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_LEFT_DISABLED)); + } else { + autoFire |= BUTTON_MASK_LEFT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_LEFT)); + } + autoFire2 &= ~BUTTON_MASK_LEFT; + theApp.autoHold &= ~BUTTON_MASK_LEFT; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT: + if(autoFires & BUTTON_MASK_RIGHT) { + autoFire &= ~BUTTON_MASK_RIGHT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_RIGHT_DISABLED)); + } else { + autoFire |= BUTTON_MASK_RIGHT; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_RIGHT)); + } + autoFire2 &= ~BUTTON_MASK_RIGHT; + theApp.autoHold &= ~BUTTON_MASK_RIGHT; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR: + if(autoFires != 0) { + theApp.autoFire = theApp.autoFire2 = 0; +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_DISABLED)); + } else { +/// systemScreenMessage(winResLoadString(IDS_AUTOFIRE_ALREADY_DISABLED)); + systemScreenMessage("already cleared"); + } + break; + default: + return FALSE; + } + + extern void DisplayPressedKeys(); DisplayPressedKeys(); + + return TRUE; +} + +void MainWnd::OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI) +{ +/// pCmdUI->Enable(emulating); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + pCmdUI->Enable(TRUE); // TEMP + + int autoFires = (theApp.autoFire | theApp.autoFire2); + + bool check = true; + switch(pCmdUI->m_nID) { + case ID_OPTIONS_JOYPAD_AUTOFIRE_A: + check = (autoFires & BUTTON_MASK_A) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_B: + check = (autoFires & BUTTON_MASK_B) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_L: + check = (autoFires & BUTTON_MASK_L) != 0; +/// extern int gbSgbMode; // from gbSGB.cpp +/// if(emulating && theApp.cartridgeType != 0 && !gbSgbMode) // regular GB has no L button +/// pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_R: + check = (autoFires & BUTTON_MASK_R) != 0; +/// extern int gbSgbMode; // from gbSGB.cpp +/// if(emulating && theApp.cartridgeType != 0 && !gbSgbMode) // regular GB has no R button +/// pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_START: + check = (autoFires & BUTTON_MASK_START) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT: + check = (autoFires & BUTTON_MASK_SELECT) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_UP: + check = (autoFires & BUTTON_MASK_UP) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN: + check = (autoFires & BUTTON_MASK_DOWN) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT: + check = (autoFires & BUTTON_MASK_LEFT) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT: + check = (autoFires & BUTTON_MASK_RIGHT) != 0; + break; + case ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR: + check = (autoFires == 0); +/// pCmdUI->Enable(!check); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + } + pCmdUI->SetCheck(check); +} + +BOOL MainWnd::OnOptionsJoypadSticky(UINT nID) +{ + switch(nID) { + case ID_STICKY_A: + if(theApp.autoHold & BUTTON_MASK_A) { + theApp.autoHold &= ~BUTTON_MASK_A; +/// systemScreenMessage(winResLoadString(IDS_STICKY_A_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_A; +/// systemScreenMessage(winResLoadString(IDS_STICKY_A)); + } + theApp.autoFire &= ~BUTTON_MASK_A; + theApp.autoFire2 &= ~BUTTON_MASK_A; + break; + case ID_STICKY_B: + if(theApp.autoHold & BUTTON_MASK_B) { + theApp.autoHold &= ~BUTTON_MASK_B; +/// systemScreenMessage(winResLoadString(IDS_STICKY_B_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_B; +/// systemScreenMessage(winResLoadString(IDS_STICKY_B)); + } + theApp.autoFire &= ~BUTTON_MASK_B; + theApp.autoFire2 &= ~BUTTON_MASK_B; + break; + case ID_STICKY_L: + if(theApp.autoHold & BUTTON_MASK_L) { + theApp.autoHold &= ~BUTTON_MASK_L; +/// systemScreenMessage(winResLoadString(IDS_STICKY_L_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_L; +/// systemScreenMessage(winResLoadString(IDS_STICKY_L)); + } + theApp.autoFire &= ~BUTTON_MASK_L; + theApp.autoFire2 &= ~BUTTON_MASK_L; + break; + case ID_STICKY_R: + if(theApp.autoHold & BUTTON_MASK_R) { + theApp.autoHold &= ~BUTTON_MASK_R; +/// systemScreenMessage(winResLoadString(IDS_STICKY_R_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_R; +/// systemScreenMessage(winResLoadString(IDS_STICKY_R)); + } + theApp.autoFire &= ~BUTTON_MASK_R; + theApp.autoFire2 &= ~BUTTON_MASK_R; + break; + case ID_STICKY_START: + if(theApp.autoHold & BUTTON_MASK_START) { + theApp.autoHold &= ~BUTTON_MASK_START; +/// systemScreenMessage(winResLoadString(IDS_STICKY_START_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_START; +/// systemScreenMessage(winResLoadString(IDS_STICKY_START)); + } + theApp.autoFire &= ~BUTTON_MASK_START; + theApp.autoFire2 &= ~BUTTON_MASK_START; + break; + case ID_STICKY_SELECT: + if(theApp.autoHold & BUTTON_MASK_SELECT) { + theApp.autoHold &= ~BUTTON_MASK_SELECT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_SELECT_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_SELECT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_SELECT)); + } + theApp.autoFire &= ~BUTTON_MASK_SELECT; + theApp.autoFire2 &= ~BUTTON_MASK_SELECT; + break; + case ID_STICKY_UP: + if(theApp.autoHold & BUTTON_MASK_UP) { + theApp.autoHold &= ~BUTTON_MASK_UP; +/// systemScreenMessage(winResLoadString(IDS_STICKY_UP_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_UP; +/// systemScreenMessage(winResLoadString(IDS_STICKY_UP)); + } + theApp.autoFire &= ~BUTTON_MASK_UP; + theApp.autoFire2 &= ~BUTTON_MASK_UP; + if(!theApp.allowLeftRight) + theApp.autoHold &= ~BUTTON_MASK_DOWN; + break; + case ID_STICKY_DOWN: + if(theApp.autoHold & BUTTON_MASK_DOWN) { + theApp.autoHold &= ~BUTTON_MASK_DOWN; +/// systemScreenMessage(winResLoadString(IDS_STICKY_DOWN_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_DOWN; +/// systemScreenMessage(winResLoadString(IDS_STICKY_DOWN)); + } + theApp.autoFire &= ~BUTTON_MASK_DOWN; + theApp.autoFire2 &= ~BUTTON_MASK_DOWN; + if(!theApp.allowLeftRight) + theApp.autoHold &= ~BUTTON_MASK_UP; + break; + case ID_STICKY_LEFT: + if(theApp.autoHold & BUTTON_MASK_LEFT) { + theApp.autoHold &= ~BUTTON_MASK_LEFT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_LEFT_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_LEFT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_LEFT)); + } + theApp.autoFire &= ~BUTTON_MASK_LEFT; + theApp.autoFire2 &= ~BUTTON_MASK_LEFT; + if(!theApp.allowLeftRight) + theApp.autoHold &= ~BUTTON_MASK_RIGHT; + break; + case ID_STICKY_RIGHT: + if(theApp.autoHold & BUTTON_MASK_RIGHT) { + theApp.autoHold &= ~BUTTON_MASK_RIGHT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_RIGHT_DISABLED)); + } else { + theApp.autoHold |= BUTTON_MASK_RIGHT; +/// systemScreenMessage(winResLoadString(IDS_STICKY_RIGHT)); + } + theApp.autoFire &= ~BUTTON_MASK_RIGHT; + theApp.autoFire2 &= ~BUTTON_MASK_RIGHT; + if(!theApp.allowLeftRight) + theApp.autoHold &= ~BUTTON_MASK_LEFT; + break; + case ID_STICKY_CLEAR: + if(theApp.autoHold != 0) { + theApp.autoHold = 0; +/// systemScreenMessage(winResLoadString(IDS_STICKY_DISABLED)); + } else { +/// systemScreenMessage(winResLoadString(IDS_STICKY_ALREADY_DISABLED)); + systemScreenMessage("already cleared"); + } + break; + default: + return FALSE; + } + + extern void DisplayPressedKeys(); DisplayPressedKeys(); + + return TRUE; +} + +void MainWnd::OnUpdateOptionsJoypadSticky(CCmdUI *pCmdUI) +{ +/// pCmdUI->Enable(emulating); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + pCmdUI->Enable(TRUE); // TEMP + + bool check = true; + switch(pCmdUI->m_nID) { + case ID_STICKY_A: + check = (theApp.autoHold & BUTTON_MASK_A) != 0; + break; + case ID_STICKY_B: + check = (theApp.autoHold & BUTTON_MASK_B) != 0; + break; + case ID_STICKY_L: + check = (theApp.autoHold & BUTTON_MASK_L) != 0; +/// extern int gbSgbMode; // from gbSGB.cpp +/// if(emulating && theApp.cartridgeType != 0 && !gbSgbMode) // regular GB has no L button +/// pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + case ID_STICKY_R: + check = (theApp.autoHold & BUTTON_MASK_R) != 0; +/// extern int gbSgbMode; // from gbSGB.cpp +/// if(emulating && theApp.cartridgeType != 0 && !gbSgbMode) // regular GB has no R button +/// pCmdUI->Enable(false); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + case ID_STICKY_START: + check = (theApp.autoHold & BUTTON_MASK_START) != 0; + break; + case ID_STICKY_SELECT: + check = (theApp.autoHold & BUTTON_MASK_SELECT) != 0; + break; + case ID_STICKY_UP: + check = (theApp.autoHold & BUTTON_MASK_UP) != 0; + break; + case ID_STICKY_DOWN: + check = (theApp.autoHold & BUTTON_MASK_DOWN) != 0; + break; + case ID_STICKY_LEFT: + check = (theApp.autoHold & BUTTON_MASK_LEFT) != 0; + break; + case ID_STICKY_RIGHT: + check = (theApp.autoHold & BUTTON_MASK_RIGHT) != 0; + break; + case ID_STICKY_CLEAR: + check = (theApp.autoHold == 0); +/// pCmdUI->Enable(!check); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! + break; + } + pCmdUI->SetCheck(check); +} + +LRESULT MainWnd::OnConfirmMode(WPARAM, LPARAM) +{ + // we need to do this separately or the window will not have the right + // parent. must be related to the way MFC does modal dialogs + winConfirmMode(); + return 0; +} + +void MainWnd::winConfirmMode() +{ + if(theApp.renderMethod == DIRECT_DRAW && theApp.videoOption > VIDEO_4X) { + theApp.winCheckFullscreen(); + ModeConfirm dlg(theApp.m_pMainWnd); + + if(!dlg.DoModal()) { + theApp.updateVideoSize(ID_OPTIONS_VIDEO_X2); + } + } + theApp.winAccelMgr.UpdateMenu(theApp.menu); +} + +void MainWnd::OnOptionsVideoFullscreenmaxscale() +{ + MaxScale dlg; + + theApp.winCheckFullscreen(); + + dlg.DoModal(); +} + +void MainWnd::OnOptionsVideoTextdisplayoptions() +{ + TextOptions dlg; + + theApp.winCheckFullscreen(); + + dlg.DoModal(); +} + +void MainWnd::OnUpdateOptionsVideoTextdisplayoptions(CCmdUI *pCmdUI) +{ + pCmdUI->Enable(TRUE); +} diff --git a/src/win32/MainWndTools.cpp b/src/win32/MainWndTools.cpp new file mode 100644 index 0000000..bf6224f --- /dev/null +++ b/src/win32/MainWndTools.cpp @@ -0,0 +1,673 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" + +#include "AccelEditor.h" +#include "AVIWrite.h" +#include "Disassemble.h" +#include "FileDlg.h" +#include "GBDisassemble.h" +#include "GBMapView.h" +#include "GBMemoryViewerDlg.h" +#include "GBOamView.h" +#include "GBPaletteView.h" +#include "GBTileView.h" +#include "GDBConnection.h" +#include "IOViewer.h" +#include "MapView.h" +#include "MemoryViewerDlg.h" +#include "MovieOpen.h" +#include "MovieCreate.h" +#include "OamView.h" +#include "PaletteView.h" +#include "Reg.h" +#include "TileView.h" +#include "WavWriter.h" +#include "WinResUtil.h" + +#include "../GBA.h" +#include "../Globals.h" +#include "../movie.h" +#include "../RTC.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern bool debugger; +extern int emulating; +extern int remoteSocket; + +extern void remoteCleanUp(); +extern void remoteSetSockets(SOCKET, SOCKET); +extern void toolsLogging(); + +void MainWnd::OnToolsDisassemble() +{ + if(theApp.cartridgeType == 0) { + Disassemble *dlg = new Disassemble(); + dlg->Create(IDD_DISASSEMBLE, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBDisassemble *dlg = new GBDisassemble(); + dlg->Create(IDD_GB_DISASSEMBLE, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsDisassemble(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsLogging() +{ + toolsLogging(); +} + +void MainWnd::OnUpdateToolsLogging(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsIoviewer() +{ + IOViewer *dlg = new IOViewer; + dlg->Create(IDD_IO_VIEWER,this); + dlg->ShowWindow(SW_SHOW); +} + +void MainWnd::OnUpdateToolsIoviewer(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && theApp.cartridgeType == 0); +} + +void MainWnd::OnToolsMapview() +{ + if(theApp.cartridgeType == 0) { + MapView *dlg = new MapView; + dlg->Create(IDD_MAP_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBMapView *dlg = new GBMapView; + dlg->Create(IDD_GB_MAP_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsMapview(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsMemoryviewer() +{ + if(theApp.cartridgeType == 0) { + MemoryViewerDlg *dlg = new MemoryViewerDlg; + dlg->Create(IDD_MEM_VIEWER, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBMemoryViewerDlg *dlg = new GBMemoryViewerDlg; + dlg->Create(IDD_MEM_VIEWER, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsOamviewer() +{ + if(theApp.cartridgeType == 0) { + OamView *dlg = new OamView; + dlg->Create(IDD_OAM_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBOamView *dlg = new GBOamView; + dlg->Create(IDD_GB_OAM_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsOamviewer(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsPaletteview() +{ + if(theApp.cartridgeType == 0) { + PaletteView *dlg = new PaletteView; + dlg->Create(IDD_PALETTE_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBPaletteView *dlg = new GBPaletteView; + dlg->Create(IDD_GB_PALETTE_VIEW, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsPaletteview(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnToolsTileviewer() +{ + if(theApp.cartridgeType == 0) { + TileView *dlg = new TileView; + dlg->Create(IDD_TILE_VIEWER, this); + dlg->ShowWindow(SW_SHOW); + } else { + GBTileView *dlg = new GBTileView; + dlg->Create(IDD_GB_TILE_VIEWER, this); + dlg->ShowWindow(SW_SHOW); + } +} + +void MainWnd::OnUpdateToolsTileviewer(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X); +} + +void MainWnd::OnDebugNextframe() +{ + if(theApp.paused) + theApp.paused = false; + theApp.winPauseNextFrame = true; +} +void MainWnd::OnUpdateDebugNextframe(CCmdUI* pCmdUI) +{ +} + +#if (defined(WIN32) && !defined(SDL)) + extern u32 currentButtons [4]; // from DirectInput.cpp +#else + u32 currentButtons [4]; /// SDL FIXME movie support NYI (the input format is quite different) +#endif + +void MainWnd::OnDebugFramesearch() +{ + extern SMovie Movie; + if(!theApp.frameSearching) + { + // starting a new search + theApp.frameSearching = true; + theApp.frameSearchStart = (Movie.state == MOVIE_STATE_NONE) ? theApp.globalFrameCount : Movie.currentFrame; + theApp.frameSearchLength = 0; + theApp.frameSearchLoadValid = false; + theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE*0], REWIND_SIZE); // 0 is start state, 1 is intermediate state (for speedup when going forward), 2 is end state + theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE*1], REWIND_SIZE); + + // store old buttons from frame before the search + for(int i = 0 ; i < 4 ; i++) + theApp.frameSearchOldInput[i] = currentButtons[i]; + } + else + { + // advance forward 1 step in the search + theApp.frameSearchLength++; + + // try it + theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE*1], REWIND_SIZE); + } + + char str [32]; + sprintf(str, "%d frame search", theApp.frameSearchLength); + systemScreenMessage(str, 0, 600); + + theApp.frameSearchSkipping = true; + + // make sure the display updates at least 1 frame to show the new message + theApp.frameSearchFirstStep = true; + + if(theApp.paused) + theApp.paused = false; +} +void MainWnd::OnUpdateDebugFramesearch(CCmdUI* pCmdUI) +{ + extern SMovie Movie; + pCmdUI->Enable(emulating && Movie.state != MOVIE_STATE_PLAY); + pCmdUI->SetCheck(theApp.frameSearching); +} + +void MainWnd::OnDebugFramesearchPrev() +{ + if(theApp.frameSearching) + { + if(theApp.frameSearchLength > 0) + { + // rewind 1 step in the search + theApp.frameSearchLength--; + } + + // try it + theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE*0], REWIND_SIZE); + + char str [32]; + sprintf(str, "%d frame search", theApp.frameSearchLength); + systemScreenMessage(str, 0, 600); + + theApp.frameSearchSkipping = true; + + // make sure the display updates at least 1 frame to show the new message + theApp.frameSearchFirstStep = true; + + if(theApp.paused) + theApp.paused = false; + } +} +void MainWnd::OnUpdateDebugFramesearchPrev(CCmdUI* pCmdUI) +{ + extern SMovie Movie; + pCmdUI->Enable(emulating && theApp.frameSearching && Movie.state != MOVIE_STATE_PLAY); +} + +void MainWnd::OnDebugFramesearchLoad() +{ + if(theApp.frameSearchLoadValid) + { + theApp.emulator.emuReadMemState(&theApp.frameSearchMemory[REWIND_SIZE*2], REWIND_SIZE); + theApp.paused = true; + + if(theApp.frameSearching) + systemScreenMessage("end frame search", 0, 600); + else + systemScreenMessage("restore search end", 0, 600); + } + theApp.frameSearching = false; + theApp.frameSearchSkipping = false; +} +void MainWnd::OnUpdateDebugFramesearchLoad(CCmdUI* pCmdUI) +{ + extern SMovie Movie; + pCmdUI->Enable(emulating && Movie.state != MOVIE_STATE_PLAY); +} + +void MainWnd::OnToolsFrameCounter() +{ + theApp.frameCounter = !theApp.frameCounter; +} +void MainWnd::OnUpdateToolsFrameCounter(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.frameCounter); +} + +void MainWnd::OnToolsInputDisplay() +{ + theApp.inputDisplay = !theApp.inputDisplay; + systemScreenMessage(theApp.inputDisplay ? "Input Display On" : "Input Display Off"); + extern void DisplayPressedKeys(); DisplayPressedKeys(); +} +void MainWnd::OnUpdateToolsInputDisplay(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.inputDisplay); +} + + +void MainWnd::OnToolsDebugGdb() +{ + theApp.winCheckFullscreen(); + GDBPortDlg dlg; + + if(dlg.DoModal()) { + GDBWaitingDlg wait(dlg.getSocket(), dlg.getPort()); + if(wait.DoModal()) { + remoteSetSockets(wait.getListenSocket(), wait.getSocket()); + debugger = true; + emulating = 1; + theApp.cartridgeType = 0; + theApp.filename = "\\gnu_stub"; + rom = (u8 *)malloc(0x2000000); + workRAM = (u8 *)calloc(1, 0x40000); + bios = (u8 *)calloc(1,0x4000); + internalRAM = (u8 *)calloc(1,0x8000); + paletteRAM = (u8 *)calloc(1,0x400); + vram = (u8 *)calloc(1, 0x20000); + oam = (u8 *)calloc(1, 0x400); + pix = (u8 *)calloc(1, 4 * 240 * 160); + ioMem = (u8 *)calloc(1, 0x400); + + theApp.emulator = GBASystem; + + CPUInit(theApp.biosFileName, theApp.useBiosFile ? true : false); + CPUReset(); + } + } +} + +void MainWnd::OnUpdateToolsDebugGdb(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket == -1); +} + +void MainWnd::OnToolsDebugLoadandwait() +{ + theApp.winCheckFullscreen(); + if(fileOpenSelect()) { + if(FileRun()) { + if(theApp.cartridgeType != 0) { + systemMessage(IDS_ERROR_NOT_GBA_IMAGE, "Error: not a GBA image"); + OnFileClose(); + return; + } + GDBPortDlg dlg; + + if(dlg.DoModal()) { + GDBWaitingDlg wait(dlg.getSocket(), dlg.getPort()); + if(wait.DoModal()) { + remoteSetSockets(wait.getListenSocket(), wait.getSocket()); + debugger = true; + emulating = 1; + } + } + } + } +} + +void MainWnd::OnUpdateToolsDebugLoadandwait(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket == -1); +} + +void MainWnd::OnToolsDebugBreak() +{ + if(armState) { + armNextPC -= 4; + reg[15].I -= 4; + } else { + armNextPC -= 2; + reg[15].I -= 2; + } + debugger = true; +} + +void MainWnd::OnUpdateToolsDebugBreak(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket != -1); +} + +void MainWnd::OnToolsDebugDisconnect() +{ + remoteCleanUp(); + debugger = false; +} + +void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption <= VIDEO_4X && remoteSocket != -1); +} + +void MainWnd::OnOptionsSoundStartrecording() +{ + theApp.winCheckFullscreen(); + CString captureBuffer; + + CString capdir = regQueryStringValue("soundRecordDir", NULL); + + if(capdir.IsEmpty()) + capdir = getDirFromFile(theApp.filename); + + CString filter = theApp.winLoadFilter(IDS_FILTER_WAV); + CString title = winResLoadString(IDS_SELECT_WAV_NAME); + + LPCTSTR exts[] = { ".WAV" }; + + FileDlg dlg(this, "", filter, 1, "WAV", exts, capdir, title, true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + captureBuffer = theApp.soundRecordName = dlg.GetPathName(); + theApp.soundRecording = true; + + if(dlg.m_ofn.nFileOffset > 0) { + captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset); + } + + int len = captureBuffer.GetLength(); + + if(len > 3 && captureBuffer[len-1] == '\\') + captureBuffer = captureBuffer.Left(len-1); + regSetStringValue("soundRecordDir", captureBuffer); +} + +void MainWnd::OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && !theApp.soundRecording); +} + +void MainWnd::OnOptionsSoundStoprecording() +{ + if(theApp.soundRecorder) { + delete theApp.soundRecorder; + theApp.soundRecorder = NULL; + } + theApp.soundRecording = false; +} + +void MainWnd::OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && theApp.soundRecording); +} + +void MainWnd::OnToolsRecordStartavirecording() +{ + theApp.winCheckFullscreen(); + CString captureBuffer; + + CString capdir = regQueryStringValue("aviRecordDir", NULL); + + if(capdir.IsEmpty()) + capdir = getDirFromFile(theApp.filename); + + CString filter = theApp.winLoadFilter(IDS_FILTER_AVI); + CString title = winResLoadString(IDS_SELECT_AVI_NAME); + + LPCTSTR exts[] = { ".AVI" }; + + FileDlg dlg(this, "", filter, 1, "AVI", exts, capdir, title, true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + captureBuffer = theApp.soundRecordName = dlg.GetPathName(); + theApp.aviRecordName = captureBuffer; + theApp.aviRecording = true; + +/// extern long linearFrameCount; linearFrameCount = 0; +/// extern long linearSoundByteCount; linearSoundByteCount = 0; + + if(dlg.m_ofn.nFileOffset > 0) { + captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset); + } + + int len = captureBuffer.GetLength(); + + if(len > 3 && captureBuffer[len-1] == '\\') + captureBuffer = captureBuffer.Left(len-1); + + regSetStringValue("aviRecordDir", captureBuffer); +} + +void MainWnd::OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && !theApp.aviRecording); +} + +void MainWnd::OnToolsRecordStopavirecording() +{ + if(theApp.aviRecorder != NULL) { + delete theApp.aviRecorder; + theApp.aviRecorder = NULL; + theApp.aviFrameNumber = 0; + } + theApp.aviRecording = false; +} + +void MainWnd::OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && theApp.aviRecording); +} + +void MainWnd::OnToolsRecordStartmovierecording() +{ + MovieCreate dlg; + dlg.DoModal(); +} + +void MainWnd::OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnToolsRecordStopmovierecording() +{ + VBAMovieStop(false); +} +void MainWnd::OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && VBAMovieGetState() == MOVIE_STATE_RECORD); +} + +void MainWnd::OnToolsPlayStartmovieplaying() +{ + MovieOpen dlg; + dlg.DoModal(); +} +void MainWnd::OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating); +} + +void MainWnd::OnToolsPlayStopmovieplaying() +{ + VBAMovieStop(false); +} +void MainWnd::OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(emulating && VBAMovieGetState() == MOVIE_STATE_PLAY); +} + +void MainWnd::OnToolsPlayReadOnly() +{ +// if(!VBAMovieActive()) +// systemScreenMessage("no movie active"); +// else + VBAMovieToggleReadOnly(); + theApp.movieReadOnly = VBAMovieActive() ? (VBAMovieReadOnly()?true:false) : !theApp.movieReadOnly; +} +void MainWnd::OnUpdateToolsPlayReadOnly(CCmdUI* pCmdUI) +{ +/// pCmdUI->Enable(VBAMovieActive()); // FIXME: this is right, but disabling menu items screws up accelerators until you view the menu! +/// pCmdUI->SetCheck(VBAMovieReadOnly()); + pCmdUI->Enable(TRUE); // TEMP + pCmdUI->SetCheck(VBAMovieActive() ? VBAMovieReadOnly() : theApp.movieReadOnly); // TEMP +} + +void MainWnd::OnToolsPlayContinue() +{ + VBAMovieSwitchToRecording(); +} +void MainWnd::OnUpdateToolsPlayContinue(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(!VBAMovieReadOnly() && VBAMovieGetState() == MOVIE_STATE_PLAY); +} + +void MainWnd::OnToolsPlayRestart() +{ + VBAMovieRestart(); +} +void MainWnd::OnUpdateToolsPlayRestart(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(VBAMovieActive()); +} + +#include "assert.h" +void MainWnd::OnToolsRewind() +{ + assert(theApp.rewindTimer > 0 && theApp.rewindSlots > 0); + if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && theApp.rewindCount) { + assert(theApp.rewindPos >= 0 && theApp.rewindPos < theApp.rewindSlots); + theApp.rewindPos = (--theApp.rewindPos + theApp.rewindSlots) % theApp.rewindSlots; + assert(theApp.rewindPos >= 0 && theApp.rewindPos < theApp.rewindSlots); + theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*theApp.rewindPos], REWIND_SIZE); + theApp.rewindCount--; + if(theApp.rewindCount > 0) + theApp.rewindCounter = 0; + else + { + theApp.rewindCounter = theApp.rewindTimer; + theApp.rewindSaveNeeded = true; + + // immediately save state to avoid eroding away the earliest you can rewind to + theApp.saveRewindStateIfNecessary(); + + theApp.rewindSaveNeeded = false; + } + } +} + +void MainWnd::OnUpdateToolsRewind(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && theApp.rewindCount); +} + +void MainWnd::OnToolsCustomize() +{ + AccelEditor dlg; + + if(dlg.DoModal()) { + theApp.winAccelMgr = dlg.mgr; + theApp.winAccelMgr.UpdateWndTable(); + theApp.winAccelMgr.Write(); + theApp.winAccelMgr.UpdateMenu(theApp.menu); + } +} + +void MainWnd::OnUpdateToolsCustomize(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} + + +void MainWnd::OnToolsCustomizeCommon() +{ + AccelEditor dlg; + dlg.m_commonOnly = true; + + if(dlg.DoModal()) { + theApp.winAccelMgr = dlg.mgr; + theApp.winAccelMgr.UpdateWndTable(); + theApp.winAccelMgr.Write(); + theApp.winAccelMgr.UpdateMenu(theApp.menu); + } +} + +void MainWnd::OnUpdateToolsCustomizeCommon(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(theApp.videoOption != VIDEO_320x240); +} diff --git a/src/win32/MapView.cpp b/src/win32/MapView.cpp new file mode 100644 index 0000000..92e7c72 --- /dev/null +++ b/src/win32/MapView.cpp @@ -0,0 +1,1026 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MapView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "MapView.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../NLS.h" +#include "../Util.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// MapView dialog + + +MapView::MapView(CWnd* pParent /*=NULL*/) + : ResizeDlg(MapView::IDD, pParent) +{ + //{{AFX_DATA_INIT(MapView) + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 1024; + bmpInfo.bmiHeader.biHeight = -1024; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 1024 * 1024); + + mapView.setData(data); + mapView.setBmpInfo(&bmpInfo); + + control = BG0CNT; + + bg = 0; + frame = 0; +} + +MapView::~MapView() +{ + free(data); + data = NULL; +} + +void MapView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MapView) + DDX_Control(pDX, IDC_NUMCOLORS, m_numcolors); + DDX_Control(pDX, IDC_MODE, m_mode); + DDX_Control(pDX, IDC_OVERFLOW, m_overflow); + DDX_Control(pDX, IDC_MOSAIC, m_mosaic); + DDX_Control(pDX, IDC_PRIORITY, m_priority); + DDX_Control(pDX, IDC_DIM, m_dim); + DDX_Control(pDX, IDC_CHARBASE, m_charbase); + DDX_Control(pDX, IDC_MAPBASE, m_mapbase); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_MAP_VIEW, mapView); + DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, mapViewZoom); + DDX_Control(pDX, IDC_COLOR, color); +} + + +BEGIN_MESSAGE_MAP(MapView, CDialog) + //{{AFX_MSG_MAP(MapView) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_FRAME_0, OnFrame0) + ON_BN_CLICKED(IDC_FRAME_1, OnFrame1) + ON_BN_CLICKED(IDC_BG0, OnBg0) + ON_BN_CLICKED(IDC_BG1, OnBg1) + ON_BN_CLICKED(IDC_BG2, OnBg2) + ON_BN_CLICKED(IDC_BG3, OnBg3) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_SAVE, OnSave) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// MapView message handlers + +void MapView::renderTextScreen(u16 control) +{ + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800]; + u8 *bmp = data; + + int sizeX = 256; + int sizeY = 256; + switch((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = 512; + break; + case 2: + sizeY = 512; + break; + case 3: + sizeX = 512; + sizeY = 512; + break; + } + + w = sizeX; + h = sizeY; + + if(control & 0x80) { + for(int y = 0; y < sizeY; y++) { + int yy = y & 255; + + if(y == 256 && sizeY > 256) { + screenBase += 0x400; + if(sizeX > 256) + screenBase += 0x400; + } + u16 *screenSource = screenBase + ((yy>>3)*32); + + for(int x = 0; x < sizeX; x++) { + u16 data = *screenSource; + + int tile = data & 0x3FF; + int tileX = (x & 7); + int tileY = y & 7; + + if(data & 0x0400) + tileX = 7 - tileX; + if(data & 0x0800) + tileY = 7 - tileY; + + u8 c = charBase[tile * 64 + tileY * 8 + tileX]; + + u16 color = palette[c]; + + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + + if(data & 0x0400) { + if(tileX == 0) + screenSource++; + } else if(tileX == 7) + screenSource++; + if(x == 255 && sizeX > 256) { + screenSource = screenBase + 0x400 + ((yy>>3)*32); + } + } + } + } else { + for(int y = 0; y < sizeY; y++) { + int yy = y & 255; + + if(y == 256 && sizeY > 256) { + screenBase += 0x400; + if(sizeX > 256) + screenBase += 0x400; + } + u16 *screenSource = screenBase + ((yy>>3)*32); + + for(int x = 0; x < sizeX; x++) { + u16 data = *screenSource; + + int tile = data & 0x3FF; + int tileX = (x & 7); + int tileY = y & 7; + + if(data & 0x0400) + tileX = 7 - tileX; + if(data & 0x0800) + tileY = 7 - tileY; + + u8 color = charBase[tile * 32 + tileY * 4 + (tileX>>1)]; + + if(tileX & 1) { + color = (color >> 4); + } else { + color &= 0x0F; + } + + int pal = (*screenSource>>8) & 0xF0; + u16 color2 = palette[pal + color]; + + *bmp++ = ((color2 >> 10) & 0x1f) << 3; + *bmp++ = ((color2 >> 5) & 0x1f) << 3; + *bmp++ = (color2 & 0x1f) << 3; + + if(data & 0x0400) { + if(tileX == 0) + screenSource++; + } else if(tileX == 7) + screenSource++; + + if(x == 255 && sizeX > 256) { + screenSource = screenBase + 0x400 + ((yy>>3)*32); + } + } + } + } + /* + switch(bg) { + case 0: + renderView(BG0HOFS<<8, BG0VOFS<<8, + 0x100, 0x000, + 0x000, 0x100, + (sizeX -1) <<8, + (sizeY -1) << 8, + true); + break; + case 1: + renderView(BG1HOFS<<8, BG1VOFS<<8, + 0x100, 0x000, + 0x000, 0x100, + (sizeX -1) <<8, + (sizeY -1) << 8, + true); + break; + case 2: + renderView(BG2HOFS<<8, BG2VOFS<<8, + 0x100, 0x000, + 0x000, 0x100, + (sizeX -1) <<8, + (sizeY -1) << 8, + true); + break; + case 3: + renderView(BG3HOFS<<8, BG3VOFS<<8, + 0x100, 0x000, + 0x000, 0x100, + (sizeX -1) <<8, + (sizeY -1) << 8, + true); + break; + } + */ +} + +void MapView::renderRotScreen(u16 control) +{ + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800]; + u8 *bmp = data; + + int sizeX = 128; + int sizeY = 128; + switch((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = sizeY = 256; + break; + case 2: + sizeX = sizeY = 512; + break; + case 3: + sizeX = sizeY = 1024; + break; + } + + w = sizeX; + h = sizeY; + + if(control & 0x80) { + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int tile = screenBase[(x>>3) + (y>>3)*(w>>3)]; + + int tileX = (x & 7); + int tileY = y & 7; + + u8 color = charBase[tile * 64 + tileY * 8 + tileX]; + u16 color2 = palette[color]; + + *bmp++ = ((color2 >> 10) & 0x1f) << 3; + *bmp++ = ((color2 >> 5) & 0x1f) << 3; + *bmp++ = (color2 & 0x1f) << 3; + } + } + } else { + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int tile = screenBase[(x>>3) + (y>>3)*(w>>3)]; + + int tileX = (x & 7); + int tileY = y & 7; + + u8 color = charBase[tile * 64 + tileY * 8 + tileX]; + u16 color2 = palette[color]; + + *bmp++ = ((color2 >> 10) & 0x1f) << 3; + *bmp++ = ((color2 >> 5) & 0x1f) << 3; + *bmp++ = (color2 & 0x1f) << 3; + } + } + } + + u32 xx; + u32 yy; + + switch(bg) { + case 2: + xx = BG2X_L | BG2X_H << 16; + yy = BG2Y_L | BG2Y_H << 16; + + /* + renderView(xx, yy, + BG2PA, BG2PC, + BG2PB, BG2PD, + (sizeX -1) <<8, + (sizeY -1) << 8, + (control & 0x2000) != 0); + */ + break; + case 3: + xx = BG3X_L | BG3X_H << 16; + yy = BG3Y_L | BG3Y_H << 16; + /* + renderView(xx, yy, + BG3PA, BG3PC, + BG3PB, BG3PD, + (sizeX -1) <<8, + (sizeY -1) << 8, + (control & 0x2000) != 0); + */ + break; + } +} + +void MapView::renderMode0() +{ + renderTextScreen(control); +} + +void MapView::renderMode1() +{ + switch(bg) { + case 0: + case 1: + renderTextScreen(control); + break; + case 2: + renderRotScreen(control); + break; + default: + bg = 0; + control = BG0CNT; + renderTextScreen(control); + break; + } +} + +void MapView::renderMode2() +{ + switch(bg) { + case 2: + case 3: + renderRotScreen(control); + break; + default: + bg = 2; + control = BG2CNT; + renderRotScreen(control); + break; + } +} + +void MapView::renderMode3() +{ + u8 *bmp = data; + u16 *src = (u16 *)&vram[0]; + + w = 240; + h = 160; + + for(int y = 0; y < 160; y++) { + for(int x = 0; x < 240; x++) { + u16 data = *src++; + *bmp++ = ((data >> 10) & 0x1f) << 3; + *bmp++ = ((data >> 5) & 0x1f) << 3; + *bmp++ = (data & 0x1f) << 3; + } + } + bg = 2; +} + + +void MapView::renderMode4() +{ + u8 *bmp = data; + u8 *src = frame ? &vram[0xa000] : &vram[0]; + u16 *pal = (u16 *)&paletteRAM[0]; + + w = 240; + h = 160; + + for(int y = 0; y < 160; y++) { + for(int x = 0; x < 240; x++) { + u8 c = *src++; + u16 data = pal[c]; + *bmp++ = ((data >> 10) & 0x1f) << 3; + *bmp++ = ((data >> 5) & 0x1f) << 3; + *bmp++ = (data & 0x1f) << 3; + } + } + bg = 2; +} + + +void MapView::renderMode5() +{ + u8 *bmp = data; + u16 *src = (u16 *)(frame ? &vram[0xa000] : &vram[0]); + + w = 160; + h = 128; + + for(int y = 0; y < 128; y++) { + for(int x = 0; x < 160; x++) { + u16 data = *src++; + *bmp++ = ((data >> 10) & 0x1f) << 3; + *bmp++ = ((data >> 5) & 0x1f) << 3; + *bmp++ = (data & 0x1f) << 3; + } + } + bg = 2; +} + +void MapView::OnRefresh() +{ + paint(); +} + +void MapView::paint() +{ + if(vram == NULL) + return; + int mode = DISPCNT & 7; + + switch(bg) { + default: + case 0: + control = BG0CNT; + break; + case 1: + control = BG1CNT; + break; + case 2: + control = BG2CNT; + break; + case 3: + control = BG3CNT; + break; + } + + switch(mode) { + case 0: + renderMode0(); + break; + case 1: + renderMode1(); + break; + case 2: + renderMode2(); + break; + case 3: + renderMode3(); + break; + case 4: + renderMode4(); + break; + case 5: + renderMode5(); + break; + } + enableButtons(mode); + SIZE s; + + if(mapView.getStretch()) { + mapView.setSize(w, h); + s.cx = s.cy = 1; + mapView.SetScrollSizes(MM_TEXT, s); + } else { + mapView.setSize(w, h); + s.cx = w; + s.cy = h; + mapView.SetScrollSizes(MM_TEXT, s); + } + + mapView.refresh(); + + CString buffer; + + u32 charBase = ((control >> 2) & 0x03) * 0x4000 + 0x6000000; + u32 screenBase = ((control >> 8) & 0x1f) * 0x800 + 0x6000000; + + buffer.Format("%d", mode); + m_mode.SetWindowText(buffer); + + if(mode >= 3) { + m_mapbase.SetWindowText(""); + m_charbase.SetWindowText(""); + } else { + buffer.Format("0x%08X", screenBase); + m_mapbase.SetWindowText(buffer); + + buffer.Format("0x%08X", charBase); + m_charbase.SetWindowText(buffer); + } + + buffer.Format("%dx%d", w, h); + m_dim.SetWindowText(buffer); + + m_numcolors.SetWindowText(control & 0x80 ? "256" : "16"); + + buffer.Format("%d", control & 3); + m_priority.SetWindowText(buffer); + + m_mosaic.SetWindowText(control & 0x40 ? "1" : "0"); + + m_overflow.SetWindowText(bg <= 1 ? "" : + control & 0x2000 ? "1" : "0"); +} + +BOOL MapView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_MAP_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\MapView", + NULL); + SIZE size; + size.cx = 1; + size.cy = 1; + mapView.SetScrollSizes(MM_TEXT,size); + int s = regQueryDwordValue("mapViewStretch", 0); + if(s) + mapView.setStretch(true); + ((CButton *)GetDlgItem(IDC_STRETCH))->SetCheck(s); + paint(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MapView::PostNcDestroy() +{ + delete this; +} + +void MapView::enableButtons(int mode) +{ + bool enable[6] = { true, true, true, true, true, true }; + + switch(mode) { + case 0: + enable[4] = false; + enable[5] = false; + break; + case 1: + enable[3] = false; + enable[4] = false; + enable[5] = false; + break; + case 2: + enable[0] = false; + enable[1] = false; + enable[4] = false; + enable[5] = false; + break; + case 3: + enable[0] = false; + enable[1] = false; + enable[2] = false; + enable[3] = false; + enable[4] = false; + enable[5] = false; + break; + case 4: + enable[0] = false; + enable[1] = false; + enable[2] = false; + enable[3] = false; + break; + case 5: + enable[0] = false; + enable[1] = false; + enable[2] = false; + enable[3] = false; + break; + } + GetDlgItem(IDC_BG0)->EnableWindow(enable[0]); + GetDlgItem(IDC_BG1)->EnableWindow(enable[1]); + GetDlgItem(IDC_BG2)->EnableWindow(enable[2]); + GetDlgItem(IDC_BG3)->EnableWindow(enable[3]); + GetDlgItem(IDC_FRAME_0)->EnableWindow(enable[4]); + GetDlgItem(IDC_FRAME_1)->EnableWindow(enable[5]); + int id = IDC_BG0; + switch(bg) { + case 1: + id = IDC_BG1; + break; + case 2: + id = IDC_BG2; + break; + case 3: + id = IDC_BG3; + break; + } + CheckRadioButton(IDC_BG0, IDC_BG3, id); + id = IDC_FRAME_0; + if(frame != 0) + id = IDC_FRAME_1; + CheckRadioButton(IDC_FRAME_0, IDC_FRAME_1, id); +} + +void MapView::OnFrame0() +{ + frame = 0; + paint(); +} + +void MapView::OnFrame1() +{ + frame = 1; + paint(); +} + +void MapView::OnBg0() +{ + bg = 0; + control = BG0CNT; + paint(); +} + +void MapView::OnBg1() +{ + bg = 1; + control = BG1CNT; + paint(); +} + +void MapView::OnBg2() +{ + bg = 2; + control = BG2CNT; + paint(); +} + +void MapView::OnBg3() +{ + bg = 3; + control = BG3CNT; + paint(); +} + +void MapView::OnStretch() +{ + mapView.setStretch(!mapView.getStretch()); + paint(); + regSetDwordValue("mapViewStretch", mapView.getStretch()); +} + +void MapView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void MapView::update() +{ + paint(); +} + +void MapView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +u32 MapView::GetTextClickAddress(u32 base, int x, int y) +{ + if(y > 255 && h > 256) { + base += 0x800; + if(w > 256) + base += 0x800; + } + if(x >= 256) + base += 0x800; + x &= 255; + y &= 255; + base += (x>>3)*2 + 64*(y>>3); + + return base; +} + + + +u32 MapView::GetClickAddress(int x, int y) +{ + int mode = DISPCNT & 7; + + u32 base = ((control >> 8) & 0x1f) * 0x800 + 0x6000000; + + // all text bgs (16 bits) + if(mode == 0 ||(mode < 3 && bg < 2)) { + return GetTextClickAddress(base, x, y); + } + // rot bgs (8 bits) + if(mode < 3) { + return base + (x>>3) + (w>>3)*(y>>3); + } + // mode 3/5 (16 bits) + if(mode != 4) { + return 0x6000000 + 0xa000*frame + 2*x + w*y*2; + } + // mode 4 (8 bits) + return 0x6000000 + 0xa000*frame + x + w*y; +} + +LRESULT MapView::OnMapInfo(WPARAM wParam, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + mapViewZoom.setColors(colors); + + int x = wParam & 0xffff; + int y = (wParam >> 16); + + CString buffer; + buffer.Format("(%d,%d)", x, y); + GetDlgItem(IDC_XY)->SetWindowText(buffer); + + u32 address = GetClickAddress(x,y); + buffer.Format("0x%08X", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + int mode = DISPCNT & 7; + if(mode >= 3) { + // bitmap modes + GetDlgItem(IDC_TILE_NUM)->SetWindowText("---"); + GetDlgItem(IDC_FLIP)->SetWindowText("--"); + GetDlgItem(IDC_PALETTE_NUM)->SetWindowText("---"); + } else if(mode == 0 || bg < 2) { + // text bgs + u16 value = *((u16 *)&vram[address - 0x6000000]); + + int tile = value & 1023; + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE_NUM)->SetWindowText(buffer); + buffer.Empty(); + buffer += value & 1024 ? 'H' : '-'; + buffer += value & 2048 ? 'V' : '-'; + GetDlgItem(IDC_FLIP)->SetWindowText(buffer); + + if(!(control & 0x80)) { + buffer.Format("%d", (value >> 12) & 15); + } else + buffer = "---"; + GetDlgItem(IDC_PALETTE_NUM)->SetWindowText(buffer); + } else { + // rot bgs + GetDlgItem(IDC_TILE_NUM)->SetWindowText("---"); + GetDlgItem(IDC_FLIP)->SetWindowText("--"); + GetDlgItem(IDC_PALETTE_NUM)->SetWindowText("---"); + } + + return TRUE; +} + +LRESULT MapView::OnColInfo(WPARAM wParam, LPARAM lParam) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + +void MapView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + + +void MapView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + +void MapView::OnSave() +{ + CString filename; + + if(theApp.captureFormat == 0) + filename = "map.png"; + else + filename = "map.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + filename, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + if(dlg.getFilterIndex() == 2) + saveBMP(dlg.GetPathName()); + else + savePNG(dlg.GetPathName()); +} diff --git a/src/win32/MapView.h b/src/win32/MapView.h new file mode 100644 index 0000000..db0a575 --- /dev/null +++ b/src/win32/MapView.h @@ -0,0 +1,122 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_) +#define AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MapView.h : header file +// + +#include "BitmapControl.h" +#include "ColorControl.h" +#include "ZoomControl.h" +#include "ResizeDlg.h" +#include "IUpdate.h" +#include "..\System.h" // Added by ClassView + +///////////////////////////////////////////////////////////////////////////// +// MapView dialog + +class MapView : public ResizeDlg, IUpdateListener +{ + private: + BITMAPINFO bmpInfo; + u8 *data; + int frame; + u16 control; + int bg; + int w; + int h; + BitmapControl mapView; + ZoomControl mapViewZoom; + ColorControl color; + bool autoUpdate; + + // Construction + public: + void savePNG(const char *name); + void saveBMP(const char *name); + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + u32 GetClickAddress(int x, int y); + u32 GetTextClickAddress(u32 base, int x, int y); + void update(); + void enableButtons(int mode); + void paint(); + void renderMode5(); + void renderMode4(); + void renderMode3(); + void renderMode2(); + void renderMode1(); + void renderMode0(); + void renderRotScreen(u16 control); + void renderTextScreen(u16 control); + MapView(CWnd* pParent = NULL); // standard constructor + ~MapView(); + + // Dialog Data + //{{AFX_DATA(MapView) + enum { IDD = IDD_MAP_VIEW }; + CStatic m_numcolors; + CStatic m_mode; + CStatic m_overflow; + CStatic m_mosaic; + CStatic m_priority; + CStatic m_dim; + CStatic m_charbase; + CStatic m_mapbase; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MapView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(MapView) + afx_msg void OnRefresh(); + virtual BOOL OnInitDialog(); + afx_msg void OnFrame0(); + afx_msg void OnFrame1(); + afx_msg void OnBg0(); + afx_msg void OnBg1(); + afx_msg void OnBg2(); + afx_msg void OnBg3(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + afx_msg void OnSave(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_) diff --git a/src/win32/MaxScale.cpp b/src/win32/MaxScale.cpp new file mode 100644 index 0000000..2daf5d7 --- /dev/null +++ b/src/win32/MaxScale.cpp @@ -0,0 +1,89 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MaxScale.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "MaxScale.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// MaxScale dialog + + +MaxScale::MaxScale(CWnd* pParent /*=NULL*/) + : CDialog(MaxScale::IDD, pParent) +{ + //{{AFX_DATA_INIT(MaxScale) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void MaxScale::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MaxScale) + DDX_Control(pDX, IDC_VALUE, m_value); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(MaxScale, CDialog) + //{{AFX_MSG_MAP(MaxScale) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// MaxScale message handlers + +void MaxScale::OnCancel() +{ + EndDialog(FALSE); +} + +void MaxScale::OnOk() +{ + CString tmp; + m_value.GetWindowText(tmp); + theApp.fsMaxScale = atoi(tmp); + EndDialog(TRUE); +} + +BOOL MaxScale::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString temp; + + temp.Format("%d", theApp.fsMaxScale); + + m_value.SetWindowText(temp); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/MaxScale.h b/src/win32/MaxScale.h new file mode 100644 index 0000000..2ad3d45 --- /dev/null +++ b/src/win32/MaxScale.h @@ -0,0 +1,67 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_) +#define AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MaxScale.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// MaxScale dialog + +class MaxScale : public CDialog +{ +// Construction +public: + MaxScale(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(MaxScale) + enum { IDD = IDD_MAX_SCALE }; + CEdit m_value; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MaxScale) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(MaxScale) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAXSCALE_H__3F42C0CC_DD5E_4A96_A60D_33AB7CBDE406__INCLUDED_) diff --git a/src/win32/MemoryViewer.cpp b/src/win32/MemoryViewer.cpp new file mode 100644 index 0000000..f747c3f --- /dev/null +++ b/src/win32/MemoryViewer.cpp @@ -0,0 +1,653 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MemoryViewer.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "MemoryViewer.h" + +#include "../System.h" +extern int emulating; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewer + +bool MemoryViewer::isRegistered = false; + +MemoryViewer::MemoryViewer() +{ + address = 0; + addressSize = 0; + dataSize = 0; + editAddress = 0; + editNibble = 0; + displayedLines = 0; + hasCaret = false; + maxNibble = 0; + font = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); + fontSize.cx = fontSize.cy = 0; + beginAscii = 0; + beginHex = 0; + dlg = NULL; + registerClass(); +} + +MemoryViewer::~MemoryViewer() +{ +} + + +BEGIN_MESSAGE_MAP(MemoryViewer, CWnd) + //{{AFX_MSG_MAP(MemoryViewer) + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_WM_VSCROLL() + ON_WM_GETDLGCODE() + ON_WM_LBUTTONDOWN() + ON_WM_SETFOCUS() + ON_WM_KILLFOCUS() + ON_WM_KEYDOWN() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_CHAR, OnWMChar) + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// MemoryViewer message handlers + +void MemoryViewer::setDialog(IMemoryViewerDlg *d) +{ + dlg = d; +} + + +void MemoryViewer::setAddress(u32 a) +{ + address = a; + if(displayedLines) { + if(addressSize) { + u16 addr = address; + if((u16)(addr+(displayedLines<<4)) < addr) { + address = 0xffff - (displayedLines<<4) + 1; + } + } else { + if((address+(displayedLines<<4)) < address) { + address = 0xffffffff - (displayedLines<<4) + 1; + } + } + } + if(addressSize) + address &= 0xffff; + setCaretPos(); + InvalidateRect(NULL, TRUE); +} + + +void MemoryViewer::setSize(int s) +{ + dataSize = s; + if(s == 0) + maxNibble = 1; + else if(s == 1) + maxNibble = 3; + else + maxNibble = 7; + + InvalidateRect(NULL, TRUE); +} + +void MemoryViewer::setDecimal(bool decimalDisplayMode) +{ + decimalDisplay = decimalDisplayMode; + InvalidateRect(NULL, TRUE); +} + + +BOOL MemoryViewer::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + +void MemoryViewer::updateScrollInfo(int lines) +{ + int page = lines * 16; + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS; + si.nMin = 0; + if(addressSize) { + si.nMax = 0x10000/page; + si.nPage = 1; + } else { + si.nMax = 0xa000000 / page; + si.nPage = page; + } + + si.nPos = address / page; + SetScrollInfo(SB_VERT, + &si, + TRUE); +} + +void MemoryViewer::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + RECT rect; + GetClientRect(&rect); + int w = rect.right - rect.left; + int h = rect.bottom - rect.top - 6; + + CDC memDC; + memDC.CreateCompatibleDC(&dc); + CBitmap bitmap, *pOldBitmap; + bitmap.CreateCompatibleBitmap(&dc, w, rect.bottom - rect.top); + pOldBitmap = memDC.SelectObject(&bitmap); + + memDC.FillRect(&rect, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH))); + memDC.DrawEdge(&rect, EDGE_ETCHED, BF_RECT); + + CFont *oldFont = memDC.SelectObject(CFont::FromHandle(font)); + + fontSize = memDC.GetTextExtent("0", 1); + + int lines = h / fontSize.cy; + + displayedLines = lines; + + updateScrollInfo(lines); + + u32 addr = address; + + memDC.SetTextColor(RGB(0,0,0)); + + u8 data[32]; + + RECT r; + r.top = 3; + r.left = 3; + r.bottom = r.top+fontSize.cy; + r.right = rect.right-3; + + int line = 0; + + for(int i = 0; i < lines; i++) { + CString buffer; + if(addressSize) + buffer.Format("%04X", addr); + else + buffer.Format("%08X", addr); + memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left += 10*fontSize.cx; + beginHex = r.left; + readData(addr, 16, data); + + int j; + + if(dataSize == 0) { + for(j = 0; j < 16; j++) { + const int nextRLeft = r.left + 3*fontSize.cx; + if(!decimalDisplay) + buffer.Format("%02X", data[j]); + else + { + const signed char num = data[j]; + if(num < -9 || num > 99) r.left -= fontSize.cx; + if(num >= -99 && num <= 99) buffer.Format("%2d", num); + else buffer.Format(""); + } + memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left = nextRLeft; + } + } + if(dataSize == 1) { + for(j = 0; j < 16; j += 2) { + const int nextRLeft = r.left + 5*fontSize.cx; + if(!decimalDisplay) + buffer.Format("%04X", data[j] | data[j+1]<<8); + else + { + const signed short num = data[j] | data[j+1]<<8; + if(num < -999 || num > 9999) r.left -= fontSize.cx; + if(num >= -9999 && num <= 9999) buffer.Format("%4d", num); + else buffer.Format(""); + } + memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left = nextRLeft; + } + } + if(dataSize == 2) { + for(j = 0; j < 16; j += 4) { + if(!decimalDisplay) + buffer.Format("%08X", data[j] | data[j+1]<<8 | data[j+2] << 16 | data[j+3] << 24); + else + { + const signed long num = data[j] | data[j+1]<<8 | data[j+2] << 16 | data[j+3] << 24; + if(num >= -9999999 && num <= 99999999) buffer.Format("%8d", num); + else buffer.Format(""); + } + memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left += 9*fontSize.cx; + } + } + + line = r.left; + + r.left += fontSize.cx; + beginAscii = r.left; + buffer.Empty(); + for(j = 0; j < 16; j++) { + char c = data[j]; + if(c >= 32 && c <= 127) { + buffer += c; + } else + buffer += '.'; + } + + memDC.DrawText(buffer, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + addr += 16; + if(addressSize) + addr &= 0xffff; + r.top += fontSize.cy; + r.bottom += fontSize.cy; + r.left = 3; + } + CPen pen; + pen.CreatePen(PS_SOLID, 1, RGB(0,0,0)); + CPen *old = memDC.SelectObject(&pen); + + memDC.MoveTo(3+fontSize.cx*9, 3); + memDC.LineTo(3+fontSize.cx*9, 3+displayedLines*fontSize.cy); + + memDC.MoveTo(line, 3); + memDC.LineTo(line, 3+displayedLines*fontSize.cy); + + memDC.SelectObject(old); + pen.DeleteObject(); + + memDC.SelectObject(oldFont); + + dc.BitBlt(0, 0, w, rect.bottom - rect.top, &memDC, 0, 0, SRCCOPY); + + memDC.SelectObject(pOldBitmap); + memDC.DeleteDC(); + bitmap.DeleteObject(); +} + +void MemoryViewer::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + int address = this->address; + switch(nSBCode) { + case SB_BOTTOM: + address = 0xffffff00; + break; + case SB_LINEDOWN: + address += 0x10; + break; + case SB_LINEUP: + address -= 0x10; + break; + case SB_PAGEDOWN: + address += (displayedLines<<4); + break; + case SB_PAGEUP: + address -= (displayedLines<<4); + break; + case SB_TOP: + address = 0; + break; + case SB_THUMBTRACK: + { + int page = displayedLines * 16; + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_TRACKPOS; + GetScrollInfo(SB_VERT, &si); + address = page * si.nTrackPos; + } + break; + } + setAddress(address); +} + +UINT MemoryViewer::OnGetDlgCode() +{ + return DLGC_WANTALLKEYS; +} + +void MemoryViewer::createEditCaret(int w, int h) +{ + if(!hasCaret || caretWidth != w || caretHeight != h) { + hasCaret = true; + caretWidth = w; + caretHeight = h; + ::CreateCaret(m_hWnd, (HBITMAP)0, w, h); + } +} + + +void MemoryViewer::destroyEditCaret() +{ + hasCaret = false; + DestroyCaret(); +} + +void MemoryViewer::setCaretPos() +{ + if(GetFocus() != this) { + destroyEditCaret(); + return; + } + + if(dlg) + dlg->setCurrentAddress(editAddress); + + if(editAddress < address || editAddress > (address -1 + (displayedLines<<4))) { + destroyEditCaret(); + return; + } + + int subAddress = (editAddress - address); + + int x = 3+10*fontSize.cx+editNibble*fontSize.cx; + int y = 3+fontSize.cy*((editAddress-address)>>4); + + if(editAscii) { + x = beginAscii + fontSize.cx*(subAddress&15); + } else { + switch(dataSize) { + case 0: + x += 3*fontSize.cx*(subAddress & 15); + break; + case 1: + x += 5*fontSize.cx*((subAddress>>1) & 7); + break; + case 2: + x += 9*fontSize.cx*((subAddress>>2) & 3); + break; + } + } + + RECT r; + GetClientRect(&r); + r.right -= 3; + if(x >= r.right) { + destroyEditCaret(); + return; + } + int w = fontSize.cx; + if((x+fontSize.cx)>=r.right) + w = r.right - x; + createEditCaret(w, fontSize.cy); + ::SetCaretPos(x, y); + ShowCaret(); +} + +void MemoryViewer::OnLButtonDown(UINT nFlags, CPoint point) +{ + int x = point.x; + int y = point.y; + int line = (y-3)/fontSize.cy; + int beforeAscii = beginHex; + int inc = 1; + int sub = 3*fontSize.cx; + switch(dataSize) { + case 0: + beforeAscii += 47*fontSize.cx; + break; + case 1: + beforeAscii += 39*fontSize.cx; + inc = 2; + sub = 5*fontSize.cx; + break; + case 2: + beforeAscii += 35*fontSize.cx; + inc = 4; + sub = 9*fontSize.cx; + break; + } + + editAddress = address + (line<<4); + if(x >= beginHex && x < beforeAscii) { + x -= beginHex; + editNibble = 0; + while(x > 0) { + x -= sub; + if(x >= 0) + editAddress += inc; + else { + editNibble = (x + sub)/fontSize.cx; + } + } + editAscii = false; + } else if(x >= beginAscii) { + int afterAscii = beginAscii+16*fontSize.cx; + if(x >= afterAscii) + x = afterAscii-1; + editAddress += (x-beginAscii)/fontSize.cx; + editNibble = 0; + editAscii = true; + } else { + return; + } + + if(editNibble > maxNibble) + editNibble = maxNibble; + SetFocus(); + setCaretPos(); +} + +void MemoryViewer::OnSetFocus(CWnd* pOldWnd) +{ + setCaretPos(); + InvalidateRect(NULL, TRUE); +} + +void MemoryViewer::OnKillFocus(CWnd* pNewWnd) +{ + destroyEditCaret(); + InvalidateRect(NULL, TRUE); +} + +void MemoryViewer::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + bool isShift = (GetKeyState(VK_SHIFT) & 0x80000000) == 0x80000000; + + switch(nChar) { + case VK_RIGHT: + if(editAscii) + moveAddress(1,0); + else if(isShift) + moveAddress((maxNibble+1)>>1,0); + else + moveAddress(0, 1); + break; + case VK_LEFT: + if(editAscii) + moveAddress(-1, 0); + else if(isShift) + moveAddress(-((maxNibble+1)>>1),0); + else + moveAddress(0, -1); + break; + case VK_DOWN: + moveAddress(16, 0); + break; + case VK_UP: + moveAddress(-16, 0); + break; + case VK_TAB: + GetNextDlgTabItem(GetParent(), isShift)->SetFocus(); + break; + } +} + +void MemoryViewer::moveAddress(s32 offset, int nibbleOff) +{ + if(offset == 0) { + if(nibbleOff == -1) { + editNibble--; + if(editNibble == -1) { + editAddress -= (maxNibble + 1) >> 1; + editNibble = maxNibble; + } + if(address == 0 && (editAddress >= (u32)(displayedLines<<4))) { + editAddress = 0; + editNibble = 0; + beep(); + } + if(editAddress < address) + setAddress(address - 16); + } else { + editNibble++; + if(editNibble > maxNibble) { + editNibble = 0; + editAddress += (maxNibble + 1) >> 1; + } + if(editAddress < address) { + editAddress -= (maxNibble + 1) >> 1; + editNibble = maxNibble; + beep(); + } + if(editAddress >= (address+(displayedLines<<4))) + setAddress(address+16); + } + } else { + editAddress += offset; + if(offset < 0 && editAddress > (address-1+(displayedLines<<4))) { + editAddress -= offset; + beep(); + return; + } + if(offset > 0 && (editAddress < address)) { + editAddress -= offset; + beep(); + return; + } + if(editAddress < address) { + if(offset & 15) + setAddress((address+offset-16) & ~15); + else + setAddress(address+offset); + } else if(editAddress > (address - 1 + (displayedLines<<4))) { + if(offset & 15) + setAddress((address+offset+16) & ~15); + else + setAddress(address+offset); + } + } + + setCaretPos(); +} + +LRESULT MemoryViewer::OnWMChar(WPARAM wParam, LPARAM LPARAM) +{ + if(OnEditInput(wParam)) + return 0; + return 1; +} + +bool MemoryViewer::OnEditInput(UINT c) +{ + if(c > 255 || !emulating) { + beep(); + return false; + } + + if(!editAscii) + c = tolower(c); + + u32 value = 256; + + if(c >= 'a' && c <= 'f') + value = 10 + (c - 'a'); + else if(c >= '0' && c <= '9') + value = (c - '0'); + if(editAscii) { + editData(editAddress, 8, 0, c); + moveAddress(1, 0); + InvalidateRect(NULL, TRUE); + } else { + if(value != 256) { + value <<= 4*(maxNibble-editNibble); + u32 mask = ~(15 << 4*(maxNibble - editNibble)); + switch(dataSize) { + case 0: + editData(editAddress, 8, mask, value); + break; + case 1: + editData(editAddress, 16, mask, value); + break; + case 2: + editData(editAddress, 32, mask, value); + break; + } + moveAddress(0, 1); + InvalidateRect(NULL, TRUE); + } + } + return true; +} + +void MemoryViewer::beep() +{ + MessageBeep((UINT)-1); +} + +void MemoryViewer::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_PARENTDC | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH )GetStockObject(WHITE_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaMemoryViewer"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} + +void MemoryViewer::setAddressSize(int s) +{ + addressSize = s; +} + + +u32 MemoryViewer::getCurrentAddress() +{ + return editAddress; +} + +int MemoryViewer::getSize() +{ + return dataSize; +} diff --git a/src/win32/MemoryViewer.h b/src/win32/MemoryViewer.h new file mode 100644 index 0000000..0a6933a --- /dev/null +++ b/src/win32/MemoryViewer.h @@ -0,0 +1,116 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_) +#define AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MemoryViewer.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewer window + +class IMemoryViewerDlg { + public: + virtual void setCurrentAddress(u32 address)=0; +}; + +class MemoryViewer : public CWnd +{ + u32 address; + int addressSize; + int dataSize; + bool hasCaret; + int caretWidth; + int caretHeight; + HFONT font; + CSize fontSize; + u32 editAddress; + int editNibble; + int maxNibble; + int displayedLines; + int beginAscii; + int beginHex; + bool editAscii; + bool decimalDisplay; + IMemoryViewerDlg *dlg; + + static bool isRegistered; + // Construction + public: + MemoryViewer(); + + // Attributes + public: + + // Operations + public: + virtual void readData(u32,int,u8 *) = 0; + virtual void editData(u32,int,int,u32)=0; + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewer) + //}}AFX_VIRTUAL + + // Implementation + public: + int getSize(); + u32 getCurrentAddress(); + void setAddressSize(int s); + void registerClass(); + void beep(); + bool OnEditInput(UINT c); + void moveAddress(s32 offset, int nibbleOff); + void setCaretPos(); + void destroyEditCaret(); + void createEditCaret(int w, int h); + void updateScrollInfo(int lines); + void setSize(int s); + void setDecimal(bool decimalDisplayMode); + void setAddress(u32 a); + void setDialog(IMemoryViewerDlg *d); + virtual ~MemoryViewer(); + + // Generated message map functions + protected: + //{{AFX_MSG(MemoryViewer) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg UINT OnGetDlgCode(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + afx_msg LRESULT OnWMChar(WPARAM wParam, LPARAM lParam); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_) diff --git a/src/win32/MemoryViewerAddressSize.cpp b/src/win32/MemoryViewerAddressSize.cpp new file mode 100644 index 0000000..78b0056 --- /dev/null +++ b/src/win32/MemoryViewerAddressSize.cpp @@ -0,0 +1,137 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MemoryViewerAddressSize.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "MemoryViewerAddressSize.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewerAddressSize dialog + + +MemoryViewerAddressSize::MemoryViewerAddressSize(u32 a, int s, CWnd* pParent /*=NULL*/) + : CDialog(MemoryViewerAddressSize::IDD, pParent) +{ + //{{AFX_DATA_INIT(MemoryViewerAddressSize) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + address = a; + size = s; +} + + +void MemoryViewerAddressSize::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MemoryViewerAddressSize) + DDX_Control(pDX, IDC_SIZE_CONTROL, m_size); + DDX_Control(pDX, IDC_ADDRESS, m_address); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(MemoryViewerAddressSize, CDialog) + //{{AFX_MSG_MAP(MemoryViewerAddressSize) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// MemoryViewerAddressSize message handlers + +BOOL MemoryViewerAddressSize::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CString buffer; + if(address != 0xFFFFFFFF) { + buffer.Format("%08X", address); + m_address.SetWindowText(buffer); + } + if(size != -1) { + buffer.Format("%08X", size); + m_size.SetWindowText(buffer); + m_size.EnableWindow(FALSE); + } + + if(size == -1 && address != 0xFFFFFFFF) + m_size.SetFocus(); + + m_address.LimitText(9); + m_size.LimitText(9); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MemoryViewerAddressSize::OnOk() +{ + CString buffer; + + m_address.GetWindowText(buffer); + if(buffer.IsEmpty()) { + m_address.SetFocus(); + return; + } + sscanf(buffer, "%x", &address); + + m_size.GetWindowText(buffer); + if(buffer.IsEmpty()) { + m_size.SetFocus(); + return; + } + sscanf(buffer, "%x", &size); + EndDialog(TRUE); +} + +void MemoryViewerAddressSize::OnCancel() +{ + EndDialog(FALSE); +} + +void MemoryViewerAddressSize::setAddress(u32 a) +{ + address = a; +} + +void MemoryViewerAddressSize::setSize(int s) +{ + size = s; +} + + +u32 MemoryViewerAddressSize::getAddress() +{ + return address; +} +\ + +int MemoryViewerAddressSize::getSize() +{ + return size; +} diff --git a/src/win32/MemoryViewerAddressSize.h b/src/win32/MemoryViewerAddressSize.h new file mode 100644 index 0000000..71d3b5e --- /dev/null +++ b/src/win32/MemoryViewerAddressSize.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_) +#define AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MemoryViewerAddressSize.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewerAddressSize dialog + +class MemoryViewerAddressSize : public CDialog +{ + u32 address; + int size; + // Construction + public: + int getSize(); + u32 getAddress(); + void setSize(int s); + void setAddress(u32 a); + MemoryViewerAddressSize(u32 a=0xffffff, int s=-1, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(MemoryViewerAddressSize) + enum { IDD = IDD_ADDR_SIZE }; + CEdit m_size; + CEdit m_address; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewerAddressSize) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(MemoryViewerAddressSize) + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void OnCancel(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_) diff --git a/src/win32/MemoryViewerDlg.cpp b/src/win32/MemoryViewerDlg.cpp new file mode 100644 index 0000000..57ccf24 --- /dev/null +++ b/src/win32/MemoryViewerDlg.cpp @@ -0,0 +1,447 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// MemoryViewerDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "MemoryViewerAddressSize.h" +#include "MemoryViewerDlg.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern int emulating; + +#define CPUReadByteQuick(addr) \ + ::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask] +#define CPUWriteByteQuick(addr, b) \ + ::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask] = (b) +#define CPUReadHalfWordQuick(addr) \ + *((u16 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) +#define CPUWriteHalfWordQuick(addr, b) \ + *((u16 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) = (b) +#define CPUReadMemoryQuick(addr) \ + *((u32 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) +#define CPUWriteMemoryQuick(addr, b) \ + *((u32 *)&::map[(addr)>>24].address[(addr) & ::map[(addr)>>24].mask]) = (b) + +///////////////////////////////////////////////////////////////////////////// +// GBAMemoryViewer control + + +GBAMemoryViewer::GBAMemoryViewer() + : MemoryViewer() +{ + setAddressSize(0); +} + +void GBAMemoryViewer::readData(u32 address, int len, u8 *data) +{ + if(emulating && rom != NULL) { + for(int i = 0; i < len; i++) { + *data++ = CPUReadByteQuick(address); + address++; + } + } else { + for(int i = 0; i < len; i++) { + *data++ = 0; + address++; + } + } +} + +void GBAMemoryViewer::editData(u32 address, int size, int mask, u32 value) +{ + u32 oldValue; + + switch(size) { + case 8: + oldValue = (CPUReadByteQuick(address) & mask) | value; + CPUWriteByteQuick(address, oldValue); + break; + case 16: + oldValue = (CPUReadHalfWordQuick(address) & mask) | value; + CPUWriteHalfWordQuick(address, oldValue); + break; + case 32: + oldValue = (CPUReadMemoryQuick(address) & mask) | value; + CPUWriteMemoryQuick(address, oldValue); + break; + } +} + + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewerDlg dialog + + +MemoryViewerDlg::MemoryViewerDlg(CWnd* pParent /*=NULL*/) + : ResizeDlg(MemoryViewerDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(MemoryViewerDlg) + m_size = -1; + //}}AFX_DATA_INIT + autoUpdate = false; + + autoUpdate = !regQueryDwordValue("memViewerAutoUpdate", 1); + OnAutoUpdate(); // FIXME: how to make this actually change the check mark? GetDlgItem(IDC_AUTO_UPDATE) returns NULL. + + decimalDisplay = !regQueryDwordValue("memViewerDecimalDisplay", 0); + OnDecimalDisplay(); // FIXME: how to make this actually change the check mark? GetDlgItem(IDC_DECIMAL_DISPLAY) returns NULL. +} + + +void MemoryViewerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MemoryViewerDlg) + DDX_Control(pDX, IDC_CURRENT_ADDRESS, m_current); + DDX_Control(pDX, IDC_ADDRESS, m_address); + DDX_Control(pDX, IDC_ADDRESSES, m_addresses); + DDX_Check(pDX, IDC_AUTO_UPDATE, autoUpdate); + DDX_Check(pDX, IDC_DECIMALDISPLAY, decimalDisplay); + DDX_Radio(pDX, IDC_8_BIT, m_size); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_VIEWER, m_viewer); +} + + +BEGIN_MESSAGE_MAP(MemoryViewerDlg, CDialog) + //{{AFX_MSG_MAP(MemoryViewerDlg) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_REFRESH, OnRefresh) + ON_BN_CLICKED(IDC_8_BIT, On8Bit) + ON_BN_CLICKED(IDC_16_BIT, On16Bit) + ON_BN_CLICKED(IDC_32_BIT, On32Bit) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_DECIMALDISPLAY, OnDecimalDisplay) + ON_BN_CLICKED(IDC_GO, OnGo) + ON_CBN_SELCHANGE(IDC_ADDRESSES, OnSelchangeAddresses) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_LOAD, OnLoad) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// MemoryViewerDlg message handlers + +BOOL MemoryViewerDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_VIEWER, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_LOAD, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_AUTO_UPDATE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_DECIMALDISPLAY, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CURRENT_ADDRESS_LABEL, DS_MoveY | DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_CURRENT_ADDRESS, DS_MoveY | DS_MoveX) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\MemoryView", + NULL); + + m_viewer.setDialog(this); + m_viewer.ShowScrollBar(SB_VERT, TRUE); + m_viewer.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); + + LPCTSTR s[] = { + "0x00000000 - BIOS", + "0x02000000 - WRAM", + "0x03000000 - IRAM", + "0x04000000 - I/O", + "0x05000000 - PALETTE", + "0x06000000 - VRAM", + "0x07000000 - OAM", + "0x08000000 - ROM" + }; + + for(int i = 0; i < 8; i++) + m_addresses.AddString(s[i]); + + m_addresses.SetCurSel(0); + + RECT cbSize; + int Height; + + m_addresses.GetClientRect(&cbSize); + Height = m_addresses.GetItemHeight(-1); + Height += m_addresses.GetItemHeight(0) * (9); + + // Note: The use of SM_CYEDGE assumes that we're using Windows '95 + // Now add on the height of the border of the edit box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // The height of the border of the drop-down box + Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges + + // now set the size of the window + m_addresses.SetWindowPos(NULL, + 0, 0, + cbSize.right, Height, + SWP_NOMOVE | SWP_NOZORDER); + + m_address.LimitText(8); + + m_size = regQueryDwordValue("memViewerDataSize", 1); + if(m_size < 0 || m_size > 2) + m_size = 0; + m_viewer.setSize(m_size); + UpdateData(FALSE); + + m_current.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT))); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MemoryViewerDlg::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +void MemoryViewerDlg::OnRefresh() +{ + m_viewer.Invalidate(); +} + +void MemoryViewerDlg::update() +{ + OnRefresh(); +} + + +void MemoryViewerDlg::On8Bit() +{ + m_viewer.setSize(0); + regSetDwordValue("memViewerDataSize", 0); +} + +void MemoryViewerDlg::On16Bit() +{ + m_viewer.setSize(1); + regSetDwordValue("memViewerDataSize", 1); +} + +void MemoryViewerDlg::On32Bit() +{ + m_viewer.setSize(2); + regSetDwordValue("memViewerDataSize", 2); +} + +void MemoryViewerDlg::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } + if(GetDlgItem(IDC_AUTO_UPDATE)) + ((CButton *)GetDlgItem(IDC_AUTO_UPDATE))->SetCheck(autoUpdate ? TRUE : FALSE); + regSetDwordValue("memViewerAutoUpdate", autoUpdate); +} + +void MemoryViewerDlg::OnDecimalDisplay() +{ + decimalDisplay = !decimalDisplay; + m_viewer.setDecimal(decimalDisplay ? true : false); + if(GetDlgItem(IDC_DECIMAL_DISPLAY)) + ((CButton *)GetDlgItem(IDC_DECIMAL_DISPLAY))->SetCheck(decimalDisplay ? TRUE : FALSE); + + regSetDwordValue("memViewerDecimalDisplay", decimalDisplay); +} + +void MemoryViewerDlg::OnGo() +{ + CString buffer; + + m_address.GetWindowText(buffer); + + u32 address; + sscanf(buffer, "%x", &address); + if(m_viewer.getSize() == 1) + address &= ~1; + else if(m_viewer.getSize() == 2) + address &= ~3; + m_viewer.setAddress(address); +} + +void MemoryViewerDlg::OnSelchangeAddresses() +{ + int cur = m_addresses.GetCurSel(); + + switch(cur) { + case 0: + m_viewer.setAddress(0); + break; + case 1: + m_viewer.setAddress(0x2000000); + break; + case 2: + m_viewer.setAddress(0x3000000); + break; + case 3: + m_viewer.setAddress(0x4000000); + break; + case 4: + m_viewer.setAddress(0x5000000); + break; + case 5: + m_viewer.setAddress(0x6000000); + break; + case 6: + m_viewer.setAddress(0x7000000); + break; + case 7: + m_viewer.setAddress(0x8000000); + break; + } +} + +void MemoryViewerDlg::setCurrentAddress(u32 address) +{ + CString buffer; + + buffer.Format("0x%08X", address); + m_current.SetWindowText(buffer); +} + +void MemoryViewerDlg::OnSave() +{ + MemoryViewerAddressSize dlg; + CString buffer; + + dlg.setAddress(m_viewer.getCurrentAddress()); + + LPCTSTR exts[] = { ".dmp" }; + + if(dlg.DoModal() == IDOK) { + CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP); + CString title = winResLoadString(IDS_SELECT_DUMP_FILE); + + FileDlg file(this, + buffer, + filter, + 0, + "DMP", + exts, + "", + title, + true); + if(file.DoModal() == IDOK) { + buffer = file.GetPathName(); + + FILE *f = fopen(buffer, "wb"); + + if(f == NULL) { + systemMessage(IDS_ERROR_CREATING_FILE, buffer); + return; + } + + int size = dlg.getSize(); + u32 addr = dlg.getAddress(); + + for(int i = 0; i < size; i++) { + fputc(CPUReadByteQuick(addr), f); + addr++; + } + + fclose(f); + } + } +} + +void MemoryViewerDlg::OnLoad() +{ + CString buffer; + LPCTSTR exts[] = { ".dmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_DUMP); + CString title = winResLoadString(IDS_SELECT_DUMP_FILE); + + FileDlg file(this, + buffer, + filter, + 0, + "DMP", + exts, + "", + title, + false); + + if(file.DoModal() == IDOK) { + buffer = file.GetPathName(); + FILE *f = fopen(buffer, "rb"); + if(f == NULL) { + systemMessage(IDS_CANNOT_OPEN_FILE, + "Cannot open file %s", + buffer); + return; + } + + MemoryViewerAddressSize dlg; + + fseek(f, 0, SEEK_END); + int size = ftell(f); + + fseek(f, 0, SEEK_SET); + + dlg.setAddress(m_viewer.getCurrentAddress()); + dlg.setSize(size); + + if(dlg.DoModal() == IDOK) { + int size = dlg.getSize(); + u32 addr = dlg.getAddress(); + + for(int i = 0; i < size; i++) { + int c = fgetc(f); + if(c == -1) + break; + CPUWriteByteQuick(addr, c); + addr++; + } + OnRefresh(); + } + fclose(f); + } +} + +void MemoryViewerDlg::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/MemoryViewerDlg.h b/src/win32/MemoryViewerDlg.h new file mode 100644 index 0000000..6ee3bfc --- /dev/null +++ b/src/win32/MemoryViewerDlg.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_) +#define AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MemoryViewerDlg.h : header file +// + +#include "MemoryViewer.h" +#include "ResizeDlg.h" +#include "IUpdate.h" + +class GBAMemoryViewer : public MemoryViewer { + public: + GBAMemoryViewer(); + virtual void readData(u32, int, u8 *); + virtual void editData(u32,int,int,u32); +}; + +///////////////////////////////////////////////////////////////////////////// +// MemoryViewerDlg dialog + +class MemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg +{ + GBAMemoryViewer m_viewer; + // Construction + public: + void setCurrentAddress(u32 address); + int autoUpdate; + int decimalDisplay; + void update(); + MemoryViewerDlg(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(MemoryViewerDlg) + enum { IDD = IDD_MEM_VIEWER }; + CEdit m_current; + CEdit m_address; + CComboBox m_addresses; + int m_size; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewerDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(MemoryViewerDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void On8Bit(); + afx_msg void On16Bit(); + afx_msg void On32Bit(); + afx_msg void OnAutoUpdate(); + afx_msg void OnDecimalDisplay(); + afx_msg void OnGo(); + afx_msg void OnSelchangeAddresses(); + afx_msg void OnSave(); + afx_msg void OnLoad(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_) diff --git a/src/win32/ModeConfirm.cpp b/src/win32/ModeConfirm.cpp new file mode 100644 index 0000000..6ac8803 --- /dev/null +++ b/src/win32/ModeConfirm.cpp @@ -0,0 +1,113 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// ModeConfirm.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "ModeConfirm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// ModeConfirm dialog + + +ModeConfirm::ModeConfirm(CWnd* pParent /*=NULL*/) + : CDialog(ModeConfirm::IDD, pParent) +{ + //{{AFX_DATA_INIT(ModeConfirm) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void ModeConfirm::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(ModeConfirm) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(ModeConfirm, CDialog) + //{{AFX_MSG_MAP(ModeConfirm) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + ON_WM_DESTROY() + ON_WM_TIMER() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// ModeConfirm message handlers + +void ModeConfirm::OnCancel() +{ + EndDialog(FALSE); +} + +void ModeConfirm::OnOk() +{ + EndDialog(TRUE); +} + +void ModeConfirm::OnDestroy() +{ + CDialog::OnDestroy(); + + KillTimer(timer); + timer = 0; +} + +BOOL ModeConfirm::OnInitDialog() +{ + CDialog::OnInitDialog(); + + timer = SetTimer(0, 1000, NULL); + + count = 10; + + CString buffer; + buffer.Format("%d", count); + + GetDlgItem(IDC_TIMER)->SetWindowText(buffer); + + CenterWindow(theApp.m_pMainWnd); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void ModeConfirm::OnTimer(UINT nIDEvent) +{ + CString buffer; + count--; + if(count == 0) + EndDialog(FALSE); + buffer.Format("%d", count); + GetDlgItem(IDC_TIMER)->SetWindowText(buffer); + + CDialog::OnTimer(nIDEvent); +} diff --git a/src/win32/ModeConfirm.h b/src/win32/ModeConfirm.h new file mode 100644 index 0000000..0e5a183 --- /dev/null +++ b/src/win32/ModeConfirm.h @@ -0,0 +1,71 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_) +#define AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ModeConfirm.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// ModeConfirm dialog + +class ModeConfirm : public CDialog +{ + // Construction + public: + int count; + UINT timer; + ModeConfirm(CWnd* pParent); // standard constructor + + // Dialog Data + //{{AFX_DATA(ModeConfirm) + enum { IDD = IDD_MODE_CONFIRM }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ModeConfirm) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(ModeConfirm) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnDestroy(); + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MODECONFIRM_H__AF9F877E_6EDF_4523_95C9_1C745ABBA796__INCLUDED_) diff --git a/src/win32/MovieCreate.cpp b/src/win32/MovieCreate.cpp new file mode 100644 index 0000000..963b7e5 --- /dev/null +++ b/src/win32/MovieCreate.cpp @@ -0,0 +1,418 @@ +// MovieCreate.cpp : implementation file +// + +#include "stdafx.h" +#include "../GBA.h" +#include "MovieCreate.h" +#include "./moviecreate.h" +#include "../movie.h" +#include "mainwnd.h" +#include "filedlg.h" +#include "WinResUtil.h" +#include "VBA.h" +#include "../gb/gbGlobals.h" +#include "../Globals.h" +#include "../NLS.h" +#include "../Util.h" +#include "../GBAInline.h" + + +#define GBC_CAPABLE ((gbRom[0x143] & 0x80) != 0) +#define SGB_CAPABLE (gbRom[0x146] == 0x03) + + +// MovieCreate dialog + +IMPLEMENT_DYNAMIC(MovieCreate, CDialog) +MovieCreate::MovieCreate(CWnd* pParent /*=NULL*/) + : CDialog(MovieCreate::IDD, pParent) +{ + //{{AFX_DATA_INIT(MovieCreate) + m_startOption = 2; // "from start" as default + m_systemOption = theApp.cartridgeType == 0 ? 0 : (GBC_CAPABLE ? 1 : (SGB_CAPABLE ? 2 : 3)); // GBA, GBC, SGB, or GB + m_biosOption = theApp.cartridgeType == 0 ? (useBios ? 2 : 1) : 0; // none for non-GBA, or introless and based on settings + //}}AFX_DATA_INIT +} + +MovieCreate::~MovieCreate() +{ +} + +BOOL MovieCreate::OnInitDialog() +{ + CDialog::OnInitDialog(); + + GetDlgItem(IDC_RECRESET)->EnableWindow(theApp.cartridgeType == 0); /// FIXME / TEMP: from-SRAM of non-GBA games is broken + + GetDlgItem(IDC_REC_GBA)->EnableWindow(theApp.cartridgeType == 0); + GetDlgItem(IDC_REC_GBC)->EnableWindow(theApp.cartridgeType != 0 && GBC_CAPABLE); + GetDlgItem(IDC_REC_SGB)->EnableWindow(theApp.cartridgeType != 0 && SGB_CAPABLE); + GetDlgItem(IDC_REC_GB )->EnableWindow(theApp.cartridgeType != 0); + + GetDlgItem(IDC_REC_NOBIOS)->EnableWindow(theApp.cartridgeType != 0); + GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(theApp.cartridgeType == 0); + GetDlgItem(IDC_REC_GBABIOS)->EnableWindow(theApp.cartridgeType == 0); + GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(theApp.cartridgeType == 0); + + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption); + + m_editFilename.LimitText(_MAX_PATH); + m_editAuthor.LimitText(MOVIE_METADATA_AUTHOR_SIZE); + m_editDescription.LimitText(MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + + // convert the ROM filename into a default movie name + { + extern char *regQueryStringValue(const char * key, char *def); // from Reg.cpp + CString capdir = regQueryStringValue("moviesDir", ""); + + if(capdir.IsEmpty()) + capdir = ((MainWnd *)theApp.m_pMainWnd)->getDirFromFile(theApp.filename); + + char str [_MAX_PATH]; + strcpy(str, theApp.filename); + strcat(str, ".vbm"); + char * strPtr = strrchr(str, (int)'\\'); + if(strPtr == NULL) + strPtr = str; + + capdir += strPtr; + movieName = capdir; + + GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName); + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MovieCreate::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MovieCreate) + DDX_Radio(pDX, IDC_RECNOW, m_startOption); + DDX_Radio(pDX, IDC_REC_GBA, m_systemOption); +/// done manually DDX_Radio(pDX, IDC_REC_NOBIOS, m_biosOption); + DDX_Control(pDX, IDC_EDIT_AUTHOR, m_editAuthor); + DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_editDescription); + DDX_Control(pDX, IDC_MOVIE_FILENAME, m_editFilename); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(MovieCreate, CDialog) + ON_BN_CLICKED(IDOK, OnBnClickedOk) + ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) + ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse) + ON_BN_CLICKED(IDC_RECSTART, OnBnClickedRecstart) + ON_BN_CLICKED(IDC_RECRESET, OnBnClickedRecreset) + ON_BN_CLICKED(IDC_RECNOW, OnBnClickedRecnow) + ON_BN_CLICKED(IDC_REC_GBA, OnBnClickedRecGba) + ON_BN_CLICKED(IDC_REC_GBC, OnBnClickedRecGbc) + ON_BN_CLICKED(IDC_REC_SGB, OnBnClickedRecSgb) + ON_BN_CLICKED(IDC_REC_GB, OnBnClickedRecGb) + ON_BN_CLICKED(IDC_REC_NOBIOS, OnBnClickedRecNobios) + ON_BN_CLICKED(IDC_REC_EMUBIOS, OnBnClickedRecEmubios) + ON_BN_CLICKED(IDC_REC_GBABIOS, OnBnClickedRecGbabios) + ON_BN_CLICKED(IDC_REC_GBABIOSINTRO, OnBnClickedRecGbabiosintro) +END_MESSAGE_MAP() + + +// MovieCreate message handlers + +void MovieCreate::OnBnClickedBrowse() +{ + theApp.winCheckFullscreen(); + CString captureBuffer; + extern char *regQueryStringValue(const char * key, char *def); // from Reg.cpp + CString capdir = regQueryStringValue("moviesDir", ""); + + if(capdir.IsEmpty()) + capdir = ((MainWnd *)theApp.m_pMainWnd)->getDirFromFile(theApp.filename); + + CString filter = theApp.winLoadFilter(IDS_FILTER_MOVIE); + CString title = winResLoadString(IDS_SELECT_MOVIE_NAME); + + LPCTSTR exts[] = { ".vbm" }; + + FileDlg dlg(this, "", filter, 1, "vbm", exts, capdir, title, true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + movieName = dlg.GetPathName(); + captureBuffer = movieName; + + if(dlg.m_ofn.nFileOffset > 0) { + captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset); + } + + int len = captureBuffer.GetLength(); + + if(len > 3 && captureBuffer[len-1] == '\\') + captureBuffer = captureBuffer.Left(len-1); + + extern void regSetStringValue(const char * key, const char * value); // from Reg.cpp + regSetStringValue("moviesDir", captureBuffer); + + GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName); +} + +void loadBIOS() +{ + if(bios == NULL) + return; + + useBios = false; + if(theApp.useBiosFile) + { + int size = 0x4000; + extern bool CPUIsGBABios(const char * file); + if(utilLoad(theApp.biosFileName, + CPUIsGBABios, + bios, + size)) { + if(size == 0x4000) + useBios = true; + } + } + if(!useBios) { + memcpy(bios, myROM, /*sizeof(myROM)*/0x4000); // copy internal emulator BIOS + theApp.useBiosFile = false; + } +} + +bool checkBIOS(CString & biosFileName) +{ + if(biosFileName.IsEmpty()) + return false; + + bool ok = false; + u8 * tempBIOS = (u8 *)malloc(0x4000); + int size = 0x4000; + extern bool CPUIsGBABios(const char * file); + if(utilLoad(biosFileName, + CPUIsGBABios, + tempBIOS, + size)) { + if(size == 0x4000) + ok = true; + else + systemMessage(MSG_INVALID_BIOS_FILE_SIZE, N_("Invalid BIOS file size")); + } + free(tempBIOS); + return ok; +} + +void MovieCreate::OnBnClickedOk() +{ + int startFlags=0, controllerFlags=0, typeFlags=0; + + if(m_startOption == 0) + startFlags |= MOVIE_START_FROM_SNAPSHOT; + else if(m_startOption == 1) + startFlags |= MOVIE_START_FROM_SRAM; + //else + // startFlags = 0; // no SRAM or snapshot + + if(m_systemOption == 0) + typeFlags |= MOVIE_TYPE_GBA, gbEmulatorType = 4; + else if(m_systemOption == 1) + typeFlags |= MOVIE_TYPE_GBC, gbEmulatorType = 1; + else if(m_systemOption == 2) + typeFlags |= MOVIE_TYPE_SGB, gbEmulatorType = 2; + else + gbEmulatorType = 3; // plain old GB + + controllerFlags |= MOVIE_CONTROLLER(0); + if(typeFlags & MOVIE_TYPE_SGB) + { + // XXX FIXME - the code for multiple controllers must be broken somehow + // (it crashes strangely during FreezeToStream in SGB games) + + // SGB games are free to request controllers while running, so we have to assume it needs all 4 +/// controllerFlags |= MOVIE_CONTROLLER(1) | MOVIE_CONTROLLER(2) | MOVIE_CONTROLLER(3); + } + + if(m_biosOption == 1) + theApp.useBiosFile = false; + if(m_biosOption == 2) + theApp.useBiosFile = true, theApp.skipBiosFile = true, loadBIOS(); + if(m_biosOption == 3) + theApp.useBiosFile = true, theApp.skipBiosFile = false, loadBIOS(); + + // get author and movie info from the edit fields: + char info [MOVIE_METADATA_SIZE], buffer [MOVIE_METADATA_SIZE]; + + GetDlgItem(IDC_EDIT_AUTHOR)->GetWindowText(buffer, MOVIE_METADATA_AUTHOR_SIZE); + strncpy(info, buffer, MOVIE_METADATA_AUTHOR_SIZE); + info[MOVIE_METADATA_AUTHOR_SIZE-1] = '\0'; + + GetDlgItem(IDC_EDIT_DESCRIPTION)->GetWindowText(buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + strncpy(info + MOVIE_METADATA_AUTHOR_SIZE, buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + info[MOVIE_METADATA_SIZE-1] = '\0'; + + + if(memLagTempEnabled && theApp.cartridgeType == 0) + { + // lag reduction is off -- if the user didn't turn it off, silently turn it back on, otherwise ask + int ans = !memLagEnabled ? IDYES : AfxGetApp()->m_pMainWnd->MessageBox("Lag reduction is currently OFF.\nIt is recommended that you turn this ON for recording.\nWould you like to turn it on now?", "Warning", MB_YESNOCANCEL|MB_ICONWARNING); + switch(ans) + { + case IDYES: + extern void SetPrefetchHack(bool); + SetPrefetchHack(true); + break; + case IDNO: break; + case IDCANCEL: return; + } + } + + + GetDlgItem(IDC_MOVIE_FILENAME)->GetWindowText(movieName); + + // actually make the movie file: + int code = VBAMovieCreate(movieName, info, startFlags, controllerFlags, typeFlags); + + if(code != SUCCESS) + { + systemMessage(0, "Failed to create movie %s", (const char *)movieName); + return; + } + + + OnOK(); +} + +void MovieCreate::OnBnClickedCancel() +{ + OnCancel(); +} + +void MovieCreate::OnBnClickedRecstart() +{ + m_startOption = 2; + if(theApp.cartridgeType == 0) + { + GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(TRUE); + GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(TRUE); + } + else + { + GetDlgItem(IDC_REC_GBC)->EnableWindow(GBC_CAPABLE); + GetDlgItem(IDC_REC_SGB)->EnableWindow(SGB_CAPABLE); + GetDlgItem(IDC_REC_GB )->EnableWindow(TRUE); + } +} + +void MovieCreate::OnBnClickedRecreset() +{ + m_startOption = 1; + if(theApp.cartridgeType == 0) + { + GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(TRUE); + GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(TRUE); + } + else + { + GetDlgItem(IDC_REC_GBC)->EnableWindow(GBC_CAPABLE); + GetDlgItem(IDC_REC_SGB)->EnableWindow(SGB_CAPABLE); + GetDlgItem(IDC_REC_GB )->EnableWindow(TRUE); + } +} + +void MovieCreate::OnBnClickedRecnow() +{ + m_startOption = 0; + + // starting from emulator bios file from a snapshot made while playing with GBA bios file won't work + if(theApp.cartridgeType == 0 && useBios) + { + if(m_biosOption == 1) + { + OnBnClickedRecGbabios(); + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption); + } + GetDlgItem(IDC_REC_EMUBIOS)->EnableWindow(FALSE); + } + + // "with intro" distinction makes no sense when continuing from snapshot + if(theApp.cartridgeType == 0) + { + if(m_biosOption == 3) + { + OnBnClickedRecGbabios(); + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + m_biosOption); + } + GetDlgItem(IDC_REC_GBABIOSINTRO)->EnableWindow(FALSE); + } + + // can't switch systems while recording from snapshot! + if(theApp.cartridgeType != 0) + { + int curSystemOption = (gbCgbMode==1 ? 1 : (gbSgbMode==1 ? 2 : 3)); // GBC, SGB, or GB + GetDlgItem(IDC_REC_GBC)->EnableWindow(curSystemOption == 1); + GetDlgItem(IDC_REC_SGB)->EnableWindow(curSystemOption == 2); + GetDlgItem(IDC_REC_GB)->EnableWindow(curSystemOption == 3); + m_systemOption = curSystemOption; + CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, IDC_REC_GBA + m_systemOption); + } +} + +void MovieCreate::OnBnClickedRecGba() +{ + m_systemOption = 0; +} + +void MovieCreate::OnBnClickedRecGbc() +{ + m_systemOption = 1; +} + +void MovieCreate::OnBnClickedRecSgb() +{ + m_systemOption = 2; +} + +void MovieCreate::OnBnClickedRecGb() +{ + m_systemOption = 3; +} + +void MovieCreate::OnBnClickedRecNobios() +{ + m_biosOption = 0; +} + +void MovieCreate::OnBnClickedRecEmubios() +{ + m_biosOption = 1; +} + +void MovieCreate::OnBnClickedRecGbabios() +{ + if(checkBIOS(theApp.biosFileName)) + m_biosOption = 2; + else + { + ((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile(); + if(checkBIOS(theApp.biosFileName)) + m_biosOption = 2; + else + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_EMUBIOS); + } +} + +void MovieCreate::OnBnClickedRecGbabiosintro() +{ + if(checkBIOS(theApp.biosFileName)) + m_biosOption = 3; + else + { + ((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile(); + if(checkBIOS(theApp.biosFileName)) + m_biosOption = 3; + else + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_EMUBIOS); + } +} diff --git a/src/win32/MovieCreate.h b/src/win32/MovieCreate.h new file mode 100644 index 0000000..35b2297 --- /dev/null +++ b/src/win32/MovieCreate.h @@ -0,0 +1,48 @@ +#pragma once + + +// MovieCreate dialog + +class MovieCreate : public CDialog +{ + DECLARE_DYNAMIC(MovieCreate) + +public: + MovieCreate(CWnd* pParent = NULL); // standard constructor + virtual ~MovieCreate(); + + virtual BOOL OnInitDialog() ; + +// Dialog Data + //{{AFX_DATA(MovieCreate) + enum { IDD = IDD_MOVIECREATE }; + int m_startOption; + int m_systemOption; + int m_biosOption; + CEdit m_editAuthor; + CEdit m_editDescription; + CEdit m_editFilename; + //}}AFX_DATA + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedCancel(); + afx_msg void OnBnClickedBrowse(); + + CString movieName; + afx_msg void OnBnClickedRecstart(); + afx_msg void OnBnClickedRecreset(); + afx_msg void OnBnClickedRecnow(); + afx_msg void OnBnClickedRecGba(); + afx_msg void OnBnClickedRecGbc(); + afx_msg void OnBnClickedRecSgb(); + afx_msg void OnBnClickedRecGb(); + afx_msg void OnBnClickedRecNobios(); + afx_msg void OnBnClickedRecEmubios(); + afx_msg void OnBnClickedRecGbabios(); + afx_msg void OnBnClickedRecGbabiosintro(); +}; diff --git a/src/win32/MovieOpen.cpp b/src/win32/MovieOpen.cpp new file mode 100644 index 0000000..486c17d --- /dev/null +++ b/src/win32/MovieOpen.cpp @@ -0,0 +1,522 @@ +// MovieOpen.cpp : implementation file +// + +#include "stdafx.h" +#include "../GBA.h" +#include "MovieOpen.h" +#include "../movie.h" +#include "mainwnd.h" +#include "filedlg.h" +#include "WinResUtil.h" +#include "VBA.h" +#include "time.h" +#include "../gb/gbGlobals.h" +#include "../Util.h" +#include "../GBAinline.h" +#include ".\movieopen.h" + + + +// MovieOpen dialog + +IMPLEMENT_DYNAMIC(MovieOpen, CDialog) +MovieOpen::MovieOpen(CWnd* pParent /*=NULL*/) + : CDialog(MovieOpen::IDD, pParent) +{ +} + +MovieOpen::~MovieOpen() +{ +} + +BOOL MovieOpen::OnInitDialog() +{ + CDialog::OnInitDialog(); + + GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(FALSE); + GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(""); + GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(""); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(""); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE); + GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE); + + CheckDlgButton(IDC_READONLY, theApp.movieReadOnly); + m_editDescription.SetReadOnly(theApp.movieReadOnly); + + // convert the ROM filename into a default movie name + { + extern char *regQueryStringValue(const char * key, char *def); // from Reg.cpp + CString capdir = regQueryStringValue("moviesDir", ""); + + if(capdir.IsEmpty()) + capdir = ((MainWnd *)theApp.m_pMainWnd)->getDirFromFile(theApp.filename); + + char str [_MAX_PATH]; + strcpy(str, theApp.filename); + strcat(str, ".vbm"); + char * strPtr = strrchr(str, (int)'\\'); + if(strPtr == NULL) + strPtr = str; + + movieName = capdir + strPtr; + + GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName); + } + + m_editFilename.LimitText(_MAX_PATH); + m_editAuthor.LimitText(MOVIE_METADATA_AUTHOR_SIZE); + m_editDescription.LimitText(MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + m_editPauseFrame.LimitText(8); + + OnBnClickedMovieRefresh(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void MovieOpen::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(MovieCreate) + DDX_Control(pDX, IDC_EDIT_AUTHOR, m_editAuthor); + DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_editDescription); + DDX_Control(pDX, IDC_MOVIE_FILENAME, m_editFilename); + DDX_Control(pDX, IDC_EDIT_PAUSEFRAME, m_editPauseFrame); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(MovieOpen, CDialog) + ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse) + ON_BN_CLICKED(IDOK, OnBnClickedOk) + ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) + ON_BN_CLICKED(IDC_MOVIE_REFRESH, OnBnClickedMovieRefresh) + ON_BN_CLICKED(IDC_READONLY, OnBnClickedReadonly) + ON_BN_CLICKED(IDC_CHECK_PAUSEFRAME, OnBnClickedCheckPauseframe) + ON_BN_CLICKED(IDC_CHECK_HIDEBORDER, OnBnClickedHideborder) + ON_EN_CHANGE(IDC_MOVIE_FILENAME, OnEnChangeMovieFilename) +END_MESSAGE_MAP() + + +// MovieOpen message handlers + +void MovieOpen::OnBnClickedBrowse() +{ + extern char *regQueryStringValue(const char * key, char *def); // from Reg.cpp + CString capdir = regQueryStringValue("moviesDir", ""); + + if(capdir.IsEmpty()) + capdir = ((MainWnd *)theApp.m_pMainWnd)->getDirFromFile(theApp.filename); + + CString filter = theApp.winLoadFilter(IDS_FILTER_MOVIE); + CString title = winResLoadString(IDS_SELECT_MOVIE_NAME); + + LPCTSTR exts[] = { ".vbm" }; + + FileDlg dlg(this, "", filter, 1, "vbm", exts, capdir, title, false, true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + movieName = dlg.GetPathName(); + + GetDlgItem(IDC_MOVIE_FILENAME)->SetWindowText(movieName); + + OnBnClickedMovieRefresh(); +} + +// returns the checksum of the BIOS that will be loaded after the next restart +u16 checksumBIOS() +{ + bool hasBIOS = false; + u8 * tempBIOS; + if(theApp.useBiosFile) + { + tempBIOS = (u8 *)malloc(0x4000); + int size = 0x4000; + extern bool CPUIsGBABios(const char * file); + if(utilLoad(theApp.biosFileName, + CPUIsGBABios, + tempBIOS, + size)) { + if(size == 0x4000) + hasBIOS = true; + } + } + + u16 biosCheck = 0; + if(hasBIOS) { + for(int i = 0; i < 0x4000; i += 4) + biosCheck += *((u32 *)&tempBIOS[i]); + free(tempBIOS); + } + + return biosCheck; +} + +void fillRomInfo(const SMovie & movieInfo, char romTitle [12], uint32 & romGameCode, uint16 & checksum, uint8 & crc) +{ + if(theApp.cartridgeType == 0) // GBA + { + extern u8 *bios, *rom; + memcpy(romTitle, (const char *)&rom[0xa0], 12); // GBA TITLE + memcpy(&romGameCode, &rom[0xac], 4); // GBA ROM GAME CODE + + bool prevUseBiosFile = theApp.useBiosFile; + theApp.useBiosFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0; + checksum = checksumBIOS(); // GBA BIOS CHECKSUM + theApp.useBiosFile = prevUseBiosFile; + crc = rom[0xbd]; // GBA ROM CRC + } + else // non-GBA + { + extern u8 *gbRom; + memcpy(romTitle, (const char *)&gbRom[0x134], 12); // GB TITLE (note this can be 15 but is truncated to 12) + romGameCode = (uint32)gbRom[0x146]; // GB ROM UNIT CODE + + checksum = (gbRom[0x14e]<<8)|gbRom[0x14f]; // GB ROM CHECKSUM + crc = gbRom[0x14d]; // GB ROM CRC + } +} + +void MovieOpen::OnBnClickedMovieRefresh() +{ + GetDlgItem(IDC_MOVIE_FILENAME)->GetWindowText(movieName); + if(VBAMovieGetInfo(movieName, &movieInfo) == SUCCESS) + { + if(movieInfo.readOnly) + { + CheckDlgButton(IDC_READONLY, TRUE); + m_editDescription.SetReadOnly(TRUE); + } + + char buffer [MOVIE_METADATA_SIZE]; + + strncpy(buffer, movieInfo.authorInfo, MOVIE_METADATA_AUTHOR_SIZE); + buffer[MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0'; + GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(buffer); + + strncpy(buffer, movieInfo.authorInfo + MOVIE_METADATA_AUTHOR_SIZE, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + buffer[MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE - 1] = '\0'; + GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(buffer); + + int option = 2; + if(movieInfo.header.startFlags & MOVIE_START_FROM_SRAM) + option = 1; + if(movieInfo.header.startFlags & MOVIE_START_FROM_SNAPSHOT) + option = 0; + CheckRadioButton(IDC_RECNOW, IDC_RECSTART, IDC_RECNOW + option); + + option = 3; + if(movieInfo.header.typeFlags & MOVIE_TYPE_SGB) + option = 2; + if(movieInfo.header.typeFlags & MOVIE_TYPE_GBC) + option = 1; + if(movieInfo.header.typeFlags & MOVIE_TYPE_GBA) + option = 0; + CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, IDC_REC_GBA + option); + + GetDlgItem(IDC_CHECK_HIDEBORDER)->ShowWindow(option == 2 ? TRUE : FALSE); + + + if(movieInfo.header.typeFlags & MOVIE_TYPE_GBA) + { + if(movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) + { + if(movieInfo.header.optionFlags & MOVIE_SETTING_SKIPBIOSFILE) + option = 2; + else + option = 3; + } + else + option = 1; + } + else + option = 0; + + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, IDC_REC_NOBIOS + option); + + + { + char* p; + time_t ttime = (time_t)movieInfo.header.uid; + strncpy(buffer, ctime(&ttime), 127); + buffer[127]='\0'; + if((p=strrchr(buffer, '\n'))) + *p='\0'; + GetDlgItem(IDC_LABEL_DATE)->SetWindowText(buffer); + + uint32 div = 60; + uint32 l=(movieInfo.header.length_frames+(div>>1))/div; + uint32 seconds=l%60; + l/=60; + uint32 minutes=l%60; + l/=60; + uint32 hours=l%60; + sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); + GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(buffer); + sprintf(buffer, "%ld", movieInfo.header.length_frames); + GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(buffer); + sprintf(buffer, "%ld", movieInfo.header.rerecord_count); + GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(buffer); + } + + { + char warning1 [1024], warning2 [1024], buffer [1024]; + + strcpy(warning1, ""); + strcpy(warning2, ""); + + char romTitle [12]; + uint32 romGameCode; + uint16 checksum; + uint8 crc; + + fillRomInfo(movieInfo, romTitle, romGameCode, checksum, crc); + + // rather than treat these as warnings, might as well always show the info in the dialog (it's probably more informative and reassuring) +/// if(strncmp(movieInfo.header.romTitle,romTitle,12) != 0) + { + char str [13]; + strncpy(str, movieInfo.header.romTitle, 12); + str[12] = '\0'; + sprintf(buffer, "title=%s ", str); + strcat(warning1, buffer); + + strncpy(str, romTitle, 12); + str[12] = '\0'; + sprintf(buffer, "title=%s ", str); + strcat(warning2, buffer); + } +/// if(((movieInfo.header.typeFlags & MOVIE_TYPE_GBA)!=0) != (theApp.cartridgeType == 0)) + { + sprintf(buffer, "type=%s ", (movieInfo.header.typeFlags&MOVIE_TYPE_GBA) ? "GBA" : (movieInfo.header.typeFlags&MOVIE_TYPE_GBC) ? "GBC" : (movieInfo.header.typeFlags&MOVIE_TYPE_SGB) ? "SGB" : "GB"); + strcat(warning1, buffer); + + sprintf(buffer, "type=%s ", theApp.cartridgeType == 0 ? "GBA" : (gbRom[0x143] & 0x80 ? "GBC" : (gbRom[0x146] == 0x03 ? "SGB" : "GB")) ); + strcat(warning2, buffer); + } +/// if(movieInfo.header.romCRC != crc) + { + sprintf(buffer, "crc=%02d ", movieInfo.header.romCRC); + strcat(warning1, buffer); + + sprintf(buffer, "crc=%02d ", crc); + strcat(warning2, buffer); + } +/// if(movieInfo.header.romGameCode != romGameCode) + { + char code [5]; + if(movieInfo.header.typeFlags&MOVIE_TYPE_GBA) + { + memcpy(code, &movieInfo.header.romGameCode, 4); + code[4] = '\0'; + sprintf(buffer, "code=%s ", code); + strcat(warning1, buffer); + } + + if(theApp.cartridgeType == 0) + { + memcpy(code, &romGameCode, 4); + code[4] = '\0'; + sprintf(buffer, "code=%s ", code); + strcat(warning2, buffer); + } + } +/// if(movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE)==0 && checksum==0)) + { + sprintf(buffer, movieInfo.header.typeFlags&MOVIE_TYPE_GBA ? ((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE)==0 ? "(bios=none) " : "(bios=%d) ") : "check=%d ", movieInfo.header.romOrBiosChecksum); + strcat(warning1, buffer); + + sprintf(buffer, checksum==0 ? "(bios=none) " : theApp.cartridgeType == 0 ? "(bios=%d) " : "check=%d ", checksum); + strcat(warning2, buffer); + } + + if(strlen(warning1) > 0) + { + sprintf(buffer, "Movie ROM: %s", warning1); + GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(buffer); + + sprintf(buffer, "Your ROM: %s", warning2); + + //if(movieInfo.header.romCRC != crc + //|| strncmp(movieInfo.header.romTitle,romTitle,12) != 0 + //|| movieInfo.header.romOrBiosChecksum != checksum && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE)==0 && checksum==0)) + // strcat(buffer, "<-- MISMATCH"); + + GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(buffer); + } + else + { + GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText("(No problems detected)"); + GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" "); + } + } + GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(TRUE); + } + else + { + GetDlgItem(IDC_LABEL_DATE)->SetWindowText(" "); + GetDlgItem(IDC_LABEL_LENGTH)->SetWindowText(" "); + GetDlgItem(IDC_LABEL_FRAMES)->SetWindowText(" "); + GetDlgItem(IDC_LABEL_RERECORD)->SetWindowText(" "); + GetDlgItem(IDC_EDIT_AUTHOR)->SetWindowText(" "); + GetDlgItem(IDC_EDIT_DESCRIPTION)->SetWindowText(" "); + GetDlgItem(IDC_LABEL_WARNING1)->SetWindowText(" "); + GetDlgItem(IDC_LABEL_WARNING2)->SetWindowText(" "); + + GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(""); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE); + GetDlgItem(IDC_CHECK_PAUSEFRAME)->EnableWindow(FALSE); + CheckDlgButton(IDC_CHECK_PAUSEFRAME, FALSE); +/* + /// FIXME: how to un-check all the radio buttons? + CheckRadioButton(IDC_RECNOW, IDC_RECSTART, -1); + CheckRadioButton(IDC_REC_GBA, IDC_REC_GB, -1); + CheckRadioButton(IDC_REC_NOBIOS, IDC_REC_GBABIOSINTRO, -1);*/ + } +} + +BOOL MovieOpen::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *res) +{ + switch( msg ) { + case WM_CTLCOLORSTATIC: + { + //HWND hwndDlg = GetSafeHwnd(); + HWND warnDlg = NULL; + GetDlgItem(IDC_LABEL_WARNING2, &warnDlg); + + if((HWND)lParam == warnDlg) + { + char romTitle [12]; + uint32 romGameCode; + uint16 checksum; + uint8 crc; + + fillRomInfo(movieInfo, romTitle, romGameCode, checksum, crc); + + if(movieInfo.header.romCRC != crc + || strncmp(movieInfo.header.romTitle,romTitle,12) != 0 + || movieInfo.header.romOrBiosChecksum != checksum + && !((movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) == 0 && checksum==0)) + { + // draw the md5 sum in red if it's different from the md5 of the rom used in the replay + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(255,0,0)); // use red for a mismatch + + // I'm not sure why this doesn't work to make the background transparent... it turns white anyway + SetBkMode(hdcStatic, TRANSPARENT); + return (LONG)GetStockObject(NULL_BRUSH); + } + } + return FALSE; + } + } + return CDialog::OnWndMsg(msg, wParam, lParam, res); +} + +void MovieOpen::OnBnClickedOk() +{ + theApp.useBiosFile = (movieInfo.header.optionFlags & MOVIE_SETTING_USEBIOSFILE) != 0; + if(theApp.useBiosFile) + { + extern bool checkBIOS(CString & biosFileName); // from MovieCreate.cpp + if(!checkBIOS(theApp.biosFileName)) + { + systemMessage(0, "This movie requires a valid GBA BIOS file to play.\nPlease locate a BIOS file."); + ((MainWnd *)theApp.m_pMainWnd)->OnOptionsEmulatorSelectbiosfile(); + if(!checkBIOS(theApp.biosFileName)) + { + systemMessage(0, "\"%s\" is not a valid BIOS file; cannot play movie without one.", theApp.biosFileName); + return; + } + } + } + extern void loadBIOS(); + loadBIOS(); + + + int code = VBAMovieOpen(movieName, IsDlgButtonChecked(IDC_READONLY)); + + + if(code != SUCCESS) + { + if(code == FILE_NOT_FOUND) + systemMessage(0, "Could not find movie file \"%s\".", (const char *)movieName); + else if(code == WRONG_FORMAT) + systemMessage(0, "Movie file \"%s\" is not in proper VBM format.", (const char *)movieName); + else if(code == WRONG_VERSION) + systemMessage(0, "Movie file \"%s\" is not a supported version.", (const char *)movieName); + else + systemMessage(0, "Failed to open movie \"%s\".", (const char *)movieName); + return; + } + else + { + // get author and movie info from the edit fields (the description might change): + char info [MOVIE_METADATA_SIZE], buffer [MOVIE_METADATA_SIZE]; + + GetDlgItem(IDC_EDIT_AUTHOR)->GetWindowText(buffer, MOVIE_METADATA_AUTHOR_SIZE); + strncpy(info, buffer, MOVIE_METADATA_AUTHOR_SIZE); + info[MOVIE_METADATA_AUTHOR_SIZE-1] = '\0'; + + GetDlgItem(IDC_EDIT_DESCRIPTION)->GetWindowText(buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + strncpy(info + MOVIE_METADATA_AUTHOR_SIZE, buffer, MOVIE_METADATA_SIZE - MOVIE_METADATA_AUTHOR_SIZE); + info[MOVIE_METADATA_SIZE-1] = '\0'; + + VBAMovieSetMetadata(info); + } + + if(IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME)) + { + char buffer [9]; + GetDlgItem(IDC_EDIT_PAUSEFRAME)->GetWindowText(buffer, 8); + buffer[8] = '\0'; + + int pauseFrame = atoi(buffer); + if(pauseFrame >= 0) + VBAMovieSetPauseAt(pauseFrame); + } + + OnOK(); +} + +void MovieOpen::OnBnClickedCancel() +{ + OnCancel(); +} + +void MovieOpen::OnBnClickedReadonly() +{ + theApp.movieReadOnly = IsDlgButtonChecked(IDC_READONLY) != 0; + m_editDescription.SetReadOnly(theApp.movieReadOnly); + OnBnClickedMovieRefresh(); +} + +void MovieOpen::OnBnClickedCheckPauseframe() +{ + if(IsDlgButtonChecked(IDC_CHECK_PAUSEFRAME)) + { + char buffer [8]; + _itoa(movieInfo.header.length_frames, buffer, 10); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(buffer); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(TRUE); + } + else + { + GetDlgItem(IDC_EDIT_PAUSEFRAME)->SetWindowText(""); + GetDlgItem(IDC_EDIT_PAUSEFRAME)->EnableWindow(FALSE); + } +} + + +void MovieOpen::OnBnClickedHideborder() +{ + theApp.hideMovieBorder = IsDlgButtonChecked(IDC_CHECK_HIDEBORDER) != 0; +} + +void MovieOpen::OnEnChangeMovieFilename() +{ + OnBnClickedMovieRefresh(); +} diff --git a/src/win32/MovieOpen.h b/src/win32/MovieOpen.h new file mode 100644 index 0000000..ec927ab --- /dev/null +++ b/src/win32/MovieOpen.h @@ -0,0 +1,46 @@ +#pragma once + + +#include "..\movie.h" + +// MovieOpen dialog + +class MovieOpen : public CDialog +{ + DECLARE_DYNAMIC(MovieOpen) + +public: + MovieOpen(CWnd* pParent = NULL); // standard constructor + virtual ~MovieOpen(); + + virtual BOOL OnInitDialog() ; + +// Dialog Data + //{{AFX_DATA(MovieOpen) + enum { IDD = IDD_MOVIEOPEN }; + CEdit m_editAuthor; + CEdit m_editDescription; + CEdit m_editFilename; + CEdit m_editPauseFrame; + CString movieName; + SMovie movieInfo; + int pauseFrame; + //}}AFX_DATA + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedBrowse(); + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedCancel(); + afx_msg void OnBnClickedMovieRefresh(); + afx_msg void OnBnClickedReadonly(); + afx_msg void OnBnClickedCheckPauseframe(); + + afx_msg void OnBnClickedHideborder(); + + virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *); + afx_msg void OnEnChangeMovieFilename(); +}; diff --git a/src/win32/OamView.cpp b/src/win32/OamView.cpp new file mode 100644 index 0000000..13c233a --- /dev/null +++ b/src/win32/OamView.cpp @@ -0,0 +1,669 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// OamView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "OamView.h" +#include "Reg.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../NLS.h" +#include "../Util.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// OamView dialog + + +OamView::OamView(CWnd* pParent /*=NULL*/) + : ResizeDlg(OamView::IDD, pParent) +{ + //{{AFX_DATA_INIT(OamView) + m_stretch = FALSE; + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 32; + bmpInfo.bmiHeader.biHeight = 32; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 64 * 64); + + oamView.setData(data); + oamView.setBmpInfo(&bmpInfo); + + number = 0; +} + + +void OamView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(OamView) + DDX_Control(pDX, IDC_SPRITE, m_sprite); + DDX_Check(pDX, IDC_STRETCH, m_stretch); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_COLOR, color); + DDX_Control(pDX, IDC_OAM_VIEW, oamView); + DDX_Control(pDX, IDC_OAM_VIEW_ZOOM, oamZoom); +} + + +BEGIN_MESSAGE_MAP(OamView, CDialog) + //{{AFX_MSG_MAP(OamView) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_EN_CHANGE(IDC_SPRITE, OnChangeSprite) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_WM_HSCROLL() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// OamView message handlers + +OamView::~OamView() +{ + free(data); + data = NULL; +} + +void OamView::paint() +{ + if(oam == NULL || paletteRAM == NULL || vram == NULL) + return; + + render(); + oamView.setSize(w,h); + oamView.refresh(); +} + +void OamView::update() +{ + paint(); +} + + + +void OamView::setAttributes(u16 a0, u16 a1, u16 a2) +{ + CString buffer; + + int y = a0 & 255; + int rot = a0 & 512; + int mode = (a0 >> 10) & 3; + int mosaic = a0 & 4096; + int color = a0 & 8192; + int duple = a0 & 1024; + int shape = (a0 >> 14) & 3; + int x = a1 & 511; + int rotParam = (a1 >> 9) & 31; + int flipH = a1 & 4096; + int flipV = a1 & 8192; + int size = (a1 >> 14) & 3; + int tile = a2 & 1023; + int prio = (a2 >> 10) & 3; + int pal = (a2 >> 12) & 15; + + buffer.Format("%d,%d", x,y); + GetDlgItem(IDC_POS)->SetWindowText(buffer); + + buffer.Format("%d", mode); + GetDlgItem(IDC_MODE)->SetWindowText(buffer); + + GetDlgItem(IDC_COLORS)->SetWindowText(color ? "256" : "16"); + + buffer.Format("%d", pal); + GetDlgItem(IDC_PALETTE)->SetWindowText(buffer); + + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE)->SetWindowText(buffer); + + buffer.Format("%d", prio); + GetDlgItem(IDC_PRIO)->SetWindowText(buffer); + + buffer.Format("%d,%d", w,h); + GetDlgItem(IDC_SIZE2)->SetWindowText(buffer); + + if(rot) { + buffer.Format("%d", rotParam); + } else + buffer.Empty(); + GetDlgItem(IDC_ROT)->SetWindowText(buffer); + + buffer.Empty(); + + if(rot) + buffer += 'R'; + else buffer += ' '; + if(!rot) { + if(flipH) + buffer += 'H'; + else + buffer += ' '; + if(flipV) + buffer += 'V'; + else + buffer += ' '; + } else { + buffer += ' '; + buffer += ' '; + } + if(mosaic) + buffer += 'M'; + else + buffer += ' '; + if(duple) + buffer += 'D'; + else + buffer += ' '; + + GetDlgItem(IDC_FLAGS)->SetWindowText(buffer); +} + +void OamView::render() +{ + int m=0; + if(oam == NULL || paletteRAM == NULL || vram == NULL) + return; + + u16 *sprites = &((u16 *)oam)[4*number]; + u16 *spritePalette = &((u16 *)paletteRAM)[0x100]; + u8 *bmp = data; + + u16 a0 = *sprites++; + u16 a1 = *sprites++; + u16 a2 = *sprites++; + + int sizeY = 8; + int sizeX = 8; + + switch(((a0 >>12) & 0x0c)|(a1>>14)) { + case 0: + break; + case 1: + sizeX = sizeY = 16; + break; + case 2: + sizeX = sizeY = 32; + break; + case 3: + sizeX = sizeY = 64; + break; + case 4: + sizeX = 16; + break; + case 5: + sizeX = 32; + break; + case 6: + sizeX = 32; + sizeY = 16; + break; + case 7: + sizeX = 64; + sizeY = 32; + break; + case 8: + sizeY = 16; + break; + case 9: + sizeY = 32; + break; + case 10: + sizeX = 16; + sizeY = 32; + break; + case 11: + sizeX = 32; + sizeY = 64; + break; + default: + return; + } + + w = sizeX; + h = sizeY; + + setAttributes(a0,a1,a2); + + int sy = (a0 & 255); + + if(a0 & 0x2000) { + int c = (a2 & 0x3FF); + // if((DISPCNT & 7) > 2 && (c < 512)) + // return; + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 2; + else + c &= 0x3FE; + + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u32 color = vram[0x10000 + (((c + (y>>3) * inc)* + 32 + (y & 7) * 8 + (x >> 3) * 64 + + (x & 7))&0x7FFF)]; + color = spritePalette[color]; + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + } + } + } else { + int c = (a2 & 0x3FF); + // if((DISPCNT & 7) > 2 && (c < 512)) + // continue; + + int inc = 32; + if(DISPCNT & 0x40) + inc = sizeX >> 3; + int palette = (a2 >> 8) & 0xF0; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + u32 color = vram[0x10000 + (((c + (y>>3) * inc)* + 32 + (y & 7) * 4 + (x >> 3) * 32 + + ((x & 7)>>1))&0x7FFF)]; + if(x & 1) + color >>= 4; + else + color &= 0x0F; + + color = spritePalette[palette+color]; + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + } + } + } +} + +void OamView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + + +void OamView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + +void OamView::OnSave() +{ + CString captureBuffer; + + if(theApp.captureFormat == 0) + captureBuffer = "oam.png"; + else + captureBuffer = "oam.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + captureBuffer, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + captureBuffer = dlg.GetPathName(); + + if(dlg.getFilterIndex() == 2) + saveBMP(captureBuffer); + else + savePNG(captureBuffer); +} + +BOOL OamView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_OAM_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_OAM_VIEW_ZOOM, DS_MoveX) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\OamView", + NULL); + m_sprite.SetWindowText("0"); + + updateScrollInfo(); + + m_stretch = regQueryDwordValue("oamViewStretch", 0); + if(m_stretch) + oamView.setStretch(true); + UpdateData(FALSE); + + paint(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void OamView::OnStretch() +{ + oamView.setStretch(!oamView.getStretch()); + paint(); + regSetDwordValue("oamViewStretch", oamView.getStretch()); +} + + +void OamView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void OamView::OnChangeSprite() +{ + CString buffer; + m_sprite.GetWindowText(buffer); + int n = atoi(buffer); + if(n < 0 || n > 127) { + buffer.Format("%d", number); + m_sprite.SetWindowText(buffer); + return; + } + number = n; + paint(); + updateScrollInfo(); +} + +void OamView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +LRESULT OamView::OnMapInfo(WPARAM wParam, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + oamZoom.setColors(colors); + + return TRUE; +} + +LRESULT OamView::OnColInfo(WPARAM wParam, LPARAM lParam) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + +void OamView::updateScrollInfo() +{ + SCROLLINFO si; + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL | SIF_POS; + si.nMin = 0; + si.nMax = 127; + si.nPage = 1; + si.nPos = number; + GetDlgItem(IDC_SCROLLBAR)->SetScrollInfo(SB_CTL, + &si, + TRUE); +} + +void OamView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + switch(nSBCode) { + case SB_BOTTOM: + number = 127; + break; + case SB_LINEDOWN: + number++; + if(number > 127) + number = 127; + break; + case SB_LINEUP: + number--; + if(number < 0) + number = 0; + break; + case SB_PAGEDOWN: + number += 16; + if(number > 127) + number = 127; + break; + case SB_PAGEUP: + number -= 16; + if(number < 0) + number = 0; + break; + case SB_TOP: + number = 0; + break; + case SB_THUMBTRACK: + number = nPos; + if(number < 0) + number = 0; + if(number > 127) + number = 127; + break; + } + + updateScrollInfo(); + + CString buffer; + buffer.Format("%d", number); + m_sprite.SetWindowText(buffer); + paint(); +} + +void OamView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/OamView.h b/src/win32/OamView.h new file mode 100644 index 0000000..dbe770b --- /dev/null +++ b/src/win32/OamView.h @@ -0,0 +1,100 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_) +#define AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// OamView.h : header file +// +#include "BitmapControl.h" +#include "ZoomControl.h" +#include "ColorControl.h" + +#include "IUpdate.h" +#include "ResizeDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// OamView dialog + +class OamView : public ResizeDlg, IUpdateListener +{ + private: + BITMAPINFO bmpInfo; + u8 *data; + int w; + int h; + int number; + bool autoUpdate; + BitmapControl oamView; + ZoomControl oamZoom; + ColorControl color; + + // Construction + public: + void updateScrollInfo(); + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + void savePNG(const char *name); + void saveBMP(const char *name); + void render(); + void setAttributes(u16 a0, u16 a1, u16 a2); + void paint(); + ~OamView(); + OamView(CWnd* pParent = NULL); // standard constructor + + virtual void update(); + // Dialog Data + //{{AFX_DATA(OamView) + enum { IDD = IDD_OAM_VIEW }; + CEdit m_sprite; + BOOL m_stretch; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(OamView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(OamView) + afx_msg void OnSave(); + virtual BOOL OnInitDialog(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnChangeSprite(); + afx_msg void OnClose(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_OAMVIEW_H__E5369352_80F8_49C4_9F23_05EB6FC1345B__INCLUDED_) diff --git a/src/win32/OpenGL.cpp b/src/win32/OpenGL.cpp new file mode 100644 index 0000000..58666e3 --- /dev/null +++ b/src/win32/OpenGL.cpp @@ -0,0 +1,638 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" +#include "MainWnd.h" +#include + +#include "../System.h" +#include "../GBA.h" +#include "../gb/gbGlobals.h" +#include "../Globals.h" +#include "../Text.h" + +#include "Reg.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#ifdef MMX +extern "C" bool cpu_mmx; + +extern bool detectMMX(); +#endif + +extern int Init_2xSaI(u32); +extern void winlog(const char *,...); +extern int systemSpeed; + +class OpenGLDisplay : public IDisplay { +private: + HDC hDC; + HGLRC hglrc; + GLuint texture; + int width; + int height; + float size; + u8 *filterData; + bool failed; + + bool initializeTexture(int w, int h); + void updateFiltering(int); +public: + OpenGLDisplay(); + virtual ~OpenGLDisplay(); + + virtual bool initialize(); + virtual void cleanup(); + virtual void render(); + virtual void checkFullScreen(); + virtual void renderMenu(); + virtual void clear(); + virtual bool changeRenderSize(int w, int h); + virtual void resize(int w, int h); + virtual DISPLAY_TYPE getType() { return OPENGL; }; + virtual void setOption(const char *, int); + virtual int selectFullScreenMode(GUID **); +}; + +OpenGLDisplay::OpenGLDisplay() +{ + hDC = NULL; + hglrc = NULL; + texture = 0; + width = 0; + height = 0; + size = 0.0f; + filterData = (u8 *)malloc(4*4*256*240); + failed = false; +} + +OpenGLDisplay::~OpenGLDisplay() +{ + cleanup(); +} + +void OpenGLDisplay::cleanup() +{ + if(texture != 0) { + glDeleteTextures(1, &texture); + texture = 0; + } + if(hglrc != NULL) { + wglDeleteContext(hglrc); + wglMakeCurrent(NULL, NULL); + hglrc = NULL; + } + if(hDC != NULL) { + ReleaseDC(*theApp.m_pMainWnd, hDC); + hDC = NULL; + } + if(filterData) { + free(filterData); + filterData = NULL; + } + width = 0; + height = 0; + size = 0.0f; +} + +bool OpenGLDisplay::initialize() +{ + theApp.sizeX = 240; + theApp.sizeY = 160; + + switch(theApp.videoOption) { + case VIDEO_1X: + theApp.surfaceSizeX = theApp.sizeX; + theApp.surfaceSizeY = theApp.sizeY; + break; + case VIDEO_2X: + theApp.surfaceSizeX = theApp.sizeX * 2; + theApp.surfaceSizeY = theApp.sizeY * 2; + break; + case VIDEO_3X: + theApp.surfaceSizeX = theApp.sizeX * 3; + theApp.surfaceSizeY = theApp.sizeY * 3; + break; + case VIDEO_4X: + theApp.surfaceSizeX = theApp.sizeX * 4; + theApp.surfaceSizeY = theApp.sizeY * 4; + break; + case VIDEO_320x240: + case VIDEO_640x480: + case VIDEO_800x600: + case VIDEO_OTHER: + { + RECT r; + ::GetWindowRect(GetDesktopWindow(), &r); + theApp.fsWidth = r.right - r.left; + theApp.fsHeight = r.bottom - r.top; + + /* Need to fix this code later. For now, Fullscreen takes the whole + screen. + int scaleX = (fsWidth / sizeX); + int scaleY = (fsHeight / sizeY); + int min = scaleX < scaleY ? scaleX : scaleY; + surfaceSizeX = sizeX * min; + surfaceSizeY = sizeY * min; + if(fullScreenStretch) { + */ + theApp.surfaceSizeX = theApp.fsWidth; + theApp.surfaceSizeY = theApp.fsHeight; + // } + } + break; + } + + theApp.rect.left = 0; + theApp.rect.top = 0; + theApp.rect.right = theApp.sizeX; + theApp.rect.bottom = theApp.sizeY; + + theApp.dest.left = 0; + theApp.dest.top = 0; + theApp.dest.right = theApp.surfaceSizeX; + theApp.dest.bottom = theApp.surfaceSizeY; + + DWORD style = WS_POPUP | WS_VISIBLE; + DWORD styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + style |= WS_OVERLAPPEDWINDOW; + else + styleEx = 0; + + if(theApp.videoOption <= VIDEO_4X) + AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx); + else + AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx); + + int winSizeX = theApp.dest.right-theApp.dest.left; + int winSizeY = theApp.dest.bottom-theApp.dest.top; + + if(theApp.videoOption > VIDEO_4X) { + winSizeX = theApp.fsWidth; + winSizeY = theApp.fsHeight; + } + + int x = 0; + int y = 0; + + if(theApp.videoOption <= VIDEO_4X) { + x = theApp.windowPositionX; + y = theApp.windowPositionY; + } + + // Create a window + MainWnd *pWnd = new MainWnd; + theApp.m_pMainWnd = pWnd; + + pWnd->CreateEx(styleEx, + theApp.wndClass, + "VisualBoyAdvance", + style, + x,y,winSizeX,winSizeY, + NULL, + 0); + + if (!(HWND)*pWnd) { + winlog("Error creating Window %08x\n", GetLastError()); + return FALSE; + } + + theApp.updateMenuBar(); + + theApp.adjustDestRect(); + + theApp.mode320Available = FALSE; + theApp.mode640Available = FALSE; + theApp.mode800Available = FALSE; + + CDC *dc = pWnd->GetDC(); + HDC hDC = dc->GetSafeHdc(); + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd + 1, // version number + PFD_DRAW_TO_WINDOW | // support window + PFD_SUPPORT_OPENGL | // support OpenGL + PFD_DOUBLEBUFFER, // double buffered + PFD_TYPE_RGBA, // RGBA type + 16, // 16-bit color depth + 0, 0, 0, 0, 0, 0, // color bits ignored + 0, // no alpha buffer + 0, // shift bit ignored + 0, // no accumulation buffer + 0, 0, 0, 0, // accum bits ignored + 32, // 32-bit z-buffer + 0, // no stencil buffer + 0, // no auxiliary buffer + PFD_MAIN_PLANE, // main layer + 0, // reserved + 0, 0, 0 // layer masks ignored + }; + int iPixelFormat; + + if(!(iPixelFormat = ChoosePixelFormat(hDC, &pfd))) { + winlog("Failed ChoosePixelFormat\n"); + return false; + } + + // obtain detailed information about + // the device context's first pixel format + if(!(DescribePixelFormat(hDC, iPixelFormat, + sizeof(PIXELFORMATDESCRIPTOR), &pfd))) { + winlog("Failed DescribePixelFormat\n"); + return false; + } + + if(!SetPixelFormat(hDC, iPixelFormat, &pfd)) { + winlog("Failed SetPixelFormat\n"); + return false; + } + + if(!(hglrc = wglCreateContext(hDC))) { + winlog("Failed wglCreateContext\n"); + return false; + } + + if(!wglMakeCurrent(hDC, hglrc)) { + winlog("Failed wglMakeCurrent\n"); + return false; + } + pWnd->ReleaseDC(dc); + + // setup 2D gl environment + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + + glViewport(0, 0, theApp.surfaceSizeX, theApp.surfaceSizeY); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrtho(0.0, (GLdouble)(theApp.surfaceSizeX), (GLdouble)(theApp.surfaceSizeY), + 0.0, 0.0,1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + systemRedShift = 3; + systemGreenShift = 11; + systemBlueShift = 19; + systemColorDepth = 32; + theApp.fsColorDepth = 32; + + Init_2xSaI(32); +#ifdef MMX + if(!theApp.disableMMX) + cpu_mmx = theApp.detectMMX(); + else + cpu_mmx = 0; +#endif + + if(theApp.ddrawDebug) { + winlog("R shift: %d\n", systemRedShift); + winlog("G shift: %d\n", systemGreenShift); + winlog("B shift: %d\n", systemBlueShift); + } + + switch(systemColorDepth) { + case 16: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + case 24: + case 32: + { + for(int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + } + break; + } + theApp.updateFilter(); + theApp.updateIFB(); + + if(failed) + return false; + + pWnd->DragAcceptFiles(TRUE); + + return TRUE; +} + +void OpenGLDisplay::clear() +{ +} + +void OpenGLDisplay::renderMenu() +{ + checkFullScreen(); + if(theApp.m_pMainWnd) + theApp.m_pMainWnd->DrawMenuBar(); +} + +void OpenGLDisplay::checkFullScreen() +{ + // if(tripleBuffering) + // pOpenGL->FlipToGDISurface(); +} + +void OpenGLDisplay::render() +{ + void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = theApp.filterFunction; + int filterWidth = theApp.filterWidth, filterHeight = theApp.filterHeight; +/* + if(textMethod == 1) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + extern void Simple1x(u8*,u32,u8*,u8*,u32,int,int); + filterFunction = Simple1x; + filterWidth = copyX; + filterHeight = copyY; + } +*/ + int pitch = filterWidth * 4 + 4; + u8 *data = pix + (theApp.sizeX+1)*4; + + if(textMethod == 1 && !filterFunction) + { + textMethod = 0; // must not be after systemMessage! + systemMessage(0,"The \"On Game\" text display mode does not work with this combination of renderers and filters.\nThe display mode is automatically being changed to \"In Game\" instead,\nbut this may cause message text to go into AVI recordings and screenshots.\nThis can be reconfigured by choosing \"Options->Video->Text Display Options...\""); + } + + if(textMethod == 0) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + DrawTextMessages((u8*)pix, (copyX+1)*(systemColorDepth/8), 0, copyY); + } + + if(filterFunction) { + data = filterData; + filterFunction(pix+pitch, + pitch, + (u8*)theApp.delta, + (u8*)filterData, + filterWidth*4*2, + filterWidth, + filterHeight); + } + + if(theApp.videoOption > VIDEO_4X && theApp.showSpeed) { + char buffer[30]; + if(theApp.showSpeed == 1) + sprintf(buffer, "%3d%%", systemSpeed); + else + sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + theApp.showRenderedFrames); + + if(filterFunction) { + int p = filterWidth * 4; + if(systemColorDepth == 24) + p = filterWidth * 6; + else if(systemColorDepth == 32) + p = filterWidth * 8; + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)filterData, + p, + 10, + filterHeight*2-10, + buffer); + else + drawText((u8*)filterData, + p, + 10, + filterHeight*2-10, + buffer); + + } else { + if(theApp.showSpeedTransparent) + drawTextTransp((u8*)pix, + pitch, + 10, + filterHeight-10, + buffer); + else + drawText((u8*)pix, + pitch, + 10, + filterHeight-10, + buffer); + } + } + + if(textMethod == 1 && filterFunction) + DrawTextMessages((u8*)filterData, filterWidth*systemColorDepth/4, 0, filterHeight*2); + + + // Texturemap complete texture to surface so we have free scaling + // and antialiasing + int mult = 1; + if(filterFunction) { + glPixelStorei(GL_UNPACK_ROW_LENGTH, 2*theApp.sizeX); + mult = 2; + } else { + glPixelStorei(GL_UNPACK_ROW_LENGTH, theApp.sizeX+1); + } + + glTexSubImage2D( GL_TEXTURE_2D,0, + 0,0, mult*theApp.sizeX,mult*theApp.sizeY, + GL_RGBA,GL_UNSIGNED_BYTE,data); + + if(theApp.glType == 0) { + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(0.0, 0.0); glVertex3i(0, 0, 0); + glTexCoord2f(mult*theApp.sizeX/size, 0.0); glVertex3i(theApp.surfaceSizeX, 0, 0); + glTexCoord2f(0.0, mult*theApp.sizeY/size); glVertex3i(0, theApp.surfaceSizeY, 0); + glTexCoord2f(mult*theApp.sizeX/size, mult*theApp.sizeY/size); glVertex3i(theApp.surfaceSizeX, theApp.surfaceSizeY, 0); + glEnd(); + } else { + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3i(0, 0, 0); + glTexCoord2f(mult*theApp.sizeX/size, 0.0); glVertex3i(theApp.surfaceSizeX, 0, 0); + glTexCoord2f(mult*theApp.sizeX/size, mult*theApp.sizeY/size); glVertex3i(theApp.surfaceSizeX, theApp.surfaceSizeY, 0); + glTexCoord2f(0.0, mult*theApp.sizeY/size); glVertex3i(0, theApp.surfaceSizeY, 0); + glEnd(); + } + + CDC *dc = theApp.m_pMainWnd->GetDC(); + + if(textMethod == 2) + { + for(int slot = 0 ; slot < SCREEN_MESSAGE_SLOTS ; slot++) + { + if(theApp.screenMessage[slot]) + { + if(((int)(GetTickCount() - theApp.screenMessageTime[slot]) < theApp.screenMessageDuration[slot]) && + (!theApp.disableStatusMessage || slot == 1 || slot == 2)) + { + dc->SetBkMode(TRANSPARENT); + + if(outlinedText) + { + dc->SetTextColor(textColor != 7 ? RGB(0,0,0) : RGB(255,255,255)); + // draw black outline + const static int xd [8] = {-1,0,1,1,1,0,-1,-1}; + const static int yd [8] = {-1,-1,-1,0,1,1,1,0}; + for(int i = 0 ; i < 8 ; i++) + { + dc->TextOut(10+xd[i], theApp.surfaceSizeY - 20*(slot+1)+yd[i], theApp.screenMessageBuffer[slot]); + } + } + + COLORREF color; + switch(textColor) + { + case 0: color = RGB(255, 255, 255); break; + case 1: color = RGB(255, 0, 0); break; + case 2: color = RGB(255, 255, 0); break; + case 3: color = RGB(0, 255, 0); break; + case 4: color = RGB(0, 255, 255); break; + case 5: color = RGB(0, 0, 255); break; + case 6: color = RGB(255, 0, 255); break; + case 7: color = RGB(0, 0, 0); break; + } + dc->SetTextColor(color); + + // draw center text + dc->TextOut(10, theApp.surfaceSizeY - 20*(slot+1), theApp.screenMessageBuffer[slot]); + } else { + theApp.screenMessage[slot] = false; + } + } + } + } + + SwapBuffers(dc->GetSafeHdc()); + + theApp.m_pMainWnd->ReleaseDC(dc); +} + +void OpenGLDisplay::resize(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrtho(0.0, (GLdouble)(w), (GLdouble)(h), + 0.0, 0.0,1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void OpenGLDisplay::updateFiltering(int value) +{ + switch(value) { + case 0: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + break; + case 1: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + break; + } +} + +bool OpenGLDisplay::initializeTexture(int w, int h) +{ + int mySize = 256; + size = 256.0f; + if(w > 255 || h > 255) { + size = 512.0f; + mySize = 512; + } + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + + int filter = regQueryDwordValue("glFilter", 0); + if(filter < 0 || filter > 1) + filter = 0; + updateFiltering(filter); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mySize, mySize, 0, GL_RGBA, + GL_UNSIGNED_BYTE, NULL ); + width = w; + height = h; + + return true; +} + +bool OpenGLDisplay::changeRenderSize(int w, int h) +{ + if(width != w || height != h) { + if(texture != 0) { + glDeleteTextures(1, &texture); + texture = 0; + } + if(!initializeTexture(w, h)) { + failed = true; + return false; + } + } + return true; +} + +void OpenGLDisplay::setOption(const char *option, int value) +{ + if(!strcmp(option, "glFilter")) + updateFiltering(value); +} + +int OpenGLDisplay::selectFullScreenMode(GUID **) +{ + HWND wnd = GetDesktopWindow(); + RECT r; + GetWindowRect(wnd, &r); + int w = (r.right - r.left) & 4095; + int h = (r.bottom - r.top) & 4095; + HDC dc = GetDC(wnd); + int c = GetDeviceCaps(dc, BITSPIXEL); + ReleaseDC(wnd, dc); + + return (c << 24) | (w << 12) | h; +} + +IDisplay *newOpenGLDisplay() +{ + return new OpenGLDisplay(); +} + diff --git a/src/win32/PaletteView.cpp b/src/win32/PaletteView.cpp new file mode 100644 index 0000000..29e8a9b --- /dev/null +++ b/src/win32/PaletteView.cpp @@ -0,0 +1,240 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// PaletteView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "PaletteView.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +void GBAPaletteViewControl::updatePalette() +{ + if(paletteRAM != NULL) + memcpy(palette, &paletteRAM[paletteAddress], 512); +} + +///////////////////////////////////////////////////////////////////////////// +// PaletteView dialog + + +PaletteView::PaletteView(CWnd* pParent /*=NULL*/) + : ResizeDlg(PaletteView::IDD, pParent) +{ + //{{AFX_DATA_INIT(PaletteView) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + autoUpdate = false; +} + +PaletteView::~PaletteView() +{ +} + + +void PaletteView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(PaletteView) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_PALETTE_VIEW, paletteView); + DDX_Control(pDX, IDC_PALETTE_VIEW_OBJ, paletteViewOBJ); + DDX_Control(pDX, IDC_COLOR, colorControl); +} + + +BEGIN_MESSAGE_MAP(PaletteView, CDialog) + //{{AFX_MSG_MAP(PaletteView) + ON_BN_CLICKED(IDC_SAVE_BG, OnSaveBg) + ON_BN_CLICKED(IDC_SAVE_OBJ, OnSaveObj) + ON_BN_CLICKED(IDC_REFRESH2, OnRefresh2) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_PALINFO, OnPalInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// PaletteView message handlers + +BOOL PaletteView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_END() + SetData(sz, + FALSE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\PaletteView", + NULL); + + paletteView.setPaletteAddress(0); + paletteView.refresh(); + + paletteViewOBJ.setPaletteAddress(0x200); + paletteViewOBJ.refresh(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void PaletteView::save(int which) +{ + CString captureBuffer; + + if(which == 0) + captureBuffer = "bg.pal"; + else + captureBuffer = "obj.pal"; + + LPCTSTR exts[] = {".pal", ".pal", ".act" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PAL); + CString title = winResLoadString(IDS_SELECT_PALETTE_NAME); + FileDlg dlg(this, + captureBuffer, + filter, + 1, + "PAL", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + PaletteViewControl *p = NULL; + + if(which == 0) + p = &paletteView; + else + p = &paletteViewOBJ; + + switch(dlg.getFilterIndex()) { + case 0: + case 1: + p->saveMSPAL(captureBuffer); + break; + case 2: + p->saveJASCPAL(captureBuffer); + break; + case 3: + p->saveAdobe(captureBuffer); + break; + } +} + +void PaletteView::OnSaveBg() +{ + save(0); +} + +void PaletteView::OnSaveObj() +{ + save(1); +} + +void PaletteView::OnRefresh2() +{ + paletteView.refresh(); + paletteViewOBJ.refresh(); +} + +void PaletteView::update() +{ + OnRefresh2(); +} + + +void PaletteView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + +void PaletteView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + +LRESULT PaletteView::OnPalInfo(WPARAM wParam, LPARAM lParam) +{ + u16 color = (u16)wParam; + u32 address = (u32)lParam; + CString buffer; + + if(address >= 0x200) + address = 0x5000200 + 2*(address & 255); + else + address = 0x5000000 + 2*(address & 255); + + buffer.Format("0x%08X", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + int r = (color & 0x1f); + int g = (color & 0x3e0) >> 5; + int b = (color & 0x7c00) >> 10; + + buffer.Format("%d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("%d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("%d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + buffer.Format("0x%04X", color); + GetDlgItem(IDC_VALUE)->SetWindowText(buffer); + + colorControl.setColor(color); + + if(address >= 0x5000200) { + paletteView.setSelected(-1); + } else + paletteViewOBJ.setSelected(-1); + + return TRUE; +} + +void PaletteView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/PaletteView.h b/src/win32/PaletteView.h new file mode 100644 index 0000000..aee3a4c --- /dev/null +++ b/src/win32/PaletteView.h @@ -0,0 +1,90 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_) +#define AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PaletteView.h : header file +// + +#include "ColorControl.h" +#include "PaletteViewControl.h" +#include "ResizeDlg.h" + +class GBAPaletteViewControl : public PaletteViewControl { + public: + virtual void updatePalette(); +}; + +///////////////////////////////////////////////////////////////////////////// +// PaletteView dialog + +class PaletteView : public ResizeDlg, IUpdateListener +{ + private: + GBAPaletteViewControl paletteView; + GBAPaletteViewControl paletteViewOBJ; + ColorControl colorControl; + bool autoUpdate; + // Construction + public: + void save(int which); + PaletteView(CWnd* pParent = NULL); // standard constructor + ~PaletteView(); + afx_msg LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); + + // Dialog Data + //{{AFX_DATA(PaletteView) + enum { IDD = IDD_PALETTE_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(PaletteView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + virtual void update(); + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(PaletteView) + virtual BOOL OnInitDialog(); + afx_msg void OnSaveBg(); + afx_msg void OnSaveObj(); + afx_msg void OnRefresh2(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_) diff --git a/src/win32/PaletteViewControl.cpp b/src/win32/PaletteViewControl.cpp new file mode 100644 index 0000000..a769d56 --- /dev/null +++ b/src/win32/PaletteViewControl.cpp @@ -0,0 +1,409 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// PaletteViewControl.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "PaletteViewControl.h" + +#include "../Util.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool PaletteViewControl::isRegistered = false; + +///////////////////////////////////////////////////////////////////////////// +// PaletteViewControl + +PaletteViewControl::PaletteViewControl() +{ + memset(&bmpInfo.bmiHeader, 0, sizeof(bmpInfo.bmiHeader)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 256; + bmpInfo.bmiHeader.biHeight = -256; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)malloc(3 * 256 * 256); + + w = 256; + h = 256; + + colors = 256; + + paletteAddress = 0; + + ZeroMemory(palette, 512); + + selected = -1; + registerClass(); +} + +PaletteViewControl::~PaletteViewControl() +{ + if(data) + free(data); +} + + +BEGIN_MESSAGE_MAP(PaletteViewControl, CWnd) + //{{AFX_MSG_MAP(PaletteViewControl) + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() + ON_WM_PAINT() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// PaletteViewControl message handlers + +void PaletteViewControl::init(int c, int w, int h) +{ + this->w = w; + this->h = h; + this->colors = c; + + bmpInfo.bmiHeader.biWidth = w; + bmpInfo.bmiHeader.biHeight = -h; +} + + +bool PaletteViewControl::saveAdobe(const char *name) +{ + FILE *f = fopen(name, "wb"); + + if(!f) + return false; + + for(int i = 0; i < colors; i++) { + u16 c = palette[i]; + int r = (c & 0x1f) << 3; + int g = (c & 0x3e0) >> 2; + int b = (c & 0x7c00) >> 7; + + u8 data[3] = { r, g, b }; + fwrite(data, 1, 3, f); + } + if(colors < 256) { + for(int i = colors; i < 256; i++) { + u8 data[3] = { 0, 0, 0 }; + fwrite(data, 1, 3, f); + } + } + fclose(f); + + return true; +} + + +bool PaletteViewControl::saveMSPAL(const char *name) +{ + FILE *f = fopen(name, "wb"); + + if(!f) + return false; + + u8 data[4] = { 'R', 'I', 'F', 'F' }; + + fwrite(data, 1, 4, f); + utilPutDword(data, 256 * 4 + 16); + fwrite(data, 1, 4, f); + u8 data3[4] = { 'P', 'A', 'L', ' ' }; + fwrite(data3, 1, 4, f); + u8 data4[4] = { 'd', 'a', 't', 'a' }; + fwrite(data4, 1, 4, f); + utilPutDword(data, 256*4+4); + fwrite(data, 1, 4, f); + utilPutWord(&data[0], 0x0300); + utilPutWord(&data[2], 256); // causes problems if not 16 or 256 + fwrite(data, 1, 4, f); + + for(int i = 0; i < colors; i++) { + u16 c = palette[i]; + int r = (c & 0x1f) << 3; + int g = (c & 0x3e0) >> 2; + int b = (c & 0x7c00) >> 7; + + u8 data7[4] = { r, g, b, 0 }; + fwrite(data7, 1, 4, f); + } + if(colors < 256) { + for(int i = colors; i < 256; i++) { + u8 data7[4] = { 0, 0, 0, 0 }; + fwrite(data7, 1, 4, f); + } + } + fclose(f); + + return true; +} + + +bool PaletteViewControl::saveJASCPAL(const char *name) +{ + FILE *f = fopen(name, "wb"); + + if(!f) + return false; + + fprintf(f, "JASC-PAL\r\n0100\r\n256\r\n"); + + for(int i = 0; i < colors; i++) { + u16 c = palette[i]; + int r = (c & 0x1f) << 3; + int g = (c & 0x3e0) >> 2; + int b = (c & 0x7c00) >> 7; + + fprintf(f, "%d %d %d\r\n", r, g, b); + } + if(colors < 256) { + for(int i = colors; i < 256; i++) + fprintf(f, "0 0 0\r\n"); + } + fclose(f); + + return true; +} + +void PaletteViewControl::setPaletteAddress(int address) +{ + paletteAddress = address; +} + + +void PaletteViewControl::setSelected(int s) +{ + selected = s; + InvalidateRect(NULL, FALSE); +} + + +void PaletteViewControl::render(u16 color, int x, int y) +{ + u8 *start = data + y*16*w*3 + x*16*3; + int skip = w*3-16*3; + + int r = (color & 0x1f) << 3; + int g = (color & 0x3e0) >> 2; + int b = (color & 0x7c00) >> 7; + + for(int i = 0; i < 16; i++) { + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + *start++ = b; + *start++ = g; + *start++ = r; + + start += skip; + } +} + +void PaletteViewControl::refresh() +{ + updatePalette(); + int sw = w/16; + int sh = h/16; + for(int i = 0; i < colors; i++) { + render(palette[i], i & (sw-1), i/sw); + } + InvalidateRect(NULL, FALSE); +} + +void PaletteViewControl::OnLButtonDown(UINT nFlags, CPoint point) +{ + int x = point.x; + int y = point.y; + RECT rect; + GetClientRect(&rect); + int h = rect.bottom - rect.top; + int w = rect.right - rect.left; + int sw = (this->w/16); + int sh = (this->h/16); + int mult = w / sw; + int multY = h / sh; + + setSelected(x/mult + (y/multY)*sw); + + GetParent()->SendMessage(WM_PALINFO, + palette[x/mult+(y/multY)*sw], + paletteAddress+(x/mult+(y/multY)*sw)); +} + +BOOL PaletteViewControl::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + + +void PaletteViewControl::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + RECT rect; + GetClientRect(&rect); + int w = rect.right - rect.left; + int h = rect.bottom - rect.top; + + CDC memDC; + memDC.CreateCompatibleDC(&dc); + CBitmap bitmap, *pOldBitmap; + bitmap.CreateCompatibleBitmap(&dc, w, h); + pOldBitmap = memDC.SelectObject(&bitmap); + + StretchDIBits(memDC.GetSafeHdc(), + 0, + 0, + w, + h, + 0, + 0, + this->w, + this->h, + data, + &bmpInfo, + DIB_RGB_COLORS, + SRCCOPY); + int sw = this->w / 16; + int sh = this->h / 16; + int mult = w / sw; + int multY = h / sh; + CPen pen; + pen.CreatePen(PS_SOLID, 1, RGB(192,192,192)); + CPen *old = memDC.SelectObject(&pen); + int i; + for(i = 1; i < sh; i++) { + memDC.MoveTo(0, i * multY); + memDC.LineTo(w, i * multY); + } + for(i = 1; i < sw; i++) { + memDC.MoveTo(i * mult, 0); + memDC.LineTo(i * mult, h); + } + memDC.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); + memDC.SelectObject(old); + pen.DeleteObject(); + + if(selected != -1) { + pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); + old = memDC.SelectObject(&pen); + + int startX = (selected & (sw-1))*mult+1; + int startY = (selected / sw)*multY+1; + int endX = startX + mult-2; + int endY = startY + multY-2; + + memDC.MoveTo(startX, startY); + memDC.LineTo(endX, startY); + memDC.LineTo(endX, endY); + memDC.LineTo(startX, endY); + memDC.LineTo(startX, startY-1); + + memDC.SelectObject(old); + pen.DeleteObject(); + } + + dc.BitBlt(0,0,w,h, + &memDC,0,0,SRCCOPY); + + memDC.SelectObject(pOldBitmap); + bitmap.DeleteObject(); + memDC.DeleteDC(); +} + +void PaletteViewControl::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaPaletteViewControl"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} diff --git a/src/win32/PaletteViewControl.h b/src/win32/PaletteViewControl.h new file mode 100644 index 0000000..a7c8922 --- /dev/null +++ b/src/win32/PaletteViewControl.h @@ -0,0 +1,90 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_) +#define AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PaletteViewControl.h : header file +// +#define WM_PALINFO WM_APP+1 + +///////////////////////////////////////////////////////////////////////////// +// PaletteViewControl window + +class PaletteViewControl : public CWnd +{ + int w; + int h; + int colors; + u8 *data; + BITMAPINFO bmpInfo; + static bool isRegistered; + int selected; + protected: + u16 palette[256]; + int paletteAddress; + // Construction + public: + PaletteViewControl(); + + virtual void updatePalette()=0; + + // Attributes + public: + + // Operations + public: + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(PaletteViewControl) + //}}AFX_VIRTUAL + + // Implementation + public: + void registerClass(); + void refresh(); + void render(u16 color, int x, int y); + void setSelected(int s); + void setPaletteAddress(int address); + bool saveJASCPAL(const char *name); + bool saveMSPAL(const char *name); + bool saveAdobe(const char *name); + void init(int c, int w, int h); + virtual ~PaletteViewControl(); + + // Generated message map functions + protected: + //{{AFX_MSG(PaletteViewControl) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PALETTEVIEWCONTROL_H__31F600AE_B7E5_4F6C_80B6_55E4B61FBD57__INCLUDED_) diff --git a/src/win32/PerfTimer.cpp b/src/win32/PerfTimer.cpp new file mode 100644 index 0000000..e886681 --- /dev/null +++ b/src/win32/PerfTimer.cpp @@ -0,0 +1,35 @@ +// CPerfTimer - a simple Win32 performance counter wrapper +// by Dean Wyant dwyant@mindspring.com + +#include "stdafx.h" +#include "PerfTimer.h" + +// Declare and initialize static member vars that get set only once and never change +__int64 CPerfTimer::m_Freq = 0; +__int64 CPerfTimer::m_Adjust = 0; + +// All functions defined inline for speed. After all, the performance counter is +// supposed to be able to time very short events fairly accurately. + + + +BOOL CPerfTimer::IsSupported() +{ // Returns FALSE if performance counter not supported. + // Call after constructing at least one CPerfTimer + return (m_Freq > 1); +} + +const double CPerfTimer::Resolution() +{ // Returns timer resolution in seconds + return 1.0/(double)m_Freq; +} + +const double CPerfTimer::Resolutionms() +{ // Returns timer resolution in milliseconds + return 1000.0/(double)m_Freq; +} + +const double CPerfTimer::Resolutionus() +{ // Returns timer resolution in microseconds + return 1000000.0/(double)m_Freq; +} diff --git a/src/win32/PerfTimer.h b/src/win32/PerfTimer.h new file mode 100644 index 0000000..e97887e --- /dev/null +++ b/src/win32/PerfTimer.h @@ -0,0 +1,403 @@ +// CPerfTimer - a simple Win32 performance counter wrapper +// by Dean Wyant dwyant@mindspring.com + +/* + +This class is simple to use. Just declare a variable(s) as type CPerfTimer, +call Start() to start timimg and call Stop() to stop timimg. You can pause a +timer by calling Stop() and then you can call Start() to resume. Retrieve the +elapsed time by calling an Elapsed..() function. Assignment, addition, +subtraction and comparison are supported. There are a few information calls +available also. All calls except Start and Stop can be performed on a timer +without stopping it. + +*/ + +#ifndef __PERFTIMER_H__ +#define __PERFTIMER_H__ + +class CPerfTimer +{ +public: + CPerfTimer(BOOL bStart = FALSE) {Init(bStart);} + + CPerfTimer(const CPerfTimer& Src); + + virtual ~CPerfTimer() {;} + + void Start(BOOL bReset = FALSE); // Start from current value or optionally from 0 + void Stop(); // Stop timing. Use Start afterwards to continue. + + BOOL IsRunning(); // Returns FALSE if stopped. + + BOOL IsSupported(); // Returns FALSE if performance counter not supported. + // Call after constructing at least one CPerfTimer + + const double Resolution(); // Returns timer resolution in seconds + const double Resolutionms(); // Returns timer resolution in milliseconds + const double Resolutionus(); // Returns timer resolution in microseconds + + const double Elapsed(); // Returns elapsed time in seconds + const double Elapsedms(); // Returns elapsed time in milliseconds + const double Elapsedus(); // Returns elapsed time in microseconds + + const CPerfTimer& operator=(const CPerfTimer& Src); // Assignment operator + + // Math operators + CPerfTimer operator+(const CPerfTimer& Src) const; + CPerfTimer operator-(const CPerfTimer& Src) const; + const CPerfTimer& operator+=(const CPerfTimer& Src); + const CPerfTimer& operator-=(const CPerfTimer& Src); + // For time in seconds + CPerfTimer operator+(const double Secs) const; + CPerfTimer operator-(const double Secs) const; + const CPerfTimer& operator+=(const double Secs); + const CPerfTimer& operator-=(const double Secs); + + // Boolean comparison operators + BOOL operator<(const CPerfTimer& Src); + BOOL operator>(const CPerfTimer& Src); + BOOL operator<=(const CPerfTimer& Src); + BOOL operator>=(const CPerfTimer& Src); + // For time in seconds + BOOL operator<(const double Secs); + BOOL operator>(const double Secs); + BOOL operator<=(const double Secs); + BOOL operator>=(const double Secs); + + virtual void Lock() const {;} // Override for thread safe operation + virtual void Unlock() const {;} // Override for thread safe operation +protected: + void Init(BOOL bStart); + void Copy(const CPerfTimer& Src); + +private: + __int64 m_Start; + static __int64 m_Freq; // does not change while system is running + static __int64 m_Adjust; // Adjustment time it takes to Start and Stop +}; + +class CPerfTimerT : public CPerfTimer +{ // You only need to use types of this class if a timer is going to be shared between threads +public: + CPerfTimerT(BOOL bStart = FALSE) + { + m_hMutex = CreateMutex(NULL,FALSE,""); + Init(bStart); + } + + CPerfTimerT(const CPerfTimerT& Src) + { + m_hMutex = CreateMutex(NULL,FALSE,""); + Copy(Src); + } + + CPerfTimerT(const CPerfTimer& Src) + { + m_hMutex = CreateMutex(NULL,FALSE,""); + Copy(Src); + } + + virtual ~CPerfTimerT() + { CloseHandle(m_hMutex); } + + const CPerfTimerT& operator=(const CPerfTimerT& Src) // Assignment operator + { + Copy(Src); + return *this; + } + + virtual void Lock() const { WaitForSingleObject(m_hMutex,10000); } + virtual void Unlock() const { ReleaseMutex(m_hMutex); } +private: + HANDLE m_hMutex; +}; + +inline void CPerfTimer::Init(BOOL bStart) +{ + if (!m_Freq) + { // Initialization should only run once + QueryPerformanceFrequency((LARGE_INTEGER *)&m_Freq); + if (!m_Freq) + m_Freq = 1; // Timer will be useless but will not cause divide by zero + m_Start = 0; + m_Adjust = 0; + Start(); // Time a Stop + Stop(); + m_Adjust = m_Start; + } + // This is the only part that normally runs + m_Start = 0; + if (bStart) + Start(); +} + +inline CPerfTimer::CPerfTimer(const CPerfTimer& Src) +{ + Copy(Src); +} + +inline void CPerfTimer::Copy(const CPerfTimer& Src) +{ + if (&Src == this) + return; // avoid deadlock if someone tries to copy it to itself + Src.Lock(); + Lock(); + m_Start = Src.m_Start; + Unlock(); + Src.Unlock(); +} + +inline void CPerfTimer::Start(BOOL bReset) +{ // Start from current value or optionally from 0 + __int64 i; + QueryPerformanceCounter((LARGE_INTEGER *)&i); + Lock(); + if ((!bReset) && (m_Start < 0)) + m_Start += i; // We are starting with an accumulated time + else + m_Start = i; // Starting from 0 + Unlock(); +} + +inline void CPerfTimer::Stop() +{ // Stop timing. Use Start afterwards to continue + Lock(); + if (m_Start <= 0) + { + Unlock(); + return; // Was not running + } + __int64 i; + QueryPerformanceCounter((LARGE_INTEGER *)&i); + m_Start += -i; // Stopped timer keeps elapsed timer ticks as a negative + if (m_Start < m_Adjust) // Do not overflow + m_Start -= m_Adjust; // Adjust for time timer code takes to run + else + m_Start = 0; // Stop must have been called directly after Start + Unlock(); +} + +inline BOOL CPerfTimer::IsRunning() +{ // Returns FALSE if stopped. + Lock(); + BOOL bRet = (m_Start > 0); // When < 0, holds elpased clicks + Unlock(); + return bRet; +} +inline const double CPerfTimer::Elapsed() +{ // Returns elapsed time in seconds + CPerfTimer Result(*this); + Result.Stop(); + return (double)(-Result.m_Start)/(double)m_Freq; +} + +inline const double CPerfTimer::Elapsedms() +{ // Returns elapsed time in milliseconds + CPerfTimer Result(*this); + Result.Stop(); + return (-Result.m_Start*1000.0)/(double)m_Freq; +} + +inline const double CPerfTimer::Elapsedus() +{ // Returns elapsed time in microseconds + CPerfTimer Result(*this); + + return (-Result.m_Start * 1000000.0)/(double)m_Freq; +} + + +// Assignment operator +inline const CPerfTimer& CPerfTimer::operator=(const CPerfTimer& Src) +{ + Copy(Src); + return *this; +} + + +// Math operators +inline CPerfTimer CPerfTimer::operator+(const CPerfTimer& Src) const +{ + CPerfTimer Result(*this); + Result += Src; + return Result; +} + +inline CPerfTimer CPerfTimer::operator-(const CPerfTimer& Src) const +{ + CPerfTimer Result(*this); + Result -= Src; + return Result; +} + +inline const CPerfTimer& CPerfTimer::operator+=(const CPerfTimer& Src) +{ + CPerfTimer SrcStop(Src); // Temp is necessary in case Src is not stopped + SrcStop.Stop(); + Lock(); + m_Start += SrcStop.m_Start; + Unlock(); + return *this; +} + +inline const CPerfTimer& CPerfTimer::operator-=(const CPerfTimer& Src) +{ + CPerfTimer SrcStop(Src); // Temp is necessary in case Src is not stopped + SrcStop.Stop(); + Lock(); + m_Start -= SrcStop.m_Start; + Unlock(); + return *this; +} + +// For time in seconds +inline CPerfTimer CPerfTimer::operator+(const double Secs) const +{ + CPerfTimer Result(*this); + Result += Secs; + return Result; +} + +inline CPerfTimer CPerfTimer::operator-(const double Secs) const +{ + CPerfTimer Result(*this); + Result += Secs; + return Result; +} + +inline const CPerfTimer& CPerfTimer::operator+=(const double Secs) +{ + Lock(); + m_Start -= (__int64)(Secs*(double)m_Freq); + Unlock(); + return *this; +} + +inline const CPerfTimer& CPerfTimer::operator-=(const double Secs) +{ + Lock(); + m_Start += (__int64)(Secs*(double)m_Freq); + Unlock(); + return *this; +} + + + +// Boolean comparison operators +inline BOOL CPerfTimer::operator<(const CPerfTimer& Src) +{ + BOOL bRet; + CPerfTimer Temp(Src); + Lock(); + if (m_Start <= 0) + { + Temp.Stop(); + bRet = (m_Start > Temp.m_Start); + Unlock(); + return bRet; + } + else + if (Temp.m_Start > 0) + { + bRet = (m_Start < Temp.m_Start); + Unlock(); + return bRet; + } + else + { + Unlock(); + CPerfTimer ThisStop(*this); + ThisStop.Stop(); + return (ThisStop.m_Start > Temp.m_Start); + } +} + +inline BOOL CPerfTimer::operator>(const CPerfTimer& Src) +{ + BOOL bRet; + CPerfTimer Temp(Src); + Lock(); + if (m_Start <= 0) + { + Temp.Stop(); + bRet = (m_Start < Temp.m_Start); + Unlock(); + return bRet; + } + else + if (Temp.m_Start > 0) + { + bRet = (m_Start > Temp.m_Start); + Unlock(); + return bRet; + } + else + { + Unlock(); + CPerfTimer ThisStop(*this); + ThisStop.Stop(); + return (ThisStop.m_Start < Temp.m_Start); + } +} + +inline BOOL CPerfTimer::operator<=(const CPerfTimer& Src) +{ + return !(*this > Src); +} + +inline BOOL CPerfTimer::operator>=(const CPerfTimer& Src) +{ + return !(*this < Src); +} + +// For time in seconds +inline BOOL CPerfTimer::operator<(const double Secs) +{ + BOOL bRet; + Lock(); + if (m_Start <= 0) + { + bRet = (m_Start > (__int64)(-Secs*(double)m_Freq)); + Unlock(); + return bRet; + } + else + { + Unlock(); + CPerfTimer ThisStop(*this); + ThisStop.Stop(); + return (ThisStop.m_Start > (__int64)(-Secs*(double)m_Freq)); + } +} + +inline BOOL CPerfTimer::operator>(const double Secs) +{ + BOOL bRet; + Lock(); + if (m_Start <= 0) + { + bRet = (m_Start < (__int64)(-Secs*(double)m_Freq)); + Unlock(); + return bRet; + } + else + { + Unlock(); + CPerfTimer ThisStop(*this); + ThisStop.Stop(); + return (ThisStop.m_Start < (__int64)(-Secs*(double)m_Freq)); + } +} + +inline BOOL CPerfTimer::operator<=(const double Secs) +{ + return !(*this > Secs); +} + +inline BOOL CPerfTimer::operator>=(const double Secs) +{ + return !(*this < Secs); +} + + +#endif //__PERFTIMER_H__ \ No newline at end of file diff --git a/src/win32/Reg.cpp b/src/win32/Reg.cpp new file mode 100644 index 0000000..c0014b3 --- /dev/null +++ b/src/win32/Reg.cpp @@ -0,0 +1,369 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" + +static char buffer[2048]; +static HKEY vbKey = NULL; +static CString regVbaPath; + +#define VBA_PREF "preferences" + +bool regEnabled = true; + +void regInit(const char *path) +{ + DWORD disp = 0; + LONG res = RegCreateKeyEx(HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance", + 0, + "", + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &vbKey, + &disp); + regVbaPath.Format("%s\\vba.ini", path); +} + +void regShutdown() +{ + LONG res = RegCloseKey(vbKey); +} + +const char *regGetINIPath() +{ + return regVbaPath; +} + +char *regQueryStringValue(const char * key, char *def) +{ + if(regEnabled) { + DWORD type = 0; + DWORD size = 2048; + + LONG res = RegQueryValueEx(vbKey, + key, + NULL, + &type, + (UCHAR *)buffer, + &size); + + if(res == ERROR_SUCCESS && type == REG_SZ) + return buffer; + + return def; + } + + DWORD res = GetPrivateProfileString(VBA_PREF, + key, + def, + (LPTSTR)buffer, + 2048, + regVbaPath); + + if(res) + return buffer; + + return def; +} + +DWORD regQueryDwordValue(const char * key, DWORD def, bool force) +{ + if(regEnabled || force) { + DWORD type = 0; + DWORD size = sizeof(DWORD); + DWORD result = 0; + + LONG res = RegQueryValueEx(vbKey, + key, + NULL, + &type, + (UCHAR *)&result, + &size); + + if(res == ERROR_SUCCESS && type == REG_DWORD) + return result; + + return def; + } + + return GetPrivateProfileInt(VBA_PREF, + key, + def, + regVbaPath); +} + +BOOL regQueryBinaryValue(const char * key, char *value, int count) +{ + if(regEnabled) { + DWORD type = 0; + DWORD size = count; + DWORD result = 0; + + + LONG res = RegQueryValueEx(vbKey, + key, + NULL, + &type, + (UCHAR *)value, + &size); + + if(res == ERROR_SUCCESS && type == REG_BINARY) + return TRUE; + + return FALSE; + } + CString k = key; + k += "Count"; + int size = GetPrivateProfileInt(VBA_PREF, + k, + -1, + regVbaPath); + if(size >= 0 && size < count) + count = size; + return GetPrivateProfileStruct(VBA_PREF, + key, + value, + count, + regVbaPath); +} + +void regSetStringValue(const char * key, const char * value) +{ + if(regEnabled) { + LONG res = RegSetValueEx(vbKey, + key, + NULL, + REG_SZ, + (const UCHAR *)value, + strlen(value)+1); + } else { + WritePrivateProfileString(VBA_PREF, + key, + value, + regVbaPath); + } +} + +void regSetDwordValue(const char * key, DWORD value, bool force) +{ + if(regEnabled || force) { + LONG res = RegSetValueEx(vbKey, + key, + NULL, + REG_DWORD, + (const UCHAR *)&value, + sizeof(DWORD)); + } else { + wsprintf(buffer, "%u", value); + WritePrivateProfileString(VBA_PREF, + key, + buffer, + regVbaPath); + } +} + +void regSetBinaryValue(const char *key, char *value, int count) +{ + if(regEnabled) { + LONG res = RegSetValueEx(vbKey, + key, + NULL, + REG_BINARY, + (const UCHAR *)value, + count); + } else { + CString k = key; + k += "Count"; + wsprintf(buffer, "%u", count); + + WritePrivateProfileString(VBA_PREF, + k, + buffer, + regVbaPath); + + WritePrivateProfileStruct(VBA_PREF, + key, + value, + count, + regVbaPath); + } +} + +void regDeleteValue(char *key) +{ + if(regEnabled) { + LONG res = RegDeleteValue(vbKey, + key); + } else { + WritePrivateProfileString(VBA_PREF, + key, + NULL, + regVbaPath); + } +} + +bool regCreateFileType(const char *ext, const char *type) +{ + DWORD disp = 0; + HKEY key; + LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT, + ext, + 0, + "", + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &key, + &disp); + if(res == ERROR_SUCCESS) { + res = RegSetValueEx(key, + "", + 0, + REG_SZ, + (const UCHAR *)type, + strlen(type)+1); + RegCloseKey(key); + return true; + } + return false; +} + +bool regAssociateType(const char *type, const char *desc, const char *application) +{ + DWORD disp = 0; + HKEY key; + LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT, + type, + 0, + "", + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &key, + &disp); + if(res == ERROR_SUCCESS) { + res = RegSetValueEx(key, + "", + 0, + REG_SZ, + (const UCHAR *)desc, + strlen(desc)+1); + HKEY key2; + res = RegCreateKeyEx(key, + "Shell\\Open\\Command", + 0, + "", + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &key2, + &disp); + if(res == ERROR_SUCCESS) { + res = RegSetValueEx(key2, + "", + 0, + REG_SZ, + (const UCHAR *)application, + strlen(application)+1); + RegCloseKey(key2); + RegCloseKey(key); + return true; + } + + RegCloseKey(key); + } + return false; +} + +static void regExportSettingsToINI(HKEY key, const char *section) +{ + char valueName[256]; + int index = 0; + while(1) { + DWORD nameSize = 256; + DWORD size = 2048; + DWORD type; + LONG res = RegEnumValue(key, + index, + valueName, + &nameSize, + NULL, + &type, + (LPBYTE)buffer, + &size); + + if(res == ERROR_SUCCESS) { + switch(type) { + case REG_DWORD: + { + char temp[256]; + wsprintf(temp, "%u", *((DWORD *)buffer)); + WritePrivateProfileString(section, + valueName, + temp, + regVbaPath); + } + break; + case REG_SZ: + WritePrivateProfileString(section, + valueName, + buffer, + regVbaPath); + break; + case REG_BINARY: + { + char temp[256]; + + wsprintf(temp, "%u", size); + CString k = valueName; + k += "Count"; + WritePrivateProfileString(section, + k, + temp, + regVbaPath); + WritePrivateProfileStruct(section, + valueName, + buffer, + size, + regVbaPath); + } + break; + } + index++; + } else + break; + } +} + +void regExportSettingsToINI() +{ + if(vbKey != NULL) { + regExportSettingsToINI(vbKey, VBA_PREF); + } + + HKEY key; + + if(RegOpenKey(HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer", &key) == + ERROR_SUCCESS) { + regExportSettingsToINI(key, "Viewer"); + RegCloseKey(key); + } +} diff --git a/src/win32/Reg.h b/src/win32/Reg.h new file mode 100644 index 0000000..7d3350e --- /dev/null +++ b/src/win32/Reg.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_REG_H +#define VBA_REG_H + +extern bool regEnabled; + +char *regQueryStringValue(const char *key, char *def); +DWORD regQueryDwordValue(const char *key, DWORD def, bool force=false); +BOOL regQueryBinaryValue(const char *key, char *value, int count); +void regSetStringValue(const char *key,const char *value); +void regSetDwordValue(const char *key,DWORD value,bool force=false); +void regSetBinaryValue(const char *key, char *value, int count); +void regDeleteValue(char *key); +void regInit(const char *); +void regShutdown(); +bool regCreateFileType(const char *ext, const char *type); +bool regAssociateType(const char *type, const char *desc, const char *application); +void regExportSettingsToINI(); +#endif // VBA_REG_H diff --git a/src/win32/ResizeDlg.cpp b/src/win32/ResizeDlg.cpp new file mode 100644 index 0000000..bee5823 --- /dev/null +++ b/src/win32/ResizeDlg.cpp @@ -0,0 +1,561 @@ +/*---------------------------------------------------------------------- + Copyright (c) Gipsysoft. All Rights Reserved. + File: DialogSizer_Set.cpp + Web site: http://gipsysoft.com + + This software is provided 'as-is', without any express or implied warranty. + + In no event will the author 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 is requested but not required. + 2) Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. Altered source is encouraged + to be submitted back to the original author so it can be shared with the + community. Please share your changes. + 3) This notice may not be removed or altered from any source distribution. + + Owner: russf@gipsysoft.com + Purpose: Main functionality for sizeable dialogs + + Store a local copy of the user settings + Subclass the window + Respond to various messages withinn the subclassed window. + + ----------------------------------------------------------------------*/ +#include "stdafx.h" +#include "VBA.h" +#include "ResizeDlg.h" +#undef ASSERT +#include "WinHelper.h" + +// moved functions to this file to reduce number of files + +struct RegistryData +{ + WINDOWPLACEMENT m_wpl; +}; + + +struct DialogData // dd +{ + HKEY hkRootSave; + LPCTSTR pcszName; + + // + // The number of items contained in the psd member. + // Used in the DeferWindowPos structure and in allocating memory + int nItemCount; + DialogSizerSizingItem *psd; + + // + // We need the smallest to respond to the WM_GETMINMAXINFO message + POINT m_ptSmallest; + + // + // We don't strictly speaking need to say how big the biggest can be but + POINT m_ptLargest; + bool m_bLargestSet; + + // + // we need this to decide how much the window has changed size when we get a WM_SIZE message + SIZE m_sizeClient; + + // + // Draw the sizing grip...or not + bool m_bMaximised; + BOOL m_bShowSizingGrip; + + WinHelper::CRect m_rcGrip; +}; + +extern bool regEnabled; +extern const char *regGetINIPath(); + +void AssertFailed(char *file, int line, char *exp) +{ + char buffer[1024]; + + sprintf(buffer, "File %s\nLine %d\nExpression %s\nPress Retry to debug", + file, line, exp); + int res = MessageBox(*theApp.m_pMainWnd, buffer, "Assertion failed!", + MB_ICONHAND | MB_SETFOREGROUND | MB_TASKMODAL | + MB_ABORTRETRYIGNORE); + + if(res == IDRETRY) { + __asm int 3; + } else if(res == IDABORT) + SendMessage(*theApp.m_pMainWnd, WM_QUIT, 0, 0); +} + +void ApiFailure(char *pcszFilename, int nLine, char *pcszExpression ) +{ + const DWORD dwLastError = ::GetLastError(); + LPCTSTR lpMsgBuf; + (void)::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, dwLastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, 0, NULL ); + + char szExeName[ MAX_PATH ]; + + if( !GetModuleFileName( NULL, szExeName, countof( szExeName ) ) ) + strcpy( szExeName, "" ); + + + char szMessage[ 1024 ]; + _snprintf( szMessage, countof( szMessage ) + , "API VERIFY Failure!" + "\nProgram: %s" + "\n" + "\nFile %s" + "\nLine %d" + "\n" + "\nExpression %s" + "\n" + "\nLast Error %d" + "\n %s" + "\n\nPress Retry to debug the application" + , szExeName + , pcszFilename + , nLine + , pcszExpression + , dwLastError + , lpMsgBuf + ); + + (void)LocalFree( (LPVOID)lpMsgBuf ); + HWND hwndParent = ::GetActiveWindow(); + hwndParent = ::GetLastActivePopup( hwndParent ); + int nCode = ::MessageBoxA( hwndParent, + szMessage, + "Debug Helper", + MB_TASKMODAL | MB_ICONHAND | MB_ABORTRETRYIGNORE | + MB_SETFOREGROUND ); + if(nCode == IDABORT) { + ::SendMessage(*theApp.m_pMainWnd, WM_QUIT, 0, 0); + } else if(nCode == IDRETRY) + __asm int 3; +} + +long FASTCALL RegQueryValueExRecursive( HKEY hKey, LPCTSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData ) +{ + TCHAR szBuffer[ 256 ]; + R_ASSERT( lstrlen( lpValueName ) < countof( szBuffer ) ); + (void)lstrcpy( szBuffer, lpValueName ); + + LPTSTR pszBuffer = szBuffer; + LPTSTR pszLast = szBuffer; + while( *pszBuffer ) + { + if( *pszBuffer == _T('\\') || *pszBuffer == _T('/') ) + { + pszLast = pszBuffer; + lpValueName = pszLast + 1; + } + pszBuffer++; + } + + if(!regEnabled) { + if(GetPrivateProfileStruct("Viewer", + lpValueName, + lpData, + *lpcbData, + regGetINIPath())) { + *lpType = REG_BINARY; + return ERROR_SUCCESS; + } + return -1; + } + + bool m_bNeedToCloseKey = false; + if( pszLast != szBuffer ) + { + *pszLast = _T('\000'); + HKEY hkeyTemp; + long lRet = RegOpenKey( hKey, szBuffer, &hkeyTemp ); + if( lRet != ERROR_SUCCESS ) + { + return lRet; + } + hKey = hkeyTemp; + m_bNeedToCloseKey = true; + } + + long lRet = RegQueryValueEx( hKey, lpValueName, lpReserved, lpType, lpData, lpcbData ); + if( m_bNeedToCloseKey ) + { + R_VERIFY( RegCloseKey( hKey ) == ERROR_SUCCESS ); + } + return lRet; +} + +long FASTCALL RegSetValueExRecursive( HKEY hKey, LPCTSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE* lpData, DWORD cbData ) +{ + TCHAR szBuffer[ 256 ]; + R_ASSERT( lstrlen( lpValueName ) < countof( szBuffer ) ); + (void)lstrcpy( szBuffer, lpValueName ); + + LPTSTR pszBuffer = szBuffer; + LPTSTR pszLast = szBuffer; + while( *pszBuffer ) + { + if( *pszBuffer == _T('\\') || *pszBuffer == _T('/') ) + { + pszLast = pszBuffer; + lpValueName = pszLast + 1; + } + pszBuffer++; + } + + if(!regEnabled) { + if(WritePrivateProfileStruct("Viewer", + lpValueName, + (LPVOID)lpData, + cbData, + regGetINIPath())) { + return ERROR_SUCCESS; + } + return -1; + } + + bool m_bNeedToCloseKey = false; + if( pszLast != szBuffer ) + { + *pszLast = _T('\000'); + HKEY hkeyTemp; + long lRet = RegOpenKey( hKey, szBuffer, &hkeyTemp ); + if( lRet != ERROR_SUCCESS ) + { + lRet = RegCreateKey( hKey, szBuffer, &hkeyTemp ); + if( lRet != ERROR_SUCCESS ) + return lRet; + } + hKey = hkeyTemp; + m_bNeedToCloseKey = true; + } + + long lRet = RegSetValueEx( hKey, lpValueName, Reserved, dwType, lpData, cbData ); + if( m_bNeedToCloseKey ) + { + R_VERIFY( RegCloseKey( hKey ) == ERROR_SUCCESS ); + } + return lRet; +} + + +int ResizeDlgGetItemCount(const DialogSizerSizingItem *psd) +{ + R_ASSERT( psd ); + int nCount = 0; + while( psd->uSizeInfo != 0xFFFFFFFF ) + { + nCount++; + psd++; + } + return nCount; +} + +void ResizeDlgUpdateGripperRect( const int cx, const int cy, WinHelper::CRect &rcGrip ) +{ + const int nGripWidth = GetSystemMetrics( SM_CYVSCROLL ); + const int nGripHeight = GetSystemMetrics( SM_CXVSCROLL ); + rcGrip.left = cx - nGripWidth; + rcGrip.top = cy - nGripHeight; + rcGrip.right = cx; + rcGrip.bottom = cy; +} + +void ResizeDlgUpdateGripper( HWND hwnd, DialogData *pdd ) +{ + if( pdd->m_bShowSizingGrip ) + { + WinHelper::CRect rcOld( pdd->m_rcGrip ); + + ResizeDlgUpdateGripperRect( pdd->m_sizeClient.cx, pdd->m_sizeClient.cy, pdd->m_rcGrip ); + + // + // We also need to invalidate the combined area of the old and new rectangles + // otherwise we would have trail of grippers when we sized the dialog larger + // in any axis + (void)UnionRect( &rcOld, &rcOld, &pdd->m_rcGrip ); + (void)InvalidateRect( hwnd, &rcOld, TRUE ); + } +} + +void ResizeDlgCopyItems( DialogSizerSizingItem *psdDest, const DialogSizerSizingItem *psdSource ) + // + // Will copy all of the items in psdSource into psdDest. +{ + // + // Loop til we reach the end + while( psdSource->uSizeInfo != 0xFFFFFFFF ) + { + *psdDest = *psdSource; + psdDest++; + psdSource++; + } + // And when we do copy the last item + *psdDest = *psdSource; +} + + +ResizeDlg::ResizeDlg(UINT id, CWnd *parent) + : CDialog(id, parent) +{ + dd = NULL; +} + +void *ResizeDlg::AddDialogData() + // + // Firstly determine if the data already exists, if it does then return that, if not then we will + // create and initialise a brand new structure. +{ + DialogData *pdd = (DialogData*)dd; + if( !pdd ) { + pdd = (DialogData *)calloc(1, sizeof(DialogData)); + } + + if( pdd ) { + // + // Store some sizes etc. for later. + CRect rc; + GetWindowRect( rc ); + pdd->m_ptSmallest.x = rc.Width(); + pdd->m_ptSmallest.y = rc.Height(); + + + GetClientRect( rc ); + pdd->m_sizeClient = rc.Size(); + dd = pdd; + ResizeDlgUpdateGripperRect( pdd->m_sizeClient.cx, pdd->m_sizeClient.cy, pdd->m_rcGrip ); + } + return pdd; +} + +BOOL ResizeDlg::SetData(const DialogSizerSizingItem *psd, + BOOL bShowSizingGrip, + HKEY hkRootSave, + LPCTSTR pcszName, + SIZE *psizeMax) + // + // Setting a dialog sizeable involves subclassing the window and handling it's + // WM_SIZE messages, if we have a hkRootSave and pcszName then we will also be loading/saving + // the size and position of the window from the registry. We load from the registry when we + // subclass the window and we save to the registry when we get a WM_DESTROY. + // + // It will return non-zero for success and zero if it fails +{ + R_ASSERT( psd ); + R_ASSERT( ( hkRootSave != NULL && pcszName != NULL ) + || ( hkRootSave == NULL && pcszName == NULL ) ); + // + // Make sure all of the parameters are valid. + if( ::IsWindow( *this ) + && psd + && ( ( hkRootSave != NULL && pcszName != NULL && + !IsBadStringPtr( pcszName, 0xFFFF ) ) || + ( hkRootSave == NULL && pcszName == NULL ) ) + && ( psizeMax == NULL || !IsBadReadPtr( psizeMax, sizeof( SIZE ) ) ) + ) { + DialogData *pdd = (DialogData *)AddDialogData(); + if( pdd ) { + pdd->hkRootSave = hkRootSave; + pdd->pcszName = pcszName; + pdd->m_bShowSizingGrip = bShowSizingGrip; + pdd->nItemCount = ResizeDlgGetItemCount( psd ) + 1; + pdd->psd = (DialogSizerSizingItem *) + calloc(pdd->nItemCount, + sizeof(DialogSizerSizingItem )); + if( pdd->psd ) { + // + // Copy all of the user controls etc. for later, this way the user can quite happily + // let the structure go out of scope. + ResizeDlgCopyItems( pdd->psd, psd ); + if( psizeMax ) { + pdd->m_ptLargest.x = psizeMax->cx; + pdd->m_ptLargest.y = psizeMax->cy; + pdd->m_bLargestSet = true; + } + + // + // If the there was save info passed in then we need to make damn good use of it + // by attempting to load the RegistryData structure + if( hkRootSave && pcszName ) { + RegistryData rd; + DWORD dwSize = sizeof( RegistryData ); + DWORD dwType = REG_BINARY; + if( RegQueryValueExRecursive( hkRootSave, pcszName, NULL, &dwType, reinterpret_cast( &rd ), &dwSize ) == ERROR_SUCCESS && dwSize == sizeof( rd ) ) { + if( !(GetWindowLong( *this, GWL_STYLE ) & WS_VISIBLE) ) + rd.m_wpl.showCmd = SW_HIDE; + + VAPI( SetWindowPlacement( &rd.m_wpl ) ); + } + } + return TRUE; + } else { + free(pdd); + } + } + } + return FALSE; +} + +void ResizeDlg::UpdateWindowSize(const int cx, const int cy, HWND hwnd) +{ + DialogData *pdd = (DialogData*)dd; + if( pdd ) { + const int nDeltaX = cx - pdd->m_sizeClient.cx; + const int nDeltaY = cy - pdd->m_sizeClient.cy; + WinHelper::CDeferWindowPos def( pdd->nItemCount ); + WinHelper::CRect rc; + const DialogSizerSizingItem *psd = pdd->psd; + while( psd->uSizeInfo != 0xFFFFFFFF ) { + HWND hwndChild = ::GetDlgItem( *this, psd->uControlID ); + if( ::IsWindow( hwndChild ) ) { + VAPI( ::GetWindowRect( hwndChild, rc ) ); + (void)::MapWindowPoints( ::GetDesktopWindow(), hwnd, + (LPPOINT)&rc, 2 ); + + // + // Adjust the window horizontally + if( psd->uSizeInfo & DS_MoveX ) { + rc.left += nDeltaX; + rc.right += nDeltaX; + } + + // + // Adjust the window vertically + if( psd->uSizeInfo & DS_MoveY ) { + rc.top += nDeltaY; + rc.bottom += nDeltaY; + } + + // + // Size the window horizontally + if( psd->uSizeInfo & DS_SizeX ) { + rc.right += nDeltaX; + } + + // + // Size the window vertically + if( psd->uSizeInfo & DS_SizeY ) { + rc.bottom += nDeltaY; + } + + (void)def.DeferWindowPos( hwndChild, NULL, rc, + SWP_NOACTIVATE | SWP_NOZORDER ); + } + psd++; + } + + pdd->m_sizeClient.cx = cx; + pdd->m_sizeClient.cy = cy; + + // + // If we have a sizing grip enabled then adjust it's position + ResizeDlgUpdateGripper( hwnd, pdd ); + } +} + +BOOL ResizeDlg::OnWndMsg(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *res ) + // Actual window procedure that will handle saving window size/position and moving + // the controls whilst the window sizes. +{ + if(dd == NULL) { + return CDialog::OnWndMsg(msg, wParam, lParam, res); + } + switch( msg ) { + case WM_ERASEBKGND: + { + BOOL r = CDialog::OnWndMsg(msg, wParam, lParam, res); + DialogData *pdd = (DialogData*)dd; + if( pdd && pdd->m_bShowSizingGrip && !pdd->m_bMaximised ) { + VAPI( ::DrawFrameControl( reinterpret_cast( wParam ), + pdd->m_rcGrip, + DFC_SCROLL, DFCS_SCROLLSIZEGRIP ) ); + } + return r; + } + case WM_SIZE: + { + DialogData *pdd = (DialogData*)dd; + if( pdd && wParam != SIZE_MINIMIZED ) { + pdd->m_bMaximised = ( wParam == SIZE_MAXIMIZED ? true : false ); + UpdateWindowSize( LOWORD( lParam ), HIWORD( lParam ), *this); + } + } + break; + case WM_NCHITTEST: + { + // + // If the gripper is enabled then perform a simple hit test on our gripper area. + DialogData *pdd = (DialogData*)dd; + if( pdd && pdd->m_bShowSizingGrip ) { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + (void)ScreenToClient( &pt ); + if( PtInRect( pdd->m_rcGrip, pt ) ) + return (BOOL)HTBOTTOMRIGHT; + } + } + break; + case WM_GETMINMAXINFO: + { + // + // Our opportunity to say that we do not want the dialog to grow or shrink any more. + DialogData *pdd = (DialogData*)dd; + LPMINMAXINFO lpmmi = reinterpret_cast( lParam ); + lpmmi->ptMinTrackSize = pdd->m_ptSmallest; + if( pdd->m_bLargestSet ) { + lpmmi->ptMaxTrackSize = pdd->m_ptLargest; + } + } + return (BOOL)0; + case WM_NOTIFY: + { + if( reinterpret_cast(lParam)->code == PSN_SETACTIVE ) { + CRect rc; + VAPI( ::GetClientRect( *GetParent( ), &rc ) ); + UpdateWindowSize( rc.Width(), rc.Height(), *GetParent( ) ); + } + } + break; + case WM_DESTROY: + { + // + // Our opportunty for cleanup. + // Simply acquire all of our objects, free the appropriate memory and remove the + // properties from the window. If we do not remove the properties then they will constitute + // a resource leak. + DialogData *pdd = (DialogData*)dd; + if( pdd ) { + RegistryData rd; + rd.m_wpl.length = sizeof( rd.m_wpl ); + VAPI( GetWindowPlacement( &rd.m_wpl ) ); + + if( pdd->hkRootSave && pdd->pcszName ) { + (void)RegSetValueExRecursive( pdd->hkRootSave, pdd->pcszName, + NULL, REG_BINARY, + reinterpret_cast( &rd ), + sizeof( rd ) ); + } + + if( pdd->psd ) { + free(pdd->psd); + } + free(pdd); + } + + } + break; + } + return CDialog::OnWndMsg(msg, wParam, lParam, res); +} diff --git a/src/win32/ResizeDlg.h b/src/win32/ResizeDlg.h new file mode 100644 index 0000000..e09d589 --- /dev/null +++ b/src/win32/ResizeDlg.h @@ -0,0 +1,59 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_WIN32_RESIZEDLG_H +#define VBA_WIN32_RESIZEDLG_H + +#ifndef _INC_TCHAR +#include +#endif // _INC_TCHAR + +// +// Predefined sizing information +#define DS_MoveX 1 +#define DS_MoveY 2 +#define DS_SizeX 4 +#define DS_SizeY 8 + +typedef struct DialogSizerSizingItem // sdi +{ + UINT uControlID; + UINT uSizeInfo; +} DialogSizerSizingItem; + +#define DIALOG_SIZER_START( name ) DialogSizerSizingItem name[] = { +#define DIALOG_SIZER_ENTRY( controlID, flags ) { controlID, flags }, +#define DIALOG_SIZER_END() { 0xFFFFFFFF, 0xFFFFFFFF } }; + +class ResizeDlg : public CDialog { + void *dd; + public: + ResizeDlg(UINT id, CWnd *parent = NULL); + + void *AddDialogData(); + BOOL SetData(const DialogSizerSizingItem *psd, + BOOL bShowSizingGrip, + HKEY hkRootSave, + LPCTSTR pcszName, + SIZE *psizeMax); + void UpdateWindowSize(const int cx, const int cy, HWND); + + virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *); +}; +#endif diff --git a/src/win32/RewindInterval.cpp b/src/win32/RewindInterval.cpp new file mode 100644 index 0000000..de5d40c --- /dev/null +++ b/src/win32/RewindInterval.cpp @@ -0,0 +1,119 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// RewindInterval.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "RewindInterval.h" +#include "math.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// RewindInterval dialog + + +RewindInterval::RewindInterval(float interval, int slots, CWnd* pParent /*=NULL*/) + : CDialog(RewindInterval::IDD, pParent) +{ + //{{AFX_DATA_INIT(RewindInterval) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + this->interval = interval; + this->slots = slots; +} + + +void RewindInterval::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(RewindInterval) + DDX_Control(pDX, IDC_INTERVAL, m_interval); + DDX_Control(pDX, IDC_REWINDSLOTS, m_slots); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(RewindInterval, CDialog) + //{{AFX_MSG_MAP(RewindInterval) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// RewindInterval message handlers + +void RewindInterval::OnCancel() +{ + EndDialog(-1); +} + +void RewindInterval::OnOk() +{ + CString buffer, buffer2; + + m_interval.GetWindowText(buffer); + m_slots.GetWindowText(buffer2); + + float interval = (float)atof(buffer); + int slots = atoi(buffer2); + + + if(interval >= 0 && (int)interval <= 600) { + if(slots >= 0 && slots <= MAX_REWIND_SLOTS) + { + int iInterval = (int)(interval*6.0f + 0.5f); + if(interval > 0 && iInterval == 0) + iInterval = 1; + EndDialog(iInterval | (slots << 16)); + theApp.winAccelMgr.UpdateMenu(theApp.menu); + } else + systemMessage(IDS_INVALID_INTERVAL_VALUE, + "Invalid rewind slot amount. Please enter a number " + "between 0 and 128 slots"); + } else + systemMessage(IDS_INVALID_INTERVAL_VALUE, + "Invalid rewind interval value. Please enter a number " + "between 0 and 600 seconds"); +} + +BOOL RewindInterval::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_interval.LimitText(5); + m_slots.LimitText(3); + + CString buffer, buffer2; + buffer.Format("%.1f", interval); + m_interval.SetWindowText(buffer); + buffer2.Format("%d", slots); + m_slots.SetWindowText(buffer2); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/RewindInterval.h b/src/win32/RewindInterval.h new file mode 100644 index 0000000..1cdb42c --- /dev/null +++ b/src/win32/RewindInterval.h @@ -0,0 +1,70 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_) +#define AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// RewindInterval.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// RewindInterval dialog + +class RewindInterval : public CDialog +{ + // Construction + public: + float interval; + int slots; + RewindInterval(float interval, int slots, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(RewindInterval) + enum { IDD = IDD_REWIND_INTERVAL }; + CEdit m_interval; + CEdit m_slots; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RewindInterval) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(RewindInterval) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_) diff --git a/src/win32/RomInfo.cpp b/src/win32/RomInfo.cpp new file mode 100644 index 0000000..1d923ca --- /dev/null +++ b/src/win32/RomInfo.cpp @@ -0,0 +1,575 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// RomInfo.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "RomInfo.h" +#include "WinResUtil.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern int gbRomSize; + +struct WinGBACompanyName { + LPCTSTR code; + LPCTSTR name; +}; + +static WinGBACompanyName winGBARomInfoCompanies[] = { + { "01", "Nintendo" }, + { "02", "Rocket Games" }, + { "08", "Capcom" }, + { "09", "Hot B Co." }, + { "0A", "Jaleco" }, + { "0B", "Coconuts Japan" }, + { "0C", "Coconuts Japan/G.X.Media" }, + { "0H", "Starfish" }, + { "0L", "Warashi Inc." }, + { "0N", "Nowpro" }, + { "0P", "Game Village" }, + { "13", "Electronic Arts Japan" }, + { "18", "Hudson Soft Japan" }, + { "19", "S.C.P." }, + { "1A", "Yonoman" }, + { "1G", "SMDE" }, + { "1P", "Creatures Inc." }, + { "1Q", "TDK Deep Impresion" }, + { "20", "Destination Software" }, + { "22", "VR 1 Japan" }, + { "25", "San-X" }, + { "28", "Kemco Japan" }, + { "29", "Seta" }, + { "2H", "Ubisoft Japan" }, + { "2K", "NEC InterChannel" }, + { "2L", "Tam" }, + { "2M", "Jordan" }, + { "2N", "Smilesoft" }, + { "2Q", "Mediakite" }, + { "36", "Codemasters" }, + { "37", "GAGA Communications" }, + { "38", "Laguna" }, + { "39", "Telstar Fun and Games" }, + { "41", "Ubi Soft Entertainment" }, + { "42", "Sunsoft" }, + { "47", "Spectrum Holobyte" }, + { "49", "IREM" }, + { "4D", "Malibu Games" }, + { "4F", "Eidos/U.S. Gold" }, + { "4J", "Fox Interactive" }, + { "4K", "Time Warner Interactive" }, + { "4Q", "Disney" }, + { "4S", "Black Pearl" }, + { "4X", "GT Interactive" }, + { "4Y", "RARE" }, + { "4Z", "Crave Entertainment" }, + { "50", "Absolute Entertainment" }, + { "51", "Acclaim" }, + { "52", "Activision" }, + { "53", "American Sammy Corp." }, + { "54", "Take 2 Interactive" }, + { "55", "Hi Tech" }, + { "56", "LJN LTD." }, + { "58", "Mattel" }, + { "5A", "Mindscape/Red Orb Ent." }, + { "5C", "Taxan" }, + { "5D", "Midway" }, + { "5F", "American Softworks" }, + { "5G", "Majesco Sales Inc" }, + { "5H", "3DO" }, + { "5K", "Hasbro" }, + { "5L", "NewKidCo" }, + { "5M", "Telegames" }, + { "5N", "Metro3D" }, + { "5P", "Vatical Entertainment" }, + { "5Q", "LEGO Media" }, + { "5S", "Xicat Interactive" }, + { "5T", "Cryo Interactive" }, + { "5W", "Red Storm Ent./BKN Ent." }, + { "5X", "Microids" }, + { "5Z", "Conspiracy Entertainment Corp." }, + { "60", "Titus Interactive Studios" }, + { "61", "Virgin Interactive" }, + { "62", "Maxis" }, + { "64", "LucasArts Entertainment" }, + { "67", "Ocean" }, + { "69", "Electronic Arts" }, + { "6E", "Elite Systems Ltd." }, + { "6F", "Electro Brain" }, + { "6G", "The Learning Company" }, + { "6H", "BBC" }, + { "6J", "Software 2000" }, + { "6L", "BAM! Entertainment" }, + { "6M", "Studio 3" }, + { "6Q", "Classified Games" }, + { "6S", "TDK Mediactive" }, + { "6U", "DreamCatcher" }, + { "6V", "JoWood Productions" }, + { "6W", "SEGA" }, + { "6X", "Wannado Edition" }, + { "6Y", "LSP" }, + { "6Z", "ITE Media" }, + { "70", "Infogrames" }, + { "71", "Interplay" }, + { "72", "JVC Musical Industries Inc" }, + { "73", "Parker Brothers" }, + { "75", "SCI" }, + { "78", "THQ" }, + { "79", "Accolade" }, + { "7A", "Triffix Ent. Inc." }, + { "7C", "Microprose Software" }, + { "7D", "Universal Interactive Studios" }, + { "7F", "Kemco" }, + { "7G", "Rage Software" }, + { "7H", "Encore" }, + { "7J", "Zoo" }, + { "7K", "BVM" }, + { "7L", "Simon & Schuster Interactive" }, + { "7M", "Asmik Ace Entertainment Inc./AIA" }, + { "7N", "Empire Interactive" }, + { "7Q", "Jester Interactive" }, + { "7T", "Scholastic" }, + { "7U", "Ignition Entertainment" }, + { "7W", "Stadlbauer" }, + { "80", "Misawa" }, + { "83", "LOZC" }, + { "8B", "Bulletproof Software" }, + { "8C", "Vic Tokai Inc." }, + { "8J", "General Entertainment" }, + { "8N", "Success" }, + { "8P", "SEGA Japan" }, + { "91", "Chun Soft" }, + { "92", "Video System" }, + { "93", "BEC" }, + { "96", "Yonezawa/S'pal" }, + { "97", "Kaneko" }, + { "99", "Victor Interactive Software" }, + { "9A", "Nichibutsu/Nihon Bussan" }, + { "9B", "Tecmo" }, + { "9C", "Imagineer" }, + { "9F", "Nova" }, + { "9H", "Bottom Up" }, + { "9L", "Hasbro Japan" }, + { "9N", "Marvelous Entertainment" }, + { "9P", "Keynet Inc." }, + { "9Q", "Hands-On Entertainment" }, + { "A0", "Telenet" }, + { "A1", "Hori" }, + { "A4", "Konami" }, + { "A6", "Kawada" }, + { "A7", "Takara" }, + { "A9", "Technos Japan Corp." }, + { "AA", "JVC" }, + { "AC", "Toei Animation" }, + { "AD", "Toho" }, + { "AF", "Namco" }, + { "AG", "Media Rings Corporation" }, + { "AH", "J-Wing" }, + { "AK", "KID" }, + { "AL", "MediaFactory" }, + { "AP", "Infogrames Hudson" }, + { "AQ", "Kiratto. Ludic Inc" }, + { "B0", "Acclaim Japan" }, + { "B1", "ASCII" }, + { "B2", "Bandai" }, + { "B4", "Enix" }, + { "B6", "HAL Laboratory" }, + { "B7", "SNK" }, + { "B9", "Pony Canyon Hanbai" }, + { "BA", "Culture Brain" }, + { "BB", "Sunsoft" }, + { "BD", "Sony Imagesoft" }, + { "BF", "Sammy" }, + { "BG", "Magical" }, + { "BJ", "Compile" }, + { "BL", "MTO Inc." }, + { "BN", "Sunrise Interactive" }, + { "BP", "Global A Entertainment" }, + { "BQ", "Fuuki" }, + { "C0", "Taito" }, + { "C2", "Kemco" }, + { "C3", "Square Soft" }, + { "C5", "Data East" }, + { "C6", "Tonkin House" }, + { "C8", "Koei" }, + { "CA", "Konami/Palcom/Ultra" }, + { "CB", "Vapinc/NTVIC" }, + { "CC", "Use Co.,Ltd." }, + { "CD", "Meldac" }, + { "CE", "FCI/Pony Canyon" }, + { "CF", "Angel" }, + { "CM", "Konami Computer Entertainment Osaka" }, + { "CP", "Enterbrain" }, + { "D1", "Sofel" }, + { "D2", "Quest" }, + { "D3", "Sigma Enterprises" }, + { "D4", "Ask Kodansa" }, + { "D6", "Naxat" }, + { "D7", "Copya System" }, + { "D9", "Banpresto" }, + { "DA", "TOMY" }, + { "DB", "LJN Japan" }, + { "DD", "NCS" }, + { "DF", "Altron Corporation" }, + { "DH", "Gaps Inc." }, + { "DN", "ELF" }, + { "E2", "Yutaka" }, + { "E3", "Varie" }, + { "E5", "Epoch" }, + { "E7", "Athena" }, + { "E8", "Asmik Ace Entertainment Inc." }, + { "E9", "Natsume" }, + { "EA", "King Records" }, + { "EB", "Atlus" }, + { "EC", "Epic/Sony Records" }, + { "EE", "IGS" }, + { "EL", "Spike" }, + { "EM", "Konami Computer Entertainment Tokyo" }, + { "EN", "Alphadream Corporation" }, + { "F0", "A Wave" }, + { "G1", "PCCW" }, + { "G4", "KiKi Co Ltd" }, + { "G5", "Open Sesame Inc." }, + { "G6", "Sims" }, + { "G7", "Broccoli" }, + { "G8", "Avex" }, + { "G9", "D3 Publisher" }, + { "GB", "Konami Computer Entertainment Japan" }, + { "GD", "Square-Enix" }, + { "HY", "Sachen" }, + { NULL, NULL } +}; + +static LPCTSTR winGBARomInfoFindMakerCode(LPCTSTR code) +{ + int i = 0; + while(winGBARomInfoCompanies[i].code) { + if(!strcmp(winGBARomInfoCompanies[i].code, code)) + return winGBARomInfoCompanies[i].name; + i++; + } + return (LPCTSTR)winResLoadString(IDS_UNKNOWN); +} + + +///////////////////////////////////////////////////////////////////////////// +// RomInfoGB dialog + + +RomInfoGB::RomInfoGB(u8 *rom, CWnd* pParent /*=NULL*/) + : CDialog(RomInfoGB::IDD, pParent) +{ + //{{AFX_DATA_INIT(RomInfoGB) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + this->rom = rom; +} + + +void RomInfoGB::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(RomInfoGB) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(RomInfoGB, CDialog) + //{{AFX_MSG_MAP(RomInfoGB) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// RomInfoGB message handlers + +void RomInfoGB::OnOk() +{ + EndDialog(TRUE); +} + +BOOL RomInfoGB::OnInitDialog() +{ + CDialog::OnInitDialog(); + + char buffer[128]; + + strncpy(buffer, (const char *)&rom[0x134], 15); + buffer[15] = 0; + GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0x143]); + GetDlgItem(IDC_ROM_COLOR)->SetWindowText(buffer); + + strncpy(buffer, (const char *)&rom[0x144],2); + buffer[2] = 0; + GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer); + + if(rom[0x14b] != 0x33) { + sprintf(buffer, "%02X", rom[0x14b]); + GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer); + } + GetDlgItem(IDC_ROM_MAKER_NAME2)->SetWindowText(winGBARomInfoFindMakerCode(buffer)); + + sprintf(buffer, "%02x", rom[0x146]); + GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer); + + CString type = winResLoadString(IDS_UNKNOWN); + switch(rom[0x147]) { + case 0x00: + type = "ROM"; + break; + case 0x01: + type = "ROM+MBC1"; + break; + case 0x02: + type = "ROM+MBC1+RAM"; + break; + case 0x03: + type = "ROM+MBC1+RAM+BATT"; + break; + case 0x05: + type = "ROM+MBC2"; + break; + case 0x06: + type = "ROM+MBC2+BATT"; + break; + case 0x0f: + type = "ROM+MBC3+TIMER+BATT"; + break; + case 0x10: + type = "ROM+MBC3+TIMER+RAM+BATT"; + break; + case 0x11: + type = "ROM+MBC3"; + break; + case 0x12: + type = "ROM+MBC3+RAM"; + break; + case 0x13: + type = "ROM+MBC3+RAM+BATT"; + break; + case 0x19: + type = "ROM+MBC5"; + break; + case 0x1a: + type = "ROM+MBC5+RAM"; + break; + case 0x1b: + type = "ROM+MBC5+RAM+BATT"; + break; + case 0x1c: + type = "ROM+MBC5+RUMBLE"; + break; + case 0x1d: + type = "ROM+MBC5+RUMBLE+RAM"; + break; + case 0x1e: + type = "ROM+MBC5+RUMBLE+RAM+BATT"; + break; + case 0x22: + type = "ROM+MBC7+BATT"; + break; + case 0xfe: + type = "ROM+HuC-3"; + break; + case 0xff: + type = "ROM+HuC-1"; + break; + } + sprintf(buffer, "%02x (%s)", rom[0x147], (const char *)type); + GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer); + + type = winResLoadString(IDS_UNKNOWN); + switch(rom[0x148]) { + case 0: + type = "32K"; + break; + case 1: + type = "64K"; + break; + case 2: + type = "128K"; + break; + case 3: + type = "256K"; + break; + case 4: + type = "512K"; + break; + case 5: + type = "1M"; + break; + case 6: + type = "2M"; + break; + case 7: + type = "4M"; + break; + } + + sprintf(buffer, "%02x (%s)", rom[0x148], (const char *)type); + GetDlgItem(IDC_ROM_SIZE)->SetWindowText(buffer); + + type = winResLoadString(IDS_UNKNOWN); + switch(rom[0x149]) { + case 0: + type = winResLoadString(IDS_NONE); + break; + case 1: + type = "2K"; + break; + case 2: + type = "8K"; + break; + case 3: + type = "32K"; + break; + case 4: + type = "128K"; + break; + case 5: + type = "64K"; + break; + } + + sprintf(buffer, "%02x (%s)", rom[0x149], (const char *)type); + GetDlgItem(IDC_ROM_RAM_SIZE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0x14a]); + GetDlgItem(IDC_ROM_DEST_CODE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0x14b]); + GetDlgItem(IDC_ROM_LIC_CODE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0x14c]); + GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer); + + u8 crc = 25; + int i; + for(i = 0x134; i < 0x14d; i++) { + crc += rom[i]; + } + + crc = 256 - crc; + + sprintf(buffer, "%02x (%02x)", crc, rom[0x14d]); + GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer); + + u16 crc16 = 0; + for(i = 0; i < gbRomSize; i++) { + crc16 += rom[i]; + } + + crc16 -= rom[0x14e]; + crc16 -= rom[0x14f]; + sprintf(buffer, "%04x (%04x)", crc16, (rom[0x14e]<<8)|rom[0x14f]); + GetDlgItem(IDC_ROM_CHECKSUM)->SetWindowText(buffer); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} +///////////////////////////////////////////////////////////////////////////// +// RomInfoGBA dialog + + +RomInfoGBA::RomInfoGBA(u8 *rom, CWnd* pParent /*=NULL*/) + : CDialog(RomInfoGBA::IDD, pParent) +{ + //{{AFX_DATA_INIT(RomInfoGBA) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + this->rom = rom; +} + + +void RomInfoGBA::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(RomInfoGBA) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(RomInfoGBA, CDialog) + //{{AFX_MSG_MAP(RomInfoGBA) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// RomInfoGBA message handlers + +void RomInfoGBA::OnOk() +{ + EndDialog(TRUE); +} + +BOOL RomInfoGBA::OnInitDialog() +{ + CDialog::OnInitDialog(); + + char buffer[13]; + + strncpy(buffer, (const char *)&rom[0xa0], 12); + buffer[12] = 0; + GetDlgItem(IDC_ROM_TITLE)->SetWindowText(buffer); + + strncpy(buffer, (const char *)&rom[0xac], 4); + buffer[4] = 0; + GetDlgItem(IDC_ROM_GAME_CODE)->SetWindowText(buffer); + + strncpy(buffer, (const char *)&rom[0xb0],2); + buffer[2] = 0; + GetDlgItem(IDC_ROM_MAKER_CODE)->SetWindowText(buffer); + + GetDlgItem(IDC_ROM_MAKER_NAME)->SetWindowText(winGBARomInfoFindMakerCode(buffer)); + + sprintf(buffer, "%02x", rom[0xb3]); + GetDlgItem(IDC_ROM_UNIT_CODE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0xb4]); + GetDlgItem(IDC_ROM_DEVICE_TYPE)->SetWindowText(buffer); + + sprintf(buffer, "%02x", rom[0xbc]); + GetDlgItem(IDC_ROM_VERSION)->SetWindowText(buffer); + + u8 crc = 0x19; + for(int i = 0xa0; i < 0xbd; i++) { + crc += rom[i]; + } + + crc = (-crc) & 255; + + sprintf(buffer, "%02x (%02x)", crc, rom[0xbd]); + GetDlgItem(IDC_ROM_CRC)->SetWindowText(buffer); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/src/win32/RomInfo.h b/src/win32/RomInfo.h new file mode 100644 index 0000000..e7005f4 --- /dev/null +++ b/src/win32/RomInfo.h @@ -0,0 +1,101 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_) +#define AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// RomInfo.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// RomInfoGB dialog + +class RomInfoGB : public CDialog +{ + // Construction + public: + RomInfoGB(u8 *rom, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(RomInfoGB) + enum { IDD = IDD_GB_ROM_INFO }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RomInfoGB) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + u8 *rom; + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(RomInfoGB) + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// +// RomInfoGBA dialog + +class RomInfoGBA : public CDialog +{ + // Construction + public: + RomInfoGBA(u8 *rom, CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(RomInfoGBA) + enum { IDD = IDD_GBA_ROM_INFO }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + u8 *rom; + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RomInfoGBA) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(RomInfoGBA) + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_) diff --git a/src/win32/Sound.h b/src/win32/Sound.h new file mode 100644 index 0000000..b46d210 --- /dev/null +++ b/src/win32/Sound.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef VBA_WIN32_SOUND_H +#define VBA_WIN32_SOUND_H + +class ISound +{ + public: + virtual ~ISound() {}; + + virtual bool init() = 0; + virtual void pause() = 0; + virtual void reset() = 0; + virtual void resume() = 0; + virtual void write() = 0; + virtual void setSpeed(float rate) = 0; + virtual bool isPlaying() = 0; +}; + +#endif diff --git a/src/win32/StringTokenizer.cpp b/src/win32/StringTokenizer.cpp new file mode 100644 index 0000000..b7ea313 --- /dev/null +++ b/src/win32/StringTokenizer.cpp @@ -0,0 +1,69 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// StringTokenizer.cpp: implementation of the StringTokenizer class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "vba.h" +#include "StringTokenizer.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +StringTokenizer::StringTokenizer(CString str, CString del) +{ + m_right = str; + m_delim = del; +} + +StringTokenizer::~StringTokenizer() +{ + +} + + +const char *StringTokenizer::next() +{ + int index = m_right.FindOneOf(m_delim); + + while(index == 0) { + m_right = m_right.Right(m_right.GetLength()-1); + index = m_right.FindOneOf(m_delim); + } + if(index == -1) { + if(m_right.IsEmpty()) + return NULL; + m_token = m_right; + m_right.Empty(); + return m_token; + } + + m_token = m_right.Left(index); + m_right = m_right.Right(m_right.GetLength()-(1+index)); + + return m_token; +} diff --git a/src/win32/StringTokenizer.h b/src/win32/StringTokenizer.h new file mode 100644 index 0000000..7deae2d --- /dev/null +++ b/src/win32/StringTokenizer.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// StringTokenizer.h: interface for the StringTokenizer class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_) +#define AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class StringTokenizer +{ + public: + const char * next(); + StringTokenizer(CString str, CString token); + virtual ~StringTokenizer(); + + private: + CString m_token; + CString m_delim; + CString m_right; +}; + +#endif // !defined(AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_) diff --git a/src/win32/TextOptions.cpp b/src/win32/TextOptions.cpp new file mode 100644 index 0000000..7f57ae7 --- /dev/null +++ b/src/win32/TextOptions.cpp @@ -0,0 +1,80 @@ +// TextOptions.cpp : implementation file +// + +#include "stdafx.h" +#include "../Text.h" +#include "TextOptions.h" +#include ".\textoptions.h" + + +// TextOptions dialog + +IMPLEMENT_DYNAMIC(TextOptions, CDialog) +TextOptions::TextOptions(CWnd* pParent /*=NULL*/) +: CDialog(TextOptions::IDD, pParent) +{ +} + +TextOptions::~TextOptions() +{ +} + +BOOL TextOptions::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CheckRadioButton(IDC_RADIO_WHITE, IDC_RADIO_BLACK, IDC_RADIO_WHITE + textColor); + CheckRadioButton(IDC_RADIO_PREFILTER, IDC_RADIO_POSTRENDER, IDC_RADIO_PREFILTER + textMethod); + CheckDlgButton(IDC_CHECK_OUTLINED, outlinedText); + CheckDlgButton(IDC_CHECK_TRANSPARENT, transparentText); + GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(GetCheckedRadioButton(IDC_RADIO_PREFILTER, IDC_RADIO_POSTRENDER) != IDC_RADIO_POSTRENDER); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void TextOptions::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(TextOptions, CDialog) + ON_BN_CLICKED(IDOK, OnBnClickedOk) + ON_BN_CLICKED(IDC_RADIO_PREFILTER, OnBnClickedRadioPrefilter) + ON_BN_CLICKED(IDC_RADIO_POSTFILTER, OnBnClickedRadioPostfilter) + ON_BN_CLICKED(IDC_RADIO_POSTRENDER, OnBnClickedRadioPostrender) +END_MESSAGE_MAP() + + +// TextOptions message handlers + +void TextOptions::OnBnClickedOk() +{ + transparentText = IsDlgButtonChecked(IDC_CHECK_TRANSPARENT) != 0; + outlinedText = IsDlgButtonChecked(IDC_CHECK_OUTLINED) != 0; + textMethod = GetCheckedRadioButton(IDC_RADIO_PREFILTER, IDC_RADIO_POSTRENDER) - IDC_RADIO_PREFILTER; + textColor = GetCheckedRadioButton(IDC_RADIO_WHITE, IDC_RADIO_BLACK) - IDC_RADIO_WHITE; + if(textMethod < 0) textMethod = 0; + if(textMethod > 2) textMethod = 2; + if(textColor < 0) textColor = 0; + if(textColor > 7) textColor = 7; + + OnOK(); +} + +void TextOptions::OnBnClickedRadioPrefilter() +{ + GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(TRUE); +} + +void TextOptions::OnBnClickedRadioPostfilter() +{ + GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(TRUE); +} + +void TextOptions::OnBnClickedRadioPostrender() +{ + GetDlgItem(IDC_CHECK_TRANSPARENT)->EnableWindow(FALSE); + CheckDlgButton(IDC_CHECK_TRANSPARENT, FALSE); +} diff --git a/src/win32/TextOptions.h b/src/win32/TextOptions.h new file mode 100644 index 0000000..443d415 --- /dev/null +++ b/src/win32/TextOptions.h @@ -0,0 +1,28 @@ +#pragma once + + +// TextOptions dialog + +class TextOptions : public CDialog +{ + DECLARE_DYNAMIC(TextOptions) + +public: + TextOptions(CWnd* pParent = NULL); // standard constructor + virtual ~TextOptions(); + + virtual BOOL OnInitDialog() ; + +// Dialog Data + enum { IDD = IDD_TEXTCONFIG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedRadioPrefilter(); + afx_msg void OnBnClickedRadioPostfilter(); + afx_msg void OnBnClickedRadioPostrender(); +}; diff --git a/src/win32/Throttle.cpp b/src/win32/Throttle.cpp new file mode 100644 index 0000000..d73a347 --- /dev/null +++ b/src/win32/Throttle.cpp @@ -0,0 +1,87 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Throttle.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "Throttle.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// Throttle dialog + + +Throttle::Throttle(CWnd* pParent /*=NULL*/) + : CDialog(Throttle::IDD, pParent) +{ + //{{AFX_DATA_INIT(Throttle) + m_throttle = 100; + //}}AFX_DATA_INIT +} + + +void Throttle::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(Throttle) + DDX_Text(pDX, IDC_THROTTLE, m_throttle); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(Throttle, CDialog) + //{{AFX_MSG_MAP(Throttle) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// Throttle message handlers + +BOOL Throttle::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void Throttle::OnCancel() +{ + EndDialog(false); +} + +void Throttle::OnOk() +{ + UpdateData(); + + if(m_throttle < 5 || m_throttle > 1000) + systemMessage(IDS_INVALID_THROTTLE_VALUE, "Invalid throttle value. Please enter a number between 5 and 1000"); + else + EndDialog(m_throttle); +} diff --git a/src/win32/Throttle.h b/src/win32/Throttle.h new file mode 100644 index 0000000..e406417 --- /dev/null +++ b/src/win32/Throttle.h @@ -0,0 +1,67 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_) +#define AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Throttle.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// Throttle dialog + +class Throttle : public CDialog +{ + // Construction + public: + Throttle(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(Throttle) + enum { IDD = IDD_THROTTLE }; + int m_throttle; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Throttle) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(Throttle) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_) diff --git a/src/win32/TileView.cpp b/src/win32/TileView.cpp new file mode 100644 index 0000000..24b3a4c --- /dev/null +++ b/src/win32/TileView.cpp @@ -0,0 +1,587 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// TileView.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "FileDlg.h" +#include "Reg.h" +#include "TileView.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../NLS.h" +#include "../Util.h" + +extern "C" { +#include +} + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// TileView dialog + + +TileView::TileView(CWnd* pParent /*=NULL*/) + : ResizeDlg(TileView::IDD, pParent) +{ + //{{AFX_DATA_INIT(TileView) + m_colors = -1; + m_charBase = -1; + m_stretch = FALSE; + //}}AFX_DATA_INIT + autoUpdate = false; + + memset(&bmpInfo, 0, sizeof(bmpInfo)); + + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = 32*8; + bmpInfo.bmiHeader.biHeight = 32*8; + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 24; + bmpInfo.bmiHeader.biCompression = BI_RGB; + data = (u8 *)calloc(1, 3 * 32*32 * 64); + + tileView.setData(data); + tileView.setBmpInfo(&bmpInfo); + + charBase = 0; + is256Colors = 0; + palette = 0; + w = h = 0; +} + +TileView::~TileView() +{ + free(data); + data = NULL; +} + +void TileView::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(TileView) + DDX_Control(pDX, IDC_PALETTE_SLIDER, m_slider); + DDX_Radio(pDX, IDC_16_COLORS, m_colors); + DDX_Radio(pDX, IDC_CHARBASE_0, m_charBase); + DDX_Check(pDX, IDC_STRETCH, m_stretch); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_TILE_VIEW, tileView); + DDX_Control(pDX, IDC_MAP_VIEW_ZOOM, zoom); + DDX_Control(pDX, IDC_COLOR, color); +} + + +BEGIN_MESSAGE_MAP(TileView, CDialog) + //{{AFX_MSG_MAP(TileView) + ON_BN_CLICKED(IDC_SAVE, OnSave) + ON_BN_CLICKED(IDC_CLOSE, OnClose) + ON_BN_CLICKED(IDC_AUTO_UPDATE, OnAutoUpdate) + ON_BN_CLICKED(IDC_16_COLORS, On16Colors) + ON_BN_CLICKED(IDC_256_COLORS, On256Colors) + ON_BN_CLICKED(IDC_CHARBASE_0, OnCharbase0) + ON_BN_CLICKED(IDC_CHARBASE_1, OnCharbase1) + ON_BN_CLICKED(IDC_CHARBASE_2, OnCharbase2) + ON_BN_CLICKED(IDC_CHARBASE_3, OnCharbase3) + ON_BN_CLICKED(IDC_CHARBASE_4, OnCharbase4) + ON_BN_CLICKED(IDC_STRETCH, OnStretch) + ON_WM_HSCROLL() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_MAPINFO, OnMapInfo) + ON_MESSAGE(WM_COLINFO, OnColInfo) + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// TileView message handlers + +void TileView::saveBMP(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); + + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w*h*3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x38); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3*w*h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data+3*w*(h-1); + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } + pixU8 -= 2*3*w; + fwrite(writeBuffer, 1, 3*w, fp); + + b = writeBuffer; + } + + fclose(fp); +} + + +void TileView::savePNG(const char *name) +{ + u8 writeBuffer[1024 * 3]; + + FILE *fp = fopen(name,"wb"); + + if(!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s", name); + return; + } + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, + NULL, + NULL); + if(!png_ptr) { + fclose(fp); + return; + } + + png_infop info_ptr = png_create_info_struct(png_ptr); + + if(!info_ptr) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + if(setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr,NULL); + fclose(fp); + return; + } + + png_init_io(png_ptr,fp); + + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr,info_ptr); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + u8 *pixU8 = (u8 *)data; + for(int y = 0; y < sizeY; y++) { + for(int x = 0; x < sizeX; x++) { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + png_write_row(png_ptr,writeBuffer); + + b = writeBuffer; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); +} + + +void TileView::OnSave() +{ + CString captureBuffer; + + if(theApp.captureFormat == 0) + captureBuffer = "tiles.png"; + else + captureBuffer = "tiles.bmp"; + + LPCTSTR exts[] = {".png", ".bmp" }; + + CString filter = theApp.winLoadFilter(IDS_FILTER_PNG); + CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME); + + FileDlg dlg(this, + captureBuffer, + filter, + theApp.captureFormat ? 2 : 1, + theApp.captureFormat ? "BMP" : "PNG", + exts, + "", + title, + true); + + if(dlg.DoModal() == IDCANCEL) { + return; + } + + captureBuffer = dlg.GetPathName(); + + if(dlg.getFilterIndex() == 2) + saveBMP(captureBuffer); + else + savePNG(captureBuffer); +} + +void TileView::renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette) +{ + u8 *bmp = &data[24*x + 8*32*24*y]; + + for(int j = 0; j < 8; j++) { + for(int i = 0; i < 8; i++) { + u8 c = charBase[tile*64 + j * 8 + i]; + + u16 color = palette[c]; + + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + + } + bmp += 31*24; // advance line + } +} + +void TileView::renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette) +{ + u8 *bmp = &data[24*x + 8*32*24*y]; + + int pal = this->palette; + + if(this->charBase == 4) + pal += 16; + + for(int j = 0; j < 8; j++) { + for(int i = 0; i < 8; i++) { + u8 c = charBase[tile*32 + j * 4 + (i>>1)]; + + if(i & 1) + c = c>>4; + else + c = c & 15; + + u16 color = palette[pal*16+c]; + + *bmp++ = ((color >> 10) & 0x1f) << 3; + *bmp++ = ((color >> 5) & 0x1f) << 3; + *bmp++ = (color & 0x1f) << 3; + } + bmp += 31*24; // advance line + } +} + + +void TileView::render() +{ + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[this->charBase * 0x4000]; + + int maxY; + + if(is256Colors) { + int tile = 0; + maxY = 16; + for(int y = 0; y < maxY; y++) { + for(int x = 0; x < 32; x++) { + if(this->charBase == 4) + renderTile256(tile, x, y, charBase, &palette[256]); + else + renderTile256(tile, x, y, charBase, palette); + tile++; + } + } + tileView.setSize(32*8, maxY*8); + w = 32*8; + h = maxY*8; + SIZE s; + s.cx = 32*8; + s.cy = maxY*8; + if(tileView.getStretch()) { + s.cx = s.cy = 1; + } + tileView.SetScrollSizes(MM_TEXT,s); + } else { + int tile = 0; + maxY = 32; + if(this->charBase == 3) + maxY = 16; + for(int y = 0; y < maxY; y++) { + for(int x = 0; x < 32; x++) { + renderTile16(tile, x, y, charBase, palette); + tile++; + } + } + tileView.setSize(32*8, maxY*8); + w = 32*8; + h = maxY*8; + SIZE s; + s.cx = 32*8; + s.cy = maxY*8; + if(tileView.getStretch()) { + s.cx = s.cy = 1; + } + tileView.SetScrollSizes(MM_TEXT, s); + } +} + +void TileView::update() +{ + paint(); +} + + +BOOL TileView::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DIALOG_SIZER_START( sz ) + DIALOG_SIZER_ENTRY( IDC_TILE_VIEW, DS_SizeX | DS_SizeY ) + DIALOG_SIZER_ENTRY( IDC_COLOR, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_R, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_G, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_B, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_REFRESH, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_CLOSE, DS_MoveY) + DIALOG_SIZER_ENTRY( IDC_SAVE, DS_MoveY) + DIALOG_SIZER_END() + SetData(sz, + TRUE, + HKEY_CURRENT_USER, + "Software\\Emulators\\VisualBoyAdvance\\Viewer\\TileView", + NULL); + + m_colors = is256Colors; + m_charBase = charBase; + + m_slider.SetRange(0, 15); + m_slider.SetPageSize(4); + m_slider.SetTicFreq(1); + + paint(); + + m_stretch = regQueryDwordValue("tileViewStretch", 0); + if(m_stretch) + tileView.setStretch(true); + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void TileView::OnClose() +{ + theApp.winRemoveUpdateListener(this); + + DestroyWindow(); +} + + +void TileView::OnAutoUpdate() +{ + autoUpdate = !autoUpdate; + if(autoUpdate) { + theApp.winAddUpdateListener(this); + } else { + theApp.winRemoveUpdateListener(this); + } +} + + +void TileView::paint() +{ + if(vram != NULL && paletteRAM != NULL) { + render(); + tileView.refresh(); + } +} + + +void TileView::On16Colors() +{ + is256Colors = 0; + paint(); +} + +void TileView::On256Colors() +{ + is256Colors = 1; + paint(); +} + +void TileView::OnCharbase0() +{ + charBase = 0; + paint(); +} + +void TileView::OnCharbase1() +{ + charBase = 1; + paint(); +} + +void TileView::OnCharbase2() +{ + charBase = 2; + paint(); +} + +void TileView::OnCharbase3() +{ + charBase = 3; + paint(); +} + +void TileView::OnCharbase4() +{ + charBase = 4; + paint(); +} + +void TileView::OnStretch() +{ + tileView.setStretch(!tileView.getStretch()); + paint(); + regSetDwordValue("tileViewStretch", tileView.getStretch()); +} + +LRESULT TileView::OnMapInfo(WPARAM wParam, LPARAM lParam) +{ + u8 *colors = (u8 *)lParam; + zoom.setColors(colors); + + int x = (wParam & 0xFFFF)/8; + int y = ((wParam >> 16) & 0xFFFF)/8; + + u32 address = 0x6000000 + 0x4000 * charBase; + int tile = 32 * y + x; + if(is256Colors) + tile *= 2; + address += 32 * tile; + + CString buffer; + buffer.Format("%d", tile); + GetDlgItem(IDC_TILE_NUMBER)->SetWindowText(buffer); + + buffer.Format("%08x", address); + GetDlgItem(IDC_ADDRESS)->SetWindowText(buffer); + + return TRUE; +} + +LRESULT TileView::OnColInfo(WPARAM wParam, LPARAM) +{ + u16 c = (u16)wParam; + + color.setColor(c); + + int r = (c & 0x1f); + int g = (c & 0x3e0) >> 5; + int b = (c & 0x7c00) >> 10; + + CString buffer; + buffer.Format("R: %d", r); + GetDlgItem(IDC_R)->SetWindowText(buffer); + + buffer.Format("G: %d", g); + GetDlgItem(IDC_G)->SetWindowText(buffer); + + buffer.Format("B: %d", b); + GetDlgItem(IDC_B)->SetWindowText(buffer); + + return TRUE; +} + +void TileView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + switch(nSBCode) { + case TB_THUMBPOSITION: + palette = nPos; + break; + default: + palette = m_slider.GetPos(); + break; + } + paint(); +} + +void TileView::PostNcDestroy() +{ + delete this; +} diff --git a/src/win32/TileView.h b/src/win32/TileView.h new file mode 100644 index 0000000..888d67b --- /dev/null +++ b/src/win32/TileView.h @@ -0,0 +1,109 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_) +#define AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// TileView.h : header file +// + +#include "BitmapControl.h" +#include "ColorControl.h" +#include "IUpdate.h" +#include "ResizeDlg.h" +#include "ZoomControl.h" + +///////////////////////////////////////////////////////////////////////////// +// TileView dialog + +class TileView : public ResizeDlg, IUpdateListener +{ + int charBase; + int is256Colors; + int palette; + BitmapControl tileView; + BITMAPINFO bmpInfo; + u8 *data; + ZoomControl zoom; + ColorControl color; + int w; + int h; + bool autoUpdate; + // Construction + public: + void paint(); + void render(); + void renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette); + void renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette); + void savePNG(const char *name); + void saveBMP(const char *name); + TileView(CWnd* pParent = NULL); // standard constructor + virtual ~TileView(); + + virtual void update(); + + // Dialog Data + //{{AFX_DATA(TileView) + enum { IDD = IDD_TILE_VIEWER }; + CSliderCtrl m_slider; + int m_colors; + int m_charBase; + BOOL m_stretch; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(TileView) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + + // Implementation + protected: + virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + + // Generated message map functions + //{{AFX_MSG(TileView) + afx_msg void OnSave(); + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnAutoUpdate(); + afx_msg void On16Colors(); + afx_msg void On256Colors(); + afx_msg void OnCharbase0(); + afx_msg void OnCharbase1(); + afx_msg void OnCharbase2(); + afx_msg void OnCharbase3(); + afx_msg void OnCharbase4(); + afx_msg void OnStretch(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_) diff --git a/src/win32/VBA.clw b/src/win32/VBA.clw new file mode 100644 index 0000000..5bae081 --- /dev/null +++ b/src/win32/VBA.clw @@ -0,0 +1,1715 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +LastClass=Hyperlink +LastTemplate=CDialog +NewFileInclude1=#include "stdafx.h" +NewFileInclude2=#include "vba.h" +LastPage=0 + +ClassCount=57 +Class1=AboutDialog +Class2=Associate +Class3=ColorButton +Class4=ColorControl +Class5=Directories +Class6=ExportGSASnapshot +Class7=FileDlg +Class8=GBACheatSearch +Class9=AddCheat +Class10=GBACheatList +Class11=GBCheatSearch +Class12=AddGBCheat +Class13=GBColorDlg +Class14=GSACodeSelect +Class15=JoypadEditControl +Class16=JoypadConfig +Class17=MotionConfig +Class18=Hyperlink +Class19=LangSelect +Class20=MainWnd +Class21=ModeConfirm +Class22=RewindInterval +Class23=RomInfoGB +Class24=RomInfoGBA +Class25=SkinButton +Class26=Throttle +Class27=VBA +Class28=VideoMode +Class29=VideoDriverSelect + +ResourceCount=44 +Resource1=IDD_MAX_SCALE +Resource2=IDD_GDB_WAITING +Resource3=IDD_GB_CHEAT_LIST +Resource4=IDD_CONFIG +Resource5=IDD_ADD_CHEAT_DLG +Resource6=IDD_GB_OAM_VIEW +Resource7=IDD_GB_ROM_INFO +Resource8=IDD_OPENDLG +Resource9=IDD_MAP_VIEW +Resource10=IDD_ABOUT +Resource11=IDD_CHEAT_LIST +Resource12=IDD_OAM_VIEW +Resource13=IDD_CODE_SELECT +Resource14=IDD_CHEATS +Resource15=IDD_GBA_ROM_INFO +Resource16=IDD_IO_VIEWER +Resource17=IDD_MEM_VIEWER +Resource18=IDD_ADDR_SIZE +Resource19=IDR_MENU +Resource20=IDD_PALETTE_VIEW +Resource21=IDD_ASSOCIATIONS +Resource22=IDD_GB_COLORS +Resource23=IDD_ADD_CHEAT +Resource24=IDD_DISASSEMBLE +Resource25=IDD_MODES +Resource26=IDD_GDB_PORT +Resource27=IDD_LANG_SELECT +Resource28=IDD_LOGGING +Resource29=IDD_DRIVERS +Resource30=IDD_EXPORT_SPS +Resource31=IDD_THROTTLE +Resource32=IDD_MODE_CONFIRM +Resource33=IDD_GB_DISASSEMBLE +Resource34=IDD_GB_PALETTE_VIEW +Resource35=IDD_REWIND_INTERVAL +Resource36=IDD_GB_TILE_VIEWER +Resource37=IDD_ACCEL_EDITOR +Resource38=IDD_GB_MAP_VIEW +Resource39=IDD_BUG_REPORT +Resource40=IDD_MOTION_CONFIG +Resource41=IDD_TILE_VIEWER +Class30=AddGSACode +Class31=GBCheatList +Class32=Disassemble +Class33=GBDisassemble +Class34=Logging +Class35=IOViewer +Class36=ZoomControl +Class37=BitmapControl +Class38=MapView +Class39=GBMapView +Class40=MemoryViewer +Class41=MemoryViewerDlg +Class42=MemoryViewerAddressSize +Class43=GBMemoryViewerDlg +Class44=OamView +Class45=GBOamView +Class46=PaletteViewControl +Class47=PaletteView +Class48=GBPaletteView +Class49=TileView +Class50=GBTileView +Class51=GBPrinterDlg +Class52=GDBPortDlg +Class53=GDBWaitingDlg +Class54=AccelEditor +Class55=CKeyboardEdit +Resource42=IDD_DIRECTORIES +Class56=MaxScale +Resource43=IDD_GB_PRINTER +Class57=BugReport +Resource44=IDR_ACCELERATOR + +[CLS:AboutDialog] +Type=0 +BaseClass=CDialog +HeaderFile=AboutDialog.h +ImplementationFile=AboutDialog.cpp +LastObject=AboutDialog + +[CLS:Associate] +Type=0 +BaseClass=CDialog +HeaderFile=Associate.h +ImplementationFile=Associate.cpp +LastObject=ID_OK + +[CLS:ColorButton] +Type=0 +BaseClass=CButton +HeaderFile=ColorButton.h +ImplementationFile=ColorButton.cpp + +[CLS:ColorControl] +Type=0 +BaseClass=CWnd +HeaderFile=ColorControl.h +ImplementationFile=ColorControl.cpp + +[CLS:Directories] +Type=0 +BaseClass=CDialog +HeaderFile=Directories.h +ImplementationFile=Directories.cpp + +[CLS:ExportGSASnapshot] +Type=0 +BaseClass=CDialog +HeaderFile=ExportGSASnapshot.h +ImplementationFile=ExportGSASnapshot.cpp + +[CLS:FileDlg] +Type=0 +BaseClass=CFileDialog +HeaderFile=FileDlg.h +ImplementationFile=FileDlg.cpp + +[CLS:GBACheatSearch] +Type=0 +BaseClass=CDialog +HeaderFile=GBACheats.h +ImplementationFile=GBACheats.cpp + +[CLS:AddCheat] +Type=0 +BaseClass=CDialog +HeaderFile=GBACheats.h +ImplementationFile=GBACheats.cpp + +[CLS:GBACheatList] +Type=0 +BaseClass=CDialog +HeaderFile=GBACheats.h +ImplementationFile=GBACheats.cpp +LastObject=GBACheatList + +[CLS:GBCheatSearch] +Type=0 +BaseClass=CDialog +HeaderFile=GBCheatsDlg.h +ImplementationFile=GBCheatsDlg.cpp + +[CLS:AddGBCheat] +Type=0 +BaseClass=CDialog +HeaderFile=GBCheatsDlg.h +ImplementationFile=GBCheatsDlg.cpp +LastObject=AddGBCheat + +[CLS:GBColorDlg] +Type=0 +BaseClass=CDialog +HeaderFile=GBColorDlg.h +ImplementationFile=GBColorDlg.cpp +LastObject=IDC_PREDEFINED +Filter=D +VirtualFilter=dWC + +[CLS:GSACodeSelect] +Type=0 +BaseClass=CDialog +HeaderFile=GSACodeSelect.h +ImplementationFile=GSACodeSelect.cpp + +[CLS:JoypadEditControl] +Type=0 +BaseClass=CEdit +HeaderFile=Joypad.h +ImplementationFile=Joypad.cpp + +[CLS:JoypadConfig] +Type=0 +BaseClass=CDialog +HeaderFile=Joypad.h +ImplementationFile=Joypad.cpp + +[CLS:CKeyboardEdit] +Type=0 +BaseClass=CEdit +HeaderFile=KeyboardEdit.h +ImplementationFile=KeyboardEdit.cpp + +[CLS:MotionConfig] +Type=0 +BaseClass=CDialog +HeaderFile=Joypad.h +ImplementationFile=Joypad.cpp + +[CLS:LangSelect] +Type=0 +BaseClass=CDialog +HeaderFile=LangSelect.h +ImplementationFile=LangSelect.cpp + +[CLS:MainWnd] +Type=0 +BaseClass=CWnd +HeaderFile=MainWnd.h +ImplementationFile=MainWnd.cpp +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS +Filter=W +VirtualFilter=WC + +[CLS:ModeConfirm] +Type=0 +BaseClass=CDialog +HeaderFile=ModeConfirm.h +ImplementationFile=ModeConfirm.cpp + +[CLS:RewindInterval] +Type=0 +BaseClass=CDialog +HeaderFile=RewindInterval.h +ImplementationFile=RewindInterval.cpp + +[CLS:RomInfoGB] +Type=0 +BaseClass=CDialog +HeaderFile=RomInfo.h +ImplementationFile=RomInfo.cpp + +[CLS:RomInfoGBA] +Type=0 +BaseClass=CDialog +HeaderFile=RomInfo.h +ImplementationFile=RomInfo.cpp + +[CLS:SkinButton] +Type=0 +BaseClass=CWnd +HeaderFile=skinButton.h +ImplementationFile=skinButton.cpp + +[CLS:Throttle] +Type=0 +BaseClass=CDialog +HeaderFile=Throttle.h +ImplementationFile=Throttle.cpp + +[CLS:VBA] +Type=0 +BaseClass=CWinApp +HeaderFile=VBA.h +ImplementationFile=VBA.cpp + +[CLS:VideoMode] +Type=0 +BaseClass=CDialog +HeaderFile=VideoMode.h +ImplementationFile=VideoMode.cpp + +[CLS:VideoDriverSelect] +Type=0 +BaseClass=CDialog +HeaderFile=VideoMode.h +ImplementationFile=VideoMode.cpp +Filter=D +VirtualFilter=dWC +LastObject=ID_CANCEL + +[DLG:IDD_ABOUT] +Type=1 +Class=AboutDialog +ControlCount=8 +Control1=IDOK,button,1342242817 +Control2=IDC_STATIC,static,1342177283 +Control3=IDC_STATIC,static,1342308353 +Control4=IDC_STATIC,static,1342308353 +Control5=IDC_URL,static,1342308353 +Control6=IDC_STATIC,static,1342308353 +Control7=IDC_STATIC,static,1342308353 +Control8=IDC_VERSION,static,1342308353 + +[DLG:IDD_ASSOCIATIONS] +Type=1 +Class=Associate +ControlCount=11 +Control1=IDC_GB,button,1342242819 +Control2=IDC_SGB,button,1342242819 +Control3=IDC_CGB,button,1342242819 +Control4=IDC_GBC,button,1342242819 +Control5=IDC_GBA,button,1342242819 +Control6=IDC_AGB,button,1342242819 +Control7=IDC_BIN,button,1342242819 +Control8=ID_OK,button,1342242817 +Control9=ID_CANCEL,button,1342242816 +Control10=IDC_STATIC,button,1342177287 +Control11=IDC_STATIC,button,1342177287 + +[DLG:IDD_DIRECTORIES] +Type=1 +Class=Directories +ControlCount=22 +Control1=IDC_ROM_DIR,button,1342242816 +Control2=IDC_GBROM_DIR,button,1342242816 +Control3=IDC_BATTERY_DIR,button,1342242816 +Control4=IDC_SAVE_DIR,button,1342242816 +Control5=IDC_CAPTURE_DIR,button,1342242816 +Control6=IDOK,button,1342242817 +Control7=IDCANCEL,button,1342242816 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_STATIC,static,1342308352 +Control10=IDC_STATIC,static,1342308352 +Control11=IDC_STATIC,static,1342308352 +Control12=IDC_ROM_PATH,edit,1484849280 +Control13=IDC_BATTERY_PATH,edit,1484849280 +Control14=IDC_SAVE_PATH,edit,1484849280 +Control15=IDC_CAPTURE_PATH,edit,1484849280 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_GBROM_PATH,edit,1484849280 +Control18=IDC_ROM_DIR_RESET,button,1342242816 +Control19=IDC_GBROM_DIR_RESET,button,1342242816 +Control20=IDC_BATTERY_DIR_RESET,button,1342242816 +Control21=IDC_SAVE_DIR_RESET,button,1342242816 +Control22=IDC_CAPTURE_DIR_RESET,button,1342242816 + +[DLG:IDD_EXPORT_SPS] +Type=1 +Class=ExportGSASnapshot +ControlCount=8 +Control1=IDC_TITLE,edit,1350631552 +Control2=IDC_DESC,edit,1350631552 +Control3=IDC_NOTES,edit,1350635652 +Control4=ID_OK,button,1342242817 +Control5=ID_CANCEL,button,1342242816 +Control6=IDC_STATIC,static,1342308352 +Control7=IDC_STATIC,static,1342308352 +Control8=IDC_STATIC,static,1342308352 + +[DLG:IDD_CHEATS] +Type=1 +Class=GBACheatSearch +ControlCount=26 +Control1=IDC_CHEAT_LIST,SysListView32,1350631429 +Control2=IDC_OLD_VALUE,button,1342308361 +Control3=IDC_SPECIFIC_VALUE,button,1342177289 +Control4=IDC_SIZE_8,button,1342308361 +Control5=IDC_SIZE_16,button,1342177289 +Control6=IDC_SIZE_32,button,1342177289 +Control7=IDC_EQ,button,1342308361 +Control8=IDC_NE,button,1342177289 +Control9=IDC_LT,button,1342177289 +Control10=IDC_LE,button,1342177289 +Control11=IDC_GT,button,1342177289 +Control12=IDC_GE,button,1342177289 +Control13=IDC_SIGNED,button,1342308361 +Control14=IDC_UNSIGNED,button,1342177289 +Control15=IDC_HEXADECIMAL,button,1342177289 +Control16=IDC_UPDATE,button,1342373891 +Control17=IDC_VALUE,edit,1350631552 +Control18=IDC_START,button,1342373888 +Control19=IDC_SEARCH,button,1342242816 +Control20=IDC_ADD_CHEAT,button,1342242816 +Control21=ID_OK,button,1342242817 +Control22=IDC_STATIC,button,1342177287 +Control23=IDC_STATIC,button,1342177287 +Control24=IDC_STATIC,button,1342177287 +Control25=IDC_STATIC,button,1342177287 +Control26=IDC_STATIC,static,1342308352 + +[DLG:IDD_ADD_CHEAT] +Type=1 +Class=AddCheat +ControlCount=16 +Control1=IDC_ADDRESS,edit,1350631552 +Control2=IDC_VALUE,edit,1350631552 +Control3=IDC_DESC,edit,1350631552 +Control4=IDC_SIZE_8,button,1342373897 +Control5=IDC_SIZE_16,button,1342177289 +Control6=IDC_SIZE_32,button,1342177289 +Control7=IDC_SIGNED,button,1342373897 +Control8=IDC_UNSIGNED,button,1342177289 +Control9=IDC_HEXADECIMAL,button,1342177289 +Control10=ID_OK,button,1342373889 +Control11=ID_CANCEL,button,1342242816 +Control12=IDC_STATIC,static,1342308352 +Control13=IDC_STATIC,button,1342177287 +Control14=IDC_STATIC,static,1342308352 +Control15=IDC_STATIC,button,1342177287 +Control16=IDC_STATIC,static,1342308352 + +[DLG:IDD_CHEAT_LIST] +Type=1 +Class=GBACheatList +ControlCount=14 +Control1=IDC_RESTORE,button,1342373891 +Control2=IDC_ADD_CODE,button,1342373888 +Control3=IDC_ADD_CHEAT,button,1342242816 +Control4=IDC_ADD_GAMESHARK,button,1342242816 +Control5=IDC_ADD_CODEBREAKER,button,1342242816 +Control6=IDC_REMOVE,button,1342242816 +Control7=IDC_REMOVE_ALL,button,1342242816 +Control8=IDC_ENABLE,button,1342242816 +Control9=ID_OK,button,1342373889 +Control10=IDC_CHEAT_LIST,SysListView32,1350762497 +Control11=IDC_STATIC,static,1342308352 +Control12=IDC_STATIC,static,1342308352 +Control13=IDC_STATIC,static,1342308352 +Control14=IDC_STATIC,button,1342177287 + +[DLG:IDD_GB_COLORS] +Type=1 +Class=GBColorDlg +ControlCount=17 +Control1=IDC_DEFAULT,button,1342308361 +Control2=IDC_USER1,button,1342177289 +Control3=IDC_USER2,button,1342177289 +Control4=IDC_PREDEFINED,combobox,1344340227 +Control5=IDC_COLOR_BG0,button,1342373888 +Control6=IDC_COLOR_BG1,button,1342242816 +Control7=IDC_COLOR_BG2,button,1342242816 +Control8=IDC_COLOR_BG3,button,1342242816 +Control9=IDC_COLOR_OB0,button,1342242816 +Control10=IDC_COLOR_OB1,button,1342242816 +Control11=IDC_COLOR_OB2,button,1342242816 +Control12=IDC_COLOR_OB3,button,1342242816 +Control13=IDC_RESET,button,1342242816 +Control14=ID_OK,button,1342242817 +Control15=ID_CANCEL,button,1342242816 +Control16=IDC_STATIC,button,1342177287 +Control17=IDC_STATIC,button,1342177287 + +[DLG:IDD_CODE_SELECT] +Type=1 +Class=GSACodeSelect +ControlCount=3 +Control1=ID_OK,button,1342242817 +Control2=ID_CANCEL,button,1342242816 +Control3=IDC_GAME_LIST,listbox,1353777411 + +[DLG:IDD_CONFIG] +Type=1 +Class=JoypadConfig +ControlCount=28 +Control1=IDC_EDIT_UP,edit,1350631552 +Control2=IDC_EDIT_DOWN,edit,1350631552 +Control3=IDC_EDIT_LEFT,edit,1350631552 +Control4=IDC_EDIT_RIGHT,edit,1350631552 +Control5=IDC_EDIT_BUTTON_A,edit,1350631552 +Control6=IDC_EDIT_BUTTON_B,edit,1350631552 +Control7=IDC_EDIT_BUTTON_L,edit,1350631552 +Control8=IDC_EDIT_BUTTON_R,edit,1350631552 +Control9=IDC_EDIT_BUTTON_SELECT,edit,1350631552 +Control10=IDC_EDIT_BUTTON_START,edit,1350631552 +Control11=IDC_EDIT_SPEED,edit,1350631552 +Control12=IDC_EDIT_CAPTURE,edit,1350631552 +Control13=IDC_EDIT_BUTTON_GS,edit,1350631552 +Control14=ID_OK,button,1342242816 +Control15=ID_CANCEL,button,1342242816 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_STATIC,static,1342308352 +Control18=IDC_STATIC,static,1342308352 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_STATIC,static,1342308352 +Control22=IDC_STATIC,static,1342308352 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_STATIC,static,1342308352 +Control26=IDC_STATIC,static,1342308352 +Control27=IDC_STATIC,static,1342308352 +Control28=IDC_STATIC,static,1342308352 + +[DLG:IDD_MOTION_CONFIG] +Type=1 +Class=MotionConfig +ControlCount=10 +Control1=IDC_EDIT_UP,edit,1350631552 +Control2=IDC_EDIT_DOWN,edit,1350631552 +Control3=IDC_EDIT_LEFT,edit,1350631552 +Control4=IDC_EDIT_RIGHT,edit,1350631552 +Control5=ID_OK,button,1342242816 +Control6=ID_CANCEL,button,1342242816 +Control7=IDC_STATIC,static,1342308352 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_STATIC,static,1342308352 +Control10=IDC_STATIC,static,1342308352 + +[DLG:IDD_LANG_SELECT] +Type=1 +Class=LangSelect +ControlCount=6 +Control1=IDC_LANG_STRING,edit,1350631552 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_LANG_NAME,static,1342308352 + +[DLG:IDD_MODE_CONFIRM] +Type=1 +Class=ModeConfirm +ControlCount=4 +Control1=ID_OK,button,1342242817 +Control2=ID_CANCEL,button,1342242816 +Control3=IDC_STATIC,static,1342308353 +Control4=IDC_TIMER,static,1342308353 + +[DLG:IDD_REWIND_INTERVAL] +Type=1 +Class=RewindInterval +ControlCount=5 +Control1=IDC_INTERVAL,edit,1350631552 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 +Control5=IDC_STATIC,static,1342308352 + +[DLG:IDD_GB_ROM_INFO] +Type=1 +Class=RomInfoGB +ControlCount=27 +Control1=ID_OK,button,1342242817 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_STATIC,static,1342308352 +Control4=IDC_STATIC,static,1342308352 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_STATIC,static,1342308352 +Control7=IDC_STATIC,static,1342308352 +Control8=IDC_ROM_TITLE,static,1342308352 +Control9=IDC_ROM_MAKER_CODE,static,1342308352 +Control10=IDC_ROM_UNIT_CODE,static,1342308352 +Control11=IDC_ROM_DEVICE_TYPE,static,1342308352 +Control12=IDC_ROM_VERSION,static,1342308352 +Control13=IDC_ROM_CRC,static,1342308352 +Control14=IDC_STATIC,static,1342308352 +Control15=IDC_ROM_COLOR,static,1342308352 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_ROM_SIZE,static,1342308352 +Control18=IDC_STATIC,static,1342308352 +Control19=IDC_ROM_RAM_SIZE,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_ROM_DEST_CODE,static,1342308352 +Control22=IDC_STATIC,static,1342308352 +Control23=IDC_ROM_LIC_CODE,static,1342308352 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_ROM_CHECKSUM,static,1342308352 +Control26=IDC_ROM_MAKER_NAME2,static,1342308352 +Control27=IDC_STATIC,static,1342308352 + +[DLG:IDD_GBA_ROM_INFO] +Type=1 +Class=RomInfoGBA +ControlCount=17 +Control1=ID_OK,button,1342242817 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_STATIC,static,1342308352 +Control4=IDC_STATIC,static,1342308352 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_STATIC,static,1342308352 +Control7=IDC_STATIC,static,1342308352 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_ROM_TITLE,static,1342308352 +Control10=IDC_ROM_GAME_CODE,static,1342308352 +Control11=IDC_ROM_MAKER_CODE,static,1342308352 +Control12=IDC_ROM_UNIT_CODE,static,1342308352 +Control13=IDC_ROM_DEVICE_TYPE,static,1342308352 +Control14=IDC_ROM_VERSION,static,1342308352 +Control15=IDC_ROM_CRC,static,1342308352 +Control16=IDC_ROM_MAKER_NAME,static,1342308352 +Control17=IDC_STATIC,static,1342308352 + +[DLG:IDD_THROTTLE] +Type=1 +Class=Throttle +ControlCount=4 +Control1=IDC_THROTTLE,edit,1350631552 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 + +[DLG:IDD_MODES] +Type=1 +Class=VideoMode +ControlCount=4 +Control1=IDC_MODES,listbox,1352728835 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 + +[DLG:IDD_DRIVERS] +Type=1 +Class=VideoDriverSelect +ControlCount=4 +Control1=IDC_DRIVERS,listbox,1352728833 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 + +[DLG:IDD_OPENDLG] +Type=1 +Class=GBMemoryViewerDlg +ControlCount=12 +Control1=1090,static,1342308352 +Control2=1152,edit,1350632576 +Control3=1120,listbox,1352732755 +Control4=65535,static,1342308352 +Control5=1088,static,1342308480 +Control6=1121,listbox,1352732755 +Control7=1089,static,1342308352 +Control8=1136,combobox,1344340035 +Control9=1091,static,1342308352 +Control10=1137,combobox,1344340819 +Control11=IDOK,button,1342373889 +Control12=IDCANCEL,button,1342373888 + +[DLG:IDD_GB_CHEAT_LIST] +Type=1 +Class=GBCheatList +ControlCount=10 +Control1=IDC_CHEAT_LIST,SysListView32,1350762497 +Control2=IDC_ADD_GG_CHEAT,button,1342373888 +Control3=IDC_ADD_GS_CHEAT,button,1342373888 +Control4=IDC_REMOVE,button,1342242816 +Control5=IDC_REMOVE_ALL,button,1342242816 +Control6=IDC_ENABLE,button,1342242816 +Control7=ID_OK,button,1342242817 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_STATIC,static,1342308352 +Control10=IDC_STATIC,static,1342308352 + +[DLG:IDD_ADD_CHEAT_DLG] +Type=1 +Class=AddGSACode +ControlCount=6 +Control1=IDC_DESC,edit,1350631552 +Control2=IDC_CODE,edit,1350635724 +Control3=ID_OK,button,1342242817 +Control4=ID_CANCEL,button,1342242816 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_STATIC,static,1342308352 + +[DLG:IDD_GB_PRINTER] +Type=1 +Class=GBPrinterDlg +ControlCount=9 +Control1=IDC_1X,button,1342308361 +Control2=IDC_2X,button,1342177289 +Control3=IDC_3X,button,1342177289 +Control4=IDC_4X,button,1342177289 +Control5=ID_PRINT,button,1342373889 +Control6=ID_SAVE,button,1342242816 +Control7=ID_OK,button,1342242816 +Control8=IDC_GB_PRINTER,static,1342308359 +Control9=IDC_STATIC,button,1342177287 + +[DLG:IDD_MAP_VIEW] +Type=1 +Class=MapView +ControlCount=44 +Control1=IDC_FRAME_0,button,1342308361 +Control2=IDC_FRAME_1,button,1342177289 +Control3=IDC_BG0,button,1342308361 +Control4=IDC_BG1,button,1342177289 +Control5=IDC_BG2,button,1342177289 +Control6=IDC_BG3,button,1342177289 +Control7=IDC_STRETCH,button,1342242819 +Control8=IDC_REFRESH,button,1342373888 +Control9=IDC_SAVE,button,1342373888 +Control10=IDC_CLOSE,button,1342242816 +Control11=IDC_MAP_VIEW,VbaBitmapControl,1342373888 +Control12=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888 +Control13=IDC_COLOR,VbaColorControl,1342242816 +Control14=IDC_R,static,1342308352 +Control15=IDC_G,static,1342308352 +Control16=IDC_B,static,1342308352 +Control17=IDC_STATIC,button,1342177287 +Control18=IDC_STATIC,button,1342177287 +Control19=IDC_AUTO_UPDATE,button,1342242819 +Control20=IDC_XY,static,1342308352 +Control21=IDC_STATIC,static,1342308352 +Control22=IDC_MODE,static,1342308352 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_MAPBASE,static,1342308352 +Control25=IDC_STATIC,static,1342308352 +Control26=IDC_CHARBASE,static,1342308352 +Control27=IDC_STATIC,static,1342308352 +Control28=IDC_DIM,static,1342308352 +Control29=IDC_STATIC,static,1342308352 +Control30=IDC_NUMCOLORS,static,1342308352 +Control31=IDC_STATIC,static,1342308352 +Control32=IDC_PRIORITY,static,1342308352 +Control33=IDC_STATIC,static,1342308352 +Control34=IDC_MOSAIC,static,1342308352 +Control35=IDC_STATIC,static,1342308352 +Control36=IDC_OVERFLOW,static,1342308352 +Control37=IDC_STATIC,static,1342308352 +Control38=IDC_ADDRESS,static,1342308352 +Control39=IDC_STATIC,static,1342308352 +Control40=IDC_TILE_NUM,static,1342308352 +Control41=IDC_STATIC,static,1342308352 +Control42=IDC_FLIP,static,1342308352 +Control43=IDC_STATIC,static,1342308352 +Control44=IDC_PALETTE_NUM,static,1342308352 + +[DLG:IDD_PALETTE_VIEW] +Type=1 +Class=PaletteView +ControlCount=21 +Control1=IDC_SAVE_BG,button,1342242816 +Control2=IDC_SAVE_OBJ,button,1342242816 +Control3=IDC_REFRESH2,button,1342242816 +Control4=IDC_CLOSE,button,1342242816 +Control5=IDC_ADDRESS,static,1342308352 +Control6=IDC_R,static,1342308352 +Control7=IDC_G,static,1342308352 +Control8=IDC_B,static,1342308352 +Control9=IDC_VALUE,static,1342308352 +Control10=IDC_COLOR,VbaColorControl,1342242816 +Control11=IDC_PALETTE_VIEW,VbaPaletteViewControl,1342242816 +Control12=IDC_PALETTE_VIEW_OBJ,VbaPaletteViewControl,1342242816 +Control13=IDC_STATIC,button,1342177287 +Control14=IDC_STATIC,button,1342177287 +Control15=IDC_STATIC,static,1342308352 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_STATIC,static,1342308352 +Control18=IDC_STATIC,static,1342308352 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_AUTO_UPDATE,button,1342242819 + +[DLG:IDD_MEM_VIEWER] +Type=1 +Class=MemoryViewerDlg +ControlCount=14 +Control1=IDC_ADDRESSES,combobox,1344339971 +Control2=IDC_8_BIT,button,1342308361 +Control3=IDC_16_BIT,button,1342177289 +Control4=IDC_32_BIT,button,1342177289 +Control5=IDC_ADDRESS,edit,1350766728 +Control6=IDC_GO,button,1342373889 +Control7=IDC_VIEWER,VbaMemoryViewer,1342242816 +Control8=IDC_AUTO_UPDATE,button,1342242819 +Control9=IDC_REFRESH,button,1342242816 +Control10=IDC_LOAD,button,1342242816 +Control11=IDC_SAVE,button,1342242816 +Control12=IDC_CLOSE,button,1342242816 +Control13=IDC_CURRENT_ADDRESS_LABEL,static,1342308352 +Control14=IDC_CURRENT_ADDRESS,edit,1484849282 + +[DLG:IDD_OAM_VIEW] +Type=1 +Class=OamView +ControlCount=32 +Control1=IDC_SPRITE,edit,1350639746 +Control2=IDC_SCROLLBAR,scrollbar,1342177280 +Control3=IDC_STRETCH,button,1342242819 +Control4=IDC_REFRESH,button,1342373888 +Control5=IDC_SAVE,button,1342373888 +Control6=IDC_CLOSE,button,1342242816 +Control7=IDC_OAM_VIEW,VbaBitmapControl,1342373888 +Control8=IDC_OAM_VIEW_ZOOM,VbaZoomControl,1342373888 +Control9=IDC_COLOR,VbaColorControl,1342242816 +Control10=IDC_POS,static,1342308352 +Control11=IDC_MODE,static,1342308352 +Control12=IDC_COLORS,static,1342308352 +Control13=IDC_PALETTE,static,1342308352 +Control14=IDC_TILE,static,1342308352 +Control15=IDC_PRIO,static,1342308352 +Control16=IDC_SIZE2,static,1342308352 +Control17=IDC_ROT,static,1342308352 +Control18=IDC_FLAGS,static,1342308352 +Control19=IDC_R,static,1342308352 +Control20=IDC_G,static,1342308352 +Control21=IDC_B,static,1342308352 +Control22=IDC_STATIC,static,1342308352 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_STATIC,static,1342308352 +Control26=IDC_STATIC,static,1342308352 +Control27=IDC_STATIC,static,1342308352 +Control28=IDC_STATIC,static,1342308352 +Control29=IDC_STATIC,static,1342308352 +Control30=IDC_STATIC,static,1342308352 +Control31=IDC_STATIC,static,1342308352 +Control32=IDC_AUTO_UPDATE,button,1342242819 + +[DLG:IDD_ACCEL_EDITOR] +Type=1 +Class=AccelEditor +ControlCount=13 +Control1=IDC_STATIC,static,1342308352 +Control2=IDC_COMMANDS,listbox,1352732931 +Control3=IDC_STATIC1,static,1342308352 +Control4=IDC_CURRENTS,listbox,1352728835 +Control5=ID_OK,button,1342242817 +Control6=ID_CANCEL,button,1342242816 +Control7=IDC_STATIC3,static,1342308352 +Control8=IDC_EDIT_KEY,edit,1350631552 +Control9=IDC_ASSIGN,button,1342242816 +Control10=IDC_REMOVE,button,1342242816 +Control11=IDC_RESET,button,1342242816 +Control12=IDC_ALREADY_AFFECTED,static,1342308864 +Control13=IDC_STATIC2,static,1342308352 + +[DLG:IDD_TILE_VIEWER] +Type=1 +Class=TileView +ControlCount=26 +Control1=IDC_16_COLORS,button,1342308361 +Control2=IDC_256_COLORS,button,1342177289 +Control3=IDC_CHARBASE_0,button,1342308361 +Control4=IDC_CHARBASE_1,button,1342177289 +Control5=IDC_CHARBASE_2,button,1342177289 +Control6=IDC_CHARBASE_3,button,1342177289 +Control7=IDC_CHARBASE_4,button,1342177289 +Control8=IDC_PALETTE_SLIDER,msctls_trackbar32,1342373889 +Control9=IDC_STRETCH,button,1342242819 +Control10=IDC_REFRESH,button,1342373888 +Control11=IDC_SAVE,button,1342242816 +Control12=IDC_CLOSE,button,1342242816 +Control13=IDC_TILE_VIEW,VbaBitmapControl,1342373888 +Control14=IDC_STATIC,button,1342177287 +Control15=IDC_STATIC,button,1342177287 +Control16=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888 +Control17=IDC_COLOR,VbaColorControl,1342242816 +Control18=IDC_R,static,1342308352 +Control19=IDC_G,static,1342308352 +Control20=IDC_B,static,1342308352 +Control21=IDC_STATIC,static,1342308352 +Control22=IDC_AUTO_UPDATE,button,1342242819 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_TILE_NUMBER,static,1342308352 +Control26=IDC_ADDRESS,static,1342308352 + +[DLG:IDD_DISASSEMBLE] +Type=1 +Class=Disassemble +ControlCount=55 +Control1=IDC_AUTOMATIC,button,1342308361 +Control2=IDC_ARM,button,1342177289 +Control3=IDC_THUMB,button,1342177289 +Control4=IDC_ADDRESS,edit,1350762632 +Control5=IDC_GO,button,1342242816 +Control6=IDC_DISASSEMBLE,listbox,1350631683 +Control7=IDC_AUTO_UPDATE,button,1342242819 +Control8=IDC_REFRESH,button,1342242816 +Control9=IDC_NEXT,button,1342242816 +Control10=IDC_CLOSE,button,1342242817 +Control11=IDC_STATIC,static,1342308352 +Control12=IDC_STATIC,static,1342308352 +Control13=IDC_STATIC,static,1342308352 +Control14=IDC_STATIC,static,1342308352 +Control15=IDC_STATIC,static,1342308352 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_STATIC,static,1342308352 +Control18=IDC_STATIC,static,1342308352 +Control19=IDC_R0,static,1342308352 +Control20=IDC_R1,static,1342308352 +Control21=IDC_R2,static,1342308352 +Control22=IDC_R3,static,1342308352 +Control23=IDC_R4,static,1342308352 +Control24=IDC_R5,static,1342308352 +Control25=IDC_R6,static,1342308352 +Control26=IDC_R7,static,1342308352 +Control27=IDC_R8,static,1342308352 +Control28=IDC_R9,static,1342308352 +Control29=IDC_R10,static,1342308352 +Control30=IDC_R11,static,1342308352 +Control31=IDC_R12,static,1342308352 +Control32=IDC_R13,static,1342308352 +Control33=IDC_R14,static,1342308352 +Control34=IDC_R15,static,1342308352 +Control35=IDC_STATIC,static,1342308352 +Control36=IDC_STATIC,static,1342308352 +Control37=IDC_STATIC,static,1342308352 +Control38=IDC_STATIC,static,1342308352 +Control39=IDC_STATIC,static,1342308352 +Control40=IDC_STATIC,static,1342308352 +Control41=IDC_STATIC,static,1342308352 +Control42=IDC_STATIC,static,1342308352 +Control43=IDC_R16,static,1342308352 +Control44=IDC_STATIC,static,1342308352 +Control45=IDC_N,button,1476460547 +Control46=IDC_Z,button,1476460547 +Control47=IDC_C,button,1476460547 +Control48=IDC_V,button,1476460547 +Control49=IDC_F,button,1476460547 +Control50=IDC_I,button,1476460547 +Control51=IDC_T,button,1476460547 +Control52=IDC_STATIC,static,1342308352 +Control53=IDC_MODE,static,1342308352 +Control54=IDC_VSCROLL,scrollbar,1342177281 +Control55=IDC_GOPC,button,1342242816 + +[DLG:IDD_GDB_PORT] +Type=1 +Class=GDBPortDlg +ControlCount=4 +Control1=ID_OK,button,1342242817 +Control2=ID_CANCEL,button,1342242816 +Control3=IDC_STATIC,static,1342308352 +Control4=IDC_PORT,edit,1350631554 + +[DLG:IDD_GDB_WAITING] +Type=1 +Class=GDBWaitingDlg +ControlCount=3 +Control1=ID_CANCEL,button,1342242816 +Control2=IDC_STATIC,static,1342308352 +Control3=IDC_PORT,static,1342308352 + +[DLG:IDD_LOGGING] +Type=1 +Class=Logging +ControlCount=15 +Control1=IDC_VERBOSE_SWI,button,1342242819 +Control2=IDC_VERBOSE_UNALIGNED_ACCESS,button,1342242819 +Control3=IDC_VERBOSE_ILLEGAL_WRITE,button,1342242819 +Control4=IDC_VERBOSE_ILLEGAL_READ,button,1342242819 +Control5=IDC_VERBOSE_DMA0,button,1342242819 +Control6=IDC_VERBOSE_DMA1,button,1342242819 +Control7=IDC_VERBOSE_DMA2,button,1342242819 +Control8=IDC_VERBOSE_DMA3,button,1342242819 +Control9=IDC_VERBOSE_UNDEFINED,button,1342242819 +Control10=IDC_VERBOSE_AGBPRINT,button,1342242819 +Control11=IDC_LOG,edit,1353779396 +Control12=IDC_SAVE,button,1342242816 +Control13=IDC_CLEAR,button,1342242816 +Control14=ID_OK,button,1342242817 +Control15=IDC_STATIC,button,1342177287 + +[DLG:IDD_ADDR_SIZE] +Type=1 +Class=MemoryViewerAddressSize +ControlCount=6 +Control1=IDC_ADDRESS,edit,1350631552 +Control2=IDC_SIZE_CONTROL,edit,1350631552 +Control3=ID_OK,button,1342242817 +Control4=ID_CANCEL,button,1342242816 +Control5=IDC_STATIC,static,1342308352 +Control6=IDC_STATIC,static,1342308352 + +[DLG:IDD_GB_DISASSEMBLE] +Type=1 +Class=GBDisassemble +ControlCount=27 +Control1=IDC_ADDRESS,edit,1350762632 +Control2=IDC_GO,button,1342242816 +Control3=IDC_DISASSEMBLE,listbox,1350631683 +Control4=IDC_AUTO_UPDATE,button,1342242819 +Control5=IDC_REFRESH,button,1342242816 +Control6=IDC_NEXT,button,1342242816 +Control7=IDC_CLOSE,button,1342242817 +Control8=IDC_STATIC,static,1342308352 +Control9=IDC_STATIC,static,1342308352 +Control10=IDC_STATIC,static,1342308352 +Control11=IDC_STATIC,static,1342308352 +Control12=IDC_STATIC,static,1342308352 +Control13=IDC_R0,static,1342308352 +Control14=IDC_R1,static,1342308352 +Control15=IDC_R2,static,1342308352 +Control16=IDC_R3,static,1342308352 +Control17=IDC_R6,static,1342308352 +Control18=IDC_N,button,1476460547 +Control19=IDC_Z,button,1476460547 +Control20=IDC_C,button,1476460547 +Control21=IDC_H,button,1476460547 +Control22=IDC_VSCROLL,scrollbar,1342177281 +Control23=IDC_GOPC,button,1342242816 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_R4,static,1342308352 +Control26=IDC_STATIC,static,1342308352 +Control27=IDC_R5,static,1342308352 + +[DLG:IDD_GB_OAM_VIEW] +Type=1 +Class=GBOamView +ControlCount=28 +Control1=IDC_SPRITE,edit,1350639746 +Control2=IDC_SCROLLBAR,scrollbar,1342177280 +Control3=IDC_STRETCH,button,1342242819 +Control4=IDC_REFRESH,button,1342373888 +Control5=IDC_SAVE,button,1342373888 +Control6=IDC_CLOSE,button,1342242816 +Control7=IDC_OAM_VIEW,VbaBitmapControl,1342373888 +Control8=IDC_OAM_VIEW_ZOOM,VbaZoomControl,1342373888 +Control9=IDC_COLOR,VbaColorControl,1342242816 +Control10=IDC_POS,static,1342308352 +Control11=IDC_PALETTE,static,1342308352 +Control12=IDC_TILE,static,1342308352 +Control13=IDC_PRIO,static,1342308352 +Control14=IDC_OAP,static,1342308352 +Control15=IDC_FLAGS,static,1342308352 +Control16=IDC_R,static,1342308352 +Control17=IDC_G,static,1342308352 +Control18=IDC_B,static,1342308352 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_STATIC,static,1342308352 +Control22=IDC_STATIC,static,1342308352 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_STATIC,static,1342308352 +Control25=IDC_STATIC,static,1342308352 +Control26=IDC_AUTO_UPDATE,button,1342242819 +Control27=IDC_BANK,static,1342308352 +Control28=IDC_STATIC,static,1342308352 + +[DLG:IDD_GB_TILE_VIEWER] +Type=1 +Class=GBTileView +ControlCount=23 +Control1=IDC_BANK_0,button,1342308361 +Control2=IDC_BANK_1,button,1342177289 +Control3=IDC_CHARBASE_0,button,1342308361 +Control4=IDC_CHARBASE_1,button,1342177289 +Control5=IDC_STRETCH,button,1342242819 +Control6=IDC_REFRESH,button,1342373888 +Control7=IDC_SAVE,button,1342242816 +Control8=IDC_CLOSE,button,1342242816 +Control9=IDC_TILE_VIEW,VbaBitmapControl,1342373888 +Control10=IDC_STATIC,button,1342177287 +Control11=IDC_STATIC,button,1342177287 +Control12=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888 +Control13=IDC_COLOR,VbaColorControl,1342242816 +Control14=IDC_R,static,1342308352 +Control15=IDC_G,static,1342308352 +Control16=IDC_B,static,1342308352 +Control17=IDC_STATIC,static,1342308352 +Control18=IDC_AUTO_UPDATE,button,1342242819 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_TILE_NUMBER,static,1342308352 +Control22=IDC_ADDRESS,static,1342308352 +Control23=IDC_PALETTE_SLIDER,msctls_trackbar32,1342373889 + +[DLG:IDD_GB_MAP_VIEW] +Type=1 +Class=GBMapView +ControlCount=28 +Control1=IDC_BANK_0,button,1342308361 +Control2=IDC_BANK_1,button,1342177289 +Control3=IDC_BG0,button,1342308361 +Control4=IDC_BG1,button,1342177289 +Control5=IDC_STRETCH,button,1342242819 +Control6=IDC_REFRESH,button,1342373888 +Control7=IDC_SAVE,button,1342373888 +Control8=IDC_CLOSE,button,1342242816 +Control9=IDC_MAP_VIEW,VbaBitmapControl,1342373888 +Control10=IDC_MAP_VIEW_ZOOM,VbaZoomControl,1342373888 +Control11=IDC_COLOR,VbaColorControl,1342242816 +Control12=IDC_R,static,1342308352 +Control13=IDC_G,static,1342308352 +Control14=IDC_B,static,1342308352 +Control15=IDC_STATIC,button,1342177287 +Control16=IDC_STATIC,button,1342177287 +Control17=IDC_AUTO_UPDATE,button,1342242819 +Control18=IDC_XY,static,1342308352 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_PRIORITY,static,1342308352 +Control21=IDC_STATIC,static,1342308352 +Control22=IDC_ADDRESS,static,1342308352 +Control23=IDC_STATIC,static,1342308352 +Control24=IDC_TILE_NUM,static,1342308352 +Control25=IDC_STATIC,static,1342308352 +Control26=IDC_FLIP,static,1342308352 +Control27=IDC_STATIC,static,1342308352 +Control28=IDC_PALETTE_NUM,static,1342308352 + +[DLG:IDD_GB_PALETTE_VIEW] +Type=1 +Class=GBPaletteView +ControlCount=21 +Control1=IDC_SAVE_BG,button,1342242816 +Control2=IDC_SAVE_OBJ,button,1342242816 +Control3=IDC_REFRESH2,button,1342242816 +Control4=IDC_CLOSE,button,1342242816 +Control5=IDC_ADDRESS,static,1342308352 +Control6=IDC_R,static,1342308352 +Control7=IDC_G,static,1342308352 +Control8=IDC_B,static,1342308352 +Control9=IDC_VALUE,static,1342308352 +Control10=IDC_COLOR,VbaColorControl,1342242816 +Control11=IDC_PALETTE_VIEW,VbaPaletteViewControl,1342242816 +Control12=IDC_PALETTE_VIEW_OBJ,VbaPaletteViewControl,1342242816 +Control13=IDC_STATIC,button,1342177287 +Control14=IDC_STATIC,button,1342177287 +Control15=IDC_STATIC,static,1342308352 +Control16=IDC_STATIC,static,1342308352 +Control17=IDC_STATIC,static,1342308352 +Control18=IDC_STATIC,static,1342308352 +Control19=IDC_STATIC,static,1342308352 +Control20=IDC_STATIC,static,1342308352 +Control21=IDC_AUTO_UPDATE,button,1342242819 + +[DLG:IDD_IO_VIEWER] +Type=1 +Class=IOViewer +ControlCount=23 +Control1=IDC_ADDRESSES,combobox,1344339971 +Control2=IDC_VALUE,static,1342308354 +Control3=IDC_BIT_15,button,1342242819 +Control4=IDC_BIT_14,button,1342242819 +Control5=IDC_BIT_13,button,1342242819 +Control6=IDC_BIT_12,button,1342242819 +Control7=IDC_BIT_11,button,1342242819 +Control8=IDC_BIT_10,button,1342242819 +Control9=IDC_BIT_9,button,1342242819 +Control10=IDC_BIT_8,button,1342242819 +Control11=IDC_BIT_7,button,1342242819 +Control12=IDC_BIT_6,button,1342242819 +Control13=IDC_BIT_5,button,1342242819 +Control14=IDC_BIT_4,button,1342242819 +Control15=IDC_BIT_3,button,1342242819 +Control16=IDC_BIT_2,button,1342242819 +Control17=IDC_BIT_1,button,1342242819 +Control18=IDC_BIT_0,button,1342242819 +Control19=IDC_AUTO_UPDATE,button,1342242819 +Control20=IDC_REFRESH,button,1342242817 +Control21=IDC_APPLY,button,1342242817 +Control22=IDC_CLOSE,button,1342242816 +Control23=IDC_STATIC,static,1342308352 + +[MNU:IDR_MENU] +Type=1 +Class=MainWnd +Command1=ID_FILE_OPEN +Command2=ID_FILE_OPENGAMEBOY +Command3=ID_FILE_LOAD +Command4=ID_FILE_SAVE +Command5=ID_FILE_LOADGAME_MOSTRECENT +Command6=ID_FILE_LOADGAME_AUTOLOADMOSTRECENT +Command7=ID_FILE_LOADGAME_SLOT1 +Command8=ID_FILE_LOADGAME_SLOT2 +Command9=ID_FILE_LOADGAME_SLOT3 +Command10=ID_FILE_LOADGAME_SLOT4 +Command11=ID_FILE_LOADGAME_SLOT5 +Command12=ID_FILE_LOADGAME_SLOT6 +Command13=ID_FILE_LOADGAME_SLOT7 +Command14=ID_FILE_LOADGAME_SLOT8 +Command15=ID_FILE_LOADGAME_SLOT9 +Command16=ID_FILE_LOADGAME_SLOT10 +Command17=ID_FILE_SAVEGAME_OLDESTSLOT +Command18=ID_FILE_SAVEGAME_SLOT1 +Command19=ID_FILE_SAVEGAME_SLOT2 +Command20=ID_FILE_SAVEGAME_SLOT3 +Command21=ID_FILE_SAVEGAME_SLOT4 +Command22=ID_FILE_SAVEGAME_SLOT5 +Command23=ID_FILE_SAVEGAME_SLOT6 +Command24=ID_FILE_SAVEGAME_SLOT7 +Command25=ID_FILE_SAVEGAME_SLOT8 +Command26=ID_FILE_SAVEGAME_SLOT9 +Command27=ID_FILE_SAVEGAME_SLOT10 +Command28=ID_FILE_PAUSE +Command29=ID_FILE_RESET +Command30=ID_FILE_RECENT_RESET +Command31=ID_FILE_RECENT_FREEZE +Command32=ID_FILE_IMPORT_BATTERYFILE +Command33=ID_FILE_IMPORT_GAMESHARKCODEFILE +Command34=ID_FILE_IMPORT_GAMESHARKSNAPSHOT +Command35=ID_FILE_EXPORT_BATTERYFILE +Command36=ID_FILE_EXPORT_GAMESHARKSNAPSHOT +Command37=ID_FILE_SCREENCAPTURE +Command38=ID_FILE_ROMINFORMATION +Command39=ID_FILE_TOGGLEMENU +Command40=ID_FILE_CLOSE +Command41=ID_FILE_EXIT +Command42=ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE +Command43=ID_OPTIONS_FRAMESKIP_THROTTLE_25 +Command44=ID_OPTIONS_FRAMESKIP_THROTTLE_50 +Command45=ID_OPTIONS_FRAMESKIP_THROTTLE_100 +Command46=ID_OPTIONS_FRAMESKIP_THROTTLE_150 +Command47=ID_OPTIONS_FRAMESKIP_THROTTLE_200 +Command48=ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER +Command49=ID_OPTIONS_FRAMESKIP_AUTOMATIC +Command50=ID_OPTIONS_VIDEO_FRAMESKIP_0 +Command51=ID_OPTIONS_VIDEO_FRAMESKIP_1 +Command52=ID_OPTIONS_VIDEO_FRAMESKIP_2 +Command53=ID_OPTIONS_VIDEO_FRAMESKIP_3 +Command54=ID_OPTIONS_VIDEO_FRAMESKIP_4 +Command55=ID_OPTIONS_VIDEO_FRAMESKIP_5 +Command56=ID_OPTIONS_VIDEO_FRAMESKIP_6 +Command57=ID_OPTIONS_VIDEO_FRAMESKIP_7 +Command58=ID_OPTIONS_VIDEO_FRAMESKIP_8 +Command59=ID_OPTIONS_VIDEO_FRAMESKIP_9 +Command60=ID_OPTIONS_VIDEO_VSYNC +Command61=ID_OPTIONS_VIDEO_RENDERMETHOD_GDI +Command62=ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW +Command63=ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D +Command64=ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL +Command65=ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY +Command66=ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY +Command67=ID_OPTIONS_VIDEO_TRIPLEBUFFERING +Command68=ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER +Command69=ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR +Command70=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST +Command71=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR +Command72=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE +Command73=ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS +Command74=ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN +Command75=ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN +Command76=ID_OPTIONS_VIDEO_X1 +Command77=ID_OPTIONS_VIDEO_X2 +Command78=ID_OPTIONS_VIDEO_X3 +Command79=ID_OPTIONS_VIDEO_X4 +Command80=ID_OPTIONS_VIDEO_FULLSCREEN320X240 +Command81=ID_OPTIONS_VIDEO_FULLSCREEN640X480 +Command82=ID_OPTIONS_VIDEO_FULLSCREEN800X600 +Command83=ID_OPTIONS_VIDEO_FULLSCREEN +Command84=ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE +Command85=ID_OPTIONS_VIDEO_DISABLESFX +Command86=ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT +Command87=ID_OPTIONS_VIDEO_LAYERS_BG0 +Command88=ID_OPTIONS_VIDEO_LAYERS_BG1 +Command89=ID_OPTIONS_VIDEO_LAYERS_BG2 +Command90=ID_OPTIONS_VIDEO_LAYERS_BG3 +Command91=ID_OPTIONS_VIDEO_LAYERS_OBJ +Command92=ID_OPTIONS_VIDEO_LAYERS_WIN0 +Command93=ID_OPTIONS_VIDEO_LAYERS_WIN1 +Command94=ID_OPTIONS_VIDEO_LAYERS_OBJWIN +Command95=ID_OPTIONS_EMULATOR_ASSOCIATE +Command96=ID_OPTIONS_EMULATOR_DIRECTORIES +Command97=ID_OPTIONS_EMULATOR_DISABLESTATUSMESSAGES +Command98=ID_OPTIONS_EMULATOR_SYNCHRONIZE +Command99=ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE +Command100=ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE +Command101=ID_OPTIONS_EMULATOR_REMOVEINTROSGBA +Command102=ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH +Command103=ID_OPTIONS_EMULATOR_AGBPRINT +Command104=ID_OPTIONS_EMULATOR_REALTIMECLOCK +Command105=ID_OPTIONS_EMULATOR_AUTOHIDEMENU +Command106=ID_OPTIONS_EMULATOR_REWINDINTERVAL +Command107=ID_OPTIONS_EMULATOR_SHOWSPEED_NONE +Command108=ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE +Command109=ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED +Command110=ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT +Command111=ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC +Command112=ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM +Command113=ID_OPTIONS_EMULATOR_SAVETYPE_SRAM +Command114=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH +Command115=ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR +Command116=ID_OPTIONS_EMULATOR_SAVETYPE_NONE +Command117=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K +Command118=ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M +Command119=ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION +Command120=ID_OPTIONS_EMULATOR_USEBIOSFILE +Command121=ID_OPTIONS_EMULATOR_SKIPBIOS +Command122=ID_OPTIONS_EMULATOR_SELECTBIOSFILE +Command123=ID_OPTIONS_EMULATOR_PNGFORMAT +Command124=ID_OPTIONS_EMULATOR_BMPFORMAT +Command125=ID_OPTIONS_SOUND_OFF +Command126=ID_OPTIONS_SOUND_MUTE +Command127=ID_OPTIONS_SOUND_ON +Command128=ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION +Command129=ID_OPTIONS_SOUND_ECHO +Command130=ID_OPTIONS_SOUND_LOWPASSFILTER +Command131=ID_OPTIONS_SOUND_REVERSESTEREO +Command132=ID_OPTIONS_SOUND_CHANNEL1 +Command133=ID_OPTIONS_SOUND_CHANNEL2 +Command134=ID_OPTIONS_SOUND_CHANNEL3 +Command135=ID_OPTIONS_SOUND_CHANNEL4 +Command136=ID_OPTIONS_SOUND_DIRECTSOUNDA +Command137=ID_OPTIONS_SOUND_DIRECTSOUNDB +Command138=ID_OPTIONS_SOUND_11KHZ +Command139=ID_OPTIONS_SOUND_22KHZ +Command140=ID_OPTIONS_SOUND_44KHZ +Command141=ID_OPTIONS_SOUND_VOLUME_25X +Command142=ID_OPTIONS_SOUND_VOLUME_5X +Command143=ID_OPTIONS_SOUND_VOLUME_1X +Command144=ID_OPTIONS_SOUND_VOLUME_2X +Command145=ID_OPTIONS_SOUND_VOLUME_3X +Command146=ID_OPTIONS_SOUND_VOLUME_4X +Command147=ID_OPTIONS_GAMEBOY_BORDER +Command148=ID_OPTIONS_GAMEBOY_PRINTER +Command149=ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC +Command150=ID_OPTIONS_GAMEBOY_AUTOMATIC +Command151=ID_OPTIONS_GAMEBOY_GBA +Command152=ID_OPTIONS_GAMEBOY_CGB +Command153=ID_OPTIONS_GAMEBOY_SGB +Command154=ID_OPTIONS_GAMEBOY_SGB2 +Command155=ID_OPTIONS_GAMEBOY_GB +Command156=ID_OPTIONS_GAMEBOY_REALCOLORS +Command157=ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS +Command158=ID_OPTIONS_GAMEBOY_COLORS +Command159=ID_OPTIONS_PRIORITY_HIGHEST +Command160=ID_OPTIONS_PRIORITY_ABOVENORMAL +Command161=ID_OPTIONS_PRIORITY_NORMAL +Command162=ID_OPTIONS_PRIORITY_BELOWNORMAL +Command163=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE +Command164=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR +Command165=ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART +Command166=ID_OPTIONS_FILTER_NORMAL +Command167=ID_OPTIONS_FILTER_TVMODE +Command168=ID_OPTIONS_FILTER_2XSAI +Command169=ID_OPTIONS_FILTER_SUPER2XSAI +Command170=ID_OPTIONS_FILTER_SUPEREAGLE +Command171=ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL +Command172=ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL +Command173=ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X +Command174=ID_OPTIONS_FILTER16BIT_SIMPLE2X +Command175=ID_OPTIONS_FILTER_BILINEAR +Command176=ID_OPTIONS_FILTER_BILINEARPLUS +Command177=ID_OPTIONS_FILTER_SCANLINES +Command178=ID_OPTIONS_FILTER_HQ2X +Command179=ID_OPTIONS_FILTER_LQ2X +Command180=ID_OPTIONS_FILTER_DISABLEMMX +Command181=ID_OPTIONS_JOYPAD_CONFIGURE_1 +Command182=ID_OPTIONS_JOYPAD_CONFIGURE_2 +Command183=ID_OPTIONS_JOYPAD_CONFIGURE_3 +Command184=ID_OPTIONS_JOYPAD_CONFIGURE_4 +Command185=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1 +Command186=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2 +Command187=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3 +Command188=ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4 +Command189=ID_OPTIONS_JOYPAD_MOTIONCONFIGURE +Command190=ID_OPTIONS_JOYPAD_AUTOFIRE_A +Command191=ID_OPTIONS_JOYPAD_AUTOFIRE_B +Command192=ID_OPTIONS_JOYPAD_AUTOFIRE_L +Command193=ID_OPTIONS_JOYPAD_AUTOFIRE_R +Command194=ID_OPTIONS_LANGUAGE_SYSTEM +Command195=ID_OPTIONS_LANGUAGE_ENGLISH +Command196=ID_OPTIONS_LANGUAGE_OTHER +Command197=ID_CHEATS_SEARCHFORCHEATS +Command198=ID_CHEATS_CHEATLIST +Command199=ID_CHEATS_AUTOMATICSAVELOADCHEATS +Command200=ID_CHEATS_DISABLECHEATS +Command201=ID_CHEATS_LOADCHEATLIST +Command202=ID_CHEATS_SAVECHEATLIST +Command203=ID_TOOLS_DISASSEMBLE +Command204=ID_TOOLS_LOGGING +Command205=ID_TOOLS_IOVIEWER +Command206=ID_TOOLS_MAPVIEW +Command207=ID_TOOLS_MEMORYVIEWER +Command208=ID_TOOLS_OAMVIEWER +Command209=ID_TOOLS_PALETTEVIEW +Command210=ID_TOOLS_TILEVIEWER +Command211=ID_DEBUG_NEXTFRAME +Command212=ID_TOOLS_DEBUG_GDB +Command213=ID_TOOLS_DEBUG_LOADANDWAIT +Command214=ID_TOOLS_DEBUG_BREAK +Command215=ID_TOOLS_DEBUG_DISCONNECT +Command216=ID_OPTIONS_SOUND_STARTRECORDING +Command217=ID_OPTIONS_SOUND_STOPRECORDING +Command218=ID_TOOLS_RECORD_STARTAVIRECORDING +Command219=ID_TOOLS_RECORD_STOPAVIRECORDING +Command220=ID_TOOLS_RECORD_STARTMOVIERECORDING +Command221=ID_TOOLS_RECORD_STOPMOVIERECORDING +Command222=ID_TOOLS_PLAY_STARTMOVIEPLAYING +Command223=ID_TOOLS_PLAY_STOPMOVIEPLAYING +Command224=ID_TOOLS_REWIND +Command225=ID_TOOLS_CUSTOMIZE +Command226=ID_HELP_BUGREPORT +Command227=ID_HELP_FAQ +Command228=ID_HELP_ABOUT +CommandCount=228 + +[ACL:IDR_ACCELERATOR] +Type=1 +Class=? +Command1=ID_OPTIONS_VIDEO_LAYERS_BG0 +Command2=ID_OPTIONS_JOYPAD_AUTOFIRE_A +Command3=ID_OPTIONS_VIDEO_LAYERS_BG1 +Command4=ID_OPTIONS_JOYPAD_AUTOFIRE_B +Command5=ID_OPTIONS_VIDEO_LAYERS_BG2 +Command6=ID_OPTIONS_JOYPAD_AUTOFIRE_L +Command7=ID_OPTIONS_VIDEO_LAYERS_BG3 +Command8=ID_OPTIONS_JOYPAD_AUTOFIRE_R +Command9=ID_OPTIONS_VIDEO_LAYERS_OBJ +Command10=ID_OPTIONS_VIDEO_LAYERS_WIN0 +Command11=ID_OPTIONS_VIDEO_LAYERS_WIN1 +Command12=ID_OPTIONS_VIDEO_LAYERS_OBJWIN +Command13=ID_TOOLS_REWIND +Command14=ID_CHEATS_SEARCHFORCHEATS +Command15=ID_FILE_LOAD +Command16=ID_DEBUG_NEXTFRAME +Command17=ID_FILE_OPEN +Command18=ID_FILE_PAUSE +Command19=ID_FILE_RESET +Command20=ID_FILE_SAVE +Command21=ID_FILE_TOGGLEMENU +Command22=ID_FILE_LOADGAME_SLOT1 +Command23=ID_FILE_MRU_FILE1 +Command24=ID_FILE_SAVEGAME_SLOT1 +Command25=ID_FILE_LOADGAME_SLOT10 +Command26=ID_FILE_MRU_FILE10 +Command27=ID_FILE_SAVEGAME_SLOT10 +Command28=ID_FILE_LOADGAME_SLOT2 +Command29=ID_FILE_MRU_FILE2 +Command30=ID_FILE_SAVEGAME_SLOT2 +Command31=ID_FILE_LOADGAME_SLOT3 +Command32=ID_FILE_MRU_FILE3 +Command33=ID_FILE_SAVEGAME_SLOT3 +Command34=ID_FILE_LOADGAME_SLOT4 +Command35=ID_FILE_MRU_FILE4 +Command36=ID_FILE_SAVEGAME_SLOT4 +Command37=ID_FILE_LOADGAME_SLOT5 +Command38=ID_FILE_MRU_FILE5 +Command39=ID_FILE_SAVEGAME_SLOT5 +Command40=ID_FILE_LOADGAME_SLOT6 +Command41=ID_FILE_MRU_FILE6 +Command42=ID_FILE_SAVEGAME_SLOT6 +Command43=ID_FILE_LOADGAME_SLOT7 +Command44=ID_FILE_MRU_FILE7 +Command45=ID_FILE_SAVEGAME_SLOT7 +Command46=ID_FILE_LOADGAME_SLOT8 +Command47=ID_FILE_MRU_FILE8 +Command48=ID_FILE_SAVEGAME_SLOT8 +Command49=ID_FILE_LOADGAME_SLOT9 +Command50=ID_FILE_MRU_FILE9 +Command51=ID_FILE_SAVEGAME_SLOT9 +Command52=ID_FILE_EXIT +CommandCount=52 + +[CLS:AddGSACode] +Type=0 +HeaderFile=GBACheats.h +ImplementationFile=GBACheats.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=AddGSACode + +[CLS:GBCheatList] +Type=0 +HeaderFile=GBCheatsDlg.h +ImplementationFile=GBCheatsDlg.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=GBCheatList + +[CLS:Disassemble] +Type=0 +HeaderFile=Disassemble.h +ImplementationFile=Disassemble.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=Disassemble + +[CLS:GBDisassemble] +Type=0 +HeaderFile=GBDisassemble.h +ImplementationFile=GBDisassemble.cpp +BaseClass=CDialog +Filter=D +LastObject=IDC_GO +VirtualFilter=dWC + +[CLS:Logging] +Type=0 +HeaderFile=Logging.h +ImplementationFile=Logging.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=IDC_LOG + +[CLS:IOViewer] +Type=0 +HeaderFile=IOViewer.h +ImplementationFile=IOViewer.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=ID_FILE_LOADGAME_SLOT1 + +[CLS:ZoomControl] +Type=0 +HeaderFile=ZoomControl.h +ImplementationFile=ZoomControl.cpp +BaseClass=CWnd +Filter=W +VirtualFilter=WC +LastObject=ZoomControl + +[CLS:BitmapControl] +Type=0 +HeaderFile=BitmapControl.h +ImplementationFile=BitmapControl.cpp +BaseClass=CScrollView +Filter=C +VirtualFilter=VWC +LastObject=BitmapControl + +[CLS:MapView] +Type=0 +HeaderFile=MapView.h +ImplementationFile=MapView.cpp +BaseClass=CDialog +Filter=D +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS +VirtualFilter=dWC + +[CLS:GBMapView] +Type=0 +HeaderFile=GBMapView.h +ImplementationFile=GBMapView.cpp +BaseClass=CDialog +Filter=D +LastObject=GBMapView +VirtualFilter=dWC + +[CLS:MemoryViewer] +Type=0 +HeaderFile=MemoryViewer.h +ImplementationFile=MemoryViewer.cpp +BaseClass=CWnd +Filter=W +VirtualFilter=WC +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS + +[CLS:MemoryViewerDlg] +Type=0 +HeaderFile=MemoryViewerDlg.h +ImplementationFile=MemoryViewerDlg.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=MemoryViewerDlg + +[CLS:MemoryViewerAddressSize] +Type=0 +HeaderFile=MemoryViewerAddressSize.h +ImplementationFile=MemoryViewerAddressSize.cpp +BaseClass=CDialog +Filter=D +LastObject=ID_CANCEL +VirtualFilter=dWC + +[CLS:GBMemoryViewerDlg] +Type=0 +HeaderFile=GBMemoryViewerDlg.h +ImplementationFile=GBMemoryViewerDlg.cpp +BaseClass=CDialog +Filter=D +LastObject=GBMemoryViewerDlg +VirtualFilter=dWC + +[CLS:OamView] +Type=0 +HeaderFile=OamView.h +ImplementationFile=OamView.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS + +[CLS:GBOamView] +Type=0 +HeaderFile=GBOamView.h +ImplementationFile=GBOamView.cpp +BaseClass=CDialog +Filter=D +LastObject=GBOamView +VirtualFilter=dWC + +[CLS:PaletteViewControl] +Type=0 +HeaderFile=PaletteViewControl.h +ImplementationFile=PaletteViewControl.cpp +BaseClass=CWnd +Filter=W +VirtualFilter=WC +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS + +[CLS:PaletteView] +Type=0 +HeaderFile=paletteview.h +ImplementationFile=paletteview.cpp +BaseClass=CDialog +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS + +[CLS:GBPaletteView] +Type=0 +HeaderFile=GBPaletteView.h +ImplementationFile=GBPaletteView.cpp +BaseClass=CDialog +Filter=D +LastObject=GBPaletteView +VirtualFilter=dWC + +[CLS:TileView] +Type=0 +HeaderFile=TileView.h +ImplementationFile=TileView.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=ID_CHEATS_AUTOMATICSAVELOADCHEATS + +[CLS:GBTileView] +Type=0 +HeaderFile=GBTileView.h +ImplementationFile=GBTileView.cpp +BaseClass=CDialog +Filter=D +LastObject=GBTileView +VirtualFilter=dWC + +[CLS:GBPrinterDlg] +Type=0 +HeaderFile=gbprinterdlg.h +ImplementationFile=gbprinterdlg.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=GBPrinterDlg + +[CLS:GDBPortDlg] +Type=0 +HeaderFile=GDBConnection.h +ImplementationFile=GDBConnection.cpp +BaseClass=CDialog +Filter=D +LastObject=GDBPortDlg +VirtualFilter=dWC + +[CLS:GDBWaitingDlg] +Type=0 +HeaderFile=GDBConnection.h +ImplementationFile=GDBConnection.cpp +BaseClass=CDialog +Filter=D +LastObject=GDBWaitingDlg +VirtualFilter=dWC + +[CLS:AccelEditor] +Type=0 +HeaderFile=AccelEditor.h +ImplementationFile=AccelEditor.cpp +BaseClass=CDialog +Filter=D +LastObject=IDC_REMOVE +VirtualFilter=dWC + +[CLS:Hyperlink] +Type=0 +HeaderFile=Hyperlink.h +ImplementationFile=Hyperlink.cpp +BaseClass=CStatic +Filter=W +VirtualFilter=WC +LastObject=Hyperlink + +[DLG:IDD_MAX_SCALE] +Type=1 +Class=MaxScale +ControlCount=5 +Control1=IDC_VALUE,edit,1350631552 +Control2=ID_OK,button,1342242817 +Control3=ID_CANCEL,button,1342242816 +Control4=IDC_STATIC,static,1342308352 +Control5=IDC_STATIC,static,1342308352 + +[CLS:MaxScale] +Type=0 +HeaderFile=MaxScale.h +ImplementationFile=MaxScale.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=MaxScale + +[DLG:IDD_BUG_REPORT] +Type=1 +Class=BugReport +ControlCount=4 +Control1=ID_OK,button,1342242816 +Control2=IDC_BUG_REPORT,edit,1352730820 +Control3=IDC_STATIC,static,1342308352 +Control4=IDC_COPY,button,1342242817 + +[CLS:BugReport] +Type=0 +HeaderFile=BugReport.h +ImplementationFile=BugReport.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=BugReport + diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp new file mode 100644 index 0000000..76c9822 --- /dev/null +++ b/src/win32/VBA.cpp @@ -0,0 +1,2707 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// VBA.cpp : Defines the class behaviors for the application. +// +#include "stdafx.h" +#include +#include + +#include "AVIWrite.h" +#include "LangSelect.h" +#include "MainWnd.h" +#include "Reg.h" +#include "resource.h" +#include "skin.h" +#include "WavWriter.h" +#include "WinResUtil.h" + +#include "../System.h" +#include "../agbprint.h" +#include "../cheatSearch.h" +#include "../GBA.h" +#include "../Globals.h" +#include "../RTC.h" +#include "../Sound.h" +#include "../Util.h" +#include "../gb/gbGlobals.h" +#include "../gb/gbPrinter.h" +#include "../Text.h" +#include "../movie.h" +#include "../nesvideos-piece.h" + +extern void Pixelate(u8*,u32,u8*,u8*,u32,int,int); +extern void Pixelate32(u8*,u32,u8*,u8*,u32,int,int); +extern void MotionBlur(u8*,u32,u8*,u8*,u32,int,int); +extern void MotionBlur32(u8*,u32,u8*,u8*,u32,int,int); +extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int); +extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int); +extern void Super2xSaI(u8*,u32,u8*,u8*,u32,int,int); +extern void Super2xSaI32(u8*,u32,u8*,u8*,u32,int,int); +extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int); +extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int); +extern void AdMame2x(u8*,u32,u8*,u8*,u32,int,int); +extern void AdMame2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void Simple2x(u8*,u32,u8*,u8*,u32,int,int); +extern void Simple2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void Bilinear(u8*,u32,u8*,u8*,u32,int,int); +extern void Bilinear32(u8*,u32,u8*,u8*,u32,int,int); +extern void BilinearPlus(u8*,u32,u8*,u8*,u32,int,int); +extern void BilinearPlus32(u8*,u32,u8*,u8*,u32,int,int); +extern void Scanlines(u8*,u32,u8*,u8*,u32,int,int); +extern void Scanlines32(u8*,u32,u8*,u8*,u32,int,int); +extern void ScanlinesTV(u8*,u32,u8*,u8*,u32,int,int); +extern void ScanlinesTV32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2x(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2xS(u8*,u32,u8*,u8*,u32,int,int); +extern void hq2xS32(u8*,u32,u8*,u8*,u32,int,int); +extern void lq2x(u8*,u32,u8*,u8*,u32,int,int); +extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3x(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3xS(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3xS32(u8*,u32,u8*,u8*,u32,int,int); + +extern void SmartIB(u8*,u32,int,int); +extern void SmartIB32(u8*,u32,int,int); +extern void MotionBlurIB(u8*,u32,int,int); +extern void InterlaceIB(u8*,u32,int,int); +extern void MotionBlurIB32(u8*,u32,int,int); + +extern void toolsLog(const char *); + +extern IDisplay *newGDIDisplay(); +extern IDisplay *newDirectDrawDisplay(); +extern IDisplay *newDirect3DDisplay(); +extern IDisplay *newOpenGLDisplay(); + +extern Input *newDirectInput(); + +extern ISound *newDirectSound(); + +extern void remoteStubSignal(int, int); +extern void remoteOutput(char *, u32); +extern void remoteStubMain(); +extern void remoteSetProtocol(int); +extern void remoteCleanUp(); +extern int remoteSocket; + +extern void InterframeCleanup(); + +void winlog(const char *msg, ...); + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +int emulating = 0; +bool debugger = false; +int RGB_LOW_BITS_MASK = 0; + +int systemFrameSkip = 0; +int systemSpeed = 0; +bool systemSoundOn = false; +u32 systemColorMap32[0x10000]; +u16 systemColorMap16[0x10000]; +u16 systemGbPalette[24]; +int systemRedShift = 0; +int systemBlueShift = 0; +int systemGreenShift = 0; +int systemColorDepth = 16; +int systemVerbose = 0; +int systemDebug = 0; +int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + +#define BMP_BUFFER_MAX_WIDTH (256) +#define BMP_BUFFER_MAX_HEIGHT (224) +#define BMP_BUFFER_MAX_DEPTH (3) +static char bmpBuffer [BMP_BUFFER_MAX_WIDTH*BMP_BUFFER_MAX_HEIGHT*BMP_BUFFER_MAX_DEPTH]; + +char movieFileToPlay [1024]; +bool playMovieFile = false; +bool playMovieFileReadOnly = false; +char wavFileToOutput [1024]; +bool outputWavFile = false; +bool outputAVIFile = false; +bool flagHideMenu = false; +int quitAfterTime = -1; +int pauseAfterTime = -1; + +void winSignal(int,int); +void winOutput(char *, u32); + +void (*dbgSignal)(int,int) = winSignal; +void (*dbgOutput)(char *, u32) = winOutput; + +#ifdef MMX +extern "C" bool cpu_mmx; +#endif + +void directXMessage(const char *msg) +{ + systemMessage(IDS_DIRECTX_7_REQUIRED, + "DirectX 7.0 or greater is required to run.\nDownload at http://www.microsoft.com/directx.\n\nError found at: %s", + msg); +} + +///////////////////////////////////////////////////////////////////////////// +// VBA + +BEGIN_MESSAGE_MAP(VBA, CWinApp) + //{{AFX_MSG_MAP(VBA) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// VBA construction + +VBA::VBA() +{ + mode320Available = false; + mode640Available = false; + mode800Available = false; + windowPositionX = 0; + windowPositionY = 0; + filterFunction = NULL; + ifbFunction = NULL; + ifbType = 0; + filterType = 0; + filterWidth = 0; + filterHeight = 0; + fsWidth = 0; + fsHeight = 0; + fsColorDepth = 0; + fsForceChange = false; + surfaceSizeX = 0; + surfaceSizeY = 0; + sizeX = 0; + sizeY = 0; + videoOption = 0; + fullScreenStretch = false; + disableStatusMessage = false; + showSpeed = 1; + showSpeedTransparent = true; + showRenderedFrames = 0; + for(int j = 0 ; j < SCREEN_MESSAGE_SLOTS ; j++) + { + screenMessage[j] = false; + screenMessageTime[j] = 0; + screenMessageDuration[j] = 0; + } + menuToggle = true; + display = NULL; + menu = NULL; + popup = NULL; + cartridgeType = 0; + soundInitialized = false; + useBiosFile = false; + skipBiosFile = false; + active = true; + paused = false; + recentFreeze = false; + autoSaveLoadCheatList = false; + pauseDuringCheatSearch = true; + modelessCheatDialogIsOpen = false; + winout = NULL; + removeIntros = false; + autoIPS = true; + winGbBorderOn = 0; + hideMovieBorder = false; + winFlashSize = 0x10000; + winRtcEnable = false; + winSaveType = 0; + rewindMemory = NULL; + frameSearchMemory = NULL; + rewindPos = 0; + rewindTopPos = 0; + rewindCounter = 0; + rewindCount = 0; + rewindSaveNeeded = false; + rewindTimer = 0; + captureFormat = 0; + tripleBuffering = true; + autoHideMenu = false; + throttle = 100; + throttleLastTime = 0; +/// autoFrameSkipLastTime = 0; +/// autoFrameSkip = false; + vsync = false; + changingVideoSize = false; + pVideoDriverGUID = NULL; + renderMethod = DIRECT_DRAW; + iconic = false; + ddrawEmulationOnly = false; + ddrawUsingEmulationOnly = false; + ddrawDebug = false; + ddrawUseVideoMemory = false; + d3dFilter = 0; + glFilter = 0; + glType = 0; + skin = NULL; + skinName = ""; + skinEnabled = false; + skinButtons = 0; + regEnabled = false; + pauseWhenInactive = true; + frameCounter = false; + inputDisplay = false; + movieReadOnly = true; + speedupToggle = false; + useOldSync = false; + useOldGBTiming = false; + allowLeftRight = false; + muteFrameAdvance = false; + frameAdvanceMuteNow = false; + winGbPrinterEnabled = false; + threadPriority = 2; + disableMMX = false; + languageOption = 0; + languageModule = NULL; + languageName = ""; + renderedFrames = 0; + input = NULL; + joypadDefault = 0; + autoFire = 0; + autoFire2 = 0; + autoHold = 0; + autoFireToggle = false; + winPauseNextFrame = false; + soundRecording = false; + soundRecorder = NULL; + sound = NULL; + aviRecording = false; + aviRecorder = NULL; + aviFrameNumber = 0; + painting = false; + sensorX = 2047; + sensorY = 2047; + mouseCounter = 0; + wasPaused = false; + frameskipadjust = 0; + autoLoadMostRecent = false; + loadMakesRecent = false; + fsMaxScale = 0; + romSize = 0; + loadMakesCurrent = false; + saveMakesCurrent = false; + currentSlot = 0; + frameSearchLoadValid = false; + frameSearching = false; + frameSearchSkipping = false; + nvVideoLog = false; + nvAudioLog = false; + LoggingEnabled = 0; +/// FPS = 60; + + updateCount = 0; + + globalFrameCount = 0; + + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + + ZeroMemory(&emulator, sizeof(emulator)); + + hAccel = NULL; + + for(int i = 0; i < 24;) { + systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); + systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); + systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); + systemGbPalette[i++] = 0; + } + + VBAMovieInit(); +} + +VBA::~VBA() +{ + InterframeCleanup(); + + saveSettings(); +/* + if(moviePlaying) { + if(movieFile != NULL) { + fclose(movieFile); + movieFile = NULL; + } + moviePlaying = false; + movieLastJoypad = 0; + } +*/ + if(VBAMovieActive()) + VBAMovieStop(true); +/* + if(movieRecording) { + if(movieFile != NULL) { + // record the last joypad change so that the correct time can be + // recorded + fwrite(&movieFrame, 1, sizeof(int), movieFile); + fwrite(&movieLastJoypad, 1, sizeof(u32), movieFile); + fclose(movieFile); + movieFile = NULL; + } + movieRecording = false; + moviePlaying = false; + movieLastJoypad = 0; + } +*/ + if(aviRecorder) { + delete aviRecorder; + aviRecorder = NULL; + aviRecording = false; + } + + if(soundRecorder) { + delete soundRecorder; + soundRecorder = NULL; + } + soundRecording = false; + soundPause(); + soundShutdown(); + + if(gbRom != NULL || rom != NULL) { + if(autoSaveLoadCheatList) + ((MainWnd *)m_pMainWnd)->winSaveCheatListDefault(); + ((MainWnd *)m_pMainWnd)->writeBatteryFile(); + cheatSearchCleanup(&cheatSearchData); + emulator.emuCleanUp(); + + if(VBAMovieActive()) + VBAMovieStop(false); + } + + if(input) + delete input; + + shutdownDisplay(); + + if(skin) { + delete skin; + } + + if(rewindMemory) + free(rewindMemory); + + if(frameSearchMemory) + free(frameSearchMemory); +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only VBA object + +VBA theApp; +#include +///////////////////////////////////////////////////////////////////////////// +// VBA initialization + +// code from SDL_main.c for Windows +/* Parse a command line buffer into arguments */ +static int parseCommandLine(char *cmdline, char **argv) +{ + char *bufp; + int argc; + + argc = 0; + for ( bufp = cmdline; *bufp; ) { + /* Skip leading whitespace */ + while ( isspace(*bufp) ) { + ++bufp; + } + /* Skip over argument */ + if ( *bufp == '"' ) { + ++bufp; + if ( *bufp ) { + if ( argv ) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while ( *bufp && (*bufp != '"') ) { + ++bufp; + } + } else { + if ( *bufp ) { + if ( argv ) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while ( *bufp && ! isspace(*bufp) ) { + ++bufp; + } + } + if ( *bufp ) { + if ( argv ) { + *bufp = '\0'; + } + ++bufp; + } + } + if ( argv ) { + argv[argc] = NULL; + } + return(argc); +} + +static void CorrectPath (CString & path) +{ + CString tempStr; + FILE * tempFile; + + if(tempFile = fopen(path, "rb")) + { + fclose(tempFile); + } + else + { + for(int i = 0 ; i < 10 ; i++) + { + switch(i) + { + case 0: { + char curDir [_MAX_PATH]; + GetCurrentDirectory(_MAX_PATH, curDir); + curDir[_MAX_PATH-1] = '\0'; + tempStr = curDir; + } break; + case 1: tempStr = regQueryStringValue("romdir","."); break; + case 2: tempStr = regQueryStringValue("moviesdir","."); break; + case 3: tempStr = regQueryStringValue("batteryDir","."); break; + case 4: tempStr = regQueryStringValue("saveDir","."); break; + case 5: tempStr = regQueryStringValue("captureDir","."); break; + case 6: tempStr = regQueryStringValue("soundRecordDir","."); break; + case 7: tempStr = regQueryStringValue("aviRecordDir","."); break; + case 8: tempStr = "C:"; + case 9: { + tempStr = regQueryStringValue("romdir","."); + char * slash = (char*)strrchr(tempStr, '\\'); + if(slash) + slash[0] = '\0'; + } break; + } + tempStr += "\\"; + tempStr += path; + + if(tempFile = fopen(tempStr, "rb")) + { + fclose(tempFile); + path = tempStr; + break; + } + } + } +} + +static void CorrectPath (char * path) +{ + CString pathCStr = path; + CorrectPath(pathCStr); + strcpy(path, pathCStr); +} + + +void debugSystemScreenMessage1(const char *msg) +{ + systemScreenMessage(msg, 3, 60); +} +void debugSystemScreenMessage2(const char *msg) +{ + systemScreenMessage(msg, 4, 60); +} + + +BOOL VBA::InitInstance() +{ + AfxEnableControlContainer(); + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +//#ifdef _AFXDLL +// Enable3dControls(); // Call this when using MFC in a shared DLL +//#else +// Enable3dControlsStatic(); // Call this when linking to MFC statically +//#endif + + SetRegistryKey(_T("VBA")); + + remoteSetProtocol(0); + + systemVerbose = GetPrivateProfileInt("config", + "verbose", + 0, + "VBA.ini"); + + systemDebug = GetPrivateProfileInt("config", + "debug", + 0, + "VBA.ini"); + ddrawDebug = GetPrivateProfileInt("config", + "ddrawDebug", + 0, + "VBA.ini") ? true : false; + + wndClass = AfxRegisterWndClass(0, LoadCursor(IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), LoadIcon(IDI_ICON)); + + char winBuffer[2048]; + + GetModuleFileName(NULL, winBuffer, 2048); + char *p = strrchr(winBuffer, '\\'); + if(p) + *p = 0; + + regInit(winBuffer); + + loadSettings(); + + if(!initInput()) + return FALSE; + + if(!initDisplay()) { + if(videoOption >= VIDEO_320x240) { + regSetDwordValue("video", VIDEO_1X); + if(pVideoDriverGUID) + regSetDwordValue("defaultVideoDriver", TRUE); + } + return FALSE; + } + + hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR)); + + winAccelMgr.Connect((MainWnd *)m_pMainWnd); + + winAccelMgr.SetRegKey(HKEY_CURRENT_USER, "Software\\Emulators\\VisualBoyAdvance"); + + extern void winAccelAddCommands(CAcceleratorManager&); + + winAccelAddCommands(winAccelMgr); + + winAccelMgr.CreateDefaultTable(); + + winAccelMgr.Load(); + + winAccelMgr.UpdateWndTable(); + + winAccelMgr.UpdateMenu(menu); + + if (m_lpCmdLine[0]) + { + int argc = parseCommandLine(m_lpCmdLine, NULL); + char **argv = (char **)malloc((argc+1)*sizeof(char *)); + parseCommandLine(m_lpCmdLine, argv); + + + + bool gotFlag = false, enoughArgs = false; + for(int i = 0 ; i < argc ; i++) + { + if(argv[i][0] == '-' || gotFlag) + { + if(!gotFlag) + loadSettings(); + gotFlag = true; + if(_stricmp(argv[i], "-rom") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + szFile = argv[++i]; + CorrectPath(szFile); + filename = szFile; + } + else + if(_stricmp(argv[i], "-bios") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + biosFileName = argv[++i]; + CorrectPath(biosFileName); + extern void loadBIOS(); + loadBIOS(); + } + else + if(_stricmp(argv[i], "-frameskip") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + frameSkip = atoi(argv[++i]); + if(frameSkip < 0) frameSkip = 0; + if(frameSkip > 9) frameSkip = 9; + gbFrameSkip = frameSkip; + } + else + if(_stricmp(argv[i], "-throttle") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + throttle = atoi(argv[++i]); + if(throttle < 5) throttle = 5; + if(throttle > 1000) throttle = 1000; + } + else + if(_stricmp(argv[i], "-throttleKeepPitch") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + accuratePitchThrottle = atoi(argv[++i]) != 0; + } + else + if(_stricmp(argv[i], "-synchronize") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + synchronize = atoi(argv[++i]) != 0; + } + else + if(_stricmp(argv[i], "-hideborder") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + hideMovieBorder = atoi(argv[++i]) != 0; + } + else + if(_stricmp(argv[i], "-play") == 0) + { + playMovieFile = true; + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + strcpy(movieFileToPlay, argv[++i]); + CorrectPath(movieFileToPlay); + if(i+1 >= argc || argv[i+1][0] == '-') {--i; goto invalidArgument;} + playMovieFileReadOnly = atoi(argv[++i]) != 0; + } + else + if(_stricmp(argv[i], "-videoLog") == 0) + { + nvVideoLog = true; + nvAudioLog = true; + LoggingEnabled = 2; + if(i+1 >= argc || argv[i+1][0] == '-') {} + else NESVideoSetVideoCmd(argv[++i]); + } + else + if(_stricmp(argv[i], "-logDebug") == 0) + { + NESVideoEnableDebugging(debugSystemScreenMessage1,debugSystemScreenMessage2); + } + else + if(_stricmp(argv[i], "-logToFile") == 0) + { + NESVideoSetFileFuncs(fopen,fclose); + } + else + if(_stricmp(argv[i], "-outputWAV") == 0) + { + outputWavFile = true; + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + strcpy(wavFileToOutput, argv[++i]); + } + else + if(_stricmp(argv[i], "-outputAVI") == 0) + { + outputAVIFile = true; + } + else + if(_stricmp(argv[i], "-quitAfter") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + quitAfterTime = atoi(argv[++i]); + } + else + if(_stricmp(argv[i], "-pauseAt") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + pauseAfterTime = atoi(argv[++i]); + } + else + if(_stricmp(argv[i], "-videoScale") == 0) + { + if(i+1 >= argc || argv[i+1][0] == '-') goto invalidArgument; + int size = atoi(argv[++i]); + if(size < 1) size = 1; + if(size > 4) size = 4; + switch(size) + { + case 1: videoOption = VIDEO_1X; break; + case 2: videoOption = VIDEO_2X; break; + case 3: videoOption = VIDEO_3X; break; + case 4: videoOption = VIDEO_4X; break; + } + } + else + if(_stricmp(argv[i], "-hideMenu") == 0) + { + flagHideMenu = true; + } + else + { + enoughArgs = true; +invalidArgument: + char str [1024]; + strcpy(str, ""); + if(_stricmp(argv[i], "-h") != 0) + if(enoughArgs) + sprintf(str, "Invalid commandline argument %d: %s\n", i, argv[i]); + else + sprintf(str, "Not enough arguments for arg %d: %s\n", i, argv[i]); + strcat(str, "Valid commands:\n" + "-h \t\t\t displays this help\n" + "-rom filename \t\t opens the given ROM\n" + "-bios filename \t\t use the given GBA BIOS\n" + "-play filename val \t\t plays the given VBM movie (val: 1 = read-only, 0 = editable)\n" + "-outputWAV filename \t outputs WAV audio to the given file\n" + "-outputAVI \t\t outputs an AVI (you are prompted for location and codec)\n" + "-frameskip val \t\t sets the frameskip amount to the given value\n" + "-synchronize val \t\t limits running speed to sound playing speed, (0 = off, 1 = on)\n" + "-throttle val \t\t sets the throttle speed to the given percentage\n" + "-hideborder val \t\t hides SGB border, if any (0 = show, 1 = hide)\n" + "-throttleKeepPitch val \t if throttle and synch, don't change sound freq (0 = off, 1 = on)\n" + "-quitAfter val \t\t close program when frame counter == val\n" + "-pauseAt val \t\t pause (movie) once when frame counter == val\n" + "-videoScale val \t\t sets the video size (val = 1 for 1X, 2 for 2X, 3 for 3X, or 4 for 4X)\n" + "-hideMenu \t\t hides the menu until program exit\n" + "\n" + "-videoLog args \t does (nesvideos) video+audio logging with the given arguments\n" + "-logToFile \t tells logging to use fopen/fclose of args, if logging is enabled\n" + "-logDebug \t tells logging to output debug info to screen, if logging is enabled\n" + ); + theApp.winCheckFullscreen(); + AfxGetApp()->m_pMainWnd->MessageBox(str, "Commandline Help", MB_OK|MB_ICONINFORMATION); + exit(0); + } + } + else + { + // assume anything else is a ROM, for backward compatibility + szFile = argv[i++]; + filename = szFile; + loadSettings(); + } + } + int index = filename.ReverseFind('.'); + + if(index != -1) + filename = filename.Left(index); + + if(szFile.GetLength() > 0) + { + if(((MainWnd*)m_pMainWnd)->FileRun()) + emulating = true; + else + emulating = false; + } + free(argv); + } + + return TRUE; +} + +void VBA::adjustDestRect() +{ + POINT point; + RECT skinRect; + if(skin) + skinRect = skin->GetBlitRect(); + + point.x = 0; + point.y = 0; + + if(skin) { + point.x = skinRect.left; + point.y = skinRect.top; + } + + m_pMainWnd->ClientToScreen(&point); + dest.top = point.y; + dest.left = point.x; + + point.x = surfaceSizeX; + point.y = surfaceSizeY; + + if(skin) { + point.x = skinRect.right; + point.y = skinRect.bottom; + } + + m_pMainWnd->ClientToScreen(&point); + dest.bottom = point.y; + dest.right = point.x; + + // make sure that dest rect lies in the monitor + if(videoOption >= VIDEO_320x240) { + dest.top -= windowPositionY; + dest.left -= windowPositionX; + dest.bottom-= windowPositionY; + dest.right -= windowPositionX; + } + + if(skin) + return; + + int menuSkip = 0; + + if(videoOption >= VIDEO_320x240 && menuToggle) { + int m = GetSystemMetrics(SM_CYMENU); + menuSkip = m; + dest.bottom -=m; + } + + if(videoOption > VIDEO_4X) { + int top = (fsHeight - surfaceSizeY) / 2; + int left = (fsWidth - surfaceSizeX) / 2; + dest.top += top; + dest.bottom += top; + dest.left += left; + dest.right += left; + if(fullScreenStretch) { + dest.top = 0+menuSkip; + dest.left = 0; + dest.right = fsWidth; + dest.bottom = fsHeight; + } + } +} + +void VBA::updateIFB() +{ + if(systemColorDepth == 16) { + switch(ifbType) { + case 0: + default: + ifbFunction = NULL; + break; + case 1: + ifbFunction = MotionBlurIB; + break; + case 2: + ifbFunction = SmartIB; + break; + } + } else if(systemColorDepth == 32) { + switch(ifbType) { + case 0: + default: + ifbFunction = NULL; + break; + case 1: + ifbFunction = MotionBlurIB32; + break; + case 2: + ifbFunction = SmartIB32; + break; + } + } else + ifbFunction = NULL; +} + +void VBA::updateFilter() +{ + filterWidth = sizeX; + filterHeight = sizeY; + + if(systemColorDepth == 16 && (videoOption > VIDEO_1X && + videoOption != VIDEO_320x240)) { + switch(filterType) { + default: + case 0: + filterFunction = NULL; + break; + case 1: + filterFunction = ScanlinesTV; + break; + case 2: + filterFunction = _2xSaI; + break; + case 3: + filterFunction = Super2xSaI; + break; + case 4: + filterFunction = SuperEagle; + break; + case 5: + filterFunction = Pixelate; + break; + case 6: + filterFunction = MotionBlur; + break; + case 7: + filterFunction = AdMame2x; + break; + case 8: + filterFunction = Simple2x; + break; + case 9: + filterFunction = Bilinear; + break; + case 10: + filterFunction = BilinearPlus; + break; + case 11: + filterFunction = Scanlines; + break; + case 12: + filterFunction = hq2xS; + break; + case 13: + filterFunction = hq2x; + break; + case 14: + filterFunction = lq2x; + break; + case 15: + filterFunction = hq3xS; + break; + case 16: + filterFunction = hq3x; + break; + } + switch(filterType) + { + case 0: // normal -> 1x texture + rect.right = sizeX; + rect.bottom = sizeY; + break; + default: // other -> 2x texture + rect.right = sizeX*2; + rect.bottom = sizeY*2; + memset(delta,255,sizeof(delta)); + break; + case 15: // hq3x -> 3x texture + case 16: + rect.right = sizeX*3; + rect.bottom = sizeY*3; + memset(delta,255,sizeof(delta)); + break; + } + } else { + if(systemColorDepth == 32 && videoOption > VIDEO_1X && + videoOption != VIDEO_320x240) { + switch(filterType) { + default: + case 0: + filterFunction = NULL; + break; + case 1: + filterFunction = ScanlinesTV32; + break; + case 2: + filterFunction = _2xSaI32; + break; + case 3: + filterFunction = Super2xSaI32; + break; + case 4: + filterFunction = SuperEagle32; + break; + case 5: + filterFunction = Pixelate32; + break; + case 6: + filterFunction = MotionBlur32; + break; + case 7: + filterFunction = AdMame2x32; + break; + case 8: + filterFunction = Simple2x32; + break; + case 9: + filterFunction = Bilinear32; + break; + case 10: + filterFunction = BilinearPlus32; + break; + case 11: + filterFunction = Scanlines32; + break; + case 12: + filterFunction = hq2xS32; + break; + case 13: + filterFunction = hq2x32; + break; + case 14: + filterFunction = lq2x32; + break; + case 15: + filterFunction = hq3xS32; + break; + case 16: + filterFunction = hq3x32; + break; + } + switch(filterType) + { + case 0: // normal -> 1x texture + rect.right = sizeX; + rect.bottom = sizeY; + break; + default: // other -> 2x texture + rect.right = sizeX*2; + rect.bottom = sizeY*2; + memset(delta,255,sizeof(delta)); + break; + case 15: // hq3x -> 3x texture + case 16: + rect.right = sizeX*3; + rect.bottom = sizeY*3; + memset(delta,255,sizeof(delta)); + break; + } + } else + filterFunction = NULL; + } + + if(display) + display->changeRenderSize(rect.right, rect.bottom); +} + +void VBA::updateMenuBar() +{ + if(flagHideMenu) + return; + + if(menu != NULL) { + if(m_pMainWnd) + m_pMainWnd->SetMenu(NULL); + m_menu.Detach(); + DestroyMenu(menu); + } + + if(popup != NULL) { + // force popup recreation if language changed + DestroyMenu(popup); + popup = NULL; + } + + m_menu.Attach(winResLoadMenu(MAKEINTRESOURCE(IDR_MENU))); + menu = (HMENU)m_menu; + + // don't set a menu if skin is active + if(skin == NULL) + if(m_pMainWnd) + m_pMainWnd->SetMenu(&m_menu); +} + +void winlog(const char *msg, ...) +{ + CString buffer; + va_list valist; + + va_start(valist, msg); + buffer.FormatV(msg, valist); + + if(theApp.winout == NULL) { + theApp.winout = fopen("vba-trace.log","w"); + } + + fputs(buffer, theApp.winout); + + va_end(valist); +} + +void log(const char *msg, ...) +{ + CString buffer; + va_list valist; + + va_start(valist, msg); + buffer.FormatV(msg, valist); + + toolsLog(buffer); + + va_end(valist); +} + +bool systemReadJoypads() +{ + if(theApp.input) + return theApp.input->readDevices(); + return false; +} + +u32 systemReadJoypad(int which, bool sensor) +{ + if(theApp.input) + return theApp.input->readDevice(which,sensor); + return 0; +} + +extern bool vbaShuttingDown; +extern long linearSoundFrameCount; +long linearFrameCount = 0; + +void systemDrawScreen() +{ + if(vbaShuttingDown) + return; + + if(!theApp.painting) + { + linearFrameCount++; + if(!theApp.sound) + { + if(linearFrameCount > 10000) + linearFrameCount -= 10000; + linearSoundFrameCount = linearFrameCount; + } + } + else + { + static bool updatingFrameCount = false; + if(!updatingFrameCount) // recursion-preventing paranoia + { + updatingFrameCount = true; + VBAUpdateFrameCountDisplay(); + updatingFrameCount = false; + } + } + + + if(theApp.display == NULL) + return; + + theApp.renderedFrames++; + + if(theApp.updateCount) { + POSITION pos = theApp.updateList.GetHeadPosition(); + while(pos) { + IUpdateListener *up = theApp.updateList.GetNext(pos); + if(up) + up->update(); + } + } + + // "in-game" text rendering + if(textMethod == 0) + { + int copyX = 240, copyY = 160; + if(theApp.cartridgeType == 1) + if(gbBorderOn) copyX = 256, copyY = 224; + else copyX = 160, copyY = 144; + + DrawTextMessages((u8*)pix, copyX*(systemColorDepth/8)+(systemColorDepth==24?0:4), 0, copyY); + } + + + if(!theApp.painting) + { + int width = 240; + int height = 160; + switch(theApp.cartridgeType) + { + case 0: + width = 240; + height = 160; + break; + case 1: + if(gbBorderOn) { + width = 256; + height = 224; + } else { + width = 160; + height = 144; + } + break; + } + + linearFrameCount--; + do + { + linearFrameCount++; + + if(theApp.aviRecording) + { + if(theApp.aviRecorder == NULL) { + FILE * temp = fopen(theApp.aviRecordName, "wb"); + if(temp == NULL) + { + theApp.aviRecording = false; + systemMessage(0,"AVI recording failed: file is read-only or already in use."); + } + else + { + fclose(temp); + + theApp.aviRecorder = new AVIWrite(); + theApp.aviFrameNumber = 0; + + theApp.aviRecorder->SetFPS(60); + + BITMAPINFOHEADER bi; + memset(&bi, 0, sizeof(bi)); + bi.biSize = 0x28; + bi.biPlanes = 1; + bi.biBitCount = 24; + bi.biWidth = width; + bi.biHeight = height; + bi.biSizeImage = 3*width*height; + theApp.aviRecorder->SetVideoFormat(&bi); + theApp.aviRecorder->Open(theApp.aviRecordName); + } + } + + if(theApp.aviRecorder != NULL) { + assert(width <= BMP_BUFFER_MAX_WIDTH && height <= BMP_BUFFER_MAX_HEIGHT && systemColorDepth <= BMP_BUFFER_MAX_DEPTH*8); + utilWriteBMP(bmpBuffer, width, height, systemColorDepth, pix); + theApp.aviRecorder->AddFrame(theApp.aviFrameNumber++, bmpBuffer); + } + } + + if(theApp.nvVideoLog) + { + // convert from whatever bit depth to 16-bit, while stripping away extra pixels + assert(width <= BMP_BUFFER_MAX_WIDTH && height <= BMP_BUFFER_MAX_HEIGHT && 16 <= BMP_BUFFER_MAX_DEPTH*8); + utilWriteBMP(bmpBuffer, width, -height, 16, pix); + NESVideoLoggingVideo((u8 *)bmpBuffer, width, height, 0x1000000 * 60); + } + } + while(linearFrameCount < linearSoundFrameCount); // compensate for frames lost due to frame skip being nonzero, etc. + } + + + if(theApp.ifbFunction) { + if(systemColorDepth == 16) + theApp.ifbFunction(pix+theApp.filterWidth*2+4, theApp.filterWidth*2+4, + theApp.filterWidth, theApp.filterHeight); + else + theApp.ifbFunction(pix+theApp.filterWidth*4+4, theApp.filterWidth*4+4, + theApp.filterWidth, theApp.filterHeight); + } + + theApp.display->render(); +} + +void systemScreenCapture(int captureNumber) +{ + if(theApp.m_pMainWnd) + ((MainWnd *)theApp.m_pMainWnd)->screenCapture(captureNumber); +} + +u32 systemGetClock() +{ + return timeGetTime(); +} + +void systemMessage(int number, const char *defaultMsg, ...) +{ + CString buffer; + va_list valist; + CString msg = defaultMsg; + if(number) + msg = winResLoadString(number); + + va_start(valist, defaultMsg); + buffer.FormatV(msg, valist); + + theApp.winCheckFullscreen(); + + AfxGetApp()->m_pMainWnd->MessageBox(buffer, winResLoadString(IDS_ERROR), MB_OK|MB_ICONERROR); + + va_end(valist); +} + +void systemSetTitle(const char *title) +{ + if(theApp.m_pMainWnd != NULL) { + AfxGetApp()->m_pMainWnd->SetWindowText(title); + } +} + +void systemShowSpeed(int speed) +{ + systemSpeed = speed; + theApp.showRenderedFrames = theApp.renderedFrames; + theApp.renderedFrames = 0; + if(theApp.videoOption <= VIDEO_4X && theApp.showSpeed) { + CString buffer; + if(theApp.showSpeed == 1) + buffer.Format("VisualBoyAdvance-%3d%%", systemSpeed); + else + buffer.Format("VisualBoyAdvance-%3d%%(%d, %d fps)", systemSpeed, + systemFrameSkip, + theApp.showRenderedFrames); + + systemSetTitle(buffer); + } +} + +void systemFrame(int rate) +{ + if(quitAfterTime >= 0 && theApp.globalFrameCount == quitAfterTime) + { + VBAMovieStop(true); + AfxPostQuitMessage(0); + } + + theApp.globalFrameCount++; + + + u32 time = systemGetClock(); + + // change the sound speed, or set it to normal - must always do this or it won't get reset after a change, but that's OK because it's inexpensive + if(theApp.sound) + theApp.sound->setSpeed(theApp.throttle != 100 && !speedup && !theApp.winPauseNextFrame && synchronize && !theApp.accuratePitchThrottle && !theApp.useOldSync ? (float)theApp.throttle / 100.0f : 1.0f); + +// bool deadSound = !theApp.sound->isPlaying(); + + // if a throttle speed is set and we're not allowed to change the sound frequency to achieve it, + // sleep for a certain amount each time we get here to approximate the necessary slowdown + if(((theApp.accuratePitchThrottle || !theApp.sound || !synchronize) + && (theApp.throttle != 100 || !synchronize)) + || theApp.throttle < 6 && !theApp.winPauseNextFrame) + { + /// FIXME: this is still a horrible way of achieving a certain frame time + /// (look at what Snes9x does - it's complicated but much much better) + + static float sleepAmt = 0.0f; // variable to smooth out the sleeping amount so it doesn't oscillate so fast +// if(!theApp.wasPaused) { + if(!speedup) { + u32 diff = time - theApp.throttleLastTime; + if(theApp.wasPaused) + diff = 0; + + int target = (100000/(rate*theApp.throttle)); + int d = (target - diff); + + sleepAmt = 0.8f * sleepAmt + 0.2f * (float)d; + if(d - sleepAmt <= 1.5f && d - sleepAmt >= -1.5f) + d = (int)(sleepAmt); + + if(d > 0) { + Sleep(d); + } + } + theApp.throttleLastTime = systemGetClock(); + //} + //else + //{ + // Sleep(100); + //} + } + + if(theApp.globalFrameCount % 10 == 0) + { + if(theApp.rewindMemory) { + if(++theApp.rewindCounter >= (theApp.rewindTimer)) { + theApp.rewindSaveNeeded = true; + theApp.rewindCounter = 0; + } + } + if(systemSaveUpdateCounter) { + if(--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED) { + ((MainWnd *)theApp.m_pMainWnd)->writeBatteryFile(); + systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; + } + } + } + + theApp.wasPaused = false; +/// theApp.autoFrameSkipLastTime = time; +} + + +void systemScreenMessage(const char *msg, int slot, int duration, const char *colorList) +{ + if(slot < 0 || slot > SCREEN_MESSAGE_SLOTS) + return; + + if(slot == 0 && (theApp.paused || (theApp.frameSearching))) + theApp.m_pMainWnd->PostMessage(WM_PAINT, NULL, NULL); // update the display when a main-slot message appears while the game is paused + + + theApp.screenMessage[slot] = true; + theApp.screenMessageTime[slot] = GetTickCount(); + theApp.screenMessageDuration[slot] = duration; + theApp.screenMessageBuffer[slot] = msg; + theApp.screenMessageColorBuffer[slot] = colorList ? colorList : ""; + + if(theApp.screenMessageBuffer[slot].GetLength() > 40) + theApp.screenMessageBuffer[slot] = theApp.screenMessageBuffer[slot].Left(40); +} + +int systemGetSensorX() +{ + return theApp.sensorX; +} + +int systemGetSensorY() +{ + return theApp.sensorY; +} + +bool systemSoundInit() +{ + if(theApp.sound) + delete theApp.sound; + + theApp.sound = newDirectSound(); + return theApp.sound->init(); +} + + +void systemSoundShutdown() +{ + if(theApp.sound) + delete theApp.sound; + theApp.sound = NULL; +} + +void systemSoundPause() +{ + if(theApp.sound) + theApp.sound->pause(); +} + +void systemSoundReset() +{ + if(theApp.sound) + theApp.sound->reset(); +} + +void systemSoundResume() +{ + if(theApp.sound) + theApp.sound->resume(); +} + +void systemWriteDataToSoundBuffer() +{ + if(theApp.sound) + theApp.sound->write(); +} + +bool systemCanChangeSoundQuality() +{ + return true; +} + +bool systemPauseOnFrame() +{ + if(theApp.winPauseNextFrame) { + theApp.paused = true; + theApp.winPauseNextFrame = false; + return true; + } + return false; +} + +void systemGbBorderOn() +{ + if(emulating && theApp.cartridgeType == 1 && gbBorderOn) { + theApp.updateWindowSize(theApp.videoOption); + } +} + +#include "assert.h" + +void VBA::saveRewindStateIfNecessary () +{ + if(rewindSaveNeeded && rewindMemory && emulator.emuWriteMemState) { + rewindCount++; + if(rewindCount > rewindSlots) + rewindCount = rewindSlots; + assert(rewindPos >= 0 && rewindPos < rewindSlots); + if(emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], REWIND_SIZE)) { + rewindPos = ++rewindPos % rewindSlots; + assert(rewindPos >= 0 && rewindPos < rewindSlots); + if(rewindCount == rewindSlots) + rewindTopPos = ++rewindTopPos % rewindSlots; + } + } + + // also update/cache some frame search stuff + if(theApp.frameSearching) + { + extern SMovie Movie; + int curFrame = (Movie.state == MOVIE_STATE_NONE) ? theApp.globalFrameCount : Movie.currentFrame; + int endFrame = theApp.frameSearchStart + theApp.frameSearchLength; + theApp.frameSearchSkipping = (curFrame < endFrame); + theApp.frameSearchFirstStep = false; + + if(curFrame == endFrame) + { + // cache intermediate state to speed up searching forward + theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE*1], REWIND_SIZE); + } + + if(curFrame == endFrame + 1) + { + theApp.emulator.emuWriteMemState(&theApp.frameSearchMemory[REWIND_SIZE*2], REWIND_SIZE); + theApp.frameSearchLoadValid = true; + } + } + else + { + theApp.frameSearchFirstStep = false; + + assert(!theApp.frameSearchSkipping); + // just in case + theApp.frameSearchSkipping = false; + } + +} + + + +BOOL VBA::OnIdle(LONG lCount) +{ + if(emulating && debugger) { + MSG msg; + remoteStubMain(); + if(debugger) + return TRUE; // continue loop + return !::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE); + } else if(emulating && active && !paused) { +/// for(int i = 0; i < 2; i++) + { + emulator.emuMain(emulator.emuCount); + + // save the state for rewinding, if necessary + saveRewindStateIfNecessary(); + + rewindSaveNeeded = false; + } + + if(mouseCounter) { + if(--mouseCounter == 0) { + SetCursor(NULL); + } + } + return TRUE; + } + + return FALSE; + + // return CWinApp::OnIdle(lCount); +} + +void VBA::addRecentFile(CString file) +{ + // Do not change recent list if frozen + if(recentFreeze) + return; + int i = 0; + for(i = 0; i < 10; i++) { + if(recentFiles[i].GetLength() == 0) + break; + + if(recentFiles[i].Compare(file) == 0) { + if(i == 0) + return; + CString p = recentFiles[i]; + for(int j = i; j > 0; j--) { + recentFiles[j] = recentFiles[j-1]; + } + recentFiles[0] = p; + return; + } + } + int num = 0; + for(i = 0; i < 10; i++) { + if(recentFiles[i].GetLength() != 0) + num++; + } + if(num == 10) { + num--; + } + + for(i = num; i >= 1; i--) { + recentFiles[i] = recentFiles[i-1]; + } + recentFiles[0] = file; +} + +void VBA::loadSettings() +{ + CString buffer; + + languageOption = regQueryDwordValue("language", 1); + if(languageOption < 0 || languageOption > 2) + languageOption = 1; + + buffer = regQueryStringValue("languageName", ""); + if(!buffer.IsEmpty()) { + languageName = buffer.Left(3); + } else + languageName = ""; + + winSetLanguageOption(languageOption, true); + + frameSkip = regQueryDwordValue("frameSkip", /*2*/ 0); + if(frameSkip < 0 || frameSkip > 9) + frameSkip = 1; + + gbFrameSkip = regQueryDwordValue("gbFrameSkip", 0); + if(gbFrameSkip < 0 || gbFrameSkip > 9) + gbFrameSkip = 0; + +/// autoFrameSkip = regQueryDwordValue("autoFrameSkip", FALSE) ? TRUE : FALSE; + accuratePitchThrottle = regQueryDwordValue("accuratePitchThrottle", FALSE) ? TRUE : FALSE; + + vsync = regQueryDwordValue("vsync", false) ? true : false ; + synchronize = regQueryDwordValue("synchronize", 1) ? true : false; + fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false; + + videoOption = regQueryDwordValue("video", 0); + + if(videoOption < 0 || videoOption > VIDEO_OTHER) + videoOption = 0; + + bool defaultVideoDriver = regQueryDwordValue("defaultVideoDriver", true) ? + true : false; + + if(!regQueryBinaryValue("videoDriverGUID", (char *)&videoDriverGUID, + sizeof(GUID))) { + defaultVideoDriver = TRUE; + } + + if(defaultVideoDriver) + pVideoDriverGUID = NULL; + else + pVideoDriverGUID = &videoDriverGUID; + + fsWidth = regQueryDwordValue("fsWidth", 0); + fsHeight = regQueryDwordValue("fsHeight", 0); + fsColorDepth = regQueryDwordValue("fsColorDepth", 0); + + if(videoOption == VIDEO_OTHER) { + if(fsWidth < 0 || fsWidth > 4095 || fsHeight < 0 || fsHeight > 4095) + videoOption = 0; + if(fsColorDepth != 16 && fsColorDepth != 24 && fsColorDepth != 32) + videoOption = 0; + } + + renderMethod = (DISPLAY_TYPE)regQueryDwordValue("renderMethod", DIRECT_DRAW); + + if(renderMethod < GDI || renderMethod > OPENGL) + renderMethod = DIRECT_DRAW; + + windowPositionX = regQueryDwordValue("windowX", 0); + if(windowPositionX < 0) + windowPositionX = 0; + windowPositionY = regQueryDwordValue("windowY", 0); + if(windowPositionY < 0) + windowPositionY = 0; + + useBiosFile = regQueryDwordValue("useBios", 0) ? true: false; + + skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false; + + memLagEnabled = regQueryDwordValue("memLagEnabled", false) ? true: false; + memLagTempEnabled = memLagEnabled; + + useOldGBTiming = regQueryDwordValue("useOldGBTiming", false) ? true: false; + + allowLeftRight = regQueryDwordValue("allowLeftRight", false) ? true: false; + + buffer = regQueryStringValue("biosFile", ""); + + if(!buffer.IsEmpty()) { + biosFileName = buffer; + } + + int res = regQueryDwordValue("soundEnable", 0x30f); + + soundEnable(res); + soundDisable(~res); + + soundOffFlag = (regQueryDwordValue("soundOff", 0)) ? true : false; + + soundQuality = regQueryDwordValue("soundQuality", 2); + + soundEcho = regQueryDwordValue("soundEcho", 0) ? true : false; + + soundLowPass = regQueryDwordValue("soundLowPass", 0) ? true : false; + + soundReverse = regQueryDwordValue("soundReverse", 0) ? true : false; + + soundVolume = regQueryDwordValue("soundVolume", 0); + if(soundVolume < 0 || soundVolume > 5) + soundVolume = 0; + + ddrawEmulationOnly = regQueryDwordValue("ddrawEmulationOnly", false) ? true : false; + ddrawUseVideoMemory = regQueryDwordValue("ddrawUseVideoMemory", false) ? true : false; + tripleBuffering = regQueryDwordValue("tripleBuffering", true) ? true : false; + + d3dFilter = regQueryDwordValue("d3dFilter", 0); + if(d3dFilter < 0 || d3dFilter > 1) + d3dFilter = 0; + glFilter = regQueryDwordValue("glFilter", 0); + if(glFilter < 0 || glFilter > 1) + glFilter = 0; + glType = regQueryDwordValue("glType", 0); + if(glType < 0 || glType > 1) + glType = 0; + + filterType = regQueryDwordValue("filter", 0); + if(filterType < 0 || filterType > 16) + filterType = 0; + + disableMMX = regQueryDwordValue("disableMMX", 0) ? true: false; + + disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false; + + showSpeed = regQueryDwordValue("showSpeed", 1); + if(showSpeed < 0 || showSpeed > 2) + showSpeed = 1; + + showSpeedTransparent = regQueryDwordValue("showSpeedTransparent", TRUE) ? + TRUE : FALSE; + + winGbPrinterEnabled = regQueryDwordValue("gbPrinter", false) ? true : false; + + if(winGbPrinterEnabled) + gbSerialFunction = gbPrinterSend; + else + gbSerialFunction = NULL; + + pauseWhenInactive = regQueryDwordValue("pauseWhenInactive", 1) ? + true : false; + + frameCounter = regQueryDwordValue("frameCounter", false) ? true : false; + inputDisplay = regQueryDwordValue("inputDisplay", false) ? true : false; + movieReadOnly = regQueryDwordValue("movieReadOnly", false) ? true : false; + + useOldSync = regQueryDwordValue("useOldSync", 0) ? TRUE : FALSE; + + muteFrameAdvance = regQueryDwordValue("muteFrameAdvance", 0) ? TRUE : FALSE; + + captureFormat = regQueryDwordValue("captureFormat", 0); + + removeIntros = regQueryDwordValue("removeIntros", false) ? true : false; + + recentFreeze = regQueryDwordValue("recentFreeze", false) ? true : false; + + autoIPS = regQueryDwordValue("autoIPS", true) ? true : false; + + cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false; + + winSaveType = regQueryDwordValue("saveType", 0); + if(winSaveType < 0 || winSaveType > 5) + winSaveType = 0; + + cpuEnhancedDetection = regQueryDwordValue("enhancedDetection", 1) ? true : + false; + + ifbType = regQueryDwordValue("ifbType", 0); + if(ifbType < 0 || ifbType > 2) + ifbType = 0; + + winFlashSize = regQueryDwordValue("flashSize", 0x10000); + if(winFlashSize != 0x10000 && winFlashSize != 0x20000) + winFlashSize = 0x10000; + + agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false); + + winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false; + rtcEnable(winRtcEnable); + + autoHideMenu = regQueryDwordValue("autoHideMenu", 0) ? true : false; + + skinEnabled = regQueryDwordValue("skinEnabled", 0) ? true : false; + + skinName = regQueryStringValue("skinName", ""); + + switch(videoOption) { + case VIDEO_320x240: + fsWidth = 320; + fsHeight = 240; + fsColorDepth = 16; + break; + case VIDEO_640x480: + fsWidth = 640; + fsHeight = 480; + fsColorDepth = 16; + break; + case VIDEO_800x600: + fsWidth = 800; + fsHeight = 600; + fsColorDepth = 16; + break; + } + + winGbBorderOn = regQueryDwordValue("borderOn", 0); + gbBorderAutomatic = regQueryDwordValue("borderAutomatic", 0); + gbEmulatorType = regQueryDwordValue("emulatorType", 0); + if(gbEmulatorType < 0 || gbEmulatorType > 5) + gbEmulatorType = 1; + gbColorOption = regQueryDwordValue("colorOption", 0); + + outlinedText = regQueryDwordValue("outlinedText", TRUE) != 0; + transparentText = regQueryDwordValue("transparentText", FALSE) != 0; + textColor = regQueryDwordValue("textColor", 0); + textMethod = regQueryDwordValue("textMethod", 1); + + threadPriority = regQueryDwordValue("priority", 2); + + if(threadPriority < 0 || threadPriority >3) + threadPriority = 2; + updatePriority(); + + autoSaveLoadCheatList = regQueryDwordValue("autoSaveCheatList", 0) ? true : false; + + pauseDuringCheatSearch = regQueryDwordValue("pauseDuringCheatSearch", 1) ? true : false; + + gbPaletteOption = regQueryDwordValue("gbPaletteOption", 0); + if(gbPaletteOption < 0) + gbPaletteOption = 0; + if(gbPaletteOption > 2) + gbPaletteOption = 2; + + regQueryBinaryValue("gbPalette", (char *)systemGbPalette, 24*sizeof(u16)); + + rewindTimer = regQueryDwordValue("rewindTimer", 0); + rewindSlots = regQueryDwordValue("rewindSlots", 64); + + if(rewindTimer < 0 || rewindTimer > 600) + rewindTimer = 0; + + if(rewindSlots <= 0) + rewindTimer = rewindSlots = 0; + if(rewindSlots > MAX_REWIND_SLOTS) + rewindSlots = MAX_REWIND_SLOTS; + + if(rewindTimer != 0) + { + if(rewindMemory == NULL) + rewindMemory = (char *)malloc(rewindSlots*REWIND_SIZE); + } + + if(frameSearchMemory == NULL) + frameSearchMemory = (char *)malloc(3*REWIND_SIZE); + + for(int i = 0; i < 10; i++) { + buffer.Format("recent%d", i); + char *s = regQueryStringValue(buffer, NULL); + if(s == NULL) + break; + recentFiles[i] = s; + } + + joypadDefault = regQueryDwordValue("joypadDefault", 0); + if(joypadDefault < 0 || joypadDefault > 3) + joypadDefault = 0; + + autoLoadMostRecent = regQueryDwordValue("autoLoadMostRecent", false) ? true : + false; + + loadMakesRecent = regQueryDwordValue("loadMakesRecent", false) ? true : false; + + loadMakesCurrent = regQueryDwordValue("loadMakesCurrent", false) ? true : false; + saveMakesCurrent = regQueryDwordValue("saveMakesCurrent", false) ? true : false; + currentSlot = regQueryDwordValue("currentSlot", 0); + + cheatsEnabled = regQueryDwordValue("cheatsEnabled", true) ? true : false; + + fsMaxScale = regQueryDwordValue("fsMaxScale", 0); + + throttle = regQueryDwordValue("throttle", 0); + if(throttle < 5 || throttle > 1000) + throttle = 100; +} + +void VBA::updateFrameSkip() +{ + switch(cartridgeType) { + case 0: + systemFrameSkip = frameSkip; + break; + case 1: + systemFrameSkip = gbFrameSkip; + break; + } +} + +void VBA::updateVideoSize(UINT id) +{ + int value = 0; + + switch(id) { + case ID_OPTIONS_VIDEO_X1: + value = VIDEO_1X; + break; + case ID_OPTIONS_VIDEO_X2: + value = VIDEO_2X; + break; + case ID_OPTIONS_VIDEO_X3: + value = VIDEO_3X; + break; + case ID_OPTIONS_VIDEO_X4: + value = VIDEO_4X; + break; + case ID_OPTIONS_VIDEO_FULLSCREEN320X240: + value = VIDEO_320x240; + fsWidth = 320; + fsHeight = 240; + fsColorDepth = 16; + break; + case ID_OPTIONS_VIDEO_FULLSCREEN640X480: + value = VIDEO_640x480; + fsWidth = 640; + fsHeight = 480; + fsColorDepth = 16; + break; + case ID_OPTIONS_VIDEO_FULLSCREEN800X600: + value = VIDEO_800x600; + fsWidth = 800; + fsHeight = 600; + fsColorDepth = 16; + break; + case ID_OPTIONS_VIDEO_FULLSCREEN: + value = VIDEO_OTHER; + break; + } + + if(videoOption == value && value != VIDEO_OTHER) + return; + + updateWindowSize(value); +} + +typedef BOOL (WINAPI *GETMENUBARINFO)(HWND, LONG, LONG, PMENUBARINFO); + +static void winCheckMenuBarInfo(int& winSizeX, int& winSizeY) +{ + HINSTANCE hinstDll; + DWORD dwVersion = 0; + + hinstDll = /**/AfxLoadLibrary("USER32.DLL"); + + if(hinstDll) { + GETMENUBARINFO func = (GETMENUBARINFO)GetProcAddress(hinstDll, + "GetMenuBarInfo"); + + if(func) { + MENUBARINFO info; + info.cbSize = sizeof(info); + + func(AfxGetMainWnd()->GetSafeHwnd(), OBJID_MENU, 0, &info); + + int menuHeight = GetSystemMetrics(SM_CYMENU); + + if((info.rcBar.bottom - info.rcBar.top) > menuHeight) { + winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1; + theApp.m_pMainWnd->SetWindowPos( + 0, //HWND_TOPMOST, + theApp.windowPositionX, + theApp.windowPositionY, + winSizeX, + winSizeY, + SWP_NOMOVE | SWP_SHOWWINDOW); + } + } + /**/AfxFreeLibrary(hinstDll); + } +} + +void VBA::updateWindowSize(int value) +{ + regSetDwordValue("video", value); + + if(value == VIDEO_OTHER) { + regSetDwordValue("fsWidth", fsWidth); + regSetDwordValue("fsHeight", fsHeight); + regSetDwordValue("fsColorDepth", fsColorDepth); + } + + if(((value >= VIDEO_320x240) && + (videoOption != value)) || + (videoOption >= VIDEO_320x240 && + value <= VIDEO_4X) || + fsForceChange) { + fsForceChange = false; + changingVideoSize = true; + shutdownDisplay(); + if(input) { + delete input; + input = NULL; + } + m_pMainWnd->DragAcceptFiles(FALSE); + CWnd *pWnd = m_pMainWnd; + m_pMainWnd = NULL; + pWnd->DestroyWindow(); + delete pWnd; + videoOption = value; + if(!initDisplay()) { + if(videoOption == VIDEO_320x240 || + videoOption == VIDEO_640x480 || + videoOption == VIDEO_800x600 || + videoOption == VIDEO_OTHER) { + regSetDwordValue("video", VIDEO_1X); + if(pVideoDriverGUID) + regSetDwordValue("defaultVideoDriver", TRUE); + } + changingVideoSize = false; + AfxPostQuitMessage(0); + return; + } + if(!initInput()) { + changingVideoSize = false; + AfxPostQuitMessage(0); + return; + } + input->checkKeys(); + updateMenuBar(); + changingVideoSize = FALSE; + updateWindowSize(videoOption); + return; + } + + sizeX = 240; + sizeY = 160; + + videoOption = value; + + if(cartridgeType == 1) { + if(gbBorderOn) { + sizeX = 256; + sizeY = 224; + gbBorderLineSkip = 256; + gbBorderColumnSkip = 48; + gbBorderRowSkip = 40; + } else { + sizeX = 160; + sizeY = 144; + gbBorderLineSkip = 160; + gbBorderColumnSkip = 0; + gbBorderRowSkip = 0; + } + } + + surfaceSizeX = sizeX; + surfaceSizeY = sizeY; + + switch(videoOption) { + case VIDEO_1X: + surfaceSizeX = sizeX; + surfaceSizeY = sizeY; + break; + case VIDEO_2X: + surfaceSizeX = sizeX * 2; + surfaceSizeY = sizeY * 2; + break; + case VIDEO_3X: + surfaceSizeX = sizeX * 3; + surfaceSizeY = sizeY * 3; + break; + case VIDEO_4X: + surfaceSizeX = sizeX * 4; + surfaceSizeY = sizeY * 4; + break; + case VIDEO_320x240: + case VIDEO_640x480: + case VIDEO_800x600: + case VIDEO_OTHER: + { + int scaleX = 1; + int scaleY = 1; + scaleX = (fsWidth / sizeX); + scaleY = (fsHeight / sizeY); + int min = scaleX < scaleY ? scaleX : scaleY; + if(fsMaxScale) + min = min > fsMaxScale ? fsMaxScale : min; + surfaceSizeX = min * sizeX; + surfaceSizeY = min * sizeY; + if((fullScreenStretch && (display != NULL && + (display->getType() != DIRECT_3D))) + || (display != NULL && display->getType() >= DIRECT_3D)) { + surfaceSizeX = fsWidth; + surfaceSizeY = fsHeight; + } + } + break; + } + + rect.right = sizeX; + rect.bottom = sizeY; + + int winSizeX = sizeX; + int winSizeY = sizeY; + + if(videoOption <= VIDEO_4X) { + dest.left = 0; + dest.top = 0; + dest.right = surfaceSizeX; + dest.bottom = surfaceSizeY; + + DWORD style = WS_POPUP | WS_VISIBLE; + + style |= WS_OVERLAPPEDWINDOW; + + menuToggle = TRUE; + AdjustWindowRectEx(&dest, style, flagHideMenu ? FALSE : TRUE, 0); //WS_EX_TOPMOST); + + winSizeX = dest.right-dest.left; + winSizeY = dest.bottom-dest.top; + + if(skin == NULL) { + m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST, + windowPositionX, + windowPositionY, + winSizeX, + winSizeY, + SWP_NOMOVE | SWP_SHOWWINDOW); + + winCheckMenuBarInfo(winSizeX, winSizeY); + } + } + + adjustDestRect(); + + updateIFB(); + updateFilter(); + + m_pMainWnd->RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); +} + +bool VBA::initDisplay() +{ + return updateRenderMethod(false); +} + +bool VBA::updateRenderMethod(bool force) +{ + bool res = updateRenderMethod0(force); + + while(!res && renderMethod > 0) { + if(renderMethod == OPENGL) + renderMethod = DIRECT_3D; + else if(renderMethod == DIRECT_3D) + renderMethod = DIRECT_DRAW; + else if(renderMethod == DIRECT_DRAW) { + if(videoOption > VIDEO_4X) { + videoOption = VIDEO_2X; + force = true; + } else + renderMethod = GDI; + } + + res = updateRenderMethod(force); + } + return res; +} + +bool VBA::updateRenderMethod0(bool force) +{ + bool initInput = false; + + if(display) { + if(display->getType() != renderMethod || force) { + if(skin) { + delete skin; + skin = NULL; + } + initInput = true; + changingVideoSize = true; + shutdownDisplay(); + if(input) { + delete input; + input = NULL; + } + CWnd *pWnd = m_pMainWnd; + + m_pMainWnd = NULL; + pWnd->DragAcceptFiles(FALSE); + pWnd->DestroyWindow(); + delete pWnd; + + display = NULL; + regSetDwordValue("renderMethod", renderMethod); + } + } + if(display == NULL) { + switch(renderMethod) { + case GDI: + display = newGDIDisplay(); + break; + case DIRECT_DRAW: + display = newDirectDrawDisplay(); + break; + case DIRECT_3D: + display = newDirect3DDisplay(); + break; + case OPENGL: + display = newOpenGLDisplay(); + break; + } + + if(display->initialize()) { + winUpdateSkin(); + if(initInput) { + if(!this->initInput()) { + changingVideoSize = false; + AfxPostQuitMessage(0); + return false; + } + input->checkKeys(); + updateMenuBar(); + changingVideoSize = false; + updateWindowSize(videoOption); + + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); + m_pMainWnd->SetFocus(); + + return true; + } else { + changingVideoSize = false; + return true; + } + } + changingVideoSize = false; + } + return true; +} + +void VBA::winCheckFullscreen() +{ + if(videoOption > VIDEO_4X && tripleBuffering) { + if(display) + display->checkFullScreen(); + } +} + +void VBA::shutdownDisplay() +{ + if(display != NULL) { + display->cleanup(); + delete display; + display = NULL; + } +} + +void VBA::directXMessage(const char *msg) +{ + systemMessage(IDS_DIRECTX_7_REQUIRED, + "DirectX 7.0 or greater is required to run.\nDownload at http://www.microsoft.com/directx.\n\nError found at: %s", + msg); +} + +void VBA::winUpdateSkin() +{ + skinButtons = 0; + if(skin) { + delete skin; + skin = NULL; + } + + if(!skinName.IsEmpty() && skinEnabled && display->isSkinSupported()) { + skin = new CSkin(); + if(skin->Initialize(skinName)) { + skin->Hook(m_pMainWnd); + skin->Enable(true); + } else { + delete skin; + skin = NULL; + } + } + + if(!skin) { + adjustDestRect(); + updateMenuBar(); + } +} + +void VBA::updatePriority() +{ + switch(threadPriority) { + case 0: + SetThreadPriority(THREAD_PRIORITY_HIGHEST); + break; + case 1: + SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL); + break; + case 3: + SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); + break; + default: + SetThreadPriority(THREAD_PRIORITY_NORMAL); + } +} + +#ifdef MMX +bool VBA::detectMMX() +{ + bool support = false; + char brand[13]; + + // check for Intel chip + __try { + __asm { + mov eax, 0; + cpuid; + mov [dword ptr brand+0], ebx; + mov [dword ptr brand+4], edx; + mov [dword ptr brand+8], ecx; + } + } + __except(EXCEPTION_EXECUTE_HANDLER) { + if(_exception_code() == STATUS_ILLEGAL_INSTRUCTION) { + return false; + } + return false; + } + // Check for Intel or AMD CPUs + if(strncmp(brand, "GenuineIntel", 12)) { + if(strncmp(brand, "AuthenticAMD", 12)) { + return false; + } + } + + __asm { + mov eax, 1; + cpuid; + test edx, 00800000h; + jz NotFound; + mov [support], 1; + NotFound: + } + return support; +} +#endif + +void VBA::winSetLanguageOption(int option, bool force) +{ + if(((option == languageOption) && option != 2) && !force) + return; + switch(option) { + case 0: + { + char lbuffer[10]; + + if(GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, + lbuffer, 10)) { + HINSTANCE l = winLoadLanguage(lbuffer); + if(l == NULL) { + LCID locIdBase = MAKELCID( MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANG_NEUTRAL ), SORT_DEFAULT ); + if(GetLocaleInfo(locIdBase, LOCALE_SABBREVLANGNAME, + lbuffer, 10)) { + l = winLoadLanguage(lbuffer); + if(l == NULL) { + systemMessage(IDS_FAILED_TO_LOAD_LIBRARY, + "Failed to load library %s", + lbuffer); + return; + } + } + } + AfxSetResourceHandle(l); + if(languageModule != NULL) + /**/AfxFreeLibrary(languageModule); + languageModule = l; + } else { + systemMessage(IDS_FAILED_TO_GET_LOCINFO, + "Failed to get locale information"); + return; + } + } + break; + case 1: + if(languageModule != NULL) + /**/AfxFreeLibrary(languageModule); + languageModule = NULL; + AfxSetResourceHandle(AfxGetInstanceHandle()); + break; + case 2: + { + if(!force) { + LangSelect dlg; + if(dlg.DoModal()) { + HINSTANCE l = winLoadLanguage(languageName); + if(l == NULL) { + systemMessage(IDS_FAILED_TO_LOAD_LIBRARY, + "Failed to load library %s", + languageName); + return; + } + AfxSetResourceHandle(l); + if(languageModule != NULL) + /**/AfxFreeLibrary(languageModule); + languageModule = l; + } + } else { + if(languageName.IsEmpty()) + return; + HINSTANCE l = winLoadLanguage(languageName); + if(l == NULL) { + systemMessage(IDS_FAILED_TO_LOAD_LIBRARY, + "Failed to load library %s", + languageName); + return; + } + AfxSetResourceHandle(l); + if(languageModule != NULL) + FreeLibrary(languageModule); + languageModule = l; + } + } + break; + } + languageOption = option; + updateMenuBar(); +} + +HINSTANCE VBA::winLoadLanguage(const char *name) +{ + CString buffer; + + buffer.Format("vba_%s.dll", name); + + HINSTANCE l = /**/AfxLoadLibrary(buffer); + + if(l == NULL) { + if(strlen(name) == 3) { + char buffer2[3]; + buffer2[0] = name[0]; + buffer2[1] = name[1]; + buffer2[2] = 0; + buffer.Format("vba_%s.dll", buffer2); + + return /**/AfxLoadLibrary(buffer); + } + } + return l; +} + + +bool VBA::initInput() +{ + if(input) + delete input; + input = newDirectInput(); + if(input->initialize()) { + input->loadSettings(); + input->checkKeys(); + return true; + } + delete input; + return false; +} + +void VBA::winAddUpdateListener(IUpdateListener *l) +{ + updateList.AddTail(l); + updateCount++; +} + +void VBA::winRemoveUpdateListener(IUpdateListener *l) +{ + POSITION pos = updateList.Find(l); + if(pos) { + updateList.RemoveAt(pos); + updateCount--; + if(updateCount < 0) + updateCount = 0; + } +} + +CString VBA::winLoadFilter(UINT id) +{ + CString res = winResLoadString(id); + res.Replace('_','|'); + + return res; +} + + +void VBA::saveSettings() +{ + regSetDwordValue("language", languageOption); + + regSetStringValue("languageName", languageName); + + regSetDwordValue("frameSkip", frameSkip); + + regSetDwordValue("gbFrameSkip", gbFrameSkip); + +/// regSetDwordValue("autoFrameSkip", autoFrameSkip); + regSetDwordValue("accuratePitchThrottle", accuratePitchThrottle); + + regSetDwordValue("vsync", vsync); + regSetDwordValue("synchronize", synchronize); + regSetDwordValue("stretch", fullScreenStretch); + + regSetDwordValue("video", videoOption); + + regSetDwordValue("defaultVideoDriver", pVideoDriverGUID == NULL); + + if(pVideoDriverGUID) { + regSetBinaryValue("videoDriverGUID", (char *)&videoDriverGUID, + sizeof(GUID)); + } + + + regSetDwordValue("fsWidth", fsWidth); + regSetDwordValue("fsHeight", fsHeight); + regSetDwordValue("fsColorDepth", fsColorDepth); + + regSetDwordValue("renderMethod", renderMethod); + + regSetDwordValue("windowX", windowPositionX); + regSetDwordValue("windowY", windowPositionY); + + regSetDwordValue("useBios", useBiosFile); + + regSetDwordValue("skipBios", skipBiosFile); + + regSetDwordValue("memLagEnabled", memLagEnabled); + + regSetDwordValue("useOldGBTiming", useOldGBTiming); + + regSetDwordValue("allowLeftRight", allowLeftRight); + + if(!biosFileName.IsEmpty()) + regSetStringValue("biosFile", biosFileName); + + regSetDwordValue("soundEnable", soundGetEnable() & 0x30f); + + regSetDwordValue("soundOff", soundOffFlag); + + regSetDwordValue("soundQuality", soundQuality); + + regSetDwordValue("soundEcho", soundEcho); + + regSetDwordValue("soundLowPass", soundLowPass); + + regSetDwordValue("soundReverse", soundReverse); + + regSetDwordValue("soundVolume", soundVolume); + + regSetDwordValue("ddrawEmulationOnly", ddrawEmulationOnly); + regSetDwordValue("ddrawUseVideoMemory", ddrawUseVideoMemory); + regSetDwordValue("tripleBuffering", tripleBuffering); + + regSetDwordValue("d3dFilter", d3dFilter); + regSetDwordValue("glFilter", glFilter); + regSetDwordValue("glType", glType); + + regSetDwordValue("filter", filterType); + + regSetDwordValue("disableMMX", disableMMX); + + regSetDwordValue("disableStatus", disableStatusMessage); + + regSetDwordValue("showSpeed", showSpeed); + + regSetDwordValue("showSpeedTransparent", showSpeedTransparent); + + regSetDwordValue("gbPrinter", winGbPrinterEnabled); + + regSetDwordValue("pauseWhenInactive", pauseWhenInactive); + + regSetDwordValue("frameCounter", frameCounter); + regSetDwordValue("inputDisplay", inputDisplay); + regSetDwordValue("movieReadOnly", movieReadOnly); + + regSetDwordValue("useOldSync", useOldSync); + + regSetDwordValue("muteFrameAdvance", muteFrameAdvance); + + regSetDwordValue("captureFormat", captureFormat); + + regSetDwordValue("removeIntros", removeIntros); + + regSetDwordValue("recentFreeze", recentFreeze); + + regSetDwordValue("autoIPS", autoIPS); + + regSetDwordValue("disableSfx", cpuDisableSfx); + + regSetDwordValue("saveType", winSaveType); + + regSetDwordValue("enhancedDetection", cpuEnhancedDetection); + + regSetDwordValue("ifbType", ifbType); + + regSetDwordValue("flashSize", winFlashSize); + + regSetDwordValue("agbPrint", agbPrintIsEnabled()); + + regSetDwordValue("rtcEnabled", winRtcEnable); + + regSetDwordValue("autoHideMenu", autoHideMenu); + + regSetDwordValue("skinEnabled", skinEnabled); + + regSetStringValue("skinName", skinName); + + regSetDwordValue("borderOn", winGbBorderOn); + regSetDwordValue("borderAutomatic", gbBorderAutomatic); + regSetDwordValue("emulatorType", gbEmulatorType); + regSetDwordValue("colorOption", gbColorOption); + + regSetDwordValue("outlinedText", outlinedText); + regSetDwordValue("transparentText", transparentText); + regSetDwordValue("textColor", textColor); + regSetDwordValue("textMethod", textMethod); + + regSetDwordValue("priority", threadPriority); + + regSetDwordValue("autoSaveCheatList", autoSaveLoadCheatList); + + regSetDwordValue("pauseDuringCheatSearch", pauseDuringCheatSearch); + + regSetDwordValue("gbPaletteOption", gbPaletteOption); + + regSetBinaryValue("gbPalette", (char *)systemGbPalette, 24*sizeof(u16)); + + regSetDwordValue("rewindTimer", rewindTimer); + regSetDwordValue("rewindSlots", rewindSlots); + + CString buffer; + for(int i = 0; i < 10; i++) { + buffer.Format("recent%d", i); + regSetStringValue(buffer, recentFiles[i]); + } + + regSetDwordValue("joypadDefault", joypadDefault); + regSetDwordValue("autoLoadMostRecent", autoLoadMostRecent); + regSetDwordValue("loadMakesRecent", loadMakesRecent); + regSetDwordValue("loadMakesCurrent", loadMakesCurrent); + regSetDwordValue("saveMakesCurrent", saveMakesCurrent); + regSetDwordValue("currentSlot", currentSlot); + regSetDwordValue("cheatsEnabled", cheatsEnabled); + regSetDwordValue("fsMaxScale", fsMaxScale); + regSetDwordValue("throttle", throttle); +} + +void winSignal(int, int) +{ +} + +#define CPUReadByteQuick(addr) \ + map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] + +void winOutput(char *s, u32 addr) +{ + if(s) { + toolsLog(s); + } else { + CString str; + char c; + + c = CPUReadByteQuick(addr); + addr++; + while(c) { + str += c; + c = CPUReadByteQuick(addr); + addr++; + } + toolsLog(str); + } +} diff --git a/src/win32/VBA.h b/src/win32/VBA.h new file mode 100644 index 0000000..f3ce89e --- /dev/null +++ b/src/win32/VBA.h @@ -0,0 +1,292 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// VBA.h : main header file for the VBA application +// + +#if !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_) +#define AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ +#error include 'stdafx.h' before including this file for PCH +#endif + +#include + +#include "AcceleratorManager.h" +#include "resource.h" // main symbols +#include "Display.h" +#include "Input.h" +#include "IUpdate.h" +#include "Sound.h" +#include "../System.h" + +///////////////////////////////////////////////////////////////////////////// +// VBA: +// See VBA.cpp for the implementation of this class +// + +enum { + VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, + VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_OTHER +}; + +#define REWIND_SIZE 400000 +#define MAX_REWIND_SLOTS 256 +#define SCREEN_MESSAGE_SLOTS 8 + +class CSkin; +class AVIWrite; +class WavWriter; + +class VBA : public CWinApp +{ + public: + CMenu m_menu; + HMENU menu; + HMENU popup; + bool mode320Available; + bool mode640Available; + bool mode800Available; + int windowPositionX; + int windowPositionY; + void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int); + void (*ifbFunction)(u8*,u32,int,int); + int ifbType; + int filterType; + int filterWidth; + int filterHeight; + int fsWidth; + int fsHeight; + int fsColorDepth; + bool fsForceChange; + int sizeX; + int sizeY; + int surfaceSizeX; + int surfaceSizeY; + int videoOption; + bool fullScreenStretch; + bool disableStatusMessage; + int showSpeed; + BOOL showSpeedTransparent; + int showRenderedFrames; + bool screenMessage [SCREEN_MESSAGE_SLOTS]; + CString screenMessageBuffer [SCREEN_MESSAGE_SLOTS]; + DWORD screenMessageTime [SCREEN_MESSAGE_SLOTS]; + int screenMessageDuration [SCREEN_MESSAGE_SLOTS]; + CString screenMessageColorBuffer [SCREEN_MESSAGE_SLOTS]; + u8 *delta[257*244*4]; + bool menuToggle; + IDisplay *display; + int cartridgeType; + bool soundInitialized; + bool useBiosFile; + bool skipBiosFile; + CString biosFileName; + bool useOldGBTiming; + bool allowLeftRight; + bool active; + bool paused; + CString recentFiles[10]; + bool recentFreeze; + bool autoSaveLoadCheatList; + bool pauseDuringCheatSearch; + bool modelessCheatDialogIsOpen; + FILE *winout; + bool removeIntros; + bool autoIPS; + int winGbBorderOn; + bool hideMovieBorder; + int winFlashSize; + bool winRtcEnable; + int winSaveType; + char *rewindMemory; + int rewindPos; + int rewindTopPos; + int rewindCounter; + int rewindCount; + bool rewindSaveNeeded; + int rewindTimer; + int rewindSlots; + int captureFormat; + bool tripleBuffering; + bool autoHideMenu; + int throttle; + u32 throttleLastTime; +/// u32 autoFrameSkipLastTime; +/// bool autoFrameSkip; + bool accuratePitchThrottle; + bool vsync; + bool changingVideoSize; + GUID videoDriverGUID; + GUID *pVideoDriverGUID; + DISPLAY_TYPE renderMethod; + bool iconic; + bool ddrawEmulationOnly; + bool ddrawUsingEmulationOnly; + bool ddrawDebug; + bool ddrawUseVideoMemory; + int d3dFilter; + int glFilter; + int glType; + CSkin *skin; + CString skinName; + bool skinEnabled; + int skinButtons; + bool pauseWhenInactive; + bool speedupToggle; + bool useOldSync; + bool muteFrameAdvance; + bool frameAdvanceMuteNow; + bool winGbPrinterEnabled; + int threadPriority; + bool disableMMX; + int languageOption; + CString languageName; + HINSTANCE languageModule; + int renderedFrames; + Input *input; + int joypadDefault; + int autoFire, autoFire2; + int autoHold; + bool autoFireToggle; + bool winPauseNextFrame; + bool frameCounter; + int globalFrameCount; + bool inputDisplay; + bool movieReadOnly; + bool soundRecording; + WavWriter *soundRecorder; + CString soundRecordName; + ISound *sound; + bool aviRecording; + AVIWrite *aviRecorder; + CString aviRecordName; + int aviFrameNumber; + bool nvVideoLog; + bool nvAudioLog; + bool painting; + int sensorX; + int sensorY; + int mouseCounter; + bool wasPaused; + int frameskipadjust; + bool autoLoadMostRecent; + bool loadMakesRecent; + int fsMaxScale; + int romSize; + bool loadMakesCurrent; + bool saveMakesCurrent; + int currentSlot; + bool frameSearching; + bool frameSearchSkipping; + bool frameSearchFirstStep; + bool frameSearchLoadValid; + int frameSearchLength; + int frameSearchStart; + u32 frameSearchOldInput [4]; + char *frameSearchMemory; + + CList updateList; + int updateCount; + + CAcceleratorManager winAccelMgr; + HACCEL hAccel; + + RECT rect; + RECT dest; + + struct EmulatedSystem emulator; + + CString szFile; + CString filename; + CString dir; + + CString wndClass; + + public: + VBA(); + ~VBA(); + + void adjustDestRect(); + void updateIFB(); + void updateFilter(); + void updateMenuBar(); + void winAddUpdateListener(IUpdateListener *l); + void winRemoveUpdateListener(IUpdateListener *l); + CString winLoadFilter(UINT id); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(VBA) + public: + virtual BOOL InitInstance(); + virtual BOOL OnIdle(LONG lCount); + //}}AFX_VIRTUAL + + // Implementation + + public: + void saveSettings(); + bool initInput(); + HINSTANCE winLoadLanguage(const char *name); + void winSetLanguageOption(int option, bool force); + bool detectMMX(); +#ifdef MMX +#endif + void updatePriority(); + void winUpdateSkin(); + void directXMessage(const char *msg); + void shutdownDisplay(); + void winCheckFullscreen(); + bool updateRenderMethod0(bool force); + bool updateRenderMethod(bool force); + bool initDisplay(); + void updateWindowSize(int value); + void updateVideoSize(UINT id); + void updateFrameSkip(); + void loadSettings(); + void addRecentFile(CString file); + void saveRewindStateIfNecessary(); + //{{AFX_MSG(VBA) + afx_msg void OnAppAbout(); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + extern VBA theApp; + +#ifdef MMX + extern "C" bool cpu_mmx; +#endif + + extern void DrawTextMessages(u8 * dest, int pitch, int left, int bottom); + + ///////////////////////////////////////////////////////////////////////////// + + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_) diff --git a/src/win32/VideoMode.cpp b/src/win32/VideoMode.cpp new file mode 100644 index 0000000..3eb7a6c --- /dev/null +++ b/src/win32/VideoMode.cpp @@ -0,0 +1,368 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// VideoMode.cpp : implementation file +// + +#include "stdafx.h" +/// #define _AFXDLL /// EVIL +/// #include "afxwin.h" /// EVIL +/// #include "afxdll_.h" /// EVIL +#include "VBA.h" + +#define DIRECTDRAW_VERSION 0x0700 +#include "ddraw.h" + +#include "VideoMode.h" + +#include "../System.h" +#include "resource.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define MAX_DRIVERS 32 // 32 drivers maximum + +//----------------------------------------------------------------------------- +// Local structures +//----------------------------------------------------------------------------- +// Keeps data on the available DDraw drivers +struct +{ + char szDescription[128]; + char szName[128]; + GUID *pGUID; + GUID GUIDcopy; + HMONITOR hm; +} Drivers[MAX_DRIVERS]; + +//----------------------------------------------------------------------------- +// Local data +//----------------------------------------------------------------------------- +static int gDriverCnt = 0; // Total number of drivers +static GUID *gpSelectedDriverGUID; + +//----------------------------------------------------------------------------- +// Name: DDEnumCallbackEx() +// Desc: This call back is used to determine the existing available DDraw +// devices, so the user can pick which one to run on. +//----------------------------------------------------------------------------- +BOOL WINAPI +DDEnumCallbackEx(GUID *pGUID, LPSTR pDescription, LPSTR pName, LPVOID pContext, HMONITOR hm) +{ + if (pGUID) + { + Drivers[gDriverCnt].GUIDcopy = *pGUID; + Drivers[gDriverCnt].pGUID = &Drivers[gDriverCnt].GUIDcopy; + } + else + Drivers[gDriverCnt].pGUID = NULL; + Drivers[gDriverCnt].szDescription[127] = '\0'; + Drivers[gDriverCnt].szName[127] = '\0'; + strncpy(Drivers[gDriverCnt].szDescription,pDescription,127); + strncpy(Drivers[gDriverCnt].szName,pName,127); + Drivers[gDriverCnt].hm = hm; + if (gDriverCnt < MAX_DRIVERS) + gDriverCnt++; + else + return DDENUMRET_CANCEL; + return DDENUMRET_OK; +} + + + + +//----------------------------------------------------------------------------- +// Name: DDEnumCallback() +// Desc: This callback is used only with old versions of DDraw. +//----------------------------------------------------------------------------- +BOOL WINAPI +DDEnumCallback(GUID *pGUID, LPSTR pDescription, LPSTR pName, LPVOID context) +{ + return (DDEnumCallbackEx(pGUID, pDescription, pName, context, NULL)); +} + +static HRESULT WINAPI addVideoMode(LPDDSURFACEDESC2 surf, LPVOID lpContext) +{ + HWND h = (HWND)lpContext; + char buffer[50]; + + switch(surf->ddpfPixelFormat.dwRGBBitCount) { + case 16: + case 24: + case 32: + if(surf->dwWidth >= 640 && surf->dwHeight >= 480) { + sprintf(buffer, "%4dx%4dx%2d", surf->dwWidth, surf->dwHeight, + surf->ddpfPixelFormat.dwRGBBitCount); + int pos = ::SendMessage(h, LB_ADDSTRING, 0, (LPARAM)buffer); + ::SendMessage(h, LB_SETITEMDATA, pos, + (surf->ddpfPixelFormat.dwRGBBitCount << 24) | + ((surf->dwWidth & 4095) << 12) | + (surf->dwHeight & 4095)); + } + } + + return DDENUMRET_OK; +} + +int winVideoModeSelect(CWnd *pWnd, GUID **guid) +{ + HINSTANCE h = /**/AfxLoadLibrary("ddraw.dll"); + + // If ddraw.dll doesn't exist in the search path, + // then DirectX probably isn't installed, so fail. + if (!h) + return -1; + + gDriverCnt = 0; + + // Note that you must know which version of the + // function to retrieve (see the following text). + // For this example, we use the ANSI version. + LPDIRECTDRAWENUMERATEEX lpDDEnumEx; + lpDDEnumEx = (LPDIRECTDRAWENUMERATEEX) + GetProcAddress(h,"DirectDrawEnumerateExA"); + + // If the function is there, call it to enumerate all display + // devices attached to the desktop, and any non-display DirectDraw + // devices. + if (lpDDEnumEx) + lpDDEnumEx(DDEnumCallbackEx, NULL, + DDENUM_ATTACHEDSECONDARYDEVICES | + DDENUM_NONDISPLAYDEVICES + ); + else { + /* + * We must be running on an old version of DirectDraw. + * Therefore MultiMon isn't supported. Fall back on + * DirectDrawEnumerate to enumerate standard devices on a + * single-monitor system. + */ + BOOL (WINAPI *lpDDEnum)(LPDDENUMCALLBACK, LPVOID); + + lpDDEnum = (BOOL (WINAPI *)(LPDDENUMCALLBACK, LPVOID)) + GetProcAddress(h, "DirectDrawEnumerateA"); + if(lpDDEnum) + lpDDEnum(DDEnumCallback,NULL); + + /* Note that it could be handy to let the OldCallback function + * be a wrapper for a DDEnumCallbackEx. + * + * Such a function would look like: + * BOOL FAR PASCAL OldCallback(GUID FAR *lpGUID, + * LPSTR pDesc, + * LPSTR pName, + * LPVOID pContext) + * { + * return Callback(lpGUID,pDesc,pName,pContext,NULL); + * } + */ + } + + int selected = 0; + + if(gDriverCnt > 1) { + VideoDriverSelect d(pWnd); + + selected = d.DoModal(); + + if(selected == -1) { + // If the library was loaded by calling LoadLibrary(), + // then you must use FreeLibrary() to let go of it. + /**/AfxFreeLibrary(h); + + return -1; + } + } + + HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *); + DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *)) + GetProcAddress(h, "DirectDrawCreateEx"); + + LPDIRECTDRAW7 ddraw = NULL; + if(DDrawCreateEx) { + HRESULT hret = DDrawCreateEx(Drivers[selected].pGUID, + (void **)&ddraw, + IID_IDirectDraw7, + NULL); + if(hret != DD_OK) { + systemMessage(0, "Error during DirectDrawCreateEx: %08x", hret); + /**/AfxFreeLibrary(h); + return -1; + } + } else { + // should not happen.... + systemMessage(0, "Error getting DirectDrawCreateEx"); + /**/AfxFreeLibrary(h); + return -1; + } + + VideoMode dlg(ddraw, pWnd); + + int res = dlg.DoModal(); + + if(res != -1) { + *guid = Drivers[selected].pGUID; + } + ddraw->Release(); + ddraw = NULL; + + // If the library was loaded by calling LoadLibrary(), + // then you must use FreeLibrary() to let go of it. + /**/AfxFreeLibrary(h); + + return res; +} + +///////////////////////////////////////////////////////////////////////////// +// VideoMode dialog + + +VideoMode::VideoMode(LPDIRECTDRAW7 pDraw, CWnd* pParent /*=NULL*/) + : CDialog(VideoMode::IDD, pParent) +{ + //{{AFX_DATA_INIT(VideoMode) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + pDirectDraw = pDraw; +} + + +void VideoMode::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(VideoMode) + DDX_Control(pDX, IDC_MODES, m_modes); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(VideoMode, CDialog) + //{{AFX_MSG_MAP(VideoMode) + ON_LBN_SELCHANGE(IDC_MODES, OnSelchangeModes) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_BN_CLICKED(ID_OK, OnOk) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// VideoMode message handlers + +void VideoMode::OnSelchangeModes() +{ + int item = m_modes.GetCurSel(); + + GetDlgItem(ID_OK)->EnableWindow(item != -1); +} + +void VideoMode::OnCancel() +{ + EndDialog(-1); +} + +void VideoMode::OnOk() +{ + int cur = m_modes.GetCurSel(); + + if(cur != -1) { + cur = m_modes.GetItemData(cur); + } + EndDialog(cur); +} + +BOOL VideoMode::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // check for available fullscreen modes + pDirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, m_modes.m_hWnd, + addVideoMode); + + GetDlgItem(ID_OK)->EnableWindow(FALSE); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +///////////////////////////////////////////////////////////////////////////// +// VideoDriverSelect dialog + + +VideoDriverSelect::VideoDriverSelect(CWnd* pParent /*=NULL*/) + : CDialog(VideoDriverSelect::IDD, pParent) +{ + //{{AFX_DATA_INIT(VideoDriverSelect) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void VideoDriverSelect::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(VideoDriverSelect) + DDX_Control(pDX, IDC_DRIVERS, m_drivers); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(VideoDriverSelect, CDialog) + //{{AFX_MSG_MAP(VideoDriverSelect) + ON_BN_CLICKED(ID_OK, OnOk) + ON_BN_CLICKED(ID_CANCEL, OnCancel) + ON_LBN_SELCHANGE(IDC_DRIVERS, OnSelchangeDrivers) + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// +// VideoDriverSelect message handlers + +void VideoDriverSelect::OnCancel() +{ + EndDialog(-1); +} + +void VideoDriverSelect::OnOk() +{ + EndDialog(m_drivers.GetCurSel()); +} + +BOOL VideoDriverSelect::OnInitDialog() +{ + CDialog::OnInitDialog(); + + for(int i = 0; i < gDriverCnt; i++) { + m_drivers.AddString(Drivers[i].szDescription); + } + + GetDlgItem(ID_OK)->EnableWindow(FALSE); + CenterWindow(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void VideoDriverSelect::OnSelchangeDrivers() +{ + GetDlgItem(ID_OK)->EnableWindow(m_drivers.GetCurSel() != -1); +} diff --git a/src/win32/VideoMode.h b/src/win32/VideoMode.h new file mode 100644 index 0000000..6b359f5 --- /dev/null +++ b/src/win32/VideoMode.h @@ -0,0 +1,102 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_) +#define AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// VideoMode.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// VideoMode dialog + +class VideoMode : public CDialog +{ + // Construction + public: + VideoMode(LPDIRECTDRAW7 pDraw,CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(VideoMode) + enum { IDD = IDD_MODES }; + CListBox m_modes; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(VideoMode) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(VideoMode) + afx_msg void OnSelchangeModes(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + LPDIRECTDRAW7 pDirectDraw; +}; + +///////////////////////////////////////////////////////////////////////////// +// VideoDriverSelect dialog + +class VideoDriverSelect : public CDialog +{ + // Construction + public: + VideoDriverSelect(CWnd* pParent = NULL); // standard constructor + + // Dialog Data + //{{AFX_DATA(VideoDriverSelect) + enum { IDD = IDD_DRIVERS }; + CListBox m_drivers; + //}}AFX_DATA + + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(VideoDriverSelect) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + // Implementation + protected: + + // Generated message map functions + //{{AFX_MSG(VideoDriverSelect) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + afx_msg void OnSelchangeDrivers(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; +#endif // !defined(AFX_VIDEOMODE_H__074B2426_32EA_4D69_9215_AB5E90F885D0__INCLUDED_) diff --git a/src/win32/VisualBoyAdvance.exe.manifest b/src/win32/VisualBoyAdvance.exe.manifest new file mode 100644 index 0000000..e09116c --- /dev/null +++ b/src/win32/VisualBoyAdvance.exe.manifest @@ -0,0 +1,23 @@ + + + +VisualBoyAdvance Emulator. + + + + + + + diff --git a/src/win32/WavWriter.cpp b/src/win32/WavWriter.cpp new file mode 100644 index 0000000..3759bfd --- /dev/null +++ b/src/win32/WavWriter.cpp @@ -0,0 +1,117 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// WavWriter.cpp: implementation of the WavWriter class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "vba.h" +#include "WavWriter.h" + +#include "../System.h" +#include "../Util.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +WavWriter::WavWriter() +{ + m_file = NULL; + m_len = 0; + m_posSize = 0; +} + +WavWriter::~WavWriter() +{ + if(m_file) + Close(); +} + +void WavWriter::Close() +{ + // calculate the total file length + u32 len = ftell(m_file)-8; + fseek(m_file, 4, SEEK_SET); + u8 data[4]; + utilPutDword(data, len); + fwrite(data, 1, 4, m_file); + // write out the size of the data section + fseek(m_file, m_posSize, SEEK_SET); + utilPutDword(data, m_len); + fwrite(data, 1, 4, m_file); + fclose(m_file); + m_file = NULL; +} + +bool WavWriter::Open(const char *name) +{ + if(m_file) + Close(); + m_file = fopen(name, "wb"); + + if(!m_file) + return false; + // RIFF header + u8 data[4] = { 'R', 'I', 'F', 'F' }; + fwrite(data, 1, 4, m_file); + utilPutDword(data, 0); + // write 0 for now. Will get filled during close + fwrite(data, 1, 4, m_file); + // write WAVE header + u8 data2[4] = { 'W', 'A', 'V', 'E' }; + fwrite(data2, 1, 4, m_file); + return true; +} + +void WavWriter::SetFormat(const WAVEFORMATEX *format) +{ + if(m_file == NULL) + return; + // write fmt header + u8 data[4] = { 'f', 'm', 't', ' ' }; + fwrite(data, 1, 4, m_file); + u32 value = sizeof(WAVEFORMATEX); + utilPutDword(data, value); + fwrite(data, 1, 4, m_file); + fwrite(format, 1, sizeof(WAVEFORMATEX), m_file); + // start data header + u8 data2[4] = { 'd', 'a', 't', 'a' }; + fwrite(data2, 1, 4, m_file); + + m_posSize = ftell(m_file); + // write 0 for data chunk size. Filled out during Close() + utilPutDword(data, 0); + fwrite(data, 1, 4, m_file); +} + +void WavWriter::AddSound(const u8 *data, int len) +{ + if(m_file == NULL) + return; + // write a block of sound data + fwrite(data, 1, len, m_file); + m_len += len; +} diff --git a/src/win32/WavWriter.h b/src/win32/WavWriter.h new file mode 100644 index 0000000..8e3c31b --- /dev/null +++ b/src/win32/WavWriter.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// WavWriter.h: interface for the WavWriter class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_) +#define AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +class WavWriter +{ + private: + FILE *m_file; + int m_len; + long m_posSize; + + public: + WavWriter(); + ~WavWriter(); + + bool Open(const char *name); + void SetFormat(const WAVEFORMATEX *format); + void AddSound(const u8 *data, int len); + + private: + void Close(); +}; + +#endif // !defined(AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_) diff --git a/src/win32/WinHelper.h b/src/win32/WinHelper.h new file mode 100644 index 0000000..66fb6b7 --- /dev/null +++ b/src/win32/WinHelper.h @@ -0,0 +1,232 @@ +/*---------------------------------------------------------------------- + Copyright (c) 1998 Gipsysoft. All Rights Reserved. + Please see the file "licence.txt" for licencing details. + File: WinHelper.h + Owner: russf@gipsysoft.com + Purpose: Windows helper functions, classes, structures and macros + that make life a little easier + These should all be zero impact classes etc. that is they + should *not* have a cpp file associated with them. + ----------------------------------------------------------------------*/ +#ifndef WINHELPER_H +#define WINHELPER_H + +//#ifndef DEBUGHLP_H +// #include +//#endif // DEBUGHLP_H + +#ifndef FASTCALL +#define FASTCALL +#endif // FASTCALL + +extern void AssertFailed(char *, int, char *); +extern void ApiFailure(char *, int, char *); + +#define R_VERIFY(a) R_ASSERT(a) +#define R_ASSERT(a) \ + do {\ + if(!(a)) {\ + AssertFailed(__FILE__, __LINE__, #a);\ + }\ + } while(0); + +#define VAPI(a) \ + do { \ + if(!(a)) {\ + ApiFailure(__FILE__, __LINE__, #a); \ + }\ + } while (0); + +#define ASSERT_VALID_HWND(a) ASSERT( ::IsWindow(a) ) + +namespace WinHelper +{ + + class CSize : public tagSIZE + // + // Wrapper for the SIZE structure + { + public: + inline CSize() {}; + inline explicit CSize( const SIZE &size ) { cx = size.cx; cy = size.cy; } + inline explicit CSize( long nSizeX, long nSizeY ) { cx = nSizeX; cy = nSizeY; } + inline void Set( long nSizeX, long nSizeY ) { cx = nSizeX; cy = nSizeY; } + inline operator LPSIZE() { return this; }; + + inline bool operator !=( const SIZE &size ) const { return cx != size.cx || cy != size.cy;} + inline CSize & operator =( const SIZE &size ) { cx = size.cx; cy = size.cy; return *this; } + inline void Empty() { cx = cy = 0; } + }; + + + class CRect : public tagRECT + // + // Wrapper for a RECT structure + { + public: + inline CRect() {} + // Initialisation constructor + inline explicit CRect( const RECT& rhs ) { Set( rhs.left, rhs.top, rhs.right, rhs.bottom );} + inline CRect(int xLeft, int yTop, int xRight, int yBottom) { Set( xLeft, yTop, xRight, yBottom ); } + // Get the width of the rectangle + inline int Width() const { return right - left; } + // Get the height of the rectangle + inline int Height() const { return bottom - top; } + // overloaded operator so you don't have to do &rc anymore + inline operator LPCRECT() const { return this; }; + inline operator LPRECT() { return this; }; + // Return the SIZE of the rectangle; + inline CSize Size() const { CSize s( Width(), Height() ); return s; } + // Return the top left of the rectangle + inline POINT TopLeft() const { POINT pt = { left, top }; return pt; } + // Return the bottom right of the rectangle + inline POINT BottomRight() const { POINT pt = { right, bottom }; return pt; } + // Set the rectangles left, top, right and bottom + inline void Set( int xLeft, int yTop, int xRight, int yBottom) { top = yTop; bottom = yBottom; right = xRight; left = xLeft; } + // Return true if the rectangle contains all zeros + inline bool IsEmpty() const { return left == 0 && right == 0 && top == 0 && bottom == 0 ? true : false; } + // Zero out our rectangle + inline void Empty() { left = right = top = bottom = 0; } + // Set the size of the rect but leave the top left position untouched. + inline void SetSize( const CSize &size ) { bottom = top + size.cy; right = left + size.cx; } + inline void SetSize( const SIZE &size ) { bottom = top + size.cy; right = left + size.cx; } + inline void SetSize( int cx, int cy ) { bottom = top + cy; right = left + cx; } + // Move the rectangle by an offset + inline void Offset( int cx, int cy ) + { + top+=cy; + bottom+=cy; + right+=cx; + left+=cx; + } + // Inflate the rectangle by the cx and cy, use negative to shrink the rectangle + inline void Inflate( int cx, int cy ) + { + top-=cy; + bottom+=cy; + right+=cx; + left-=cx; + } + // Assignment from a RECT + inline CRect &operator = ( const RECT&rhs ) + { + left = rhs.left; top = rhs.top; + right = rhs.right; bottom = rhs.bottom; + return *this; + } + + // Return true if the point passed is within the rectangle + inline bool PtInRect( const POINT &pt ) const { return ( pt.x >= left && pt.x < right && pt.y >=top && pt.y < bottom ); } + // Return true if the rectangle passed overlaps this rectangle + inline bool Intersect( const RECT &rc ) const { return ( rc.left < right && rc.right > left && rc.top < bottom && rc.bottom > top ); } + }; + + + class CPoint : public tagPOINT + // + // Wrapper for the POINT structure + { + public: + inline CPoint() {}; + inline CPoint( LPARAM lParam ) { x = LOWORD( lParam ); y = HIWORD(lParam); } + inline CPoint( int nX, int nY ) { x = nX; y = nY; } + inline CPoint( const POINT &pt ) { x = pt.x; y = pt.y; } + inline bool operator == ( const CPoint &rhs ) const { return x == rhs.x && y == rhs.y; } + inline bool operator != ( const CPoint &rhs ) const { return x != rhs.x || y != rhs.y; } + inline operator LPPOINT () { return this; } + }; + + + class CScrollInfo : public tagSCROLLINFO + { + public: + CScrollInfo( UINT fPassedMask ) { cbSize = sizeof( tagSCROLLINFO ); fMask = fPassedMask; } + }; + + + class CCriticalSection + // + // Simple crtical section handler/wrapper + { + public: + inline CCriticalSection() { ::InitializeCriticalSection(&m_sect); } + inline ~CCriticalSection() { ::DeleteCriticalSection(&m_sect); } + + // Blocking lock. + inline void Lock() { ::EnterCriticalSection(&m_sect); } + // Unlock + inline void Unlock() { ::LeaveCriticalSection(&m_sect); } + + class CLock + // + // Simple lock class for the critcal section + { + public: + inline CLock( CCriticalSection § ) : m_sect( sect ) { m_sect.Lock(); } + inline ~CLock() { m_sect.Unlock(); } + private: + CCriticalSection &m_sect; + + CLock(); + CLock( const CLock &); + CLock& operator =( const CLock &); + }; + + private: + CRITICAL_SECTION m_sect; + + CCriticalSection( const CCriticalSection & ); + CCriticalSection& operator =( const CCriticalSection & ); + }; + + +#define ZeroStructure( t ) ZeroMemory( &t, sizeof( t ) ) +#define countof( t ) (sizeof( (t) ) / sizeof( (t)[0] ) ) +#define UNREF(P) UNREFERENCED_PARAMETER(P) + + inline bool IsShiftPressed() + { + return GetKeyState(VK_SHIFT) & 0x8000 ? true : false; + } + + inline bool IsAltPressed() + { + return GetKeyState(VK_MENU) & 0x8000 ? true : false; + } + + inline bool IsControlPressed() + { + return GetKeyState(VK_CONTROL) & 0x8000 ? true : false; + } + + inline HICON LoadIcon16x16( HINSTANCE hInst, UINT uID ) + // + // Load a 16x16 icon from the same resource as the other size icons. + { + return reinterpret_cast( ::LoadImage( hInst, MAKEINTRESOURCE( uID ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ) ); + } + + + class CDeferWindowPos + // + // Wrapper for the Begin, Defer and End WindowPos functions. Nothing glamorous. + { + public: + inline CDeferWindowPos( const int nWindows = 1 ) : m_hdlDef( ::BeginDeferWindowPos( nWindows ) ) {} + inline ~CDeferWindowPos() { R_VERIFY( ::EndDeferWindowPos( m_hdlDef ) ); } + inline HDWP DeferWindowPos( HWND hWnd, HWND hWndInsertAfter , int x, int y, int cx, int cy, UINT uFlags ) + { + return ::DeferWindowPos( m_hdlDef, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags ); + } + inline HDWP DeferWindowPos( HWND hWnd, HWND hWndInsertAfter, const CRect &rc, UINT uFlags ) + { + return ::DeferWindowPos( m_hdlDef, hWnd, hWndInsertAfter, rc.left, rc.top, rc.Width(), rc.Height(), uFlags ); + } + + private: + HDWP m_hdlDef; + }; + +} // WinHelper + +#endif //WINHELPER_H diff --git a/src/win32/WinResUtil.cpp b/src/win32/WinResUtil.cpp new file mode 100644 index 0000000..968df8a --- /dev/null +++ b/src/win32/WinResUtil.cpp @@ -0,0 +1,109 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "stdafx.h" + +static HINSTANCE winResGetInstance(LPCTSTR resType, LPCTSTR resName) +{ + // TODO: make language DLL first + return AfxFindResourceHandle(resName, resType); +} + + +UCHAR *winResGetResource(LPCTSTR resType, LPCTSTR resName) +{ + HINSTANCE winResInstance = winResGetInstance(resType, resName); + + HRSRC hRsrc = FindResourceEx(winResInstance, resType, resName, 0); + + if(hRsrc != NULL) { + HGLOBAL hGlobal = LoadResource(winResInstance, hRsrc); + + if(hGlobal != NULL) { + UCHAR * b = (UCHAR *)LockResource(hGlobal); + + return b; + } + } + return NULL; +} + +HMENU winResLoadMenu(LPCTSTR menuName) +{ + UCHAR * b = winResGetResource(RT_MENU, menuName); + + if(b != NULL) { + HMENU menu = LoadMenuIndirect((CONST MENUTEMPLATE *)b); + + if(menu != NULL) + return menu; + } + + return LoadMenu(NULL, menuName); +} + +int winResDialogBox(LPCTSTR boxName, + HWND parent, + DLGPROC dlgProc, + LPARAM lParam) +{ + /* + UCHAR * b = winResGetResource(RT_DIALOG, boxName); + + if(b != NULL) { + + return DialogBoxIndirectParam(hInstance, + (LPCDLGTEMPLATE)b, + parent, + dlgProc, + lParam); + } + + return DialogBoxParam(hInstance, + boxName, + parent, + dlgProc, + lParam); + */ + return 0; +} + +int winResDialogBox(LPCTSTR boxName, + HWND parent, + DLGPROC dlgProc) +{ + return winResDialogBox(boxName, + parent, + dlgProc, + 0); +} + +CString winResLoadString(UINT id) +{ + int stId = id / 16 + 1; + HINSTANCE inst = winResGetInstance(RT_STRING, MAKEINTRESOURCE(stId)); + + CString res; + if(res.LoadString(id)) + return res; + + // TODO: handle case where string is only in the default English + res = ""; + + return res; +} diff --git a/src/win32/WinResUtil.h b/src/win32/WinResUtil.h new file mode 100644 index 0000000..8184c95 --- /dev/null +++ b/src/win32/WinResUtil.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +extern HMENU winResLoadMenu(LPCTSTR menuName); + +extern int winResDialogBox(LPCTSTR boxName, + HWND parent, + DLGPROC dlgProc); + +extern int winResDialogBox(LPCTSTR boxName, + HWND parent, + DLGPROC dlgProc, + LPARAM lParam); + +extern CString winResLoadString(UINT id); diff --git a/src/win32/ZoomControl.cpp b/src/win32/ZoomControl.cpp new file mode 100644 index 0000000..67509fc --- /dev/null +++ b/src/win32/ZoomControl.cpp @@ -0,0 +1,190 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// ZoomControl.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "ZoomControl.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool ZoomControl::isRegistered = false; + +///////////////////////////////////////////////////////////////////////////// +// ZoomControl + +ZoomControl::ZoomControl() +{ + ZeroMemory(colors, 3*64); + selected = -1; + registerClass(); +} + +ZoomControl::~ZoomControl() +{ +} + + +BEGIN_MESSAGE_MAP(ZoomControl, CWnd) + //{{AFX_MSG_MAP(ZoomControl) + ON_WM_PAINT() + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// ZoomControl message handlers + +void ZoomControl::registerClass() +{ + if(!isRegistered) { + WNDCLASS wc; + ZeroMemory(&wc, sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.hInstance = AfxGetInstanceHandle(); + wc.hIcon = NULL; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "VbaZoomControl"; + AfxRegisterClass(&wc); + isRegistered = true; + } +} + +void ZoomControl::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + RECT rect; + GetClientRect(&rect); + + int w = rect.right - rect.left; + int h = rect.bottom - rect.top; + + CDC memDC ; + memDC.CreateCompatibleDC(&dc); + CBitmap bitmap, *pOldBitmap; + bitmap.CreateCompatibleBitmap(&dc, w, h); + + pOldBitmap = memDC.SelectObject(&bitmap); + + int multX = w / 8; + int multY = h / 8; + + int i; + for(i = 0; i < 64; i++) { + CBrush b; + b.CreateSolidBrush(RGB(colors[i*3+2], colors[i*3+1], colors[i*3])); + + RECT r; + int x = i & 7; + int y = i / 8; + r.top = y*multY; + r.left = x*multX; + r.bottom = r.top + multY; + r.right = r.left + multX; + memDC.FillRect(&r, &b); + b.DeleteObject(); + } + + CPen pen; + pen.CreatePen(PS_SOLID, 1, RGB(192,192,192)); + CPen *old = (CPen *)memDC.SelectObject(&pen); + + for(i = 0; i < 8; i++) { + memDC.MoveTo(0, i * multY); + memDC.LineTo(w, i * multY); + memDC.MoveTo(i * multX, 0); + memDC.LineTo(i * multX, h); + } + + if(selected != -1) { + CPen pen2; + pen2.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); + CPen *old2 = (CPen*)memDC.SelectObject(&pen2); + + int startX = (selected & 7)*multX+1; + int startY = (selected / 8)*multY+1; + int endX = startX + multX-2; + int endY = startY + multY-2; + + memDC.MoveTo(startX, startY); + memDC.LineTo(endX, startY); + memDC.LineTo(endX, endY); + memDC.LineTo(startX, endY); + memDC.LineTo(startX, startY-1); + memDC.SelectObject(old2); + pen2.DeleteObject(); + } + memDC.SelectObject(old); + pen.DeleteObject(); + + dc.BitBlt(0,0,w,h, + &memDC,0,0, SRCCOPY); + + memDC.SelectObject(pOldBitmap); + bitmap.DeleteObject(); + memDC.DeleteDC(); +} + +void ZoomControl::OnLButtonDown(UINT nFlags, CPoint point) +{ + RECT rect; + GetClientRect(&rect); + + int height = rect.bottom - rect.top; + int width = rect.right - rect.left; + + int multX = width / 8; + int multY = height / 8; + + selected = point.x / multX + 8 * (point.y / multY); + + int c = point.x / multX + 8 * (point.y/multY); + u16 color = colors[c*3] << 7 | + colors[c*3+1] << 2 | + (colors[c*3+2] >> 3); + + GetParent()->PostMessage(WM_COLINFO, + color, + 0); + + Invalidate(); +} + +BOOL ZoomControl::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + +void ZoomControl::setColors(const u8 *c) +{ + memcpy(colors, c, 3*64); + selected = -1; + Invalidate(); +} diff --git a/src/win32/ZoomControl.h b/src/win32/ZoomControl.h new file mode 100644 index 0000000..d70b4c9 --- /dev/null +++ b/src/win32/ZoomControl.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_) +#define AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_ + +#include "..\System.h" // Added by ClassView +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ZoomControl.h : header file +// +#ifndef WM_COLINFO +#define WM_COLINFO WM_APP+100 +#endif + +///////////////////////////////////////////////////////////////////////////// +// ZoomControl window + +class ZoomControl : public CWnd +{ + // Construction + public: + ZoomControl(); + + // Attributes + public: + + // Operations + public: + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ZoomControl) + //}}AFX_VIRTUAL + + // Implementation + public: + void setColors(const u8 *c); + static bool isRegistered; + virtual ~ZoomControl(); + + // Generated message map functions + protected: + //{{AFX_MSG(ZoomControl) + afx_msg void OnPaint(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + int selected; + u8 colors[3*64]; + void registerClass(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_) diff --git a/src/win32/gbadvance.ico b/src/win32/gbadvance.ico new file mode 100644 index 0000000..aa35b5c Binary files /dev/null and b/src/win32/gbadvance.ico differ diff --git a/src/win32/resource.h b/src/win32/resource.h new file mode 100644 index 0000000..ac5ef39 --- /dev/null +++ b/src/win32/resource.h @@ -0,0 +1,908 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by vba.rc +// +#define IDS_UNSUPPORTED_VBA_SGM 1 +#define IDS_CANNOT_LOAD_SGM 2 +#define IDS_SAVE_GAME_NOT_USING_BIOS 3 +#define IDS_SAVE_GAME_USING_BIOS 4 +#define IDS_UNSUPPORTED_SAVE_TYPE 5 +#define IDS_CANNOT_OPEN_FILE 6 +#define IDS_BAD_ZIP_FILE 7 +#define IDS_NO_IMAGE_ON_ZIP 8 +#define IDS_ERROR_OPENING_IMAGE 9 +#define IDS_ERROR_READING_IMAGE 10 +#define IDS_UNSUPPORTED_BIOS_FUNCTION 11 +#define IDS_INVALID_BIOS_FILE_SIZE 12 +#define IDS_INVALID_CHEAT_CODE 13 +#define IDS_UNKNOWN_ARM_OPCDOE 14 +#define IDS_UNKNOWN_THUMB_OPCODE 15 +#define IDS_ERROR_CREATING_FILE 16 +#define IDS_FAILED_TO_READ_SGM 17 +#define IDS_FAILED_TO_READ_RTC 18 +#define IDS_UNSUPPORTED_VB_SGM 19 +#define IDS_CANNOT_LOAD_SGM_FOR 20 +#define IDS_ERROR_OPENING_IMAGE_FROM 21 +#define IDS_ERROR_READING_IMAGE_FROM 22 +#define IDS_UNSUPPORTED_ROM_SIZE 23 +#define IDS_UNSUPPORTED_RAM_SIZE 24 +#define IDS_UNKNOWN_CARTRIDGE_TYPE 25 +#define IDS_MAXIMUM_NUMBER_OF_CHEATS 26 +#define IDS_INVALID_GAMESHARK_CODE 27 +#define IDS_INVALID_GAMEGENIE_CODE 28 +#define IDS_INVALID_CHEAT_TO_REMOVE 29 +#define IDS_INVALID_CHEAT_CODE_ADDRESS 30 +#define IDS_UNSUPPORTED_CHEAT_LIST_VERSION 31 +#define IDS_UNSUPPORTED_CHEAT_LIST_TYPE 32 +#define IDS_INVALID_GSA_CODE 33 +#define IDS_CANNOT_IMPORT_SNAPSHOT_FOR 34 +#define IDS_UNSUPPORTED_SNAPSHOT_FILE 35 +#define IDS_UNSUPPORTED_ARM_MODE 36 +#define IDS_UNSUPPORTED_CODE_FILE 37 +#define IDS_GSA_CODE_WARNING 38 +#define IDS_INVALID_CBA_CODE 39 +#define IDS_CBA_CODE_WARNING 40 +#define IDS_OUT_OF_MEMORY 41 +#define IDI_ICON 101 +#define IDD_REGISTERS 102 +#define IDD_DEBUG 103 +#define IDR_MENU 104 +#define IDD_ABOUT 105 +#define IDR_ACCELERATOR 106 +#define IDD_CHEATS 107 +#define IDD_ADD_CHEAT 108 +#define IDD_DIRECTORIES 109 +#define IDD_CONFIG 110 +#define IDD_GS 111 +#define IDD_GG 112 +#define IDD_CHEAT_LIST 113 +#define IDD_ASSOCIATIONS 114 +#define IDR_GB_PRINTER 115 +#define IDD_GBA_ROM_INFO 116 +#define IDD_GB_ROM_INFO 117 +#define IDD_GB_CHEAT_LIST 118 +#define IDD_ADD_CHEAT_DLG 119 +#define IDD_GB_PRINTER 120 +#define IDD_MOTION_CONFIG 121 +#define IDD_LANG_SELECT 122 +#define IDD_CODE_SELECT 123 +#define IDD_OPENDLG 124 +#define IDD_MAP_VIEW 126 +#define IDD_PALETTE_VIEW 127 +#define IDD_MEM_VIEWER 128 +#define IDD_OAM_VIEW 130 +#define IDD_ACCEL_EDITOR 131 +#define IDD_TILE_VIEWER 132 +#define IDD_GB_COLORS 133 +#define IDD_DISASSEMBLE 134 +#define IDD_GDB_PORT 135 +#define IDD_GDB_WAITING 136 +#define IDD_LOGGING 137 +#define IDD_EXPORT_SPS 138 +#define IDD_ADDR_SIZE 139 +#define IDD_MODES 140 +#define IDD_DRIVERS 142 +#define IDD_THROTTLE 143 +#define IDD_GB_DISASSEMBLE 144 +#define IDD_GB_OAM_VIEW 145 +#define IDD_GB_TILE_VIEWER 146 +#define IDD_GB_MAP_VIEW 147 +#define IDD_GB_PALETTE_VIEW 148 +#define IDD_MODE_CONFIRM 149 +#define IDD_REWIND_INTERVAL 150 +#define IDD_IO_VIEWER 151 +#define IDD_MAX_SCALE 154 +#define IDD_BUG_REPORT 155 +#define IDD_MOVIECREATE 156 +#define IDD_MOVIEOPEN 157 +#define IDD_TEXTCONFIG 158 +#define IDC_R0 1000 +#define IDC_EDIT_UP 1000 +#define IDC_R1 1001 +#define IDC_EDIT_DOWN 1001 +#define IDC_R2 1002 +#define IDC_EDIT_LEFT 1002 +#define IDC_R3 1003 +#define IDC_EDIT_RIGHT 1003 +#define IDC_R4 1004 +#define IDC_EDIT_BUTTON_A 1004 +#define IDC_R5 1005 +#define IDC_EDIT_BUTTON_B 1005 +#define IDC_R6 1006 +#define IDC_EDIT_BUTTON_SELECT 1006 +#define IDC_R7 1007 +#define IDC_EDIT_BUTTON_START 1007 +#define IDC_R8 1008 +#define ID_OK 1008 +#define IDC_R9 1009 +#define ID_CANCEL 1009 +#define ID_SAVE 1009 +#define IDC_R10 1010 +#define IDC_EDIT_SPEED 1010 +#define IDC_R11 1011 +#define IDC_EDIT_CAPTURE 1011 +#define IDC_R12 1012 +#define IDC_EDIT_BUTTON_L 1012 +#define IDC_R13 1013 +#define IDC_EDIT_BUTTON_GS 1013 +#define IDC_R14 1014 +#define IDC_EDIT_BUTTON_R 1014 +#define IDC_R15 1015 +#define IDC_R16 1016 +#define IDC_R17 1017 +#define IDC_N_FLAG 1018 +#define IDC_ROM_DIR 1018 +#define IDC_Z_FLAG 1019 +#define IDC_NEXT 1019 +#define IDC_BATTERY_DIR 1019 +#define IDC_C_FLAG 1020 +#define IDC_CONTINUE 1020 +#define IDC_SAVE_DIR 1020 +#define IDC_V_FLAG 1021 +#define IDC_CAPTURE_DIR 1021 +#define IDC_CHEAT_LIST 1021 +#define IDC_IRQ 1022 +#define IDC_ROM_PATH 1022 +#define IDC_START 1022 +#define IDC_T_FLAG 1023 +#define IDC_BATTERY_PATH 1023 +#define IDC_SEARCH 1023 +#define IDS_DIRECTX_7_REQUIRED 1024 +#define IDC_SAVE_PATH 1024 +#define IDC_ADD_CHEAT 1024 +#define IDC_M4 1025 +#define IDC_CAPTURE_PATH 1025 +#define IDC_OLD_VALUE 1025 +#define IDC_ADD_GS_CHEAT 1025 +#define IDS_DISABLING_VIDEO_MEMORY 1025 +#define IDC_ADD_GAMESHARK 1025 +#define IDC_M3 1026 +#define IDC_SPECIFIC_VALUE 1026 +#define IDS_SETTING_WILL_BE_EFFECTIVE 1026 +#define IDC_GBROM_DIR 1026 +#define IDC_MOVIES_DIR 1026 +#define IDC_M2 1027 +#define IDS_DISABLING_EMULATION_ONLY 1027 +#define IDC_GBROM_PATH 1027 +#define IDC_MOVIES_PATH 1027 +#define IDC_M1 1028 +#define IDC_SIZE_8 1028 +#define IDS_FAILED_TO_OPEN_FILE 1028 +#define IDC_ROM_DIR_RESET 1028 +#define IDC_M0 1029 +#define IDC_SIZE_16 1029 +#define IDS_FAILED_TO_READ_ZIP_DIR 1029 +#define IDC_GBROM_DIR_RESET 1029 +#define IDC_MOVIES_DIR_RESET 1029 +#define IDC_SIZE_32 1030 +#define IDS_UNSUPPORTED_FILE_TYPE 1030 +#define IDC_BATTERY_DIR_RESET 1030 +#define IDC_EQ 1031 +#define IDS_CANNOT_CREATE_DIRECTSOUND 1031 +#define IDC_SAVE_DIR_RESET 1031 +#define IDC_NE 1032 +#define IDS_CANNOT_SETCOOPERATIVELEVEL 1032 +#define IDC_CAPTURE_DIR_RESET 1032 +#define IDC_LT 1033 +#define IDS_CANNOT_CREATESOUNDBUFFER 1033 +#define IDC_LE 1034 +#define IDS_CANNOT_SETFORMAT_PRIMARY 1034 +#define IDC_GT 1035 +#define IDS_CANNOT_CREATESOUNDBUFFER_SEC 1035 +#define IDC_GE 1036 +#define IDS_CANNOT_PLAY_PRIMARY 1036 +#define IDC_SIGNED 1037 +#define IDS_SEARCH_PRODUCED_TOO_MANY 1037 +#define IDC_UNSIGNED 1038 +#define IDS_NUMBER_CANNOT_BE_EMPTY 1038 +#define IDS_INVALID_ADDRESS 1039 +#define IDC_HEXADECIMAL 1040 +#define IDS_MISALIGNED_HALFWORD 1040 +#define IDC_VALUE 1041 +#define IDS_MISALIGNED_WORD 1041 +#define IDC_ADDRESS 1042 +#define IDS_VALUE_CANNOT_BE_EMPTY 1042 +#define IDS_ERROR_ON_STARTDOC 1043 +#define IDC_R 1043 +#define IDS_ERROR_ON_STARTPAGE 1044 +#define IDC_G 1044 +#define IDS_ERROR_PRINTING_ON_STRETCH 1045 +#define IDC_B 1045 +#define IDC_UPDATE 1046 +#define IDS_ERROR_ON_ENDPAGE 1046 +#define IDC_TILE_NUM 1046 +#define IDC_GGDESC 1047 +#define IDS_ERROR_ON_ENDDOC 1047 +#define IDC_FLIP 1047 +#define IDC_GGCODE 1048 +#define IDS_ERROR 1048 +#define IDC_PALETTE_NUM 1048 +#define IDC_GGADD 1049 +#define IDS_JOY_LEFT 1049 +#define IDC_GGDEL 1050 +#define IDS_JOY_RIGHT 1050 +#define IDC_GGLIST 1051 +#define IDS_JOY_UP 1051 +#define IDC_GGRES 1052 +#define IDS_JOY_DOWN 1052 +#define IDC_GGQUIT 1053 +#define IDS_JOY_BUTTON 1053 +#define IDC_GSDESC 1054 +#define IDS_SELECT_ROM_DIR 1054 +#define IDC_GSCODE 1055 +#define IDS_SELECT_BATTERY_DIR 1055 +#define IDC_GSADD 1056 +#define IDS_SELECT_SAVE_DIR 1056 +#define IDC_GSDEL 1057 +#define IDS_SELECT_CAPTURE_DIR 1057 +#define IDC_GSLIST 1058 +#define IDS_SELECT_BIOS_FILE 1058 +#define IDC_GSRES 1059 +#define IDS_RESET 1059 +#define IDC_GSQUIT 1060 +#define IDS_AUTOFIRE_A_DISABLED 1060 +#define IDC_FREEZE 1061 +#define IDS_AUTOFIRE_A 1061 +#define IDS_AUTOFIRE_B_DISABLED 1062 +#define IDS_AUTOFIRE_B 1063 +#define IDS_AUTOFIRE_L_DISABLED 1064 +#define IDS_AUTOFIRE_L 1065 +#define IDS_AUTOFIRE_R_DISABLED 1066 +#define IDC_REMOVE 1067 +#define IDS_AUTOFIRE_R 1067 +#define IDC_REMOVE_ALL 1068 +#define IDS_SELECT_ROM 1068 +#define IDS_SELECT_SAVE_GAME_NAME 1069 +#define IDC_ENABLE 1070 +#define IDS_LOADED_STATE 1070 +#define IDS_LOADED_STATE_N 1071 +#define IDS_WROTE_STATE 1072 +#define IDS_WROTE_STATE_N 1073 +#define IDC_RESTORE 1074 +#define IDS_LOADED_BATTERY 1074 +#define IDC_GBA 1075 +#define IDS_SELECT_CAPTURE_NAME 1075 +#define IDC_AGB 1076 +#define IDS_SCREEN_CAPTURE 1076 +#define IDC_BIN 1077 +#define IDS_ADDRESS 1077 +#define IDC_GB 1078 +#define IDS_OLD_VALUE 1078 +#define IDC_SGB 1079 +#define IDC_ROM_TITLE 1079 +#define IDS_NEW_VALUE 1079 +#define IDC_CGB 1080 +#define IDC_ROM_GAME_CODE 1080 +#define IDS_ADD_CHEAT_CODE 1080 +#define IDC_GBC 1081 +#define IDC_ROM_MAKER_CODE 1081 +#define IDS_CODE 1081 +#define IDC_ROM_UNIT_CODE 1082 +#define IDS_DESCRIPTION 1082 +#define IDC_ROM_DEVICE_TYPE 1083 +#define IDS_STATUS 1083 +#define IDC_ROM_VERSION 1084 +#define IDS_ADD_GG_CODE 1084 +#define IDC_ROM_CRC 1085 +#define IDS_ADD_GS_CODE 1085 +#define IDC_ROM_COLOR 1086 +#define IDC_CODE 1086 +#define IDS_POCKET_PRINTER 1086 +#define IDC_ROM_MAKER_NAME 1086 +#define IDC_ROM_SIZE 1087 +#define IDC_DESC 1087 +#define IDS_UNKNOWN 1087 +#define IDC_ROM_RAM_SIZE 1088 +#define IDC_ADD_GG_CHEAT 1088 +#define IDS_NONE 1088 +#define IDC_ROM_DEST_CODE 1089 +#define IDC_GB_PRINTER 1089 +#define IDS_FAILED_TO_LOAD_LIBRARY 1089 +#define IDC_ROM_LIC_CODE 1090 +#define IDC_1X 1090 +#define IDS_FAILED_TO_GET_LOCINFO 1090 +#define IDC_EDIT_AUTHOR 1090 +#define IDC_ROM_CHECKSUM 1091 +#define IDC_2X 1091 +#define IDS_SELECT_CHEAT_LIST_NAME 1091 +#define IDC_EDIT_DESCRIPTION 1091 +#define IDC_3X 1092 +#define IDS_FILTER_BIOS 1092 +#define IDC_4X 1093 +#define IDS_FILTER_ROM 1093 +#define IDC_ROM_MAKER_NAME2 1093 +#define ID_PRINT 1094 +#define IDS_FILTER_SGM 1094 +#define IDC_ADD_GSA 1095 +#define IDC_ADD_CODE 1095 +#define IDS_FILTER_CHEAT_LIST 1095 +#define IDC_TRANSLATION_BY 1096 +#define IDS_FILTER_PNG 1096 +#define IDC_LANG_STRING 1097 +#define IDS_LOADED_CHEATS 1097 +#define IDC_LANG_NAME 1098 +#define IDS_ERROR_DISP_COLOR 1098 +#define IDS_ADD_GSA_CODE 1099 +#define IDC_GAME_LIST 1099 +#define IDS_FILTER_SPS 1100 +#define IDS_SELECT_SNAPSHOT_FILE 1101 +#define IDC_ADD_CODEBREAKER 1101 +#define IDS_FILTER_SAV 1102 +#define IDS_SELECT_BATTERY_FILE 1103 +#define IDS_FILTER_GBS 1104 +#define IDS_FILTER_GCF 1105 +#define IDS_SELECT_CODE_FILE 1106 +#define IDS_SAVE_WILL_BE_LOST 1107 +#define IDS_CONFIRM_ACTION 1108 +#define IDS_CODES_WILL_BE_LOST 1109 +#define IDS_FILTER_SPC 1110 +#define IDS_ADD_CBA_CODE 1111 +#define IDS_FILTER_WAV 1112 +#define IDS_SELECT_WAV_NAME 1113 +#define IDC_FRAME_0 1113 +#define IDS_FILTER_GBROM 1114 +#define IDC_FRAME_1 1114 +#define IDC_BG0 1115 +#define IDS_FILTER_PAL 1115 +#define IDC_BG1 1116 +#define IDS_SELECT_PALETTE_NAME 1116 +#define IDC_BG2 1117 +#define IDS_SEARCH_PRODUCED_NO_RESULTS 1117 +#define IDC_BG3 1118 +#define IDS_ERROR_BINDING 1118 +#define IDS_ERROR_LISTENING 1119 +#define IDS_ERROR_CREATING_SOCKET 1120 +#define IDS_ACK_NOT_RECEIVED 1121 +#define IDS_ERROR_NOT_GBA_IMAGE 1122 +#define IDS_EEPROM_NOT_SUPPORTED 1123 +#define IDC_MAP_VIEW 1124 +#define IDS_FILTER_DUMP 1124 +#define IDC_PALETTE_VIEW 1125 +#define IDS_SELECT_DUMP_FILE 1125 +#define IDC_PALETTE_VIEW_OBJ 1126 +#define IDC_REFRESH 1126 +#define IDS_FILTER_AVI 1126 +#define IDC_SAVE 1127 +#define IDC_GOPC 1127 +#define IDS_SELECT_AVI_NAME 1127 +#define IDC_APPLY 1127 +#define IDS_INVALID_THROTTLE_VALUE 1128 +#define IDC_REFRESH2 1129 +#define IDS_FILTER_INI 1129 +#define IDS_SELECT_SKIN_FILE 1130 +#define IDC_CLOSE 1131 +#define IDS_FILTER_VMV 1131 +#define IDS_FILTER_MOVIE 1131 +#define IDS_SELECT_MOVIE_NAME 1132 +#define IDS_BUG_REPORT 1133 +#define IDS_UNSUPPORTED_MOVIE_VERSION 1134 +#define IDS_END_OF_MOVIE 1135 +#define IDC_COLOR 1136 +#define IDS_INVALID_INTERVAL_VALUE 1136 +#define IDC_SAVE_BG 1137 +#define IDS_REGISTRY 1137 +#define IDC_SAVE_OBJ 1138 +#define IDC_MAP_VIEW_ZOOM 1138 +#define IDS_MOVIE_PLAY 1138 +#define IDS_AUTOFIRE_DISABLED 1139 +#define IDC_VIEWER 1140 +#define IDS_AUTOFIRE_ALREADY_DISABLED 1140 +#define IDC_ADDRESSES 1141 +#define IDS_AUTOFIRE_START_DISABLED 1141 +#define IDS_AUTOFIRE_START 1142 +#define IDC_GO 1143 +#define IDS_AUTOFIRE_SELECT_DISABLED 1143 +#define IDC_8_BIT 1144 +#define IDS_AUTOFIRE_SELECT 1144 +#define IDC_16_BIT 1145 +#define IDS_AUTOFIRE_UP_DISABLED 1145 +#define IDC_32_BIT 1146 +#define IDS_AUTOFIRE_UP 1146 +#define IDC_OAM_VIEW 1147 +#define IDS_AUTOFIRE_DOWN_DISABLED 1147 +#define IDC_OAM_VIEW_ZOOM 1148 +#define IDS_AUTOFIRE_DOWN 1148 +#define IDS_AUTOFIRE_LEFT_DISABLED 1149 +#define IDC_SPRITE 1150 +#define IDS_AUTOFIRE_LEFT 1150 +#define IDC_POS 1151 +#define IDS_AUTOFIRE_RIGHT_DISABLED 1151 +#define IDC_MODE 1152 +#define IDS_AUTOFIRE_RIGHT 1152 +#define IDC_COLORS 1153 +#define IDC_MAPBASE 1153 +#define IDS_RERECORDED_STATE_N 1153 +#define IDC_PALETTE 1154 +#define IDC_CHARBASE 1154 +#define IDS_REPLAYED_STATE_N 1154 +#define IDC_TILE 1155 +#define IDC_DIM 1155 +#define IDC_PRIO 1156 +#define IDC_NUMCOLORS 1156 +#define IDC_SCROLLBAR 1157 +#define IDC_PRIORITY 1157 +#define IDC_MOSAIC 1158 +#define IDC_SIZE2 1159 +#define IDC_OVERFLOW 1159 +#define IDC_ROT 1160 +#define IDC_FLAGS 1161 +#define IDC_COMMANDS 1162 +#define IDC_BANK 1162 +#define IDC_CURRENTS 1163 +#define IDC_ASSIGN 1164 +#define IDC_RESET 1165 +#define IDC_EDIT_KEY 1166 +#define IDC_ALREADY_AFFECTED 1167 +#define IDC_TILE_VIEW 1168 +#define IDC_16_COLORS 1169 +#define IDC_256_COLORS 1170 +#define IDC_CHARBASE_0 1173 +#define IDC_CHARBASE_1 1174 +#define IDC_CHARBASE_2 1175 +#define IDC_CHARBASE_3 1176 +#define IDC_PALETTE_SLIDER 1177 +#define IDC_CHARBASE_4 1178 +#define IDC_COLOR_BG0 1178 +#define IDC_COLOR_BG1 1179 +#define IDC_URL 1179 +#define IDC_COLOR_BG2 1180 +#define IDC_STRETCH 1180 +#define IDC_COLOR_BG3 1181 +#define IDC_COLOR_OB0 1182 +#define IDC_COLOR_OB1 1183 +#define IDC_COLOR_OB2 1184 +#define IDC_COLOR_OB3 1185 +#define IDC_TRANSLATOR_URL 1186 +#define IDC_STATIC1 1187 +#define IDC_STATIC2 1188 +#define IDC_STATIC3 1189 +#define IDC_STATIC4 1190 +#define IDC_DEFAULT 1191 +#define IDC_USER1 1192 +#define IDC_USER2 1193 +#define IDC_DISASSEMBLE 1196 +#define IDC_AUTOMATIC 1199 +#define IDC_ARM 1200 +#define IDC_THUMB 1201 +#define IDC_RECNOW 1201 +#define IDC_RECRESET 1202 +#define IDC_JOYPAD1 1203 +#define IDC_RECSTART 1203 +#define IDC_REC_NOBIOS 1204 +#define IDC_AUTO_UPDATE 1204 +#define IDC_JOYPAD2 1204 +#define IDC_REC_EMUBIOS 1205 +#define IDC_JOYPAD3 1205 +#define IDC_REC_GBABIOS 1206 +#define IDC_JOYPAD4 1206 +#define IDC_REC_GBABIOSINTRO 1207 +#define IDC_MOVIE_FILENAME 1208 +#define IDC_N 1210 +#define IDC_LABEL_DATE 1210 +#define IDC_Z 1211 +#define IDC_LABEL_LENGTH 1211 +#define IDC_C 1212 +#define IDC_LABEL_FRAMES 1212 +#define IDC_V 1213 +#define IDC_LABEL_RERECORD 1213 +#define IDC_F 1214 +#define IDC_LABEL_FROM 1214 +#define IDC_I 1215 +#define IDC_T 1216 +#define IDC_LABEL_WARNING1 1216 +#define IDC_PORT 1217 +#define IDC_LABEL_WARNING2 1217 +#define IDC_VSCROLL 1218 +#define IDC_LABEL_FROM2 1218 +#define IDC_VERSION 1219 +#define IDC_VERBOSE_SWI 1223 +#define IDC_VERBOSE_UNALIGNED_ACCESS 1224 +#define IDC_VERBOSE_ILLEGAL_WRITE 1225 +#define IDC_VERBOSE_ILLEGAL_READ 1226 +#define IDC_LOG 1227 +#define IDC_CLEAR 1228 +#define IDC_VERBOSE_DMA0 1229 +#define IDC_VERBOSE_DMA1 1230 +#define IDC_TILE_NUMBER 1230 +#define IDC_VERBOSE_DMA2 1231 +#define IDC_XY 1231 +#define IDC_VERBOSE_DMA3 1232 +#define IDC_VERBOSE_UNDEFINED 1233 +#define IDC_TITLE 1234 +#define IDC_VERBOSE_AGBPRINT 1234 +#define IDC_CURRENT_ADDRESS 1235 +#define IDC_NOTES 1236 +#define IDC_CURRENT_ADDRESS_LABEL 1236 +#define IDC_LOAD 1238 +#define IDC_SIZE_CONTROL 1240 +#define IDC_MODES 1240 +#define IDC_DRIVERS 1241 +#define IDC_THROTTLE 1242 +#define IDC_READONLY 1242 +#define IDC_H 1243 +#define IDC_OAP 1244 +#define IDC_BANK_0 1245 +#define IDC_BANK_1 1246 +#define IDC_TIMER 1247 +#define IDC_INTERVAL 1248 +#define IDC_REWINDSLOTS 1249 +#define IDC_BIT_0 1250 +#define IDC_BIT_1 1251 +#define IDC_PREDEFINED 1251 +#define IDC_BIT_2 1252 +#define IDC_BUG_REPORT 1252 +#define IDC_BIT_3 1253 +#define IDC_COPY 1253 +#define IDC_BIT_4 1254 +#define IDC_BROWSE 1254 +#define IDC_BIT_5 1255 +#define IDC_COMBO1 1255 +#define IDC_MOVIE_REFRESH 1255 +#define IDC_BIT_6 1256 +#define IDC_REC_GBA 1257 +#define IDC_BIT_7 1257 +#define IDC_REC_GBC 1258 +#define IDC_BIT_8 1258 +#define IDC_REC_SGB 1259 +#define IDC_BIT_9 1259 +#define IDC_REC_SGB2 1260 +#define IDC_BIT_10 1260 +#define IDC_REC_GB 1260 +#define IDC_BIT_11 1261 +#define IDC_RADIO1 1261 +#define IDC_BIT_12 1262 +#define IDC_EDIT_PAUSEFRAME 1262 +#define IDC_BIT_13 1263 +#define IDC_CHECK_PAUSEFRAME 1263 +#define IDC_BIT_14 1264 +#define IDC_SLIDER1 1264 +#define IDC_BIT_15 1265 +#define IDC_CHECK_HIDEBORDER 1265 +#define IDC_RADIO_WHITE 1266 +#define IDC_RADIO_RED 1267 +#define IDC_RADIO_YELLOW 1268 +#define IDC_RADIO_GREEN 1269 +#define IDC_RADIO_CYAN 1270 +#define IDC_RADIO_BLUE 1271 +#define IDC_RADIO_MAGENTA 1272 +#define IDC_RADIO_BLACK 1273 +#define IDC_CHECK_OUTLINED 1274 +#define IDC_CHECK_TRANSPARENT 1275 +#define IDC_RADIO_PREFILTER 1276 +#define IDC_RADIO_POSTFILTER 1277 +#define IDC_RADIO_POSTRENDER 1278 +#define IDC_COMMANDS_HIDDEN 1279 +#define IDC_DECIMALDISPLAY 1281 +#define IDC_DECIMAL_DISPLAY 1281 +#define IDC_CHEATREFRESHBUTTON 1283 +#define IDC_CANCEL 1284 +#define ID_HELP_ABOUT 40001 +#define ID_FILE_EXIT 40002 +#define ID_OPTIONS_VIDEO_FRAMESKIP_0 40003 +#define ID_OPTIONS_VIDEO_FRAMESKIP_1 40004 +#define ID_OPTIONS_VIDEO_FRAMESKIP_2 40005 +#define ID_OPTIONS_VIDEO_FRAMESKIP_3 40006 +#define ID_OPTIONS_VIDEO_FRAMESKIP_4 40007 +#define ID_OPTIONS_VIDEO_FRAMESKIP_5 40008 +#define ID_OPTIONS_VIDEO_VSYNC 40009 +#define ID_OPTIONS_VIDEO_X1 40010 +#define ID_OPTIONS_VIDEO_X2 40011 +#define ID_OPTIONS_VIDEO_X3 40012 +#define ID_OPTIONS_VIDEO_X4 40013 +#define ID_FILE_PAUSE 40014 +#define ID_OPTIONS_EMULATOR_DIRECTORIES 40015 +#define ID_OPTIONS_JOYPAD 40016 +#define ID_OPTIONS_EMULATOR_SYNCHRONIZE 40017 +#define ID_FILE_RESET 40018 +#define ID_FILE_LOAD 40019 +#define ID_OPTIONS_SOUND_DIRECTSOUNDA 40020 +#define ID_OPTIONS_SOUND_DIRECTSOUNDB 40021 +#define ID_OPTIONS_SOUND_OFF 40022 +#define ID_OPTIONS_SOUND_MUTE 40023 +#define ID_OPTIONS_SOUND_ON 40024 +#define ID_OPTIONS_SOUND_CHANNEL1 40025 +#define ID_OPTIONS_SOUND_CHANNEL2 40026 +#define ID_OPTIONS_SOUND_CHANNEL3 40027 +#define ID_OPTIONS_SOUND_CHANNEL4 40028 +#define ID_OPTIONS_EMULATOR_USEBIOSFILE 40029 +#define ID_OPTIONS_EMULATOR_SELECTBIOSFILE 40030 +#define ID_CHEATS_SEARCHFORCHEATS 40031 +#define ID_CHEATS_ADDCHEAT 40032 +#define ID_OPTIONS_VIDEO_DISABLESFX 40033 +#define ID_OPTIONS_GAMEBOY_BORDER 40034 +#define ID_FILE_SAVEGAME_SLOT1 40035 +#define ID_FILE_SAVEGAME_SLOT2 40036 +#define ID_FILE_SAVEGAME_SLOT3 40037 +#define ID_FILE_SAVEGAME_SLOT4 40038 +#define ID_FILE_SAVEGAME_SLOT5 40039 +#define ID_FILE_SAVEGAME_SLOT6 40040 +#define ID_FILE_SAVEGAME_SLOT7 40041 +#define ID_FILE_SAVEGAME_SLOT8 40042 +#define ID_FILE_SAVEGAME_SLOT9 40043 +#define ID_FILE_SAVEGAME_SLOT10 40044 +#define ID_FILE_LOADGAME_SLOT1 40045 +#define ID_FILE_LOADGAME_SLOT2 40046 +#define ID_FILE_LOADGAME_SLOT3 40047 +#define ID_FILE_LOADGAME_SLOT4 40048 +#define ID_FILE_LOADGAME_SLOT5 40049 +#define ID_FILE_LOADGAME_SLOT6 40050 +#define ID_FILE_LOADGAME_SLOT7 40051 +#define ID_FILE_LOADGAME_SLOT8 40052 +#define ID_FILE_LOADGAME_SLOT9 40053 +#define ID_FILE_LOADGAME_SLOT10 40054 +#define ID_OPTIONS_GAMEBOY_AUTOMATIC 40057 +#define ID_OPTIONS_GAMEBOY_CGB 40058 +#define ID_OPTIONS_GAMEBOY_GBA 40059 +#define ID_OPTIONS_GAMEBOY_SGB 40060 +#define ID_OPTIONS_GAMEBOY_GB 40062 +#define ID_OPTIONS_GAMEBOY_REALCOLORS 40063 +#define ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS 40064 +#define ID_CHEATS_GAMEBOY 40065 +#define ID_OPTIONS_SOUND_11KHZ 40067 +#define ID_OPTIONS_SOUND_22KHZ 40068 +#define ID_OPTIONS_SOUND_44KHZ 40069 +#define ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY 40070 +#define ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY 40071 +#define ID_OPTIONS_PRIORITY_HIGHEST 40072 +#define ID_OPTIONS_PRIORITY_ABOVENORMAL 40073 +#define ID_OPTIONS_PRIORITY_NORMAL 40074 +#define ID_OPTIONS_PRIORITY_BELOWNORMAL 40075 +#define ID_OPTIONS_VIDEO_FULLSCREEN320X240 40076 +#define ID_OPTIONS_VIDEO_FULLSCREEN640X480 40077 +#define ID_OPTIONS_FILTER_NORMAL 40078 +#define ID_OPTIONS_FILTER_2XSAI 40079 +#define ID_OPTIONS_FILTER_SUPER2XSAI 40081 +#define ID_OPTIONS_FILTER_SUPEREAGLE 40082 +#define ID_OPTIONS_FILTER_TVMODE 40083 +#define ID_CHEATS_CHEATLIST 40084 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_A_OLD 40085 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_B_OLD 40086 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_L_OLD 40087 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_R_OLD 40088 +#define ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT 40089 +#define ID_OPTIONS_EMULATOR_ASSOCIATE 40091 +#define ID_OPTIONS_FILTER_DISABLEMMX 40093 +#define ID_OPTIONS_1X 40096 +#define ID_OPTIONS_2X 40097 +#define ID_OPTIONS_3X 40098 +#define ID_OPTIONS_4X 40099 +#define ID_FILE_ROMINFORMATION 40100 +#define ID_CHEATS_ADDCHEATCODE 40101 +#define ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES 40102 +#define ID_OPTIONS_JOYPAD_MOTIONCONFIGURE 40103 +#define ID_FILE_SCREENCAPTURE 40104 +#define ID_OPTIONS_LANGUAGE_SYSTEM 40105 +#define ID_OPTIONS_LANGUAGE_ENGLISH 40106 +#define ID_OPTIONS_LANGUAGE_OTHER 40107 +#define ID_OPTIONS_GAMEBOY_PRINTER 40108 +#define ID_FILE_RECENT_RESET 40109 +#define ID_CHEATS_SAVECHEATLIST 40110 +#define ID_CHEATS_LOADCHEATLIST 40111 +#define ID_CHEATS_AUTOMATICSAVELOADCHEATS 40112 +#define ID_FILE_IMPORT_GAMESHARKSNAPSHOT 40115 +#define ID_FILE_IMPORT_BATTERYFILE 40116 +#define ID_FILE_IMPORT_GAMESHARKCODEFILE 40117 +#define ID_FILE_EXPORT_BATTERYFILE 40118 +#define ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL 40121 +#define ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL 40122 +#define ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE 40124 +#define ID_OPTIONS_SOUND_STARTRECORDING 40125 +#define ID_OPTIONS_SOUND_STOPRECORDING 40126 +#define ID_OPTIONS_VIDEO_LAYERS_BG0 40127 +#define ID_OPTIONS_VIDEO_LAYERS_BG1 40128 +#define ID_OPTIONS_VIDEO_LAYERS_BG2 40129 +#define ID_OPTIONS_VIDEO_LAYERS_BG3 40130 +#define ID_OPTIONS_VIDEO_LAYERS_OBJ 40131 +#define ID_OPTIONS_VIDEO_LAYERS_WIN0 40132 +#define ID_OPTIONS_VIDEO_LAYERS_WIN1 40133 +#define ID_OPTIONS_VIDEO_LAYERS_OBJWIN 40134 +#define ID_FILE_OPENGAMEBOY 40135 +#define ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION 40136 +#define ID_DEBUG_NEXTFRAME 40137 +#define ID_TOOLS_MAPVIEW 40138 +#define ID_TOOLS_PALETTEVIEW 40139 +#define ID_OPTIONS_EMULATOR_PNGFORMAT 40140 +#define ID_OPTIONS_EMULATOR_BMPFORMAT 40141 +#define ID_TOOLS_CUSTOMIZE_COMMON 40142 +#define ID_TOOLS_MEMORYVIEWER 40143 +#define ID_TOOLS_OAMVIEWER 40144 +#define ID_TOOLS_TILEVIEWER 40146 +#define ID_OPTIONS_GAMEBOY_COLORS 40147 +#define ID_OPTIONS_SOUND_ECHO 40148 +#define ID_OPTIONS_SOUND_LOWPASSFILTER 40149 +#define ID_OPTIONS_SOUND_REVERSESTEREO 40150 +#define ID_TOOLS_DISASSEMBLE 40151 +#define ID_TOOLS_DEBUG_GDB 40152 +#define ID_TOOLS_DEBUG_LOADANDWAIT 40153 +#define ID_TOOLS_DEBUG_DISCONNECT 40154 +#define ID_TOOLS_DEBUG_BREAK 40155 +#define ID_TOOLS_LOGGING 40156 +#define ID_OPTIONS_EMULATOR_SPEEDHACK 40157 +#define ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE 40158 +#define ID_OPTIONS_EMULATOR_REMOVEINTROSGBA 40159 +#define ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X 40160 +#define ID_OPTIONS_FILTER16BIT_SIMPLE2X 40161 +#define ID_FILE_RECENT_FREEZE 40162 +#define ID_FILE_EXPORT_GAMESHARKSNAPSHOT 40163 +#define ID_OPTIONS_VIDEO_FULLSCREEN800X600 40164 +#define ID_OPTIONS_VIDEO_FRAMESKIP_6 40165 +#define ID_OPTIONS_VIDEO_FRAMESKIP_7 40166 +#define ID_OPTIONS_VIDEO_FRAMESKIP_8 40167 +#define ID_OPTIONS_VIDEO_FRAMESKIP_9 40168 +#define ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC 40169 +#define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM 40170 +#define ID_OPTIONS_EMULATOR_SAVETYPE_SRAM 40171 +#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH 40172 +#define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR 40173 +#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K 40174 +#define ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M 40175 +#define ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH 40176 +#define ID_TOOLS_RECORD_STARTAVIRECORDING 40178 +#define ID_TOOLS_RECORD_STOPAVIRECORDING 40179 +#define ID_OPTIONS_SOUND_VOLUME_1X 40182 +#define ID_OPTIONS_SOUND_VOLUME_2X 40183 +#define ID_OPTIONS_SOUND_VOLUME_3X 40184 +#define ID_OPTIONS_SOUND_VOLUME_4X 40185 +#define ID_OPTIONS_FILTER_BILINEAR 40186 +#define ID_OPTIONS_FILTER_BILINEARPLUS 40187 +#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE 40188 +#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR 40189 +#define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART 40190 +#define ID_OPTIONS_VIDEO_FULLSCREEN 40191 +#define ID_OPTIONS_VIDEO_TRIPLEBUFFERING 40192 +#define ID_OPTIONS_FRAMESKIP_AUTOMATIC 40194 +#define ID_OPTIONS_EMULATOR_SHOWSPEED_NONE 40195 +#define ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE 40196 +#define ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED 40197 +#define ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT 40198 +#define ID_OPTIONS_JOYPAD_CONFIGURE_1 40199 +#define ID_OPTIONS_JOYPAD_CONFIGURE_2 40200 +#define ID_OPTIONS_JOYPAD_CONFIGURE_3 40201 +#define ID_OPTIONS_JOYPAD_CONFIGURE_4 40202 +#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1 40208 +#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2 40209 +#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3 40210 +#define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4 40211 +#define ID_OPTIONS_EMULATOR_STORESETTINGSINREGISTRY 40214 +#define ID_FILE_EXPORT_SETTINGSTOINI 40215 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE 40216 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER 40221 +#define ID_OPTIONS_FILTER_SCANLINES 40223 +#define ID_OPTIONS_VIDEO_RENDERMETHOD_GDI 40228 +#define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW 40229 +#define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D 40230 +#define ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL 40231 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER 40233 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR 40234 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DTRILINEAR 40235 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DANISOTROPIC 40236 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST 40237 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR 40238 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE 40239 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS 40240 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN 40245 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN 40246 +#define ID_OPTIONS_EMULATOR_AGBPRINT 40247 +#define ID_OPTIONS_EMULATOR_REALTIMECLOCK 40248 +#define ID_OPTIONS_GAMEBOY_SGB2 40249 +#define ID_SYSTEM_MINIMIZE 40250 +#define ID_TOOLS_RECORD_STARTMOVIERECORDING 40251 +#define ID_TOOLS_RECORD_STOPMOVIERECORDING 40252 +#define ID_TOOLS_PLAY_STARTMOVIEPLAYING 40253 +#define ID_TOOLS_PLAY_STOPMOVIEPLAYING 40254 +#define ID_OPTIONS_EMULATOR_AUTOHIDEMENU 40255 +#define ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC 40256 +#define ID_OPTIONS_EMULATOR_REWIND 40257 +#define ID_TOOLS_REWIND 40258 +#define ID_OPTIONS_EMULATOR_SKIPBIOS 40259 +#define ID_HELP_BUGREPORT 40260 +#define ID_HELP_FAQ 40261 +#define ID_OPTIONS_EMULATOR_REWINDINTERVAL 40262 +#define ID_FILE_TOGGLEMENU 40263 +#define ID_OPTIONS_EMULATOR_SAVETYPE_NONE 40264 +#define ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION 40265 +#define ID_TOOLS_IOVIEWER 40266 +#define ID_OPTIONS_SOUND_VOLUME_5X 40270 +#define ID_OPTIONS_SOUND_VOLUME_25X 40271 +#define ID_CHEATS_DISABLECHEATS 40272 +#define ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE 40273 +#define ID_OPTIONS_FILTER_LQ2X 40275 +#define ID_OPTIONS_FILTER_HQ2X 40276 +#define ID_OPTIONS_FILTER_HQ2X2 40277 +#define ID_OPTIONS_FILTER_HQ3X 40278 +#define ID_OPTIONS_FILTER_HQ3X2 40279 +#define ID_OPTIONS_FRAMESKIP_ACCURATEPITCH 40289 +#define ID_OPTIONS_FRAMESKIP_ACCURATESPEED 40290 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_6 40324 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_25 40326 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_37 40327 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_50 40328 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_75 40329 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_87 40330 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_100 40331 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_112 40332 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_125 40333 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_150 40334 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_200 40335 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_300 40336 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_15 40337 +#define ID_TOOLS_FRAMECOUNTER 40341 +#define ID_TOOLS_INPUTDISPLAY 40342 +#define ID_Menu 40361 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE 40364 +#define ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE 40365 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_A 40366 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_B 40367 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_L 40368 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_R 40369 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_START 40370 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT 40371 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_UP 40372 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN 40373 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT 40374 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT 40375 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR 40376 +#define ID_OPTIONS_SOUND_MUTEFRAMEADVANCE 40378 +#define ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT 40382 +#define ID_TOOLS_PLAY_READONLY 40385 +#define ID_TOOLS_PLAY_RESTART 40387 +#define ID_TOOLS_PLAY_CONTINUE 40388 +#define ID_FILE_LOADGAME_AUTOLOADMOSTRECENT 40393 +#define ID_EMULATOR_GBALAG 40394 +#define ID_EMULATOR_USEOLDGBTIMING 40395 +#define ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS 40397 +#define ID_STICKY_A 40399 +#define ID_STICKY_B 40400 +#define ID_STICKY_R 40402 +#define ID_STICKY_START 40403 +#define ID_STICKY_SELECT 40404 +#define ID_STICKY_UP 40405 +#define ID_STICKY_DOWN 40406 +#define ID_STICKY_LEFT 40407 +#define ID_STICKY_RIGHT 40408 +#define ID_STICKY_L 40410 +#define ID_STICKY_CLEAR 40412 +#define ID_FILE_SAVEGAME_DECREMENTSLOT 40416 +#define ID_Menu40417 40417 +#define ID_FILE_LOADGAME_MOSTRECENT 40420 +#define ID_FILE_LOADGAME_CURRENT 40423 +#define ID_FILE_LOADGAME_MAKECURRENT 40424 +#define ID_FILE_SAVEGAME_CURRENT 40427 +#define ID_FILE_SAVEGAME_MAKECURRENT 40428 +#define ID_FILE_SAVEGAME_OLDESTSLOT 40429 +#define ID_FILE_SAVEGAME_INCREMENTSLOT 40430 +#define ID_FILE_LOADGAME_MAKERECENT 40431 +#define ID_DEBUG_FRAMESEARCH 40432 +#define ID_DEBUG_FRAMESEARCHLOAD 40438 +#define ID_DEBUG_FRAMESEARCHPREV 40439 +#define ID_SELECT_SLOT1 40440 +#define ID_SELECT_SLOT2 40441 +#define ID_SELECT_SLOT3 40442 +#define ID_SELECT_SLOT4 40443 +#define ID_SELECT_SLOT5 40444 +#define ID_SELECT_SLOT6 40445 +#define ID_SELECT_SLOT7 40446 +#define ID_SELECT_SLOT8 40447 +#define ID_SELECT_SLOT9 40448 +#define ID_SELECT_SLOT10 40449 +#define ID_TOOLS_DEBUG 40450 +#define ID_TOOLS_CUSTOMIZE 40452 +#define ID_OPTIONS_SPEED 40453 +#define ID_SPEED_BLA 40454 +#define ID_SPEED_FRAMESKIP 40455 +#define ID_FRAMESKIP_BLA 40456 +#define ID_SPEED_SETSPEED 40457 +#define ID_SETSPEED_BLA 40458 +#define ID_SOUND_SOUNDCHANNELS 40459 +#define ID_CHEATS_PAUSEDURINGCHEATSEARCH 40463 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 159 +#define _APS_NEXT_COMMAND_VALUE 40464 +#define _APS_NEXT_CONTROL_VALUE 1285 +#define _APS_NEXT_SYMED_VALUE 103 +#endif +#endif diff --git a/src/win32/skin.cpp b/src/win32/skin.cpp new file mode 100644 index 0000000..6fc76f5 --- /dev/null +++ b/src/win32/skin.cpp @@ -0,0 +1,588 @@ +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +// +// WINDOWS SKINNING TUTORIAL - by Vander Nunes - virtware.net +// This is the source-code that shows what is discussed in the tutorial. +// The code is simplified for the sake of clarity, but all the needed +// features for handling skinned windows is present. Please read +// the article for more information. +// +// skin.cpp : CSkin class implementation +// 28/02/2002 : initial release. +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +#include "stdafx.h" +#include "skin.h" +#include +#include "xImage.h" + +#include "../System.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +// ---------------------------------------------------------------------------- +// constructor 1 - use it when you have not already created the app window. +// this one will not subclass automatically, you must call Hook() and Enable() +// to subclass the app window and enable the skin respectively. +// will throw an exception if unable to initialize skin from resource. +// ---------------------------------------------------------------------------- + +CSkin::CSkin() +{ + // default starting values + m_bHooked = false; + m_OldWndProc = NULL; + + m_rect.top = 0; + m_rect.bottom = 0; + m_rect.right = 0; + m_rect.left = 0; + + m_dOldStyle = 0; + + m_oldRect = m_rect; + m_nButtons = 0; + m_buttons = NULL; +} + +// ---------------------------------------------------------------------------- +// destructor - just call the destroyer +// ---------------------------------------------------------------------------- +CSkin::~CSkin() +{ + Destroy(); +} + +HBITMAP CSkin::LoadImage(const char *filename) +{ + CxImage image; + image.Load(filename); + if(!image.IsValid()) { + return NULL; + } + + return image.MakeBitmap(NULL); +} + +// ---------------------------------------------------------------------------- +// Initialize the skin +// ---------------------------------------------------------------------------- +bool CSkin::Initialize(const char *skinFile) +{ + // try to retrieve the skin data from resource. + bool res = GetSkinData(skinFile); + if(!res) + systemMessage(0, m_error); + return res; +} + +// ---------------------------------------------------------------------------- +// destroy skin resources and free allocated resources +// ---------------------------------------------------------------------------- +void CSkin::Destroy() +{ + if (m_buttons) { + delete[] m_buttons; + m_buttons = NULL; + } + + // unhook the window + UnHook(); + + // free bitmaps and device context + if (m_dcSkin) { SelectObject(m_dcSkin, m_hOldBmp); DeleteDC(m_dcSkin); m_dcSkin = NULL; } + if (m_hBmp) { DeleteObject(m_hBmp); m_hBmp = NULL; } + + // free skin region + if (m_rgnSkin) { DeleteObject(m_rgnSkin); m_rgnSkin = NULL; } + +} + + + +// ---------------------------------------------------------------------------- +// toggle skin on/off - must be Hooked() before attempting to enable skin. +// ---------------------------------------------------------------------------- +bool CSkin::Enable(bool bEnable) +{ + // refuse to enable if there is no window subclassed yet. + if (!Hooked()) return false; + + // toggle + m_bEnabled = bEnable; + + // force window repainting + InvalidateRect(m_hWnd, NULL, TRUE); + + return true; +} + + + +// ---------------------------------------------------------------------------- +// tell if the skinning is enabled +// ---------------------------------------------------------------------------- +bool CSkin::Enabled() +{ + return m_bEnabled; +} + + + +// ---------------------------------------------------------------------------- +// hook a window +// ---------------------------------------------------------------------------- +bool CSkin::Hook(CWnd *pWnd) +{ + // unsubclass any other window + if (Hooked()) UnHook(); + + // this will be our new subclassed window + m_hWnd = (HWND)*pWnd; + + // -------------------------------------------------- + // change window style (get rid of the caption bar) + // -------------------------------------------------- + DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE); + m_dOldStyle = dwStyle; + dwStyle &= ~(WS_CAPTION|WS_SIZEBOX); + SetWindowLong(m_hWnd, GWL_STYLE, dwStyle); + + RECT r; + pWnd->GetWindowRect(&r); + m_oldRect = r; + pWnd->MoveWindow(r.left, + r.top, + m_iWidth, + m_iHeight, + FALSE); + + pWnd->SetMenu(NULL); + + if(m_rgnSkin != NULL) + // set the skin region to the window + pWnd->SetWindowRgn(m_rgnSkin, true); + + // subclass the window procedure + m_OldWndProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)SkinWndProc); + + // store a pointer to our class instance inside the window procedure. + if (!SetProp(m_hWnd, "skin", (void*)this)) + { + // if we fail to do so, we just can't activate the skin. + UnHook(); + return false; + } + + + // update flag + m_bHooked = ( m_OldWndProc ? true : false ); + + for(int i = 0; i < m_nButtons; i++) { + RECT r; + m_buttons[i].GetRect(r); + m_buttons[i].CreateButton("", WS_VISIBLE, r, pWnd, 0); + } + + // force window repainting + RedrawWindow(NULL,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); + + // successful return if we're hooked. + return m_bHooked; +} + + + +// ---------------------------------------------------------------------------- +// unhook the window +// ---------------------------------------------------------------------------- +bool CSkin::UnHook() +{ + // just to be safe we'll check this + WNDPROC OurWnd; + + // cannot unsubclass if there is no window subclassed + // returns true anyways. + if (!Hooked()) return true; + + if(m_rgnSkin != NULL) + // remove the skin region from the window + SetWindowRgn(m_hWnd, NULL, true); + + // unsubclass the window procedure + OurWnd = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)m_OldWndProc); + + // remove the pointer to our class instance, but if we fail we don't care. + RemoveProp(m_hWnd, "skin"); + + // update flag - if we can't get our window procedure address again, + // we failed to unhook the window. + m_bHooked = ( OurWnd ? false : true ); + + SetWindowLong(m_hWnd, GWL_STYLE, m_dOldStyle); + + RECT r; + + GetWindowRect(m_hWnd, &r); + + MoveWindow(m_hWnd, + r.left, + r.top, + m_oldRect.right - m_oldRect.left, + m_oldRect.bottom - m_oldRect.top, + FALSE); + + // force window repainting + RedrawWindow(NULL,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN); + + // successful return if we're unhooked. + return !m_bHooked; +} + + + +// ---------------------------------------------------------------------------- +// tell us if there is a window subclassed +// ---------------------------------------------------------------------------- +bool CSkin::Hooked() +{ + return m_bHooked; +} + + + +// ---------------------------------------------------------------------------- +// return the skin bitmap width +// ---------------------------------------------------------------------------- +int CSkin::Width() +{ + return m_iWidth; +} + + + +// ---------------------------------------------------------------------------- +// return the skin bitmap height +// ---------------------------------------------------------------------------- +int CSkin::Height() +{ + return m_iHeight; +} + + + +// ---------------------------------------------------------------------------- +// return the skin device context +// ---------------------------------------------------------------------------- +HDC CSkin::HDC() +{ + return m_dcSkin; +} + +bool CSkin::ParseRect(char *buffer, RECT& rect) +{ + char *token = strtok(buffer, ","); + + if(token == NULL) + return false; + rect.left = atoi(token); + + token = strtok(NULL, ","); + if(token == NULL) + return false; + rect.top = atoi(token); + + token = strtok(NULL, ","); + if(token == NULL) + return false; + rect.right = rect.left + atoi(token); + + token = strtok(NULL, ","); + if(token == NULL) + return false; + rect.bottom = rect.top + atoi(token); + + token = strtok(NULL, ","); + if(token != NULL) + return false; + + return true; +} + +HRGN CSkin::LoadRegion(const char *rgn) +{ + // ------------------------------------------------- + // then, we retrieve the skin region from resource. + // ------------------------------------------------- + FILE *f = fopen(rgn, "rb"); + if(!f) return NULL; + + fseek(f, 0, SEEK_END); + int size = ftell(f); + LPRGNDATA pSkinData = (LPRGNDATA)malloc(size); + if(!pSkinData) { + fclose(f); + return NULL; + } + + fseek(f, 0, SEEK_SET); + + fread(pSkinData, 1, size, f); + + fclose(f); + + // create the region using the binary data. + HRGN r = ExtCreateRegion(NULL, size, pSkinData); + + // free the allocated resource + free(pSkinData); + + return r; +} + +// ---------------------------------------------------------------------------- +// skin retrieval helper +// ---------------------------------------------------------------------------- +bool CSkin::GetSkinData(const char *skinFile) +{ + // ------------------------------------------------- + // retrieve the skin bitmap from resource. + // ------------------------------------------------- + + char buffer[2048]; + + if(!GetPrivateProfileString("skin", "image", "", buffer, 2048, skinFile)) { + m_error = "Missing skin bitmap"; + return false; + } + CString bmpName = buffer; + CString rgn = ""; + if(GetPrivateProfileString("skin", "region", "", buffer, 2048, skinFile)) { + rgn = buffer; + } + + if(!GetPrivateProfileString("skin", "draw", "", buffer, 2048, skinFile)) { + m_error = "Missing draw rectangle"; + return false; + } + + if(!ParseRect(buffer, m_rect)) { + m_error = "Invalid draw rectangle"; + return false; + } + + m_nButtons = GetPrivateProfileInt("skin", "buttons", 0, skinFile); + + if(m_nButtons) { + m_buttons = new SkinButton[m_nButtons]; + for(int i = 0; i < m_nButtons; i++) { + if(!ReadButton(skinFile, i)) + return false; + } + } + + CString path = skinFile; + int index = path.ReverseFind('\\'); + if(index != -1) { + path = path.Left(index+1); + } + + bmpName = path + bmpName; + if(strcmp(rgn, "")) + rgn = path + rgn; + + m_hBmp = LoadImage(bmpName); + + if (!m_hBmp) { + m_error = "Error loading skin bitmap " + bmpName; + return false; + } + + // get skin info + BITMAP bmp; + GetObject(m_hBmp, sizeof(bmp), &bmp); + + // get skin dimensions + m_iWidth = bmp.bmWidth; + m_iHeight = bmp.bmHeight; + + if(strcmp(rgn, "")) { + m_rgnSkin = LoadRegion(rgn); + if(m_rgnSkin == NULL) { + m_error = "Error loading skin region " + rgn; + return false; + } + } + + // ------------------------------------------------- + // well, things are looking good... + // as a quick providence, just create and keep + // a device context for our later blittings. + // ------------------------------------------------- + + // create a context compatible with the user desktop + m_dcSkin = CreateCompatibleDC(0); + if (!m_dcSkin) return false; + + // select our bitmap + m_hOldBmp = (HBITMAP)SelectObject(m_dcSkin, m_hBmp); + + + // ------------------------------------------------- + // done + // ------------------------------------------------- + return true; +} + +bool CSkin::ReadButton(const char *skinFile, int num) +{ + char buffer[2048]; + + CString path = skinFile; + int index = path.ReverseFind('\\'); + if(index != -1) { + path = path.Left(index+1); + } + sprintf(buffer, "button-%d", num); + CString name = buffer; + + if(!GetPrivateProfileString(name, "normal", "", buffer, 2048, skinFile)) { + m_error = "Missing button bitmap for " + name; + return false; + } + + CString normalBmp = path + buffer; + + HBITMAP bmp = LoadImage(normalBmp); + if(!bmp) { + m_error = "Error loading button bitmap " + normalBmp; + return false; + } + m_buttons[num].SetNormalBitmap(bmp); + + if(!GetPrivateProfileString(name, "down", "", buffer, 2048, skinFile)) { + m_error = "Missing button down bitmap " + name; + return false; + } + + CString downBmp = path + buffer; + + bmp = LoadImage(downBmp); + + if (!bmp) { + m_error = "Error loading button down bitmap " + downBmp; + return false; + } + m_buttons[num].SetDownBitmap(bmp); + + if(GetPrivateProfileString(name, "over", "", buffer, 2048, skinFile)) { + CString overBmp = path + buffer; + + bmp = LoadImage(overBmp); + + if (!bmp) { + m_error = "Error loading button over bitmap " + overBmp; + return false; + } + m_buttons[num].SetOverBitmap(bmp); + } + + if(GetPrivateProfileString(name, "region", "", buffer, 2048, skinFile)) { + CString region = path + buffer; + + HRGN rgn = LoadRegion(region); + if(!rgn) { + m_error = "Error loading button region " + region; + return false; + } + m_buttons[num].SetRegion(rgn); + } + + if(!GetPrivateProfileString(name, "id", "", buffer, 2048, skinFile)) { + "Missing button ID for " + name; + return false; + } + m_buttons[num].SetId(buffer); + + if(!GetPrivateProfileString(name, "rect", "", buffer, 2048, skinFile)) { + m_error = "Missing button rectangle for " + name; + return false; + } + + RECT r; + if(!ParseRect(buffer, r)) { + m_error = "Invalid button rectangle for " + name; + return false; + } + m_buttons[num].SetRect(r); + + return true; +} + +// ------------------------------------------------------------------------ +// Default skin window procedure. +// Here the class will handle WM_PAINT and WM_LBUTTONDOWN, originally sent +// to the application window, but now subclassed. Any other messages will +// just pass through the procedure and reach the original app procedure. +// ------------------------------------------------------------------------ +LRESULT CALLBACK SkinWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) +{ + // we will need a pointer to the associated class instance + // (it was stored in the window before, remember?) + CSkin *pSkin = (CSkin*)GetProp(hWnd, "skin"); + + // to handle WM_PAINT + PAINTSTRUCT ps; + + // if we fail to get our class instance, we can't handle anything. + if (!pSkin) return DefWindowProc(hWnd,uMessage,wParam,lParam); + + switch(uMessage) + { + case WM_WINDOWPOSCHANGING: + { + LPWINDOWPOS pos = (LPWINDOWPOS)lParam; + pos->cx = pSkin->Width(); + pos->cy = pSkin->Height(); + return 0L; + } + break; + + case WM_PAINT: + { + // --------------------------------------------------------- + // here we just need to blit our skin + // directly to the device context + // passed by the painting message. + // --------------------------------------------------------- + BeginPaint(hWnd,&ps); + + // blit the skin + BitBlt(ps.hdc,0,0,pSkin->Width(),pSkin->Height(),pSkin->HDC(),0,0,SRCCOPY); + + EndPaint(hWnd,&ps); + break; + } + + case WM_LBUTTONDOWN: + { + // --------------------------------------------------------- + // this is a common trick for easy dragging of the window. + // this message fools windows telling that the user is + // actually dragging the application caption bar. + // --------------------------------------------------------- + SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL); + break; + } + + } + + // --------------------------------------------------------- + // call the default window procedure to keep things going. + // --------------------------------------------------------- + return CallWindowProc(pSkin->m_OldWndProc, hWnd, uMessage, wParam, lParam); +} diff --git a/src/win32/skin.h b/src/win32/skin.h new file mode 100644 index 0000000..69d3832 --- /dev/null +++ b/src/win32/skin.h @@ -0,0 +1,162 @@ +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +// +// WINDOWS SKINNING TUTORIAL - by Vander Nunes - virtware.net +// This is the source-code that shows what is discussed in the tutorial. +// The code is simplified for the sake of clarity, but all the needed +// features for handling skinned windows is present. Please read +// the article for more information. +// +// skin.h : CSkin class declaration +// 28/02/2002 : initial release. +// +// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + + +#ifndef _SKIN_H_ + +#define _SKIN_H_ + +#include "skinButton.h" + + + +// -------------------------------------------------------------------------- +// The CSkin class will load the skin from a resource +// and subclass the associated window, so that the +// WM_PAINT message will be redirected to the provided +// window procedure. All the skin handling will be automatized. +// -------------------------------------------------------------------------- + +class CSkin +{ + + // -------------------------------------------------------------------------- + // the skin window procedure, where the class + // will handle WM_PAINT and WM_LBUTTONDOWN automatically. + // -------------------------------------------------------------------------- + friend LRESULT CALLBACK SkinWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam); + + private: + + // the associated window handle + HWND m_hWnd; + + // the old window procedure + WNDPROC m_OldWndProc; + + // skin region + HRGN m_rgnSkin; + + // the internal skin device context handle + HDC m_dcSkin; + + // bitmap and old bitmap from the device context + HBITMAP m_hBmp, m_hOldBmp; + + // skin dimensions + int m_iWidth, m_iHeight; + + // on|off toggle + bool m_bEnabled; + + // tell the class if it has a window subclassed. + bool m_bHooked; + + // skin retrieval helper + bool GetSkinData(const char *skin); + + RECT m_rect; + + DWORD m_dOldStyle; + RECT m_oldRect; + int m_nButtons; + SkinButton *m_buttons; + CString m_error; + + public: + + // ---------------------------------------------------------------------------- + // constructor 1 - use it when you have not already created the app window. + // this one will not subclass automatically, you must call Hook() to subclass. + // will throw an exception if unable to initialize skin from resource. + // ---------------------------------------------------------------------------- + + CSkin(); + + // ---------------------------------------------------------------------------- + // destructor - just call the destroyer + // ---------------------------------------------------------------------------- + + virtual ~CSkin(); + + // ---------------------------------------------------------------------------- + // Initialize the skin + // ---------------------------------------------------------------------------- + bool Initialize(const char *); + + + // ---------------------------------------------------------------------------- + // destroy skin resources and free allocated resources + // ---------------------------------------------------------------------------- + + void Destroy(); + + // ---------------------------------------------------------------------------- + // subclass a window. + // ---------------------------------------------------------------------------- + + bool Hook(CWnd *pWnd); + + // ---------------------------------------------------------------------------- + // unsubclass the subclassed window. + // ---------------------------------------------------------------------------- + + bool UnHook(); + + // ---------------------------------------------------------------------------- + // tell us if we have a window subclassed. + // ---------------------------------------------------------------------------- + + bool Hooked(); + + // ---------------------------------------------------------------------------- + // toggle skin on/off. + // ---------------------------------------------------------------------------- + + bool Enable(bool bEnable); + + // ---------------------------------------------------------------------------- + // tell if the skinning is enabled + // ---------------------------------------------------------------------------- + + bool Enabled(); + + // ---------------------------------------------------------------------------- + // return the skin bitmap width. + // ---------------------------------------------------------------------------- + + int Width(); + + // ---------------------------------------------------------------------------- + // return the skin bitmap height. + // ---------------------------------------------------------------------------- + + int Height(); + + // Return blit rect + RECT &GetBlitRect() { return m_rect; } + + // ---------------------------------------------------------------------------- + // return the skin device context. + // ---------------------------------------------------------------------------- + + HDC HDC(); + + private: + HBITMAP LoadImage(const char *); + bool ReadButton(const char *, int); + static bool ParseRect(char *, RECT &); + static HRGN LoadRegion(const char *); +}; + +#endif diff --git a/src/win32/skinButton.cpp b/src/win32/skinButton.cpp new file mode 100644 index 0000000..d17dbd9 --- /dev/null +++ b/src/win32/skinButton.cpp @@ -0,0 +1,328 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// skinButton.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "skinButton.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern bool winAccelGetID(const char *command, WORD& id); + +///////////////////////////////////////////////////////////////////////////// +// SkinButton + +SkinButton::SkinButton() +{ + normalBmp = NULL; + downBmp = NULL; + overBmp = NULL; + mouseOver = false; + id = ""; + idCommand = 0; + region = NULL; + buttonMask = 0; + menu = -1; +} + +SkinButton::~SkinButton() +{ + DestroyWindow(); + if(normalBmp) { + DeleteObject(normalBmp); + normalBmp = NULL; + } + if(downBmp) { + DeleteObject(downBmp); + downBmp = NULL; + } + if(overBmp) { + DeleteObject(overBmp); + overBmp = NULL; + } + if(region) { + DeleteObject(region); + region = NULL; + } +} + + +BEGIN_MESSAGE_MAP(SkinButton, CWnd) + //{{AFX_MSG_MAP(SkinButton) + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_WM_KILLFOCUS() + ON_WM_CAPTURECHANGED() + ON_WM_CONTEXTMENU() + //}}AFX_MSG_MAP + ON_MESSAGE(WM_LBUTTONUP, OnLButtonUpMsg) + ON_MESSAGE(WM_LBUTTONDOWN, OnLButtonDownMsg) + ON_MESSAGE(WM_MOUSEMOVE, OnMouseMoveMsg) + ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeaveMsg) + END_MESSAGE_MAP() + + + ///////////////////////////////////////////////////////////////////////////// +// SkinButton message handlers + +BOOL SkinButton::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + +void SkinButton::OnPaint() +{ + PAINTSTRUCT ps; + HDC hDC = ::BeginPaint(m_hWnd, &ps); + HDC memDC = ::CreateCompatibleDC(hDC); + UINT state = ::SendMessage(m_hWnd, BM_GETSTATE, 0, 0); + HBITMAP oldBitmap; + if(state & BST_PUSHED) + oldBitmap = (HBITMAP)SelectObject(memDC, downBmp); + else if(mouseOver && overBmp != NULL) + oldBitmap = (HBITMAP)SelectObject(memDC, overBmp); + else + oldBitmap = (HBITMAP)SelectObject(memDC, normalBmp); + SelectClipRgn(hDC, region); + BitBlt(hDC, 0, 0, theApp.rect.right - theApp.rect.left, + theApp.rect.bottom - theApp.rect.top, memDC, 0, 0, SRCCOPY); + SelectClipRgn(hDC, NULL); + SelectObject(memDC, oldBitmap); + DeleteDC(memDC); + + ::EndPaint(m_hWnd, &ps); +} + +LRESULT SkinButton::OnLButtonUpMsg(WPARAM wParam, LPARAM lParam) +{ + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + RECT r; + GetClientRect(&r); + BOOL inside = PtInRect(&r, pt); + if(region != NULL) + inside &= PtInRegion(region, pt.x, pt.y); + if(inside) { + HWND hWnd = m_hWnd; + if(idCommand != 0) + GetParent()->SendMessage(WM_COMMAND, idCommand, 0); + else if(buttonMask) + theApp.skinButtons = 0; + else if(menu != -1) { + HMENU m = GetSubMenu(theApp.menu, menu); + pt.x = r.left; + pt.y = r.bottom; + ClientToScreen(&pt); + theApp.m_pMainWnd->SendMessage(WM_INITMENUPOPUP, (WPARAM)m, menu); + TrackPopupMenu(m, 0, pt.x, pt.y, 0, *theApp.m_pMainWnd, NULL); + } + + return ::DefWindowProc(hWnd, WM_LBUTTONUP, wParam, lParam); + } + return GetParent()->SendMessage(WM_LBUTTONUP, wParam, lParam); +} + +LRESULT SkinButton::OnLButtonDownMsg(WPARAM wParam, LPARAM lParam) +{ + if(idCommand != 0) + return Default(); + + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + RECT r; + GetClientRect(&r); + BOOL inside = PtInRect(&r, pt); + if(region != NULL) + inside &= PtInRegion(region, pt.x, pt.y); + if(inside) { + if(buttonMask) + theApp.skinButtons = buttonMask; + return Default(); + } + return GetParent()->SendMessage(WM_LBUTTONDOWN, wParam, lParam); +} + +LRESULT SkinButton::OnMouseMoveMsg(WPARAM wParam, LPARAM lParam) +{ + if(wParam & MK_LBUTTON && !mouseOver) + return Default(); + + if(GetCapture() != this) { + SetCapture(); + } + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + // ClientToScreen(getHandle(), &p); + RECT r; + GetClientRect(&r); + BOOL inside = PtInRect(&r, pt); + if(region != NULL) + inside &= PtInRegion(region, pt.x, pt.y); + + if(!inside) { + // HWND h = WindowFromPoint(p); + // if(h != getHandle()) { + if(mouseOver) { + mouseOver = false; + Invalidate(); + } + if(!(wParam & MK_LBUTTON)) + ReleaseCapture(); + } else { + if(!mouseOver) { + mouseOver = true; + Invalidate(); + } + } + return Default(); +} + +void SkinButton::OnKillFocus(CWnd* pNewWnd) +{ + mouseOver = false; + Invalidate(); + + CWnd::OnKillFocus(pNewWnd); +} + +void SkinButton::OnCaptureChanged(CWnd *pWnd) +{ + if(mouseOver) { + ReleaseCapture(); + Invalidate(); + } + + CWnd::OnCaptureChanged(pWnd); +} + +LRESULT SkinButton::OnMouseLeaveMsg(WPARAM wParam, LPARAM lParam) +{ + if(mouseOver) { + ReleaseCapture(); + mouseOver = false; + Invalidate(); + } + + return Default(); +} + +void SkinButton::OnContextMenu(CWnd* pWnd, CPoint point) +{ +} + +void SkinButton::SetNormalBitmap(HBITMAP bmp) +{ + normalBmp = bmp; +} + +void SkinButton::SetDownBitmap(HBITMAP bmp) +{ + downBmp = bmp; +} + +void SkinButton::SetOverBitmap(HBITMAP bmp) +{ + overBmp = bmp; +} + +void SkinButton::SetRect(const RECT& r) +{ + rect = r; +} + +void SkinButton::SetId(const char *id) +{ + this->id = id; + if(!winAccelGetID(id, idCommand)) { + if(!strcmp(id, "A")) + buttonMask = 1; + else if(!strcmp("B", id)) + buttonMask = 2; + else if(!strcmp("SEL", id)) + buttonMask = 4; + else if(!strcmp("START", id)) + buttonMask = 8; + else if(!strcmp("R", id)) + buttonMask = 16; + else if(!strcmp("L", id)) + buttonMask = 32; + else if(!strcmp("U", id)) + buttonMask = 64; + else if(!strcmp("D", id)) + buttonMask = 128; + else if(!strcmp("BR", id)) + buttonMask = 256; + else if(!strcmp("BL", id)) + buttonMask = 512; + else if(!strcmp("SPEED", id)) + buttonMask = 1024; + else if(!strcmp("CAPTURE", id)) + buttonMask = 2048; + else if(!strcmp("GS", id)) + buttonMask = 4096; + else if(!strcmp("UR", id)) + buttonMask = 64+16; + else if(!strcmp("UL", id)) + buttonMask = 64+32; + else if(!strcmp("DR", id)) + buttonMask = 128+16; + else if(!strcmp("DL", id)) + buttonMask = 128+32; + else if(!strcmp("MENUFILE", id)) + menu = 0; + else if(!strcmp("MENUOPTIONS", id)) + menu = 1; + else if(!strcmp("MENUCHEATS", id)) + menu = 2; + else if(!strcmp("MENUTOOLS", id)) + menu = 3; + else if(!strcmp("MENUHELP", id)) + menu = 4; + } +} + +void SkinButton::SetRegion(HRGN rgn) +{ + region = rgn; +} + +void SkinButton::GetRect(RECT& r) +{ + r = rect; +} + +BOOL SkinButton::CreateButton(const char *name, DWORD style, const RECT& r, + CWnd *parent, UINT id) +{ + return CWnd::Create("BUTTON", + name, + style|WS_CHILDWINDOW, + r, + parent, + id); +} diff --git a/src/win32/skinButton.h b/src/win32/skinButton.h new file mode 100644 index 0000000..8fa7312 --- /dev/null +++ b/src/win32/skinButton.h @@ -0,0 +1,93 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#if !defined(AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_) +#define AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// skinButton.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// SkinButton window + +class SkinButton : public CWnd +{ + // Construction + public: + SkinButton(); + + // Attributes + private: + HBITMAP normalBmp; + HBITMAP downBmp; + HBITMAP overBmp; + RECT rect; + bool mouseOver; + CString id; + HRGN region; + WORD idCommand; + int buttonMask; + int menu; + + // Operations + public: + BOOL CreateButton(const char *, DWORD, const RECT&, CWnd *, UINT); + + void SetNormalBitmap(HBITMAP); + void SetDownBitmap(HBITMAP); + void SetOverBitmap(HBITMAP); + void SetRect(const RECT &); + void GetRect(RECT& r); + void SetId(const char *); + void SetRegion(HRGN); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(SkinButton) + //}}AFX_VIRTUAL + + // Implementation + public: + afx_msg LRESULT OnMouseLeaveMsg(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMouseMoveMsg(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnLButtonDownMsg(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnLButtonUpMsg(WPARAM wParam, LPARAM lParam); + virtual ~SkinButton(); + + // Generated message map functions + protected: + //{{AFX_MSG(SkinButton) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); + afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg void OnCaptureChanged(CWnd *pWnd); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + ///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_) diff --git a/src/win32/stdafx.cpp b/src/win32/stdafx.cpp new file mode 100644 index 0000000..7a2d90f --- /dev/null +++ b/src/win32/stdafx.cpp @@ -0,0 +1,26 @@ +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// stdafx.cpp : source file that includes just the standard includes +// DialogSizer.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/src/win32/stdafx.h b/src/win32/stdafx.h new file mode 100644 index 0000000..4fc1019 --- /dev/null +++ b/src/win32/stdafx.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. +// Copyright (C) 1999-2003 Forgotten +// Copyright (C) 2004 Forgotten and the VBA development team + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or(at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +// some build target defines: + +#ifndef _WIN32_WINDOWS +# define _WIN32_WINDOWS 0x0410 // Windows 98 + +///# define _WIN32_WINDOWS 0x0500 // Windows NT + +///# define _WIN32_WINDOWS 0x0501 // Windows XP + +#endif + +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0410 // Windows 98 + +///# define _WIN32_WINNT 0x0500 // Windows NT + +///# define _WIN32_WINNT 0x0501 // Windows XP + +#endif + +#ifndef WINVER +///# define WINVER 0x0410 // Windows 98 + +#define WINVER 0x0500 // Windows NT + +///# define WINVER 0x0501 // Windows XP + +#endif + + + +#if !defined(AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_) +#define AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Insert your headers here +//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include +#include +#include "VBA.h" + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A7126ECB_A234_4116_A7D0_BE50547E87F8__INCLUDED_) diff --git a/src/win32/vba.aps b/src/win32/vba.aps new file mode 100644 index 0000000..d8904f7 Binary files /dev/null and b/src/win32/vba.aps differ diff --git a/src/win32/vba.rc b/src/win32/vba.rc new file mode 100644 index 0000000..97849d1 --- /dev/null +++ b/src/win32/vba.rc @@ -0,0 +1,2748 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" +#include "vba.rc2" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,7,2,560 + PRODUCTVERSION 1,7,2,560 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x29L +#else + FILEFLAGS 0x28L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "VisualBoyAdvance comes with NO WARRANTY. Use it at your own risk." + VALUE "CompanyName", "None" + VALUE "FileDescription", "VisualBoyAdvance emulator" + VALUE "FileVersion", "1, 7, 2, 560" + VALUE "InternalName", "VisualBoyAdvance" + VALUE "LegalCopyright", "Copyright Š 2004 Forgotten and the VBA team" + VALUE "OriginalFilename", "VisualBoyAdvance.exe" + VALUE "PrivateBuild", "0" + VALUE "ProductName", "VisualBoyAdvance emulator" + VALUE "ProductVersion", "1, 7, 2, 560" + VALUE "SpecialBuild", "0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "#include ""vba.rc2""\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON ICON "gbadvance.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPENDLG DIALOG 36, 24, 202, 117 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | + WS_CAPTION | WS_SYSMENU +CAPTION "Open" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "File &name:",1090,2,1,81,8 + EDITTEXT 1152,0,10,104,12,ES_AUTOHSCROLL | ES_OEMCONVERT + LISTBOX 1120,1,24,104,53,LBS_SORT | LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_VSCROLL | + WS_TABSTOP + LTEXT "&Folders:",-1,112,0,53,9 + LTEXT "",1088,113,10,86,9,SS_NOPREFIX + LISTBOX 1121,112,24,88,52,LBS_SORT | LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_VSCROLL | + WS_TABSTOP + LTEXT "List files of &type:",1089,1,75,81,9 + COMBOBOX 1136,1,87,104,13,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + LTEXT "Dri&ves:",1091,113,76,70,9 + COMBOBOX 1137,112,87,71,68,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | + CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | + WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,24,102,50,14,WS_GROUP + PUSHBUTTON "Cancel",IDCANCEL,90,102,50,14,WS_GROUP +END + +IDD_ABOUT DIALOGEX 0, 0, 164, 101 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About VisualBoyAdvance" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,56,80,50,14 + ICON IDI_ICON,IDC_STATIC,5,12,21,20 + CTEXT "VisualBoyAdvance Emulator",IDC_STATIC,14,7,134,8 + CTEXT "Copyright (c) 2004 Forgotten and the VBA team", + IDC_STATIC,6,35,150,8 + CTEXT "http://vba.ngemu.com",IDC_URL,43,55,76,8 + CTEXT "Contribution by Costis",IDC_STATIC,30,45,102,8 + CTEXT "Version",IDC_STATIC,46,16,70,8 + CTEXT "",IDC_VERSION,36,25,98,8 + CTEXT "Re-recording additions by Nitsuja",IDC_STATIC,24,66,117, + 8 +END + +IDD_DIRECTORIES DIALOGEX 0, 0, 284, 129 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Directories" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + PUSHBUTTON "Browse...",IDC_ROM_DIR,174,7,50,14 + PUSHBUTTON "Browse...",IDC_MOVIES_DIR,174,26,50,14 + PUSHBUTTON "Browse...",IDC_BATTERY_DIR,174,45,50,14 + PUSHBUTTON "Browse...",IDC_SAVE_DIR,174,64,50,14 + PUSHBUTTON "Browse...",IDC_CAPTURE_DIR,174,83,50,14 + DEFPUSHBUTTON "OK",IDOK,88,108,50,14 + PUSHBUTTON "Cancel",IDCANCEL,145,108,50,14 + LTEXT "ROM:",IDC_STATIC,7,9,20,8 + LTEXT "Battery:",IDC_STATIC,7,47,25,8 + LTEXT "Save Game:",IDC_STATIC,7,66,40,8 + LTEXT "Capture:",IDC_STATIC,7,85,28,8 + EDITTEXT IDC_ROM_PATH,49,7,121,14,ES_AUTOHSCROLL | WS_DISABLED + EDITTEXT IDC_BATTERY_PATH,49,45,121,14,ES_AUTOHSCROLL | + WS_DISABLED + EDITTEXT IDC_SAVE_PATH,49,64,121,14,ES_AUTOHSCROLL | WS_DISABLED + EDITTEXT IDC_CAPTURE_PATH,49,83,121,14,ES_AUTOHSCROLL | + WS_DISABLED + LTEXT "Movies:",IDC_STATIC,7,28,26,8 + EDITTEXT IDC_MOVIES_PATH,49,26,121,14,ES_AUTOHSCROLL | + WS_DISABLED + PUSHBUTTON "Reset",IDC_ROM_DIR_RESET,228,6,50,14 + PUSHBUTTON "Reset",IDC_MOVIES_DIR_RESET,228,25,50,14 + PUSHBUTTON "Reset",IDC_BATTERY_DIR_RESET,228,45,50,14 + PUSHBUTTON "Reset",IDC_SAVE_DIR_RESET,228,64,50,14 + PUSHBUTTON "Reset",IDC_CAPTURE_DIR_RESET,228,83,50,14 +END + +IDD_CONFIG DIALOGEX 0, 0, 135, 211 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | + WS_SYSMENU +CAPTION "Joypad setup" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_EDIT_UP,47,5,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_DOWN,47,19,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_LEFT,47,33,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_RIGHT,47,47,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_A,47,61,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_B,47,75,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_L,47,89,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_R,47,103,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_SELECT,47,117,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_START,47,131,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_SPEED,47,145,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_CAPTURE,47,159,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_BUTTON_GS,47,173,81,12,ES_AUTOHSCROLL + PUSHBUTTON "OK",ID_OK,20,190,40,14 + PUSHBUTTON "Cancel",ID_CANCEL,74,190,40,14 + LTEXT "Up:",IDC_STATIC,5,5,35,10 + LTEXT "Down:",IDC_STATIC,5,19,35,10 + LTEXT "Left:",IDC_STATIC,5,33,35,10 + LTEXT "Right:",IDC_STATIC,5,47,35,10 + LTEXT "Button A:",IDC_STATIC,5,61,35,10 + LTEXT "Button B:",IDC_STATIC,5,75,35,10 + LTEXT "Button L:",IDC_STATIC,5,89,35,10 + LTEXT "Button R:",IDC_STATIC,5,103,35,10 + LTEXT "Select:",IDC_STATIC,5,117,35,10 + LTEXT "Start:",IDC_STATIC,5,131,35,10 + LTEXT "Speed:",IDC_STATIC,5,145,35,10 + LTEXT "Capture:",IDC_STATIC,5,159,35,10 + LTEXT "GS:",IDC_STATIC,5,173,35,10 +END + +IDD_CHEATS DIALOGEX 0, 0, 276, 253 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "Search for cheats" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,3,5,265,111 + CONTROL "Ol&d value",IDC_OLD_VALUE,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,11,129,46,10 + CONTROL "Specifi&c value",IDC_SPECIFIC_VALUE,"Button", + BS_AUTORADIOBUTTON,11,141,61,10 + CONTROL "&8 bits",IDC_SIZE_8,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,11,167,33,10 + CONTROL "&16 bits",IDC_SIZE_16,"Button",BS_AUTORADIOBUTTON,11, + 179,37,10 + CONTROL "&32 bits",IDC_SIZE_32,"Button",BS_AUTORADIOBUTTON,11, + 191,37,10 + CONTROL "&Equal",IDC_EQ,"Button",BS_AUTORADIOBUTTON | WS_GROUP, + 100,128,34,10 + CONTROL "&Not equal",IDC_NE,"Button",BS_AUTORADIOBUTTON,100,140, + 47,10 + CONTROL "&Less than",IDC_LT,"Button",BS_AUTORADIOBUTTON,100,152, + 47,10 + CONTROL "Le&ss or equal",IDC_LE,"Button",BS_AUTORADIOBUTTON,100, + 164,58,10 + CONTROL "&Greather than",IDC_GT,"Button",BS_AUTORADIOBUTTON,100, + 176,59,10 + CONTROL "G&reater or equal",IDC_GE,"Button",BS_AUTORADIOBUTTON, + 100,188,67,10 + CONTROL "S&igned",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,202,130,38,10 + CONTROL "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,202, + 142,46,10 + CONTROL "&Hexadecimal",IDC_HEXADECIMAL,"Button", + BS_AUTORADIOBUTTON,202,154,57,10 + CONTROL "search u&pdates vals",IDC_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,192,192,76,10 + EDITTEXT IDC_VALUE,95,211,172,14,ES_AUTOHSCROLL + PUSHBUTTON "&Start",IDC_START,15,237,50,14,WS_GROUP + PUSHBUTTON "S&earch",IDC_SEARCH,80,236,50,14 + PUSHBUTTON "&Add cheat",IDC_ADD_CHEAT,145,236,50,14 + DEFPUSHBUTTON "OK",ID_OK,210,236,50,14 + GROUPBOX "&Search type",IDC_STATIC,3,118,84,36 + GROUPBOX "&Data size",IDC_STATIC,3,158,84,44 + GROUPBOX "Compare type",IDC_STATIC,95,118,92,84 + GROUPBOX "Signed/Unsigned",IDC_STATIC,192,118,76,50 + LTEXT "Enter &value:",IDC_STATIC,3,214,69,8 + PUSHBUTTON "Refresh New &Values",IDC_CHEATREFRESHBUTTON,192,172,75, + 14,NOT WS_VISIBLE +END + +IDD_ADD_CHEAT DIALOG 0, 0, 186, 137 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Add cheat" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_ADDRESS,60,6,123,14,ES_AUTOHSCROLL + EDITTEXT IDC_VALUE,60,24,123,14,ES_AUTOHSCROLL + EDITTEXT IDC_DESC,60,42,123,14,ES_AUTOHSCROLL + CONTROL "8-bit",IDC_SIZE_8,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,11,70,29,10 + CONTROL "16-bit",IDC_SIZE_16,"Button",BS_AUTORADIOBUTTON,62,70, + 33,10 + CONTROL "32-bit",IDC_SIZE_32,"Button",BS_AUTORADIOBUTTON,117,70, + 33,10 + CONTROL "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,11,97,38,10 + CONTROL "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON,62, + 98,46,10 + CONTROL "&Hexadecimal",IDC_HEXADECIMAL,"Button", + BS_AUTORADIOBUTTON,117,98,57,10 + DEFPUSHBUTTON "&OK",ID_OK,36,116,50,14,WS_GROUP + PUSHBUTTON "&Cancel",ID_CANCEL,99,116,50,14 + LTEXT "&Value:",IDC_STATIC,3,27,54,8 + GROUPBOX "Number format",IDC_STATIC,3,88,180,24 + LTEXT "&Address:",IDC_STATIC,3,9,54,8 + GROUPBOX "Size",IDC_STATIC,3,60,180,24 + LTEXT "&Description:",IDC_STATIC,3,45,55,8 +END + +IDD_CHEAT_LIST DIALOG 0, 0, 280, 250 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Cheat list" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Restore &previous values",IDC_RESTORE,"Button", + BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,5,183,92,10 + PUSHBUTTON "&Code...",IDC_ADD_CODE,9,208,64,14,WS_GROUP + PUSHBUTTON "C&heat...",IDC_ADD_CHEAT,75,208,64,14 + PUSHBUTTON "&Gameshark...",IDC_ADD_GAMESHARK,141,208,64,14 + PUSHBUTTON "CodeBreaker...",IDC_ADD_CODEBREAKER,206,208,64,14 + PUSHBUTTON "&Remove",IDC_REMOVE,9,230,64,14 + PUSHBUTTON "Remove A&ll",IDC_REMOVE_ALL,75,230,64,14 + PUSHBUTTON "&Enable/Dis.",IDC_ENABLE,141,230,64,14 + DEFPUSHBUTTON "&OK",ID_OK,206,230,64,14,WS_GROUP + CONTROL "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | WS_BORDER | + WS_GROUP | WS_TABSTOP,5,15,269,156 + LTEXT "Status legend:",IDC_STATIC,6,3,46,8 + LTEXT "E: Enabled",IDC_STATIC,188,3,36,8 + LTEXT "D: Disabled",IDC_STATIC,234,3,38,8 + GROUPBOX "Add",IDC_STATIC,5,199,268,27 +END + +IDD_ASSOCIATIONS DIALOG 0, 0, 116, 95 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Associations" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL ".gb",IDC_GB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,15, + 26,10 + CONTROL ".sgb",IDC_SGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15, + 29,29,10 + CONTROL ".cgb",IDC_CGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15, + 43,30,10 + CONTROL ".gbc",IDC_GBC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15, + 57,30,10 + CONTROL ".gba",IDC_GBA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75, + 13,30,10 + CONTROL ".agb",IDC_AGB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75, + 27,30,10 + CONTROL ".bin",IDC_BIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75, + 41,27,10 + DEFPUSHBUTTON "OK",ID_OK,3,78,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,63,78,50,14 + GROUPBOX "GBA Types",IDC_STATIC,63,3,50,51 + GROUPBOX "GB Types",IDC_STATIC,3,3,50,69 +END + +IDD_GBA_ROM_INFO DIALOG 0, 0, 220, 142 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Rom information" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",ID_OK,84,121,50,14 + LTEXT "Game title:",IDC_STATIC,7,10,60,8 + LTEXT "Game code:",IDC_STATIC,7,24,60,8 + LTEXT "Maker code:",IDC_STATIC,7,38,60,8 + LTEXT "Main unit code:",IDC_STATIC,7,66,60,8 + LTEXT "Device type:",IDC_STATIC,7,80,60,8 + LTEXT "ROM version:",IDC_STATIC,7,94,60,8 + LTEXT "CRC:",IDC_STATIC,7,108,60,8 + LTEXT "",IDC_ROM_TITLE,80,10,133,8 + LTEXT "",IDC_ROM_GAME_CODE,80,24,133,8 + LTEXT "",IDC_ROM_MAKER_CODE,80,38,133,8 + LTEXT "",IDC_ROM_UNIT_CODE,80,66,133,8 + LTEXT "",IDC_ROM_DEVICE_TYPE,80,80,133,8 + LTEXT "",IDC_ROM_VERSION,80,94,133,8 + LTEXT "",IDC_ROM_CRC,80,108,133,8 + LTEXT "",IDC_ROM_MAKER_NAME,80,52,133,8 + LTEXT "Maker name:",IDC_STATIC,7,52,60,8 +END + +IDD_GB_ROM_INFO DIALOG 0, 0, 220, 225 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Rom information" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",ID_OK,84,200,50,14 + LTEXT "Game title:",IDC_STATIC,7,10,60,8 + LTEXT "Maker code:",IDC_STATIC,7,38,60,8 + LTEXT "Unit code:",IDC_STATIC,7,68,60,8 + LTEXT "Cartridge type:",IDC_STATIC,7,82,60,8 + LTEXT "ROM version:",IDC_STATIC,7,152,60,8 + LTEXT "CRC:",IDC_STATIC,7,166,60,8 + LTEXT "",IDC_ROM_TITLE,80,10,133,8 + LTEXT "",IDC_ROM_MAKER_CODE,80,38,133,8 + LTEXT "",IDC_ROM_UNIT_CODE,80,68,133,8 + LTEXT "",IDC_ROM_DEVICE_TYPE,80,82,133,8 + LTEXT "",IDC_ROM_VERSION,80,152,133,8 + LTEXT "",IDC_ROM_CRC,80,166,133,8 + LTEXT "Color:",IDC_STATIC,7,24,60,8 + LTEXT "",IDC_ROM_COLOR,80,24,133,8 + LTEXT "ROM size:",IDC_STATIC,7,96,60,8 + LTEXT "",IDC_ROM_SIZE,80,96,133,8 + LTEXT "RAM size:",IDC_STATIC,7,110,60,8 + LTEXT "",IDC_ROM_RAM_SIZE,80,110,133,8 + LTEXT "Dest. code:",IDC_STATIC,7,124,60,8 + LTEXT "",IDC_ROM_DEST_CODE,80,124,133,8 + LTEXT "License code:",IDC_STATIC,7,138,60,8 + LTEXT "",IDC_ROM_LIC_CODE,80,138,133,8 + LTEXT "Checksum:",IDC_STATIC,7,180,60,8 + LTEXT "",IDC_ROM_CHECKSUM,80,180,133,8 + LTEXT "",IDC_ROM_MAKER_NAME2,80,52,133,8 + LTEXT "Maker name:",IDC_STATIC,7,52,60,8 +END + +IDD_GB_CHEAT_LIST DIALOG 0, 0, 286, 221 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Gameboy Cheat List" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "",IDC_CHEAT_LIST,"SysListView32",LVS_REPORT | WS_BORDER | + WS_GROUP | WS_TABSTOP,9,20,269,156 + PUSHBUTTON "Add &GameGenie...",IDC_ADD_GG_CHEAT,9,183,80,14, + WS_GROUP + PUSHBUTTON "&Add GameShark...",IDC_ADD_GS_CHEAT,103,183,80,14, + WS_GROUP + PUSHBUTTON "&Remove",IDC_REMOVE,197,183,80,14 + PUSHBUTTON "Remove A&ll",IDC_REMOVE_ALL,9,202,80,14 + PUSHBUTTON "&Enable/Dis.",IDC_ENABLE,103,202,80,14 + DEFPUSHBUTTON "&OK",ID_OK,197,202,80,14 + LTEXT "Status legend:",IDC_STATIC,10,9,46,8 + LTEXT "E: Enabled",IDC_STATIC,195,9,36,8 + LTEXT "D: Disabled",IDC_STATIC,241,9,38,8 +END + +IDD_ADD_CHEAT_DLG DIALOG 0, 0, 182, 107 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Title" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_DESC,60,7,120,14,ES_AUTOHSCROLL + EDITTEXT IDC_CODE,60,23,120,58,ES_MULTILINE | ES_UPPERCASE | + ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN + DEFPUSHBUTTON "OK",ID_OK,33,86,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,99,86,50,14 + LTEXT "&Description:",IDC_STATIC,3,10,54,8 + LTEXT "&Code:",IDC_STATIC,3,29,54,8 +END + +IDD_GB_PRINTER DIALOG 0, 0, 178, 209 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "GB Printer" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "&1x",IDC_1X,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13, + 166,22,10 + CONTROL "&2x",IDC_2X,"Button",BS_AUTORADIOBUTTON,55,166,23,10 + CONTROL "&3x",IDC_3X,"Button",BS_AUTORADIOBUTTON,98,166,23,10 + CONTROL "&4x",IDC_4X,"Button",BS_AUTORADIOBUTTON,141,166,23,10 + DEFPUSHBUTTON "&Print...",ID_PRINT,7,190,50,14,WS_GROUP + PUSHBUTTON "&Save...",ID_SAVE,64,190,50,14 + PUSHBUTTON "&Close",ID_OK,121,190,50,14 + CONTROL "",IDC_GB_PRINTER,"Static",SS_BLACKFRAME | WS_GROUP,7,6, + 162,146 + GROUPBOX "Print Size",IDC_STATIC,7,156,162,25 +END + +IDD_MOTION_CONFIG DIALOG 0, 0, 135, 78 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Motion Sensor" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_EDIT_UP,47,2,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_DOWN,47,16,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_LEFT,47,30,81,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_RIGHT,47,44,81,12,ES_AUTOHSCROLL + PUSHBUTTON "OK",ID_OK,20,60,40,14 + PUSHBUTTON "Cancel",ID_CANCEL,74,60,40,14 + LTEXT "Up:",IDC_STATIC,5,2,35,10 + LTEXT "Down:",IDC_STATIC,5,16,35,10 + LTEXT "Left:",IDC_STATIC,5,30,35,10 + LTEXT "Right:",IDC_STATIC,5,44,35,10 +END + +IDD_LANG_SELECT DIALOG 0, 0, 186, 68 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Language selection" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_LANG_STRING,140,25,40,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",ID_OK,30,49,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,104,49,50,14 + LTEXT "Current system language is:",IDC_STATIC,6,9,123,8 + LTEXT "Enter language name (3 letter):",IDC_STATIC,6,30,127,8 + LTEXT "",IDC_LANG_NAME,140,9,40,8 +END + +IDD_CODE_SELECT DIALOG 0, 0, 316, 235 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select codes to import" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",ID_OK,91,214,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,174,214,50,14 + LISTBOX IDC_GAME_LIST,7,7,302,205,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | + WS_TABSTOP +END + +IDD_MAP_VIEW DIALOG 0, 0, 322, 238 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Map view" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Frame 0",IDC_FRAME_0,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,22,41,10 + CONTROL "Frame 1",IDC_FRAME_1,"Button",BS_AUTORADIOBUTTON,13,36, + 41,10 + CONTROL "BG0",IDC_BG0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13, + 63,30,10 + CONTROL "BG1",IDC_BG1,"Button",BS_AUTORADIOBUTTON,13,77,30,10 + CONTROL "BG2",IDC_BG2,"Button",BS_AUTORADIOBUTTON,13,91,30,10 + CONTROL "BG3",IDC_BG3,"Button",BS_AUTORADIOBUTTON,13,105,30,10 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,7,122,68,10 + CONTROL "Auto update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,7,134,55,10 + PUSHBUTTON "&Refresh",IDC_REFRESH,25,217,50,14,WS_GROUP + PUSHBUTTON "&Save...",IDC_SAVE,88,217,50,14,WS_GROUP + PUSHBUTTON "&Close",IDC_CLOSE,155,217,50,14 + CONTROL "MapView",IDC_MAP_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,187,15,128,128 + CONTROL "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,7,148,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,187,164, + 48,47 + LTEXT "",IDC_R,245,173,50,8 + LTEXT "",IDC_G,245,185,50,8 + LTEXT "",IDC_B,245,197,50,8 + GROUPBOX "Frame",IDC_STATIC,7,11,63,37 + GROUPBOX "Background",IDC_STATIC,7,52,63,67 + LTEXT "",IDC_XY,129,95,53,8 + LTEXT "Mode:",IDC_STATIC,80,15,34,8 + LTEXT "",IDC_MODE,130,15,53,8 + LTEXT "Map Base:",IDC_STATIC,80,25,35,8 + LTEXT "",IDC_MAPBASE,130,25,53,8 + LTEXT "Char Base:",IDC_STATIC,80,35,36,8 + LTEXT "",IDC_CHARBASE,130,35,53,8 + LTEXT "Size:",IDC_STATIC,80,45,37,8 + LTEXT "",IDC_DIM,130,45,53,8 + LTEXT "Colors:",IDC_STATIC,80,55,37,8 + LTEXT "",IDC_NUMCOLORS,130,55,53,8 + LTEXT "Priority:",IDC_STATIC,80,65,37,8 + LTEXT "",IDC_PRIORITY,130,65,53,8 + LTEXT "Mosaic:",IDC_STATIC,80,75,37,8 + LTEXT "",IDC_MOSAIC,130,75,53,8 + LTEXT "Overflow:",IDC_STATIC,80,85,37,8 + LTEXT "",IDC_OVERFLOW,130,85,53,8 + LTEXT "Address:",IDC_STATIC,80,105,37,8 + LTEXT "",IDC_ADDRESS,130,105,53,8 + LTEXT "Tile:",IDC_STATIC,80,115,37,8 + LTEXT "",IDC_TILE_NUM,130,115,53,8 + LTEXT "Flip:",IDC_STATIC,80,125,37,8 + LTEXT "",IDC_FLIP,130,125,53,8 + LTEXT "Palette:",IDC_STATIC,80,135,37,8 + LTEXT "",IDC_PALETTE_NUM,130,135,53,8 +END + +IDD_PALETTE_VIEW DIALOG 0, 0, 316, 266 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Palette View" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Save BG...",IDC_SAVE_BG,30,245,50,14 + PUSHBUTTON "Save OBJ...",IDC_SAVE_OBJ,98,245,50,14 + PUSHBUTTON "&Refresh",IDC_REFRESH2,166,245,50,14 + PUSHBUTTON "&Close",IDC_CLOSE,234,245,50,14 + LTEXT "",IDC_ADDRESS,53,168,50,8 + LTEXT "",IDC_R,53,180,50,8 + LTEXT "",IDC_G,53,192,50,8 + LTEXT "",IDC_B,53,204,50,8 + LTEXT "",IDC_VALUE,53,216,50,8 + CONTROL "Custom1",IDC_COLOR,"VbaColorControl",WS_TABSTOP,161,168, + 50,50 + CONTROL "PaletteViewBG",IDC_PALETTE_VIEW,"VbaPaletteViewControl", + WS_TABSTOP,12,30,128,128 + CONTROL "PaletteViewBG",IDC_PALETTE_VIEW_OBJ, + "VbaPaletteViewControl",WS_TABSTOP,166,30,128,128 + GROUPBOX "Background",IDC_STATIC,7,20,137,143 + GROUPBOX "Sprite",IDC_STATIC,161,20,137,143 + LTEXT "Address:",IDC_STATIC,7,168,38,8 + LTEXT "R:",IDC_STATIC,7,180,41,8 + LTEXT "G:",IDC_STATIC,7,192,43,8 + LTEXT "B:",IDC_STATIC,7,204,38,8 + LTEXT "Value:",IDC_STATIC,7,216,38,8 + LTEXT "Click on a color for more information",IDC_STATIC,7,7, + 302,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,229,71,10 +END + +IDD_MEM_VIEWER DIALOGEX 0, 0, 380, 178 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Memory viewer" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + COMBOBOX IDC_ADDRESSES,7,7,109,30,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + CONTROL "8-bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP, + 120,9,29,10 + CONTROL "16-bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,154,9,33, + 10 + CONTROL "32-bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,192,9,33, + 10 + EDITTEXT IDC_ADDRESS,238,7,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | + ES_WANTRETURN | WS_GROUP + DEFPUSHBUTTON "&Go",IDC_GO,323,7,50,14,WS_GROUP + CONTROL "Viewer",IDC_VIEWER,"VbaMemoryViewer",WS_TABSTOP,7,22, + 366,112 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,139,71,10 + PUSHBUTTON "&Refresh",IDC_REFRESH,67,157,50,14 + PUSHBUTTON "&Load...",IDC_LOAD,132,157,50,14 + PUSHBUTTON "&Save...",IDC_SAVE,197,157,50,14 + PUSHBUTTON "&Close",IDC_CLOSE,262,157,50,14 + LTEXT "Current address:",IDC_CURRENT_ADDRESS_LABEL,210,142,77, + 8 + EDITTEXT IDC_CURRENT_ADDRESS,291,139,82,14,ES_RIGHT | + ES_AUTOHSCROLL | WS_DISABLED + CONTROL "Decimal Display",IDC_DECIMAL_DISPLAY,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,102,139,66,10 +END + +IDD_OAM_VIEW DIALOG 0, 0, 234, 185 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Oam Viewer" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_SPRITE,7,19,76,14,ES_RIGHT | ES_AUTOHSCROLL | + ES_NUMBER + SCROLLBAR IDC_SCROLLBAR,7,33,76,11 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,138,79,10 + PUSHBUTTON "&Refresh",IDC_REFRESH,7,164,50,14,WS_GROUP + PUSHBUTTON "&Save...",IDC_SAVE,91,164,50,14,WS_GROUP + PUSHBUTTON "&Close",IDC_CLOSE,177,164,50,14 + CONTROL "MapView",IDC_OAM_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,87,7,64,64 + CONTROL "Zoom",IDC_OAM_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,163,7,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,87,79,48, + 47 + LTEXT "",IDC_POS,31,47,50,8 + LTEXT "",IDC_MODE,31,57,50,8 + LTEXT "",IDC_COLORS,31,67,50,8 + LTEXT "",IDC_PALETTE,31,77,50,8 + LTEXT "",IDC_TILE,31,87,50,8 + LTEXT "",IDC_PRIO,31,97,50,8 + LTEXT "",IDC_SIZE2,31,107,50,8 + LTEXT "",IDC_ROT,31,117,50,8 + LTEXT "",IDC_FLAGS,31,127,50,8 + LTEXT "",IDC_R,145,88,50,8 + LTEXT "",IDC_G,145,100,50,8 + LTEXT "",IDC_B,145,112,50,8 + LTEXT "Pos:",IDC_STATIC,7,47,24,8 + LTEXT "Mode:",IDC_STATIC,7,57,24,8 + LTEXT "Colors:",IDC_STATIC,7,67,24,8 + LTEXT "Pal:",IDC_STATIC,7,77,24,8 + LTEXT "Tile:",IDC_STATIC,7,87,24,8 + LTEXT "Prio:",IDC_STATIC,7,97,24,8 + LTEXT "Size:",IDC_STATIC,7,107,24,8 + LTEXT "Sprite:",IDC_STATIC,7,7,50,8 + LTEXT "Rot.:",IDC_STATIC,7,117,24,8 + LTEXT "Flags:",IDC_STATIC,7,127,24,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,150,71,10 +END + +IDD_ACCEL_EDITOR DIALOGEX 0, 0, 320, 130 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Accelerator Editor" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + LTEXT "&Commands:",IDC_STATIC,9,9,38,8 + LISTBOX IDC_COMMANDS,9,18,139,83,LBS_SORT | LBS_NOINTEGRALHEIGHT | + LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP + LTEXT "Current &Keys:",IDC_STATIC1,156,9,43,8 + LISTBOX IDC_CURRENTS,156,18,100,52,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",ID_OK,263,9,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,263,25,50,14 + LTEXT "Enter &New Shortcut Key:",IDC_STATIC3,156,74,79,8 + EDITTEXT IDC_EDIT_KEY,156,89,100,12,ES_AUTOHSCROLL + PUSHBUTTON "&Assign",IDC_ASSIGN,263,108,50,14 + PUSHBUTTON "&Remove",IDC_REMOVE,263,92,50,14 + PUSHBUTTON "Re&set All",IDC_RESET,283,52,6,14,NOT WS_VISIBLE | + WS_DISABLED + LTEXT "Static",IDC_ALREADY_AFFECTED,8,114,111,10, + SS_CENTERIMAGE + LTEXT "Currently assigned to :",IDC_STATIC2,8,104,73,10 + LISTBOX IDC_COMMANDS_HIDDEN,275,50,8,9,NOT LBS_NOTIFY | LBS_SORT | + LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | NOT + WS_VISIBLE | WS_DISABLED | NOT WS_BORDER | WS_VSCROLL | + WS_TABSTOP +END + +IDD_TILE_VIEWER DIALOG 0, 0, 326, 266 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Tile Viewer" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "16",IDC_16_COLORS,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,20,24,10 + CONTROL "256",IDC_256_COLORS,"Button",BS_AUTORADIOBUTTON,13,30, + 28,10 + CONTROL "0x6000000",IDC_CHARBASE_0,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,57,51,10 + CONTROL "0x6004000",IDC_CHARBASE_1,"Button",BS_AUTORADIOBUTTON, + 13,67,51,10 + CONTROL "0x6008000",IDC_CHARBASE_2,"Button",BS_AUTORADIOBUTTON, + 13,77,51,10 + CONTROL "0x600C000",IDC_CHARBASE_3,"Button",BS_AUTORADIOBUTTON, + 13,87,52,10 + CONTROL "0x6010000",IDC_CHARBASE_4,"Button",BS_AUTORADIOBUTTON, + 13,97,49,10 + CONTROL "Slider1",IDC_PALETTE_SLIDER,"msctls_trackbar32", + TBS_AUTOTICKS | WS_GROUP | WS_TABSTOP,1,124,76,22 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,149,79,10 + PUSHBUTTON "Refresh",IDC_REFRESH,7,245,50,14,WS_GROUP + PUSHBUTTON "Save...",IDC_SAVE,138,245,50,14 + PUSHBUTTON "Close",IDC_CLOSE,269,245,50,14 + CONTROL "Custom1",IDC_TILE_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,191,7,128,128 + GROUPBOX "Colors",IDC_STATIC,7,7,66,38 + GROUPBOX "Char Base",IDC_STATIC,7,46,65,64 + CONTROL "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,7,174,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,98,183,48, + 47 + LTEXT "",IDC_R,156,192,50,8 + LTEXT "",IDC_G,156,204,50,8 + LTEXT "",IDC_B,156,216,50,8 + LTEXT "Palette:",IDC_STATIC,7,113,65,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,160,71,10 + LTEXT "Tile:",IDC_STATIC,79,14,41,8 + LTEXT "Address:",IDC_STATIC,79,26,41,8 + LTEXT "",IDC_TILE_NUMBER,135,14,50,8 + LTEXT "",IDC_ADDRESS,135,26,50,8 +END + +IDD_GB_COLORS DIALOGEX 0, 0, 169, 121 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Gameboy Mono Colors" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "Default",IDC_DEFAULT,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,7,7,39,10 + CONTROL "User 1",IDC_USER1,"Button",BS_AUTORADIOBUTTON,67,7,37, + 10 + CONTROL "User 2",IDC_USER2,"Button",BS_AUTORADIOBUTTON,125,7,37, + 10 + COMBOBOX IDC_PREDEFINED,7,21,155,30,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "",IDC_COLOR_BG0,15,47,28,14,WS_GROUP + PUSHBUTTON "",IDC_COLOR_BG1,52,47,28,14 + PUSHBUTTON "",IDC_COLOR_BG2,89,47,28,14 + PUSHBUTTON "",IDC_COLOR_BG3,126,47,28,14 + PUSHBUTTON "",IDC_COLOR_OB0,15,78,28,14 + PUSHBUTTON "",IDC_COLOR_OB1,52,78,28,14 + PUSHBUTTON "",IDC_COLOR_OB2,89,78,28,14 + PUSHBUTTON "",IDC_COLOR_OB3,126,78,28,14 + PUSHBUTTON "Reset",IDC_RESET,7,100,50,14 + DEFPUSHBUTTON "OK",ID_OK,59,100,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,111,100,50,14 + GROUPBOX "Background",IDC_STATIC,8,37,154,29 + GROUPBOX "Sprite",IDC_STATIC,8,67,154,30 +END + +IDD_DISASSEMBLE DIALOG 0, 0, 402, 225 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Disassemble" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Automatic",IDC_AUTOMATIC,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,7,9,47,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,62,9,32,10 + CONTROL "THUMB",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,103,9,42, + 10 + EDITTEXT IDC_ADDRESS,158,7,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | + WS_GROUP + DEFPUSHBUTTON "Go",IDC_GO,232,7,50,14 + LISTBOX IDC_DISASSEMBLE,7,25,276,161,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_TABSTOP + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,191,71,10 + PUSHBUTTON "Refresh",IDC_REFRESH,120,204,50,14 + PUSHBUTTON "Next",IDC_NEXT,233,204,50,14 + PUSHBUTTON "Close",IDC_CLOSE,346,204,50,14 + LTEXT "R0:",IDC_STATIC,309,7,18,8 + LTEXT "R1:",IDC_STATIC,309,15,18,8 + LTEXT "R2:",IDC_STATIC,309,23,18,8 + LTEXT "R3:",IDC_STATIC,309,31,18,8 + LTEXT "R4:",IDC_STATIC,309,39,18,8 + LTEXT "R5:",IDC_STATIC,309,47,18,8 + LTEXT "R6:",IDC_STATIC,309,55,18,8 + LTEXT "R7:",IDC_STATIC,309,63,18,8 + LTEXT "",IDC_R0,344,7,52,8 + LTEXT "",IDC_R1,344,15,52,8 + LTEXT "",IDC_R2,344,23,52,8 + LTEXT "",IDC_R3,344,31,52,8 + LTEXT "",IDC_R4,344,39,52,8 + LTEXT "",IDC_R5,344,47,52,8 + LTEXT "",IDC_R6,344,55,52,8 + LTEXT "",IDC_R7,344,63,52,8 + LTEXT "",IDC_R8,344,71,52,8 + LTEXT "",IDC_R9,344,79,52,8 + LTEXT "",IDC_R10,344,87,52,8 + LTEXT "",IDC_R11,344,95,52,8 + LTEXT "",IDC_R12,344,103,52,8 + LTEXT "",IDC_R13,344,111,52,8 + LTEXT "",IDC_R14,344,119,52,8 + LTEXT "",IDC_R15,344,127,52,8 + LTEXT "R8:",IDC_STATIC,309,71,18,8 + LTEXT "R9:",IDC_STATIC,309,79,18,8 + LTEXT "R10:",IDC_STATIC,309,87,18,8 + LTEXT "R11:",IDC_STATIC,309,95,18,8 + LTEXT "R12:",IDC_STATIC,309,103,18,8 + LTEXT "R13:",IDC_STATIC,309,111,18,8 + LTEXT "R14:",IDC_STATIC,309,119,18,8 + LTEXT "R15:",IDC_STATIC,309,127,18,8 + LTEXT "",IDC_R16,344,135,52,8 + LTEXT "R16:",IDC_STATIC,309,135,20,8 + CONTROL "N",IDC_N,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,309,146,21,10 + CONTROL "Z",IDC_Z,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,309,156,21,10 + CONTROL "C",IDC_C,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,309,166,21,10 + CONTROL "V",IDC_V,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,309,176,21,10 + CONTROL "F",IDC_F,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,342,156,20,10 + CONTROL "I",IDC_I,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,342,146,18,10 + CONTROL "T",IDC_T,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,342,166,21,10 + LTEXT "Mode:",IDC_STATIC,341,176,21,8 + LTEXT "",IDC_MODE,376,176,20,8 + SCROLLBAR IDC_VSCROLL,283,25,10,161,SBS_VERT + PUSHBUTTON "Goto R15",IDC_GOPC,7,204,50,14 +END + +IDD_GDB_PORT DIALOG 0, 0, 186, 51 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "GDB connection" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",ID_OK,34,30,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,102,30,50,14 + LTEXT "Port to wait for connection:",IDC_STATIC,7,10,105,8 + EDITTEXT IDC_PORT,125,7,54,14,ES_RIGHT | ES_AUTOHSCROLL +END + +IDD_GDB_WAITING DIALOG 0, 0, 186, 44 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Waiting..." +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Cancel",ID_CANCEL,67,23,50,14 + LTEXT "Waiting for connection on port:",IDC_STATIC,7,7,117,8 + LTEXT "",IDC_PORT,143,7,36,8 +END + +IDD_LOGGING DIALOG 0, 0, 366, 218 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "Logging" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "SWI",IDC_VERBOSE_SWI,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,17,87,10 + CONTROL "Unaligned memory",IDC_VERBOSE_UNALIGNED_ACCESS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,10,30,87,10 + CONTROL "Illegal write",IDC_VERBOSE_ILLEGAL_WRITE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,10,43,87,10 + CONTROL "Illegal read",IDC_VERBOSE_ILLEGAL_READ,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,10,56,87,10 + CONTROL "DMA 0",IDC_VERBOSE_DMA0,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,69,87,10 + CONTROL "DMA 1",IDC_VERBOSE_DMA1,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,82,87,10 + CONTROL "DMA 2",IDC_VERBOSE_DMA2,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,95,87,10 + CONTROL "DMA 3",IDC_VERBOSE_DMA3,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,108,87,10 + CONTROL "Undefined instruction",IDC_VERBOSE_UNDEFINED,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,10,121,87,10 + CONTROL "AGBPrint",IDC_VERBOSE_AGBPRINT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,10,134,87,10 + EDITTEXT IDC_LOG,107,7,252,183,ES_MULTILINE | ES_AUTOVSCROLL | + ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL + PUSHBUTTON "Save...",IDC_SAVE,75,197,50,14 + PUSHBUTTON "Clear",IDC_CLEAR,137,197,50,14 + DEFPUSHBUTTON "OK",ID_OK,197,197,50,14 + GROUPBOX "Verbose",IDC_STATIC,7,7,93,142 +END + +IDD_EXPORT_SPS DIALOG 0, 0, 248, 148 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Export Gameshark Snapshot" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_TITLE,84,7,157,14,ES_AUTOHSCROLL + EDITTEXT IDC_DESC,84,27,157,14,ES_AUTOHSCROLL + EDITTEXT IDC_NOTES,84,47,157,73,ES_MULTILINE | ES_AUTOHSCROLL | + ES_WANTRETURN + DEFPUSHBUTTON "OK",ID_OK,67,127,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,130,127,50,14 + LTEXT "Title:",IDC_STATIC,7,8,62,8 + LTEXT "Description:",IDC_STATIC,7,28,63,8 + LTEXT "Notes:",IDC_STATIC,7,48,60,8 +END + +IDD_ADDR_SIZE DIALOG 0, 0, 186, 67 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Enter address and size" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_ADDRESS,99,6,80,14,ES_AUTOHSCROLL + EDITTEXT IDC_SIZE_CONTROL,99,26,80,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",ID_OK,34,46,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,102,46,50,14 + LTEXT "Address:",IDC_STATIC,7,11,65,8 + LTEXT "Size:",IDC_STATIC,7,29,65,8 +END + +IDD_MODES DIALOG 0, 0, 208, 129 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select video mode" +FONT 8, "MS Sans Serif" +BEGIN + LISTBOX IDC_MODES,7,18,194,80,LBS_SORT | LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",ID_OK,45,108,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,112,108,50,14 + LTEXT "Available video modes:",IDC_STATIC,7,7,194,8 +END + +IDD_DRIVERS DIALOG 0, 0, 208, 121 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select video driver" +FONT 8, "MS Sans Serif" +BEGIN + LISTBOX IDC_DRIVERS,7,17,194,80,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",ID_OK,45,104,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,112,104,50,14 + LTEXT "Available drivers:",IDC_STATIC,7,7,194,8 +END + +IDD_THROTTLE DIALOG 0, 0, 186, 63 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Throttle" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_THROTTLE,7,20,172,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",ID_OK,37,42,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,99,42,50,14 + LTEXT "Enter desired throttle (5%...1000%):",IDC_STATIC,7,7, + 172,8 +END + +IDD_GB_DISASSEMBLE DIALOG 0, 0, 344, 225 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "GB Disassemble" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_ADDRESS,7,7,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | + WS_GROUP + DEFPUSHBUTTON "Go",IDC_GO,81,7,50,14 + LISTBOX IDC_DISASSEMBLE,7,25,222,161,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_TABSTOP + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,191,71,10 + PUSHBUTTON "Refresh",IDC_REFRESH,100,204,50,14 + PUSHBUTTON "Next",IDC_NEXT,193,204,50,14 + PUSHBUTTON "Close",IDC_CLOSE,287,204,50,14 + LTEXT "AF:",IDC_STATIC,250,25,18,8 + LTEXT "BC:",IDC_STATIC,250,35,18,8 + LTEXT "DE:",IDC_STATIC,250,45,18,8 + LTEXT "HL:",IDC_STATIC,250,55,18,8 + LTEXT "IFF:",IDC_STATIC,250,85,18,8 + LTEXT "",IDC_R0,285,25,52,8 + LTEXT "",IDC_R1,285,35,52,8 + LTEXT "",IDC_R2,285,45,52,8 + LTEXT "",IDC_R3,285,55,52,8 + LTEXT "",IDC_R6,285,85,52,8 + CONTROL "N",IDC_N,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,250,109,21,10 + CONTROL "Z",IDC_Z,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,250,97,21,10 + CONTROL "C",IDC_C,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,250,133,21,10 + CONTROL "H",IDC_H,"Button",BS_AUTOCHECKBOX | WS_DISABLED | + WS_TABSTOP,250,121,21,10 + SCROLLBAR IDC_VSCROLL,229,25,10,161,SBS_VERT + PUSHBUTTON "Goto PC",IDC_GOPC,7,204,50,14 + LTEXT "SP:",IDC_STATIC,250,65,18,8 + LTEXT "",IDC_R4,285,65,52,8 + LTEXT "PC:",IDC_STATIC,250,75,18,8 + LTEXT "",IDC_R5,285,75,52,8 +END + +IDD_GB_OAM_VIEW DIALOG 0, 0, 234, 185 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "GB Oam Viewer" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_SPRITE,7,19,76,14,ES_RIGHT | ES_AUTOHSCROLL | + ES_NUMBER + SCROLLBAR IDC_SCROLLBAR,7,33,76,11 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,138,79,10 + PUSHBUTTON "&Refresh",IDC_REFRESH,7,164,50,14,WS_GROUP + PUSHBUTTON "&Save...",IDC_SAVE,91,164,50,14,WS_GROUP + PUSHBUTTON "&Close",IDC_CLOSE,177,164,50,14 + CONTROL "MapView",IDC_OAM_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,87,7,64,64 + CONTROL "Zoom",IDC_OAM_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,163,7,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,87,79,48, + 47 + LTEXT "",IDC_POS,31,47,50,8 + LTEXT "",IDC_PALETTE,31,87,50,8 + LTEXT "",IDC_TILE,31,57,50,8 + LTEXT "",IDC_PRIO,31,67,50,8 + LTEXT "",IDC_OAP,31,77,50,8 + LTEXT "",IDC_FLAGS,31,97,50,8 + LTEXT "",IDC_R,145,88,50,8 + LTEXT "",IDC_G,145,100,50,8 + LTEXT "",IDC_B,145,112,50,8 + LTEXT "Pos:",IDC_STATIC,7,47,24,8 + LTEXT "Pal:",IDC_STATIC,7,87,24,8 + LTEXT "Tile:",IDC_STATIC,7,57,24,8 + LTEXT "Prio:",IDC_STATIC,7,67,24,8 + LTEXT "OAP:",IDC_STATIC,7,77,24,8 + LTEXT "Sprite:",IDC_STATIC,7,7,50,8 + LTEXT "Flags:",IDC_STATIC,7,97,24,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,150,71,10 + LTEXT "",IDC_BANK,31,107,50,8 + LTEXT "Bank:",IDC_STATIC,7,107,24,8 +END + +IDD_GB_TILE_VIEWER DIALOG 0, 0, 326, 238 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "GB Tile Viewer" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "0",IDC_BANK_0,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13, + 20,20,10 + CONTROL "1",IDC_BANK_1,"Button",BS_AUTORADIOBUTTON,13,30,20,10 + CONTROL "0x8000",IDC_CHARBASE_0,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,57,39,10 + CONTROL "0x8800",IDC_CHARBASE_1,"Button",BS_AUTORADIOBUTTON,13, + 67,39,10 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,122,79,10 + PUSHBUTTON "Refresh",IDC_REFRESH,7,217,50,14,WS_GROUP + PUSHBUTTON "Save...",IDC_SAVE,138,217,50,14 + PUSHBUTTON "Close",IDC_CLOSE,269,217,50,14 + CONTROL "Custom1",IDC_TILE_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,191,7,128,128 + GROUPBOX "VRAM Bank",IDC_STATIC,7,7,66,38 + GROUPBOX "Char Base",IDC_STATIC,7,46,65,35 + CONTROL "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,7,147,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,98,156,48, + 47 + LTEXT "",IDC_R,156,164,50,8 + LTEXT "",IDC_G,156,176,50,8 + LTEXT "",IDC_B,156,188,50,8 + LTEXT "Palette:",IDC_STATIC,7,86,65,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,133,71,10 + LTEXT "Tile:",IDC_STATIC,79,14,41,8 + LTEXT "Address:",IDC_STATIC,79,26,41,8 + LTEXT "",IDC_TILE_NUMBER,135,14,50,8 + LTEXT "",IDC_ADDRESS,135,26,50,8 + CONTROL "Slider1",IDC_PALETTE_SLIDER,"msctls_trackbar32", + TBS_AUTOTICKS | WS_GROUP | WS_TABSTOP,1,98,76,22 +END + +IDD_GB_MAP_VIEW DIALOG 0, 0, 322, 238 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +CAPTION "GB Map Viewer" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "0x8000",IDC_BANK_0,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,22,39,10 + CONTROL "0x8800",IDC_BANK_1,"Button",BS_AUTORADIOBUTTON,13,36,39, + 10 + CONTROL "0x9800",IDC_BG0,"Button",BS_AUTORADIOBUTTON | WS_GROUP, + 13,63,39,10 + CONTROL "0x9C00",IDC_BG1,"Button",BS_AUTORADIOBUTTON,13,77,40,10 + CONTROL "Stretch to fit",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,122,68,10 + PUSHBUTTON "&Refresh",IDC_REFRESH,25,217,50,14,WS_GROUP + PUSHBUTTON "&Save...",IDC_SAVE,88,217,50,14,WS_GROUP + PUSHBUTTON "&Close",IDC_CLOSE,155,217,50,14 + CONTROL "MapView",IDC_MAP_VIEW,"VbaBitmapControl",WS_GROUP | + WS_TABSTOP,187,15,128,128 + CONTROL "Zoom",IDC_MAP_VIEW_ZOOM,"VbaZoomControl",WS_GROUP | + WS_TABSTOP,7,148,64,64 + CONTROL "Color",IDC_COLOR,"VbaColorControl",WS_TABSTOP,187,164, + 48,47 + LTEXT "",IDC_R,245,173,50,8 + LTEXT "",IDC_G,245,185,50,8 + LTEXT "",IDC_B,245,197,50,8 + GROUPBOX "Char Base",IDC_STATIC,7,11,63,37 + GROUPBOX "Map Base",IDC_STATIC,7,52,63,41 + CONTROL "Auto update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,134,55,10 + LTEXT "",IDC_XY,129,18,53,8 + LTEXT "Priority:",IDC_STATIC,80,68,37,8 + LTEXT "",IDC_PRIORITY,130,68,53,8 + LTEXT "Address:",IDC_STATIC,80,28,37,8 + LTEXT "",IDC_ADDRESS,130,28,53,8 + LTEXT "Tile:",IDC_STATIC,80,38,37,8 + LTEXT "",IDC_TILE_NUM,130,38,53,8 + LTEXT "Flip:",IDC_STATIC,80,48,37,8 + LTEXT "",IDC_FLIP,130,48,53,8 + LTEXT "Palette:",IDC_STATIC,80,58,37,8 + LTEXT "",IDC_PALETTE_NUM,130,58,53,8 +END + +IDD_GB_PALETTE_VIEW DIALOG 0, 0, 196, 234 +STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "GB Palette Viewer" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Save BG...",IDC_SAVE_BG,7,191,50,14 + PUSHBUTTON "Save OBJ...",IDC_SAVE_OBJ,73,191,50,14 + PUSHBUTTON "&Refresh",IDC_REFRESH2,139,191,50,14 + PUSHBUTTON "&Close",IDC_CLOSE,73,213,50,14 + LTEXT "",IDC_ADDRESS,53,117,50,8 + LTEXT "",IDC_R,53,129,50,8 + LTEXT "",IDC_G,53,141,50,8 + LTEXT "",IDC_B,53,153,50,8 + LTEXT "",IDC_VALUE,53,165,50,8 + CONTROL "Custom1",IDC_COLOR,"VbaColorControl",WS_TABSTOP,119,117, + 50,50 + CONTROL "PaletteViewBG",IDC_PALETTE_VIEW,"VbaPaletteViewControl", + WS_TABSTOP,11,30,64,64 + CONTROL "PaletteViewBG",IDC_PALETTE_VIEW_OBJ, + "VbaPaletteViewControl",WS_TABSTOP,120,30,64,64 + GROUPBOX "BG",IDC_STATIC,6,20,74,81 + GROUPBOX "Sprite",IDC_STATIC,115,20,74,81 + LTEXT "Index:",IDC_STATIC,7,117,38,8 + LTEXT "R:",IDC_STATIC,7,129,41,8 + LTEXT "G:",IDC_STATIC,7,141,43,8 + LTEXT "B:",IDC_STATIC,7,153,38,8 + LTEXT "Value:",IDC_STATIC,7,165,38,8 + LTEXT "Click on a color for more information",IDC_STATIC,7,7, + 182,8 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,178,71,10 +END + +IDD_MODE_CONFIRM DIALOG 0, 0, 186, 57 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Confirm mode" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",ID_OK,31,36,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,103,36,50,14 + CTEXT "Do you want to keep the current mode?",IDC_STATIC,7,7, + 172,8 + CTEXT "",IDC_TIMER,7,19,172,8 +END + +IDD_REWIND_INTERVAL DIALOGEX 0, 0, 188, 132 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Rewind Settings" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_INTERVAL,7,26,174,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",ID_OK,37,111,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,99,111,50,14 + LTEXT "Enter the rewind interval (0.2 ... 600) in seconds:", + IDC_STATIC,7,7,174,8 + LTEXT "Or enter 0 to disable rewind.",IDC_STATIC,7,15,174,8 + EDITTEXT IDC_REWINDSLOTS,7,66,174,14,ES_AUTOHSCROLL + LTEXT "Enter number of rewind slots (1...256)",IDC_STATIC,7,46, + 174,8 + LTEXT "Or enter 0 to disable rewind.",IDC_STATIC,7,55,174,8 + LTEXT "If enabled, Tools->Rewind will rewind the state by seconds, as many as intervals back.", + IDC_STATIC,7,87,173,17 +END + +IDD_IO_VIEWER DIALOG 0, 0, 269, 238 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "I/O Viewer" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_ADDRESSES,7,7,255,30,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + RTEXT "",IDC_VALUE,103,23,159,8 + CONTROL "",IDC_BIT_15,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,34, + 255,10 + CONTROL "",IDC_BIT_14,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,44, + 255,10 + CONTROL "",IDC_BIT_13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54, + 255,8 + CONTROL "",IDC_BIT_12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64, + 255,10 + CONTROL "",IDC_BIT_11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,74, + 255,10 + CONTROL "",IDC_BIT_10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,84, + 255,10 + CONTROL "",IDC_BIT_9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,94, + 255,10 + CONTROL "",IDC_BIT_8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,104, + 255,10 + CONTROL "",IDC_BIT_7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,114, + 255,10 + CONTROL "",IDC_BIT_6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124, + 255,10 + CONTROL "",IDC_BIT_5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,134, + 255,10 + CONTROL "",IDC_BIT_4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,144, + 255,10 + CONTROL "",IDC_BIT_3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,154, + 255,10 + CONTROL "",IDC_BIT_2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,164, + 255,10 + CONTROL "",IDC_BIT_1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,174, + 255,10 + CONTROL "",IDC_BIT_0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,184, + 255,10 + CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,201,71,10 + DEFPUSHBUTTON "&Refresh",IDC_REFRESH,54,221,50,14 + DEFPUSHBUTTON "&Apply",IDC_APPLY,110,221,50,14 + PUSHBUTTON "&Close",IDC_CLOSE,166,221,50,14 + LTEXT "Value:",IDC_STATIC,7,23,72,8 +END + +IDD_MAX_SCALE DIALOG 0, 0, 186, 68 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Fullscreen scale" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_VALUE,7,28,172,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",ID_OK,37,47,50,14 + PUSHBUTTON "Cancel",ID_CANCEL,99,47,50,14 + LTEXT "Enter the maxium fullscreen scale:",IDC_STATIC,7,7,172, + 8 + LTEXT "Enter 0 to use maximum scale.",IDC_STATIC,7,17,172,8 +END + +IDD_BUG_REPORT DIALOG 0, 0, 296, 186 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Bug Report" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "&OK",ID_OK,157,165,50,14 + EDITTEXT IDC_BUG_REPORT,11,22,278,131,ES_MULTILINE | + ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | + WS_VSCROLL + LTEXT "Bug report data:",IDC_STATIC,7,7,282,8 + DEFPUSHBUTTON "&Copy",IDC_COPY,87,164,50,14 +END + +IDD_MOVIECREATE DIALOGEX 0, 0, 320, 168 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Record Movie" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,193,147,50,14 + PUSHBUTTON "Cancel",IDCANCEL,256,147,50,14 + EDITTEXT IDC_MOVIE_FILENAME,7,18,250,13,ES_AUTOHSCROLL + LTEXT "Movie File",-1,7,7,33,8 + PUSHBUTTON "&Browse...",IDC_BROWSE,264,17,48,14 + EDITTEXT IDC_EDIT_AUTHOR,57,35,200,14,ES_AUTOHSCROLL + LTEXT "Author:",-1,7,38,43,8,0,WS_EX_RIGHT + EDITTEXT IDC_EDIT_DESCRIPTION,57,52,255,14,ES_AUTOHSCROLL + LTEXT "Description:",-1,7,55,43,8,0,WS_EX_RIGHT + GROUPBOX "Game System",-1,116,74,85,64 + CONTROL "Game Boy Advance",IDC_REC_GBA,"Button", + BS_AUTORADIOBUTTON | WS_GROUP,119,86,79,10 + CONTROL "Game Boy Color",IDC_REC_GBC,"Button",BS_AUTORADIOBUTTON, + 119,99,67,10 + CONTROL "Super Game Boy",IDC_REC_SGB,"Button",BS_AUTORADIOBUTTON, + 119,112,69,10 + CONTROL "Game Boy",IDC_REC_GB,"Button",BS_AUTORADIOBUTTON,119, + 124,49,10 + GROUPBOX "Bios Settings",-1,214,74,86,64 + GROUPBOX "Record Options",-1,18,74,85,64 + CONTROL "From now (snapshot)",IDC_RECNOW,"Button", + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,21,118,77,10 + CONTROL "From reset (SRAM)",IDC_RECRESET,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,21,104,75,10 + CONTROL "From start (power-on)",IDC_RECSTART,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,21,90,78,10 + CONTROL "No BIOS",IDC_REC_NOBIOS,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,218,86,44,10 + CONTROL "Emulator's BIOS",IDC_REC_EMUBIOS,"Button", + BS_AUTORADIOBUTTON,218,99,67,10 + CONTROL "GBA BIOS",IDC_REC_GBABIOS,"Button",BS_AUTORADIOBUTTON, + 218,112,49,10 + CONTROL "GBA BIOS with intro",IDC_REC_GBABIOSINTRO,"Button", + BS_AUTORADIOBUTTON,218,124,79,10 +END + +IDD_MOVIEOPEN DIALOGEX 0, 0, 320, 240 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Play Movie" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,196,214,50,14 + PUSHBUTTON "Cancel",IDCANCEL,255,214,50,14 + EDITTEXT IDC_MOVIE_FILENAME,7,18,250,13,ES_AUTOHSCROLL + LTEXT "Movie File",-1,7,7,33,8 + PUSHBUTTON "&Browse...",IDC_BROWSE,265,17,48,14 + LTEXT "Recording Date:",-1,12,87,53,8 + LTEXT "Length:",-1,40,99,25,8 + LTEXT "Frames:",-1,40,111,26,8 + LTEXT "Re-record Count:",-1,10,123,55,8 + LTEXT "DATE",IDC_LABEL_DATE,68,87,124,8 + LTEXT "LENGTH",IDC_LABEL_LENGTH,68,99,93,8 + LTEXT "FRAMES",IDC_LABEL_FRAMES,68,111,67,8 + LTEXT "RERECORD",IDC_LABEL_RERECORD,68,123,46,8 + CONTROL "Open Read-Only",IDC_READONLY,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,189,7,70,10 + LTEXT "Press OK to start playing the movie.\nNote that this will erase or overwrite your game's SRAM,\nand may change other emulator settings.", + -1,8,209,177,24 + LTEXT "Movie ROM: ...",IDC_LABEL_WARNING1,8,34,300,8 + LTEXT "Your ROM: ...",IDC_LABEL_WARNING2,12,43,295,9,0, + WS_EX_TRANSPARENT + EDITTEXT IDC_EDIT_AUTHOR,57,54,200,12,ES_AUTOHSCROLL | + ES_READONLY + LTEXT "Author:",-1,7,56,43,8,0,WS_EX_RIGHT + EDITTEXT IDC_EDIT_DESCRIPTION,57,68,255,12,ES_AUTOHSCROLL + LTEXT "Description:",-1,7,69,43,8,0,WS_EX_RIGHT + GROUPBOX "Game System",-1,112,137,85,64 + RADIOBUTTON "Game Boy Advance",IDC_REC_GBA,116,149,79,10,WS_GROUP + RADIOBUTTON "Game Boy Color",IDC_REC_GBC,116,162,67,10 + RADIOBUTTON "Super Game Boy",IDC_REC_SGB,116,175,69,10 + RADIOBUTTON "Game Boy",IDC_REC_GB,116,187,49,10 + GROUPBOX "Record Options",-1,18,137,77,64 + RADIOBUTTON "From snapshot",IDC_RECNOW,22,180,62,10,WS_GROUP | + WS_TABSTOP + RADIOBUTTON "From reset/SRAM",IDC_RECRESET,22,167,70,10,WS_TABSTOP + RADIOBUTTON "From power-on",IDC_RECSTART,22,153,63,10,WS_TABSTOP + RADIOBUTTON "No BIOS",IDC_REC_NOBIOS,219,149,44,10,WS_GROUP + RADIOBUTTON "Emulator's BIOS",IDC_REC_EMUBIOS,219,162,67,10 + RADIOBUTTON "GBA BIOS",IDC_REC_GBABIOS,219,175,49,10 + RADIOBUTTON "GBA BIOS with intro",IDC_REC_GBABIOSINTRO,219,187,79,10 + GROUPBOX "Bios Settings",-1,214,137,86,64 + PUSHBUTTON "&Refresh",IDC_MOVIE_REFRESH,265,3,48,14 + EDITTEXT IDC_EDIT_PAUSEFRAME,254,109,45,12,ES_AUTOHSCROLL + CONTROL "Pause at frame:",IDC_CHECK_PAUSEFRAME,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,189,110,63,10 + CONTROL "Hide SGB Border",IDC_CHECK_HIDEBORDER,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,116,123,70,10 +END + +IDD_TEXTCONFIG DIALOGEX 0, 0, 139, 120 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | + WS_SYSMENU +CAPTION "Text Options" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,69,99,63,14 + PUSHBUTTON "Cancel",IDCANCEL,7,99,53,14 + GROUPBOX "Color",IDC_STATIC,7,7,54,86 + CONTROL "White",IDC_RADIO_WHITE,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,13,16,35,8 + CONTROL "Red",IDC_RADIO_RED,"Button",BS_AUTORADIOBUTTON,13,25,29, + 8 + CONTROL "Yellow",IDC_RADIO_YELLOW,"Button",BS_AUTORADIOBUTTON,13, + 34,36,9 + CONTROL "Green",IDC_RADIO_GREEN,"Button",BS_AUTORADIOBUTTON,13, + 43,35,9 + CONTROL "Cyan",IDC_RADIO_CYAN,"Button",BS_AUTORADIOBUTTON,13,53, + 33,8 + CONTROL "Blue",IDC_RADIO_BLUE,"Button",BS_AUTORADIOBUTTON,13,63, + 29,8 + CONTROL "Magenta",IDC_RADIO_MAGENTA,"Button",BS_AUTORADIOBUTTON, + 13,72,44,8 + CONTROL "Black",IDC_RADIO_BLACK,"Button",BS_AUTORADIOBUTTON,13, + 82,32,8 + CONTROL "Outlined",IDC_CHECK_OUTLINED,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,74,17,43,10 + CONTROL "Transparent",IDC_CHECK_TRANSPARENT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,74,28,55,10 + GROUPBOX "Mode",IDC_STATIC,69,7,63,36 + GROUPBOX "Display",IDC_STATIC,69,48,63,45 + CONTROL "In Game",IDC_RADIO_PREFILTER,"Button", + BS_AUTORADIOBUTTON | WS_GROUP,73,58,43,10 + CONTROL "On Game",IDC_RADIO_POSTFILTER,"Button", + BS_AUTORADIOBUTTON,73,69,45,10 + CONTROL "On Screen",IDC_RADIO_POSTRENDER,"Button", + BS_AUTORADIOBUTTON,73,80,49,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPENDLG, DIALOG + BEGIN + RIGHTMARGIN, 165 + END + + IDD_ABOUT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 157 + TOPMARGIN, 7 + BOTTOMMARGIN, 94 + END + + IDD_DIRECTORIES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 277 + TOPMARGIN, 7 + BOTTOMMARGIN, 122 + END + + IDD_CONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 128 + TOPMARGIN, 7 + BOTTOMMARGIN, 204 + END + + IDD_CHEATS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 269 + TOPMARGIN, 7 + BOTTOMMARGIN, 246 + END + + IDD_ADD_CHEAT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 130 + END + + IDD_CHEAT_LIST, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 273 + TOPMARGIN, 7 + BOTTOMMARGIN, 243 + END + + IDD_ASSOCIATIONS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 109 + TOPMARGIN, 7 + BOTTOMMARGIN, 88 + END + + IDD_GBA_ROM_INFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 213 + TOPMARGIN, 7 + BOTTOMMARGIN, 135 + END + + IDD_GB_ROM_INFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 213 + TOPMARGIN, 7 + BOTTOMMARGIN, 218 + END + + IDD_GB_CHEAT_LIST, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 279 + TOPMARGIN, 7 + BOTTOMMARGIN, 214 + END + + IDD_ADD_CHEAT_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 175 + TOPMARGIN, 7 + BOTTOMMARGIN, 100 + END + + IDD_GB_PRINTER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 171 + TOPMARGIN, 7 + BOTTOMMARGIN, 202 + END + + IDD_MOTION_CONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 128 + TOPMARGIN, 7 + BOTTOMMARGIN, 71 + END + + IDD_LANG_SELECT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 61 + END + + IDD_CODE_SELECT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 228 + END + + IDD_MAP_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 315 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END + + IDD_PALETTE_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 259 + END + + IDD_MEM_VIEWER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 373 + TOPMARGIN, 7 + BOTTOMMARGIN, 171 + END + + IDD_OAM_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 227 + TOPMARGIN, 7 + BOTTOMMARGIN, 178 + END + + IDD_ACCEL_EDITOR, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 313 + TOPMARGIN, 7 + BOTTOMMARGIN, 122 + END + + IDD_TILE_VIEWER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 319 + TOPMARGIN, 7 + BOTTOMMARGIN, 259 + END + + IDD_GB_COLORS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 162 + TOPMARGIN, 7 + BOTTOMMARGIN, 114 + END + + IDD_DISASSEMBLE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 396 + TOPMARGIN, 7 + BOTTOMMARGIN, 218 + END + + IDD_GDB_PORT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 44 + END + + IDD_GDB_WAITING, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 37 + END + + IDD_LOGGING, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 359 + TOPMARGIN, 7 + BOTTOMMARGIN, 211 + END + + IDD_EXPORT_SPS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 241 + TOPMARGIN, 7 + BOTTOMMARGIN, 141 + END + + IDD_ADDR_SIZE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 60 + END + + IDD_MODES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 201 + TOPMARGIN, 7 + BOTTOMMARGIN, 122 + END + + IDD_DRIVERS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 201 + TOPMARGIN, 7 + BOTTOMMARGIN, 114 + END + + IDD_THROTTLE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 56 + END + + IDD_GB_DISASSEMBLE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 337 + TOPMARGIN, 7 + BOTTOMMARGIN, 218 + END + + IDD_GB_OAM_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 227 + TOPMARGIN, 7 + BOTTOMMARGIN, 178 + END + + IDD_GB_TILE_VIEWER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 319 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END + + IDD_GB_MAP_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 315 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END + + IDD_GB_PALETTE_VIEW, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 189 + TOPMARGIN, 7 + BOTTOMMARGIN, 227 + END + + IDD_MODE_CONFIRM, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 50 + END + + IDD_REWIND_INTERVAL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 181 + TOPMARGIN, 7 + BOTTOMMARGIN, 125 + END + + IDD_IO_VIEWER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 262 + TOPMARGIN, 7 + BOTTOMMARGIN, 235 + END + + IDD_MAX_SCALE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 61 + END + + IDD_BUG_REPORT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 289 + TOPMARGIN, 7 + BOTTOMMARGIN, 179 + END + + IDD_MOVIECREATE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 312 + TOPMARGIN, 7 + BOTTOMMARGIN, 161 + END + + IDD_MOVIEOPEN, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 313 + TOPMARGIN, 7 + BOTTOMMARGIN, 235 + END + + IDD_TEXTCONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 132 + TOPMARGIN, 7 + BOTTOMMARGIN, 113 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MENU MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Open ROM...", ID_FILE_OPEN + POPUP "Rece&nt ROM" + BEGIN + MENUITEM "&Clear", ID_FILE_RECENT_RESET + MENUITEM "&Lock", ID_FILE_RECENT_FREEZE + MENUITEM SEPARATOR + END + MENUITEM SEPARATOR + POPUP "Loa&d Game" + BEGIN + MENUITEM "Current slot", ID_FILE_LOADGAME_CURRENT + MENUITEM "Most recent slot", ID_FILE_LOADGAME_MOSTRECENT + + MENUITEM "Load from file...", ID_FILE_LOAD + MENUITEM SEPARATOR + MENUITEM "Slot #1", ID_FILE_LOADGAME_SLOT1 + MENUITEM "Slot #2", ID_FILE_LOADGAME_SLOT2 + MENUITEM "Slot #3", ID_FILE_LOADGAME_SLOT3 + MENUITEM "Slot #4", ID_FILE_LOADGAME_SLOT4 + MENUITEM "Slot #5", ID_FILE_LOADGAME_SLOT5 + MENUITEM "Slot #6", ID_FILE_LOADGAME_SLOT6 + MENUITEM "Slot #7", ID_FILE_LOADGAME_SLOT7 + MENUITEM "Slot #8", ID_FILE_LOADGAME_SLOT8 + MENUITEM "Slot #9", ID_FILE_LOADGAME_SLOT9 + MENUITEM "Slot #10", ID_FILE_LOADGAME_SLOT10 + MENUITEM SEPARATOR + MENUITEM "Auto load most recent", ID_FILE_LOADGAME_AUTOLOADMOSTRECENT + + MENUITEM "Make recent on load", ID_FILE_LOADGAME_MAKERECENT + + MENUITEM "Make current on load", ID_FILE_LOADGAME_MAKECURRENT + + END + POPUP "S&ave Game" + BEGIN + MENUITEM "Current slot", ID_FILE_SAVEGAME_CURRENT + MENUITEM "Oldest slot", ID_FILE_SAVEGAME_OLDESTSLOT + + MENUITEM "Save to file...", ID_FILE_SAVE + MENUITEM SEPARATOR + MENUITEM "Slot #1", ID_FILE_SAVEGAME_SLOT1 + MENUITEM "Slot #2", ID_FILE_SAVEGAME_SLOT2 + MENUITEM "Slot #3", ID_FILE_SAVEGAME_SLOT3 + MENUITEM "Slot #4", ID_FILE_SAVEGAME_SLOT4 + MENUITEM "Slot #5", ID_FILE_SAVEGAME_SLOT5 + MENUITEM "Slot #6", ID_FILE_SAVEGAME_SLOT6 + MENUITEM "Slot #7", ID_FILE_SAVEGAME_SLOT7 + MENUITEM "Slot #8", ID_FILE_SAVEGAME_SLOT8 + MENUITEM "Slot #9", ID_FILE_SAVEGAME_SLOT9 + MENUITEM "Slot #10", ID_FILE_SAVEGAME_SLOT10 + MENUITEM SEPARATOR + MENUITEM "Increase current slot", ID_FILE_SAVEGAME_INCREMENTSLOT + + MENUITEM "Decrease current slot", ID_FILE_SAVEGAME_DECREMENTSLOT + + MENUITEM SEPARATOR + MENUITEM "Make current on save", ID_FILE_SAVEGAME_MAKECURRENT + + END + MENUITEM SEPARATOR + MENUITEM "&Pause", ID_FILE_PAUSE + MENUITEM "&Reset", ID_FILE_RESET + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM SEPARATOR + POPUP "&Import" + BEGIN + MENUITEM "&Battery file...", ID_FILE_IMPORT_BATTERYFILE + + MENUITEM "Gameshark &code file...", ID_FILE_IMPORT_GAMESHARKCODEFILE + + MENUITEM "&Gameshark Snapshot...", ID_FILE_IMPORT_GAMESHARKSNAPSHOT + + END + POPUP "E&xport" + BEGIN + MENUITEM "&Battery file...", ID_FILE_EXPORT_BATTERYFILE + + MENUITEM "&Gameshark Snapshot...", ID_FILE_EXPORT_GAMESHARKSNAPSHOT + + END + MENUITEM SEPARATOR + MENUITEM "Screen capt&ure...", ID_FILE_SCREENCAPTURE + MENUITEM "Ro&m information...", ID_FILE_ROMINFORMATION + MENUITEM "&Toggle menu", ID_FILE_TOGGLEMENU + MENUITEM SEPARATOR + MENUITEM "&Exit", ID_FILE_EXIT + END + POPUP "&Options" + BEGIN + POPUP "&Controls" + BEGIN + MENUITEM "&Configure Controls...", ID_OPTIONS_JOYPAD_CONFIGURE_1 + + MENUITEM "Configure Motion Sensor...", ID_OPTIONS_JOYPAD_MOTIONCONFIGURE + + POPUP "Configure Other Controllers" + BEGIN + MENUITEM "Controller &2...", ID_OPTIONS_JOYPAD_CONFIGURE_2 + + MENUITEM "Controller &3...", ID_OPTIONS_JOYPAD_CONFIGURE_3 + + MENUITEM "Controller &4...", ID_OPTIONS_JOYPAD_CONFIGURE_4 + + END + POPUP "Default Controller" + BEGIN + MENUITEM "1", ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1 + + MENUITEM "2", ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2 + + MENUITEM "3", ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3 + + MENUITEM "4", ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4 + + END + MENUITEM SEPARATOR + MENUITEM "Allow Left+Right / Up+Down", ID_OPTIONS_JOYPAD_ALLOWLEFTRIGHT + + MENUITEM SEPARATOR + POPUP "&Auto-fire" + BEGIN + MENUITEM "&A", ID_OPTIONS_JOYPAD_AUTOFIRE_A + + MENUITEM "&B", ID_OPTIONS_JOYPAD_AUTOFIRE_B + + MENUITEM "&L", ID_OPTIONS_JOYPAD_AUTOFIRE_L + + MENUITEM "&R", ID_OPTIONS_JOYPAD_AUTOFIRE_R + + MENUITEM "&Start", ID_OPTIONS_JOYPAD_AUTOFIRE_START + + MENUITEM "S&elect", ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT + + MENUITEM "Up", ID_OPTIONS_JOYPAD_AUTOFIRE_UP + + MENUITEM "Down", ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN + + MENUITEM "Left", ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT + + MENUITEM "Right", ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT + + MENUITEM "&Clear All", ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR + + END + POPUP "Auto-hold" + BEGIN + MENUITEM "&A", ID_STICKY_A + MENUITEM "&B", ID_STICKY_B + MENUITEM "&L", ID_STICKY_L + MENUITEM "&R", ID_STICKY_R + MENUITEM "&Start", ID_STICKY_START + MENUITEM "&Select", ID_STICKY_SELECT + MENUITEM "Up", ID_STICKY_UP + MENUITEM "Down", ID_STICKY_DOWN + MENUITEM "Left", ID_STICKY_LEFT + MENUITEM "Right", ID_STICKY_RIGHT + MENUITEM "&Clear All", ID_STICKY_CLEAR + END + END + POPUP "Speed" + BEGIN + POPUP "&Frame Skip" + BEGIN + MENUITEM "skip &0 (don't skip any frames)", + ID_OPTIONS_VIDEO_FRAMESKIP_0 + + MENUITEM "skip &1 (skip every other frame)", + ID_OPTIONS_VIDEO_FRAMESKIP_1 + + MENUITEM "skip &2 (skip 2 out of every 3 frames)", + ID_OPTIONS_VIDEO_FRAMESKIP_2 + + MENUITEM "skip &3", ID_OPTIONS_VIDEO_FRAMESKIP_3 + + MENUITEM "skip &4", ID_OPTIONS_VIDEO_FRAMESKIP_4 + + MENUITEM "skip &5", ID_OPTIONS_VIDEO_FRAMESKIP_5 + + MENUITEM "skip &6", ID_OPTIONS_VIDEO_FRAMESKIP_6 + + MENUITEM "skip &7", ID_OPTIONS_VIDEO_FRAMESKIP_7 + + MENUITEM "skip &8", ID_OPTIONS_VIDEO_FRAMESKIP_8 + + MENUITEM "skip &9 (skip 9 out of every 10 frames)", + ID_OPTIONS_VIDEO_FRAMESKIP_9 + + END + POPUP "Set Speed" + BEGIN + MENUITEM "6% (very slow)", ID_OPTIONS_FRAMESKIP_THROTTLE_6 + + MENUITEM "25%", ID_OPTIONS_FRAMESKIP_THROTTLE_25 + + MENUITEM "50% (half speed)", ID_OPTIONS_FRAMESKIP_THROTTLE_50 + + MENUITEM "75%", ID_OPTIONS_FRAMESKIP_THROTTLE_75 + + MENUITEM "100% (normal speed)", ID_OPTIONS_FRAMESKIP_THROTTLE_100 + + MENUITEM "150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150 + + MENUITEM "200% (double speed)", ID_OPTIONS_FRAMESKIP_THROTTLE_200 + + MENUITEM "Other...", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER + + MENUITEM SEPARATOR + MENUITEM "Increase", ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE + + MENUITEM "Decrease", ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE + + END + MENUITEM SEPARATOR + MENUITEM "Accurate Sound &Pitch", ID_OPTIONS_FRAMESKIP_ACCURATEPITCH + + MENUITEM "Accurate Emulation &Speed", ID_OPTIONS_FRAMESKIP_ACCURATESPEED + + MENUITEM SEPARATOR + POPUP "Process &Priority" + BEGIN + MENUITEM "&Highest", ID_OPTIONS_PRIORITY_HIGHEST + + MENUITEM "&Above Normal", ID_OPTIONS_PRIORITY_ABOVENORMAL + + MENUITEM "&Normal", ID_OPTIONS_PRIORITY_NORMAL + + MENUITEM "&Below Normal", ID_OPTIONS_PRIORITY_BELOWNORMAL + + END + END + MENUITEM SEPARATOR + POPUP "&Video" + BEGIN + MENUITEM "&Vsync", ID_OPTIONS_VIDEO_VSYNC + POPUP "Render Method" + BEGIN + MENUITEM "GDI", ID_OPTIONS_VIDEO_RENDERMETHOD_GDI + + MENUITEM "DirectDraw", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW + + MENUITEM "Direct3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D + + MENUITEM "OpenGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL + + MENUITEM SEPARATOR + MENUITEM "DDraw &Emulation Only", ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY + + MENUITEM "DDraw Use &Video Memory", ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY + + MENUITEM "DDraw Triple Buffering", ID_OPTIONS_VIDEO_TRIPLEBUFFERING + + MENUITEM SEPARATOR + MENUITEM "D3D Nearest", ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DNOFILTER + + MENUITEM "D3D Bilinear", ID_OPTIONS_VIDEO_RENDEROPTIONS_D3DBILINEAR + + MENUITEM SEPARATOR + MENUITEM "GL Nearest", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLNEAREST + + MENUITEM "GL Bilinear", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR + + MENUITEM "GL Triangle", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE + + MENUITEM "GL Quads", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS + + MENUITEM SEPARATOR + MENUITEM "Select skin...", ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN + + MENUITEM "Skin", ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN + + END + MENUITEM SEPARATOR + MENUITEM "x&1", ID_OPTIONS_VIDEO_X1 + MENUITEM "x&2", ID_OPTIONS_VIDEO_X2 + MENUITEM "x&3", ID_OPTIONS_VIDEO_X3 + MENUITEM "x&4", ID_OPTIONS_VIDEO_X4 + MENUITEM "Full Screen (320x240)", ID_OPTIONS_VIDEO_FULLSCREEN320X240 + + MENUITEM "Full Screen (640x480)", ID_OPTIONS_VIDEO_FULLSCREEN640X480 + + MENUITEM "Full Screen (800x600)", ID_OPTIONS_VIDEO_FULLSCREEN800X600 + + MENUITEM "&Other Full Screen...", ID_OPTIONS_VIDEO_FULLSCREEN + + MENUITEM "Full screen max scale...", ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE + + MENUITEM SEPARATOR + MENUITEM "Text display options...", ID_OPTIONS_VIDEO_TEXTDISPLAYOPTIONS + + MENUITEM "D&isable status messages", ID_OPTIONS_VIDEO_DISABLESTATUSMESSAGES + + MENUITEM SEPARATOR + MENUITEM "&Disable SFX", ID_OPTIONS_VIDEO_DISABLESFX + + MENUITEM "Fullscreen stretch to &fit", ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT + + MENUITEM SEPARATOR + POPUP "Graphics &Layers" + BEGIN + MENUITEM "BG 0", ID_OPTIONS_VIDEO_LAYERS_BG0 + + MENUITEM "BG 1", ID_OPTIONS_VIDEO_LAYERS_BG1 + + MENUITEM "BG 2", ID_OPTIONS_VIDEO_LAYERS_BG2 + + MENUITEM "BG 3", ID_OPTIONS_VIDEO_LAYERS_BG3 + + MENUITEM "OBJ", ID_OPTIONS_VIDEO_LAYERS_OBJ + + MENUITEM "WIN 0", ID_OPTIONS_VIDEO_LAYERS_WIN0 + + MENUITEM "WIN 1", ID_OPTIONS_VIDEO_LAYERS_WIN1 + + MENUITEM "OBJ WIN", ID_OPTIONS_VIDEO_LAYERS_OBJWIN + + END + END + POPUP "F&ilter" + BEGIN + POPUP "Interframe Blending" + BEGIN + MENUITEM "None", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE + + MENUITEM "Motion Blur", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR + + MENUITEM "Smart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART + + END + MENUITEM SEPARATOR + MENUITEM "&Normal", ID_OPTIONS_FILTER_NORMAL + MENUITEM "&TV Mode", ID_OPTIONS_FILTER_TVMODE + MENUITEM "&2xSaI", ID_OPTIONS_FILTER_2XSAI + MENUITEM "&Super 2xSaI", ID_OPTIONS_FILTER_SUPER2XSAI + + MENUITEM "Super &Eagle", ID_OPTIONS_FILTER_SUPEREAGLE + + MENUITEM "Pixelate", ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL + + MENUITEM "Motion Blur", ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL + + MENUITEM "AdvanceMAME Scale2x", ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X + + MENUITEM "Simple 2x", ID_OPTIONS_FILTER16BIT_SIMPLE2X + + MENUITEM "Bilinear", ID_OPTIONS_FILTER_BILINEAR + + MENUITEM "Bilinear Plus", ID_OPTIONS_FILTER_BILINEARPLUS + + MENUITEM "Scanlines", ID_OPTIONS_FILTER_SCANLINES + + MENUITEM "hq2xS", ID_OPTIONS_FILTER_HQ2X2 + MENUITEM "hq2x", ID_OPTIONS_FILTER_HQ2X + MENUITEM "lq2x", ID_OPTIONS_FILTER_LQ2X + MENUITEM "hq3xS", ID_OPTIONS_FILTER_HQ3X2 + MENUITEM "hq3x", ID_OPTIONS_FILTER_HQ3X + MENUITEM SEPARATOR + MENUITEM "&Disable MMX optimizations", ID_OPTIONS_FILTER_DISABLEMMX + + END + POPUP "&Sound" + BEGIN + MENUITEM "&On", ID_OPTIONS_SOUND_ON + MENUITEM "&Mute", ID_OPTIONS_SOUND_MUTE + MENUITEM "Off", ID_OPTIONS_SOUND_OFF + MENUITEM SEPARATOR + MENUITEM "Echo", ID_OPTIONS_SOUND_ECHO + MENUITEM "Low pass filter", ID_OPTIONS_SOUND_LOWPASSFILTER + + MENUITEM "Reverse Stereo", ID_OPTIONS_SOUND_REVERSESTEREO + + MENUITEM "Use old synchronization", ID_OPTIONS_SOUND_USEOLDSYNCHRONIZATION + + MENUITEM "Mute frame advance", ID_OPTIONS_SOUND_MUTEFRAMEADVANCE + + MENUITEM SEPARATOR + POPUP "&Volume" + BEGIN + MENUITEM ".25X", ID_OPTIONS_SOUND_VOLUME_25X + + MENUITEM ".5X", ID_OPTIONS_SOUND_VOLUME_5X + + MENUITEM "&1x", ID_OPTIONS_SOUND_VOLUME_1X + + MENUITEM "&2x", ID_OPTIONS_SOUND_VOLUME_2X + + MENUITEM "&3x", ID_OPTIONS_SOUND_VOLUME_3X + + MENUITEM "&4x", ID_OPTIONS_SOUND_VOLUME_4X + + END + POPUP "Sound &channels" + BEGIN + MENUITEM "Channel &1", ID_OPTIONS_SOUND_CHANNEL1 + , CHECKED + MENUITEM "Channel &2", ID_OPTIONS_SOUND_CHANNEL2 + , CHECKED + MENUITEM "Channel &3", ID_OPTIONS_SOUND_CHANNEL3 + , CHECKED + MENUITEM "Channel &4", ID_OPTIONS_SOUND_CHANNEL4 + , CHECKED + MENUITEM "Direct Sound &A", ID_OPTIONS_SOUND_DIRECTSOUNDA + , CHECKED + MENUITEM "Direct Sound &B", ID_OPTIONS_SOUND_DIRECTSOUNDB + , CHECKED + END + MENUITEM SEPARATOR + MENUITEM "11 &Khz", ID_OPTIONS_SOUND_11KHZ + MENUITEM "22 K&hz", ID_OPTIONS_SOUND_22KHZ + MENUITEM "44 Kh&z", ID_OPTIONS_SOUND_44KHZ + END + MENUITEM SEPARATOR + POPUP "&Emulator" + BEGIN + MENUITEM "Pause when inactive window", ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE + + MENUITEM "Auto hide menu", ID_OPTIONS_EMULATOR_AUTOHIDEMENU + + MENUITEM "Rewind settings...", ID_OPTIONS_EMULATOR_REWINDINTERVAL + + POPUP "Show speed" + BEGIN + MENUITEM "None", ID_OPTIONS_EMULATOR_SHOWSPEED_NONE + + MENUITEM "Percentage", ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE + + MENUITEM "Detailed", ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED + + MENUITEM SEPARATOR + MENUITEM "Transparent", ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT + + END + MENUITEM SEPARATOR + MENUITEM "&Directories...", ID_OPTIONS_EMULATOR_DIRECTORIES + + MENUITEM "&Associate...", ID_OPTIONS_EMULATOR_ASSOCIATE + + MENUITEM "PNG format", ID_OPTIONS_EMULATOR_PNGFORMAT + + MENUITEM "BMP format", ID_OPTIONS_EMULATOR_BMPFORMAT + + MENUITEM SEPARATOR + MENUITEM "&Synchronize emulation speed", + ID_OPTIONS_EMULATOR_SYNCHRONIZE + + MENUITEM "Automatic IPS patching", ID_OPTIONS_EMULATOR_AUTOMATICALLYIPSPATCH + + MENUITEM "Speed up toggle", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE + + MENUITEM "AGB Print", ID_OPTIONS_EMULATOR_AGBPRINT + + MENUITEM "Real Time Clock", ID_OPTIONS_EMULATOR_REALTIMECLOCK + + MENUITEM "Lag Reduction (GBA)", ID_EMULATOR_GBALAG + MENUITEM "Use Old Frame Timing", ID_EMULATOR_USEOLDGBTIMING + + POPUP "Save Type" + BEGIN + MENUITEM "&Automatic", ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC + + MENUITEM "EEPROM", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM + + MENUITEM "SRAM", ID_OPTIONS_EMULATOR_SAVETYPE_SRAM + + MENUITEM "Flash", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH + + MENUITEM "EEPROM+Sensor", ID_OPTIONS_EMULATOR_SAVETYPE_EEPROMSENSOR + + MENUITEM "None", ID_OPTIONS_EMULATOR_SAVETYPE_NONE + + MENUITEM SEPARATOR + MENUITEM "Flash 64K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K + + MENUITEM "Flash 128K", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M + + MENUITEM SEPARATOR + MENUITEM "Enhanced detection", ID_OPTIONS_EMULATOR_SAVETYPE_ENHANCEDDETECTION + + END + MENUITEM SEPARATOR + MENUITEM "&Use BIOS file", ID_OPTIONS_EMULATOR_USEBIOSFILE + + MENUITEM "Skip BIOS intro", ID_OPTIONS_EMULATOR_SKIPBIOS + + MENUITEM "S&elect BIOS file...", ID_OPTIONS_EMULATOR_SELECTBIOSFILE + + END + POPUP "&Gameboy" + BEGIN + MENUITEM "&Automatic Mode", ID_OPTIONS_GAMEBOY_AUTOMATIC + + MENUITEM "&Game Boy Advance (GBA/AGB)", ID_OPTIONS_GAMEBOY_GBA + MENUITEM "&Game Boy Color (GBC/CGB)", ID_OPTIONS_GAMEBOY_CGB + MENUITEM "Game Boy Color + SGB borders", ID_OPTIONS_GAMEBOY_SGB2 + MENUITEM "&Super Game Boy (SGB)", ID_OPTIONS_GAMEBOY_SGB + MENUITEM "Game &Boy (GB)", ID_OPTIONS_GAMEBOY_GB + MENUITEM SEPARATOR + MENUITEM "Border Automatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC + + MENUITEM "Border Always", ID_OPTIONS_GAMEBOY_BORDER + + MENUITEM "Emulate &Printer", ID_OPTIONS_GAMEBOY_PRINTER + + MENUITEM SEPARATOR + MENUITEM "&Real Colors", ID_OPTIONS_GAMEBOY_REALCOLORS + + MENUITEM "Ga&meboy Colors", ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS + + MENUITEM "Customize Colors...", ID_OPTIONS_GAMEBOY_COLORS + + END + MENUITEM SEPARATOR + POPUP "&Language" + BEGIN + MENUITEM "&System", ID_OPTIONS_LANGUAGE_SYSTEM + + MENUITEM "&English", ID_OPTIONS_LANGUAGE_ENGLISH + + MENUITEM "&Other...", ID_OPTIONS_LANGUAGE_OTHER + + END + END + POPUP "&Cheats" + BEGIN + MENUITEM "&Search for cheats...", ID_CHEATS_SEARCHFORCHEATS + MENUITEM "Pause during cheat search", ID_CHEATS_PAUSEDURINGCHEATSEARCH + + MENUITEM "&Cheat list...", ID_CHEATS_CHEATLIST + MENUITEM SEPARATOR + MENUITEM "&Automatic save/load cheats", ID_CHEATS_AUTOMATICSAVELOADCHEATS + + MENUITEM "Disable cheats", ID_CHEATS_DISABLECHEATS + MENUITEM "&Load cheat list...", ID_CHEATS_LOADCHEATLIST + MENUITEM "Sa&ve cheat list...", ID_CHEATS_SAVECHEATLIST + END + POPUP "&Tools" + BEGIN + POPUP "Debug" + BEGIN + MENUITEM "Disassemble...", ID_TOOLS_DISASSEMBLE + MENUITEM "Logging...", ID_TOOLS_LOGGING + MENUITEM "&IO Viewer...", ID_TOOLS_IOVIEWER + MENUITEM "&Map Viewer...", ID_TOOLS_MAPVIEW + MENUITEM "M&emory viewer...", ID_TOOLS_MEMORYVIEWER + MENUITEM "OAM Viewer...", ID_TOOLS_OAMVIEWER + MENUITEM "&Palette Viewer...", ID_TOOLS_PALETTEVIEW + MENUITEM "Tile Viewer...", ID_TOOLS_TILEVIEWER + POPUP "GDB" + BEGIN + MENUITEM "Wait for connection...", ID_TOOLS_DEBUG_GDB + MENUITEM "Load and wait...", ID_TOOLS_DEBUG_LOADANDWAIT + + MENUITEM "Break into GDB", ID_TOOLS_DEBUG_BREAK + MENUITEM "Disconnect", ID_TOOLS_DEBUG_DISCONNECT + + END + END + MENUITEM SEPARATOR + MENUITEM "Frame Counter", ID_TOOLS_FRAMECOUNTER + MENUITEM "Input Display", ID_TOOLS_INPUTDISPLAY + MENUITEM SEPARATOR + MENUITEM "&Frame Advance", ID_DEBUG_NEXTFRAME + MENUITEM "Rewind", ID_TOOLS_REWIND + MENUITEM "Frame Search", ID_DEBUG_FRAMESEARCH + MENUITEM "Frame Search Prev", ID_DEBUG_FRAMESEARCHPREV + MENUITEM "Frame Search End", ID_DEBUG_FRAMESEARCHLOAD + MENUITEM SEPARATOR + POPUP "Play" + BEGIN + MENUITEM "Start playing movie...", ID_TOOLS_PLAY_STARTMOVIEPLAYING + + MENUITEM "Stop playing movie", ID_TOOLS_PLAY_STOPMOVIEPLAYING + + MENUITEM SEPARATOR + MENUITEM "Read-only mode", ID_TOOLS_PLAY_READONLY + MENUITEM SEPARATOR + MENUITEM "Continue recording from here", ID_TOOLS_PLAY_CONTINUE + MENUITEM "Watch from beginning", ID_TOOLS_PLAY_RESTART + END + POPUP "Record" + BEGIN + MENUITEM "Start movie recording...", ID_TOOLS_RECORD_STARTMOVIERECORDING + + MENUITEM "Stop movie recording", ID_TOOLS_RECORD_STOPMOVIERECORDING + + MENUITEM SEPARATOR + MENUITEM "Start AVI recording...", ID_TOOLS_RECORD_STARTAVIRECORDING + + MENUITEM "Stop AVI recording", ID_TOOLS_RECORD_STOPAVIRECORDING + + MENUITEM SEPARATOR + MENUITEM "Start sound recording...", ID_OPTIONS_SOUND_STARTRECORDING + + MENUITEM "Stop sound recording", ID_OPTIONS_SOUND_STOPRECORDING + + END + MENUITEM SEPARATOR + MENUITEM "Customize All Commands...", ID_TOOLS_CUSTOMIZE + MENUITEM "Customize Common Hotkeys...", ID_TOOLS_CUSTOMIZE_COMMON + END + POPUP "&Help" + BEGIN + MENUITEM "Bug Report", ID_HELP_BUGREPORT + MENUITEM "FAQ (website)", ID_HELP_FAQ + MENUITEM SEPARATOR + MENUITEM "&About...", ID_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_ACCELERATOR ACCELERATORS +BEGIN + "C", ID_CHEATS_SEARCHFORCHEATS, VIRTKEY, CONTROL, NOINVERT + VK_OEM_6, ID_DEBUG_FRAMESEARCH, VIRTKEY, NOINVERT + "L", ID_DEBUG_FRAMESEARCHLOAD, VIRTKEY, NOINVERT + VK_OEM_4, ID_DEBUG_FRAMESEARCHPREV, VIRTKEY, NOINVERT + "N", ID_DEBUG_NEXTFRAME, VIRTKEY, CONTROL, NOINVERT + VK_OEM_5, ID_DEBUG_NEXTFRAME, VIRTKEY, NOINVERT + "X", ID_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT + "L", ID_FILE_LOAD, VIRTKEY, SHIFT, CONTROL, + NOINVERT + VK_F1, ID_FILE_LOADGAME_SLOT1, VIRTKEY, NOINVERT + VK_F10, ID_FILE_LOADGAME_SLOT10, VIRTKEY, NOINVERT + VK_F2, ID_FILE_LOADGAME_SLOT2, VIRTKEY, NOINVERT + VK_F3, ID_FILE_LOADGAME_SLOT3, VIRTKEY, NOINVERT + VK_F4, ID_FILE_LOADGAME_SLOT4, VIRTKEY, NOINVERT + VK_F5, ID_FILE_LOADGAME_SLOT5, VIRTKEY, NOINVERT + VK_F6, ID_FILE_LOADGAME_SLOT6, VIRTKEY, NOINVERT + VK_F7, ID_FILE_LOADGAME_SLOT7, VIRTKEY, NOINVERT + VK_F8, ID_FILE_LOADGAME_SLOT8, VIRTKEY, NOINVERT + VK_F9, ID_FILE_LOADGAME_SLOT9, VIRTKEY, NOINVERT + VK_F1, ID_FILE_MRU_FILE1, VIRTKEY, CONTROL, NOINVERT + VK_F10, ID_FILE_MRU_FILE10, VIRTKEY, CONTROL, NOINVERT + VK_F2, ID_FILE_MRU_FILE2, VIRTKEY, CONTROL, NOINVERT + VK_F3, ID_FILE_MRU_FILE3, VIRTKEY, CONTROL, NOINVERT + VK_F4, ID_FILE_MRU_FILE4, VIRTKEY, CONTROL, NOINVERT + VK_F5, ID_FILE_MRU_FILE5, VIRTKEY, CONTROL, NOINVERT + VK_F6, ID_FILE_MRU_FILE6, VIRTKEY, CONTROL, NOINVERT + VK_F7, ID_FILE_MRU_FILE7, VIRTKEY, CONTROL, NOINVERT + VK_F8, ID_FILE_MRU_FILE8, VIRTKEY, CONTROL, NOINVERT + VK_F9, ID_FILE_MRU_FILE9, VIRTKEY, CONTROL, NOINVERT + "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "P", ID_FILE_PAUSE, VIRTKEY, CONTROL, NOINVERT + VK_PAUSE, ID_FILE_PAUSE, VIRTKEY, NOINVERT + "R", ID_FILE_RESET, VIRTKEY, CONTROL, NOINVERT + "S", ID_FILE_SAVE, VIRTKEY, SHIFT, CONTROL, + NOINVERT + VK_F1, ID_FILE_SAVEGAME_SLOT1, VIRTKEY, SHIFT, NOINVERT + VK_F10, ID_FILE_SAVEGAME_SLOT10, VIRTKEY, SHIFT, NOINVERT + VK_F2, ID_FILE_SAVEGAME_SLOT2, VIRTKEY, SHIFT, NOINVERT + VK_F3, ID_FILE_SAVEGAME_SLOT3, VIRTKEY, SHIFT, NOINVERT + VK_F4, ID_FILE_SAVEGAME_SLOT4, VIRTKEY, SHIFT, NOINVERT + VK_F5, ID_FILE_SAVEGAME_SLOT5, VIRTKEY, SHIFT, NOINVERT + VK_F6, ID_FILE_SAVEGAME_SLOT6, VIRTKEY, SHIFT, NOINVERT + VK_F7, ID_FILE_SAVEGAME_SLOT7, VIRTKEY, SHIFT, NOINVERT + VK_F8, ID_FILE_SAVEGAME_SLOT8, VIRTKEY, SHIFT, NOINVERT + VK_F9, ID_FILE_SAVEGAME_SLOT9, VIRTKEY, SHIFT, NOINVERT + VK_ESCAPE, ID_FILE_TOGGLEMENU, VIRTKEY, NOINVERT + VK_OEM_MINUS, ID_OPTIONS_FRAMESKIP_THROTTLE_DECREASE, VIRTKEY, + NOINVERT + VK_OEM_PLUS, ID_OPTIONS_FRAMESKIP_THROTTLE_INCREASE, VIRTKEY, + NOINVERT + "1", ID_OPTIONS_JOYPAD_AUTOFIRE_A, VIRTKEY, ALT, NOINVERT + "2", ID_OPTIONS_JOYPAD_AUTOFIRE_B, VIRTKEY, ALT, NOINVERT + VK_OEM_3, ID_OPTIONS_JOYPAD_AUTOFIRE_CLEAR, VIRTKEY, ALT, NOINVERT + "8", ID_OPTIONS_JOYPAD_AUTOFIRE_DOWN, VIRTKEY, ALT, NOINVERT + "3", ID_OPTIONS_JOYPAD_AUTOFIRE_L, VIRTKEY, ALT, NOINVERT + "9", ID_OPTIONS_JOYPAD_AUTOFIRE_LEFT, VIRTKEY, ALT, NOINVERT + "4", ID_OPTIONS_JOYPAD_AUTOFIRE_R, VIRTKEY, ALT, NOINVERT + "0", ID_OPTIONS_JOYPAD_AUTOFIRE_RIGHT, VIRTKEY, ALT, NOINVERT + "6", ID_OPTIONS_JOYPAD_AUTOFIRE_SELECT, VIRTKEY, ALT, + NOINVERT + "5", ID_OPTIONS_JOYPAD_AUTOFIRE_START, VIRTKEY, ALT, NOINVERT + "7", ID_OPTIONS_JOYPAD_AUTOFIRE_UP, VIRTKEY, ALT, NOINVERT + "1", ID_OPTIONS_VIDEO_LAYERS_BG0, VIRTKEY, CONTROL, NOINVERT + "2", ID_OPTIONS_VIDEO_LAYERS_BG1, VIRTKEY, CONTROL, NOINVERT + "3", ID_OPTIONS_VIDEO_LAYERS_BG2, VIRTKEY, CONTROL, NOINVERT + "4", ID_OPTIONS_VIDEO_LAYERS_BG3, VIRTKEY, CONTROL, NOINVERT + "5", ID_OPTIONS_VIDEO_LAYERS_OBJ, VIRTKEY, CONTROL, NOINVERT + "8", ID_OPTIONS_VIDEO_LAYERS_OBJWIN, VIRTKEY, CONTROL, + NOINVERT + "6", ID_OPTIONS_VIDEO_LAYERS_WIN0, VIRTKEY, CONTROL, NOINVERT + "7", ID_OPTIONS_VIDEO_LAYERS_WIN1, VIRTKEY, CONTROL, NOINVERT + VK_OEM_PERIOD, ID_TOOLS_FRAMECOUNTER, VIRTKEY, NOINVERT + VK_OEM_COMMA, ID_TOOLS_INPUTDISPLAY, VIRTKEY, NOINVERT + "8", ID_TOOLS_PLAY_READONLY, VIRTKEY, SHIFT, NOINVERT + "B", ID_TOOLS_REWIND, VIRTKEY, CONTROL, NOINVERT + "1", ID_SELECT_SLOT1, VIRTKEY, NOINVERT + "2", ID_SELECT_SLOT2, VIRTKEY, NOINVERT + "3", ID_SELECT_SLOT3, VIRTKEY, NOINVERT + "4", ID_SELECT_SLOT4, VIRTKEY, NOINVERT + "5", ID_SELECT_SLOT5, VIRTKEY, NOINVERT + "6", ID_SELECT_SLOT6, VIRTKEY, NOINVERT + "7", ID_SELECT_SLOT7, VIRTKEY, NOINVERT + "8", ID_SELECT_SLOT8, VIRTKEY, NOINVERT + "9", ID_SELECT_SLOT9, VIRTKEY, NOINVERT + "0", ID_SELECT_SLOT10, VIRTKEY, NOINVERT + "L", ID_FILE_LOADGAME_CURRENT, VIRTKEY, CONTROL, NOINVERT + "S", ID_FILE_SAVEGAME_CURRENT, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// RT_MANIFEST +// + +1 RT_MANIFEST "VisualBoyAdvance.exe.manifest" + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_UNSUPPORTED_VBA_SGM "Unsupported VisualBoyAdvance save game version %d" + IDS_CANNOT_LOAD_SGM "Cannot load save game for %s" + IDS_SAVE_GAME_NOT_USING_BIOS "Save game is not using the BIOS file" + IDS_SAVE_GAME_USING_BIOS "Save game is using the BIOS file" + IDS_UNSUPPORTED_SAVE_TYPE "Unsupported save type %d" + IDS_CANNOT_OPEN_FILE "Cannot open file %s" + IDS_BAD_ZIP_FILE "Bad ZIP file %s" + IDS_NO_IMAGE_ON_ZIP "No image found on ZIP file %s" + IDS_ERROR_OPENING_IMAGE "Error opening image %s" + IDS_ERROR_READING_IMAGE "Error reading image %s" + IDS_UNSUPPORTED_BIOS_FUNCTION + "Unsupported BIOS function %02x called from %08x. A BIOS file is needed in order to get correct behaviour." + IDS_INVALID_BIOS_FILE_SIZE "Invalid BIOS file size" + IDS_INVALID_CHEAT_CODE "Invalid cheat code '%s'. Supported formats are:\nXXXXXXXX:YY, XXXXXXXX:YYYY, XXXXXXXX:YYYYYYYY." + IDS_UNKNOWN_ARM_OPCDOE "Unimplemented opcode %08x from %08x" + IDS_UNKNOWN_THUMB_OPCODE "Unknown opcode %04x from %08x" +END + +STRINGTABLE +BEGIN + IDS_ERROR_CREATING_FILE "Error creating file %s" + IDS_FAILED_TO_READ_SGM "Failed to read complete save game %s (%d)" + IDS_FAILED_TO_READ_RTC "Failed to read RTC from save game %s (continuing)" + IDS_UNSUPPORTED_VB_SGM "Unsupported VisualBoy save game version %d" + IDS_CANNOT_LOAD_SGM_FOR "Cannot load save game for %s. Playing %s" + IDS_ERROR_OPENING_IMAGE_FROM "Error opening image %s from zip file %s" + IDS_ERROR_READING_IMAGE_FROM "Error reading image %s from zip file %s" + IDS_UNSUPPORTED_ROM_SIZE "Unsupported rom size %02x" + IDS_UNSUPPORTED_RAM_SIZE "Unsupported ram size %02x" + IDS_UNKNOWN_CARTRIDGE_TYPE "Unknown cartridge type %02x" + IDS_MAXIMUM_NUMBER_OF_CHEATS "Maximum number of cheats reached." + IDS_INVALID_GAMESHARK_CODE "Invalid GameShark code: %s" + IDS_INVALID_GAMEGENIE_CODE "Invalid GameGenie code: %s" + IDS_INVALID_CHEAT_TO_REMOVE "Invalid cheat to remove %d" + IDS_INVALID_CHEAT_CODE_ADDRESS "Invalid cheat code address: %08x" + IDS_UNSUPPORTED_CHEAT_LIST_VERSION "Unsupported cheat list version %d" +END + +STRINGTABLE +BEGIN + IDS_DIRECTX_7_REQUIRED "DirectX 7.0 or greater is required to run.\nDownload at http://www.microsoft.com/directx.\n\nError found at: %s" + IDS_DISABLING_VIDEO_MEMORY "Disabling Use Video Memory setting" + IDS_SETTING_WILL_BE_EFFECTIVE + "Setting will be effective the next time you start the emulator" + IDS_DISABLING_EMULATION_ONLY "Disabling Emulation Only setting" + IDS_FAILED_TO_OPEN_FILE "Failed to open file %s" + IDS_FAILED_TO_READ_ZIP_DIR "Failed to read zip directory for file %s" + IDS_UNSUPPORTED_FILE_TYPE "The file ""%s"" is an unsupported type." + IDS_CANNOT_CREATE_DIRECTSOUND "Cannot create DirectSound %08x" + IDS_CANNOT_SETCOOPERATIVELEVEL "Cannot SetCooperativeLevel %08x" + IDS_CANNOT_CREATESOUNDBUFFER "Cannot CreateSoundBuffer %08x" + IDS_CANNOT_SETFORMAT_PRIMARY "Cannot SetFormat for primary %08x" + IDS_CANNOT_CREATESOUNDBUFFER_SEC "Cannot CreateSoundBuffer secondary %08x" + IDS_CANNOT_PLAY_PRIMARY "Cannot Play primary %08x" + IDS_SEARCH_PRODUCED_TOO_MANY + "Search produced %d results.\nThey have been remembered, but are too many to display.\nPlease refine it better by performing additional searches." + IDS_NUMBER_CANNOT_BE_EMPTY "Number cannot be empty" + IDS_INVALID_ADDRESS "Invalid address: %08x" +END + +STRINGTABLE +BEGIN + IDS_MISALIGNED_HALFWORD "Misaligned half-word address: %08x" + IDS_MISALIGNED_WORD "Misaligned word address: %08x" + IDS_VALUE_CANNOT_BE_EMPTY "Value cannot be empty" + IDS_ERROR_ON_STARTDOC "Error on StartDoc" + IDS_ERROR_ON_STARTPAGE "Error on StartPage" + IDS_ERROR_PRINTING_ON_STRETCH "Error printing on StretchDIBits" + IDS_ERROR_ON_ENDPAGE "Error on EndPage" + IDS_ERROR_ON_ENDDOC "Error on EndDoc" + IDS_ERROR "Error" + IDS_JOY_LEFT "Joy %d Left" + IDS_JOY_RIGHT "Joy %d Right" + IDS_JOY_UP "Joy %d Up" + IDS_JOY_DOWN "Joy %d Down" + IDS_JOY_BUTTON "Joy %d %s" + IDS_SELECT_ROM_DIR "Select ROM directory:" + IDS_SELECT_BATTERY_DIR "Select Battery directory:" +END + +STRINGTABLE +BEGIN + IDS_SELECT_SAVE_DIR "Select Save Directory:" + IDS_SELECT_CAPTURE_DIR "Select Capture directory:" + IDS_SELECT_BIOS_FILE "Select BIOS file" + IDS_RESET "Reset" + IDS_AUTOFIRE_A_DISABLED "turbo A off" + IDS_AUTOFIRE_A "turbo A on" + IDS_AUTOFIRE_B_DISABLED "turbo B off" + IDS_AUTOFIRE_B "turbo B on" + IDS_AUTOFIRE_L_DISABLED "turbo L off" + IDS_AUTOFIRE_L "turbo L on" + IDS_AUTOFIRE_R_DISABLED "turbo R off" + IDS_AUTOFIRE_R "turbo R on" + IDS_SELECT_ROM "Select ROM" + IDS_SELECT_SAVE_GAME_NAME "Select save game name" + IDS_LOADED_STATE "Loaded state" + IDS_LOADED_STATE_N "Loaded %d" +END + +STRINGTABLE +BEGIN + IDS_WROTE_STATE "Saved state" + IDS_WROTE_STATE_N "Saved %d" + IDS_LOADED_BATTERY "Loaded battery" + IDS_SELECT_CAPTURE_NAME "Select screen capture name" + IDS_SCREEN_CAPTURE "Screen capture" + IDS_ADDRESS "Address" + IDS_OLD_VALUE "Old Value" + IDS_NEW_VALUE "New Value" + IDS_ADD_CHEAT_CODE "Add cheat code" + IDS_CODE "Code" + IDS_DESCRIPTION "Description" + IDS_STATUS "Status" + IDS_ADD_GG_CODE "Add GameGenie code" + IDS_ADD_GS_CODE "Add GameShark code" + IDS_POCKET_PRINTER "Pocket Printer" + IDS_UNKNOWN "Unknown" +END + +STRINGTABLE +BEGIN + IDS_NONE "None" + IDS_FAILED_TO_LOAD_LIBRARY "Failed to load library %s" + IDS_FAILED_TO_GET_LOCINFO "Failed to get locale information" + IDS_SELECT_CHEAT_LIST_NAME "Select cheat list name" + IDS_FILTER_BIOS "Gameboy Advance_*.BIN;*.AGB;*.GBA;*.BIOS;*.ZIP;*.Z;*.GZ__" + IDS_FILTER_ROM "All Gameboy / Gameboy Advance_*.BIN;*.AGB;*.GBA;*.MB;*.ELF;*.GB;*.SGB;*.CGB;*.GBC;*.ZIP;*.Z;*.GZ_Gameboy Advance_*.BIN;*.AGB;*.GBA_Gameboy_*.GB;*.SGB;*.CGB;*.GBC__" + IDS_FILTER_SGM "VisualBoyAdvance Save Game_*.SGM__" + IDS_FILTER_CHEAT_LIST "VisualBoyAdvance Cheat List_*.CLT__" + IDS_FILTER_PNG "PNG Image_*.PNG_BMP Image_*.BMP__" + IDS_LOADED_CHEATS "Loaded cheats" + IDS_ERROR_DISP_COLOR "Unsupported display setting for color depth: %d bits. \nWindows desktop must be in either 16-bit, 24-bit or 32-bit mode for this program to work in window mode." + IDS_ADD_GSA_CODE "Add GamesharkAdvance code" + IDS_FILTER_SPS "Gameshark Snapshot_*.SPS__" + IDS_SELECT_SNAPSHOT_FILE "Select snapshot file" + IDS_FILTER_SAV "Battery file_*.SAV_Flash save_*.DAT__" + IDS_SELECT_BATTERY_FILE "Select battery file" +END + +STRINGTABLE +BEGIN + IDS_UNSUPPORTED_CHEAT_LIST_TYPE "Unsupported cheat list type %d" + IDS_INVALID_GSA_CODE "Invalid GSA code. Format is XXXXXXXXYYYYYYYY." + IDS_CANNOT_IMPORT_SNAPSHOT_FOR + "Cannot import snapshot for %s. Current game is %s" + IDS_UNSUPPORTED_SNAPSHOT_FILE "Unsupported snapshot file %s" + IDS_UNSUPPORTED_ARM_MODE "Unsupported ARM mode %02x" + IDS_UNSUPPORTED_CODE_FILE "Unsupported code file %s" + IDS_GSA_CODE_WARNING "Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly." + IDS_INVALID_CBA_CODE "Invalid CBA code. Format is XXXXXXXX YYYY." + IDS_CBA_CODE_WARNING "Warning: Codes seem to be for a different game.\nCodes may not work correctly." + IDS_OUT_OF_MEMORY "Failed to allocate memory for %s" +END + +STRINGTABLE +BEGIN + IDS_FILTER_GBS "Gameboy Snapshot_*.GBS__" + IDS_FILTER_GCF "Gameshark Code File_*.GCF__" + IDS_SELECT_CODE_FILE "Select code file" + IDS_SAVE_WILL_BE_LOST "Importing a snapshot file will erase any saved games and reset the emulator. Do you want to continue?" + IDS_CONFIRM_ACTION "Please confirm action" + IDS_CODES_WILL_BE_LOST "Importing a code file will erase any entered codes. Do you want to continue?" + IDS_FILTER_SPC "Gameshark Code File_*.SPC;*.XPC__" + IDS_ADD_CBA_CODE "Add CodeBreakerAdvance code" + IDS_FILTER_WAV "Wave file_*.WAV__" + IDS_SELECT_WAV_NAME "Select wave file name" + IDS_FILTER_GBROM "All Gameboy_*.GB;*.SGB;*.CGB;*.GBC;*.ZIP;*.Z;*.GZ_Gameboy_*.GB_Super Gameboy_*.SGB_Color Gameboy_*.CGB;*.GBC__" + IDS_FILTER_PAL "Windows Palette (*.PAL)_*.PAL_PaintShop Palette (*.PAL)_*.PAL_Adobe Color Table (*.ACT)_*.ACT__" + IDS_SELECT_PALETTE_NAME "Select palette name:" + IDS_SEARCH_PRODUCED_NO_RESULTS "Search produced no results." + IDS_ERROR_BINDING "Error binding socket. Port probably in use." + IDS_ERROR_LISTENING "Error listening on socket." +END + +STRINGTABLE +BEGIN + IDS_ERROR_CREATING_SOCKET "Error creating socket." + IDS_ACK_NOT_RECEIVED "ACK not received from GDB." + IDS_ERROR_NOT_GBA_IMAGE "Error: not a GBA image." + IDS_EEPROM_NOT_SUPPORTED "EEPROM saves cannot be exported." + IDS_FILTER_DUMP "Memory Dump_*.DMP__" + IDS_SELECT_DUMP_FILE "Select dump file name" + IDS_FILTER_AVI "AVI File_*.AVI__" + IDS_SELECT_AVI_NAME "Select AVI file name" + IDS_INVALID_THROTTLE_VALUE + "Invalid throttle value. Please enter a number between 5 and 1000." + IDS_FILTER_INI "Skin INI File_*.INI__" + IDS_SELECT_SKIN_FILE "Select the skin file name" + IDS_FILTER_MOVIE "VisualBoyAdvance Movie (.vbm)_*.vbm__" + IDS_SELECT_MOVIE_NAME "Select movie name" + IDS_BUG_REPORT "The bug report information is now available on the Windows Clipboard. Please paste it into any bug report made by email or on forums to help solve problems more easily." + IDS_UNSUPPORTED_MOVIE_VERSION "Unsupported movie version %d." + IDS_END_OF_MOVIE "end of movie" +END + +STRINGTABLE +BEGIN + IDS_INVALID_INTERVAL_VALUE + "Invalid rewind interval value. Please enter a number between 0 and 600 seconds." + IDS_REGISTRY "VisualBoyAdvance no longer uses the registry to store its settings. Your previous settings have been exported into the file: %s" + IDS_MOVIE_PLAY "Playing a movie will load a save state which may erase your previous battery saves. Please be sure to have a saved state if you don't want to loose any previous data." + IDS_AUTOFIRE_DISABLED "autofire off" + IDS_AUTOFIRE_ALREADY_DISABLED "autofire already off" + IDS_AUTOFIRE_START_DISABLED "turbo Start off" + IDS_AUTOFIRE_START "turbo Start on" + IDS_AUTOFIRE_SELECT_DISABLED "turbo Select off" + IDS_AUTOFIRE_SELECT "turbo Select on" + IDS_AUTOFIRE_UP_DISABLED "turbo Up off" + IDS_AUTOFIRE_UP "turbo Up on" + IDS_AUTOFIRE_DOWN_DISABLED "turbo Down off" + IDS_AUTOFIRE_DOWN "turbo Down on" + IDS_AUTOFIRE_LEFT_DISABLED "turbo Left off" + IDS_AUTOFIRE_LEFT "turbo Left on" + IDS_AUTOFIRE_RIGHT_DISABLED "turbo Right off" +END + +STRINGTABLE +BEGIN + IDS_AUTOFIRE_RIGHT "turbo Right on" + IDS_RERECORDED_STATE_N "Re-record from %d" + IDS_REPLAYED_STATE_N "Rewind to %d" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/win32/vba.rc2 b/src/win32/vba.rc2 new file mode 100644 index 0000000..f4cbf4a --- /dev/null +++ b/src/win32/vba.rc2 @@ -0,0 +1,50 @@ + +// what the hell? all this file does is cause enigmatic build errors... + +/* +#ifndef _MAC +#include "../AutoBuild.h" +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION FILEVER + PRODUCTVERSION PRODUCTVER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x29L +#else + FILEFLAGS 0x28L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "VisualBoyAdvance comes with NO WARRANTY. Use it at your own risk.\0" + VALUE "CompanyName", "None\0" + VALUE "FileDescription", "VisualBoyAdvance emulator\0" + VALUE "FileVersion", STRFILEVER + VALUE "InternalName", "VisualBoyAdvance\0" + VALUE "LegalCopyright", "Copyright Š 2004 Forgotten and the VBA team\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "VisualBoyAdvance.exe\0" + VALUE "PrivateBuild", "0\0" + VALUE "ProductName", "VisualBoyAdvance emulator\0" + VALUE "ProductVersion", STRPRODUCTVER + VALUE "SpecialBuild", "0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC +*/ \ No newline at end of file diff --git a/win32/GBA.vcproj b/win32/GBA.vcproj new file mode 100644 index 0000000..09ff1f4 --- /dev/null +++ b/win32/GBA.vcproj @@ -0,0 +1,1419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/win32/Makefile.am b/win32/Makefile.am new file mode 100644 index 0000000..556b49c --- /dev/null +++ b/win32/Makefile.am @@ -0,0 +1,9 @@ +EXTRA_DIST = \ + gba.sln \ + GBA.vcproj \ + lib \ + include \ + directx + +dist-hook: + rm -rf `find $(distdir) -name CVS` diff --git a/win32/Makefile.in b/win32/Makefile.in new file mode 100644 index 0000000..5162e02 --- /dev/null +++ b/win32/Makefile.in @@ -0,0 +1,311 @@ +# Makefile.in generated by automake 1.7.9 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMSGFMT = @GMSGFMT@ +GTKMM_CFLAGS = @GTKMM_CFLAGS@ +GTKMM_CPPFLAGS = @GTKMM_CPPFLAGS@ +GTKMM_LIBS = @GTKMM_LIBS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NASM = @NASM@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VBA_EXTRA = @VBA_EXTRA@ +VBA_LIBS = @VBA_LIBS@ +VBA_SRC_EXTRA = @VBA_SRC_EXTRA@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +EXTRA_DIST = \ + gba_sdl.dsp \ + gba_sdl.dsw \ + gba_sdl.sln \ + gba_sdl.vcproj \ + GBA.dsp \ + GBA.dsw \ + gba.sln \ + GBA.vcproj \ + SDL-1.2.2 \ + lib \ + include + +subdir = win32 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = $(srcdir)/Makefile.in Makefile.am +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu win32/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook +check-am: all-am +check: check-am +all-am: Makefile + +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + + +dist-hook: + rm -rf `find $(distdir) -name CVS` +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/win32/directx/d3d8.h b/win32/directx/d3d8.h new file mode 100644 index 0000000..2600282 --- /dev/null +++ b/win32/directx/d3d8.h @@ -0,0 +1,1279 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D8_H_ +#define _D3D8_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + + +/* This identifier is passed to Direct3DCreate8 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. + * (The number itself has no meaning.)*/ + +#define D3D_SDK_VERSION 220 + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D8 */ +/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ +DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); + +/* IID_IDirect3DDevice8 */ +/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ +DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); + +/* IID_IDirect3DResource8 */ +/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ +DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); + +/* IID_IDirect3DBaseTexture8 */ +/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ +DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); + +/* IID_IDirect3DTexture8 */ +/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ +DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); + +/* IID_IDirect3DCubeTexture8 */ +/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ +DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); + +/* IID_IDirect3DVolumeTexture8 */ +/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); + +/* IID_IDirect3DVertexBuffer8 */ +/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); + +/* IID_IDirect3DIndexBuffer8 */ +/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); + +/* IID_IDirect3DSurface8 */ +/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ +DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); + +/* IID_IDirect3DVolume8 */ +/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ +DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); + +/* IID_IDirect3DSwapChain8 */ +/* {928C088B-76B9-4C6B-A536-A590853876CD} */ +DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); + +#endif + +#ifdef __cplusplus + +interface IDirect3D8; +interface IDirect3DDevice8; + +interface IDirect3DResource8; +interface IDirect3DBaseTexture8; +interface IDirect3DTexture8; +interface IDirect3DVolumeTexture8; +interface IDirect3DCubeTexture8; + +interface IDirect3DVertexBuffer8; +interface IDirect3DIndexBuffer8; + +interface IDirect3DSurface8; +interface IDirect3DVolume8; + +interface IDirect3DSwapChain8; + +#endif + + +typedef interface IDirect3D8 IDirect3D8; +typedef interface IDirect3DDevice8 IDirect3DDevice8; +typedef interface IDirect3DResource8 IDirect3DResource8; +typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; +typedef interface IDirect3DTexture8 IDirect3DTexture8; +typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; +typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; +typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; +typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; +typedef interface IDirect3DSurface8 IDirect3DSurface8; +typedef interface IDirect3DVolume8 IDirect3DVolume8; +typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; + +#include "d3d8types.h" +#include "d3d8caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D8 object. This object supports + * enumeration and allows the creation of Direct3DDevice8 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); + + +/* + * Direct3D interfaces + */ + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D8 + +DECLARE_INTERFACE_(IDirect3D8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D8 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; +}; + +typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D8_AddRef(p) (p)->AddRef() +#define IDirect3D8_Release(p) (p)->Release() +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice8 + +DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice8 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; + STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; + STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; + STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; + STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; + STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; +}; + +typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#else +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice8_AddRef(p) (p)->AddRef() +#define IDirect3DDevice8_Release(p) (p)->Release() +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice8_EndScene(p) (p)->EndScene() +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain8 + +DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain8 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; +}; + +typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#else +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain8_Release(p) (p)->Release() +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource8 + +DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource8_AddRef(p) (p)->AddRef() +#define IDirect3DResource8_Release(p) (p)->Release() +#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource8_GetType(p) (p)->GetType() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture8 + +DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#else +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture8_Release(p) (p)->Release() +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture8 + +DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DTexture8_Release(p) (p)->Release() +#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture8_GetType(p) (p)->GetType() +#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture8 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; +}; + +typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture8_Release(p) (p)->Release() +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture8 + +DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture8_Release(p) (p)->Release() +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer8 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer8_Release(p) (p)->Release() +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer8 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer8_Release(p) (p)->Release() +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface8 + +DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSurface8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; +}; + +typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#else +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface8_AddRef(p) (p)->AddRef() +#define IDirect3DSurface8_Release(p) (p)->Release() +#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume8 + +DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; +}; + +typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume8_AddRef(p) (p)->AddRef() +#define IDirect3DVolume8_Release(p) (p)->Release() +#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() +#endif + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D8 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D8 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for + * the current mode only. + * + ****************************************************************************/ + +#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL + +/**************************************************************************** + * + * Flags for IDirect3D8::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L + + +/**************************************************************************** + * + * Parameter for IDirect3D8::CreateDevice's iAdapter + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D8::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_NO_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX8 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D_H_ */ + diff --git a/win32/directx/d3d8.lib b/win32/directx/d3d8.lib new file mode 100644 index 0000000..828ed30 Binary files /dev/null and b/win32/directx/d3d8.lib differ diff --git a/win32/directx/d3d8caps.h b/win32/directx/d3d8caps.h new file mode 100644 index 0000000..6a7dc11 --- /dev/null +++ b/win32/directx/d3d8caps.h @@ -0,0 +1,364 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8caps.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _D3D8CAPS_H +#define _D3D8CAPS_H + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + +typedef struct _D3DCAPS8 +{ + /* Device Info */ + D3DDEVTYPE DeviceType; + UINT AdapterOrdinal; + + /* Caps from DX7 Draw */ + DWORD Caps; + DWORD Caps2; + DWORD Caps3; + DWORD PresentationIntervals; + + /* Cursor Caps */ + DWORD CursorCaps; + + /* 3D Device Caps */ + DWORD DevCaps; + + DWORD PrimitiveMiscCaps; + DWORD RasterCaps; + DWORD ZCmpCaps; + DWORD SrcBlendCaps; + DWORD DestBlendCaps; + DWORD AlphaCmpCaps; + DWORD ShadeCaps; + DWORD TextureCaps; + DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture8's + DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture8's + DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture8's + DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture8's + DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture8's + + DWORD LineCaps; // D3DLINECAPS + + DWORD MaxTextureWidth, MaxTextureHeight; + DWORD MaxVolumeExtent; + + DWORD MaxTextureRepeat; + DWORD MaxTextureAspectRatio; + DWORD MaxAnisotropy; + float MaxVertexW; + + float GuardBandLeft; + float GuardBandTop; + float GuardBandRight; + float GuardBandBottom; + + float ExtentsAdjust; + DWORD StencilCaps; + + DWORD FVFCaps; + DWORD TextureOpCaps; + DWORD MaxTextureBlendStages; + DWORD MaxSimultaneousTextures; + + DWORD VertexProcessingCaps; + DWORD MaxActiveLights; + DWORD MaxUserClipPlanes; + DWORD MaxVertexBlendMatrices; + DWORD MaxVertexBlendMatrixIndex; + + float MaxPointSize; + + DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxVertexIndex; + DWORD MaxStreams; + DWORD MaxStreamStride; // max stride for SetStreamSource + + DWORD VertexShaderVersion; + DWORD MaxVertexShaderConst; // number of vertex shader constant registers + + DWORD PixelShaderVersion; + float MaxPixelShaderValue; // max value of pixel shader arithmetic component + +} D3DCAPS8; + +// +// BIT DEFINES FOR D3DCAPS8 DWORD MEMBERS +// + +// +// Caps +// +#define D3DCAPS_READ_SCANLINE 0x00020000L + +// +// Caps2 +// +#define D3DCAPS2_NO2DDURING3DSCENE 0x00000002L +#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L +#define D3DCAPS2_CANRENDERWINDOWED 0x00080000L +#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L +#define D3DCAPS2_RESERVED 0x02000000L +#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L +#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L + +// +// Caps3 +// +#define D3DCAPS3_RESERVED 0x8000001fL + +// Indicates that the device can respect the ALPHABLENDENABLE render state +// when fullscreen while using the FLIP or DISCARD swap effect. +// COPY and COPYVSYNC swap effects work whether or not this flag is set. +#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L + +// +// PresentationIntervals +// +#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L +#define D3DPRESENT_INTERVAL_ONE 0x00000001L +#define D3DPRESENT_INTERVAL_TWO 0x00000002L +#define D3DPRESENT_INTERVAL_THREE 0x00000004L +#define D3DPRESENT_INTERVAL_FOUR 0x00000008L +#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L + +// +// CursorCaps +// +// Driver supports HW color cursor in at least hi-res modes(height >=400) +#define D3DCURSORCAPS_COLOR 0x00000001L +// Driver supports HW cursor also in low-res modes(height < 400) +#define D3DCURSORCAPS_LOWRES 0x00000002L + +// +// DevCaps +// +#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ +#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */ +#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */ +#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */ +#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */ +#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */ +#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */ +#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */ +#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */ +#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */ +#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ +#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/ +#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */ +#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */ +#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */ +#define D3DDEVCAPS_PUREDEVICE 0x00100000L /* Device supports D3DCREATE_PUREDEVICE */ +#define D3DDEVCAPS_QUINTICRTPATCHES 0x00200000L /* Device supports quintic Beziers and BSplines */ +#define D3DDEVCAPS_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */ +#define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */ +#define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */ + +// +// PrimitiveMiscCaps +// +#define D3DPMISCCAPS_MASKZ 0x00000002L +#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L +#define D3DPMISCCAPS_CULLNONE 0x00000010L +#define D3DPMISCCAPS_CULLCW 0x00000020L +#define D3DPMISCCAPS_CULLCCW 0x00000040L +#define D3DPMISCCAPS_COLORWRITEENABLE 0x00000080L +#define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x00000100L /* Device correctly clips scaled points to clip planes */ +#define D3DPMISCCAPS_CLIPTLVERTS 0x00000200L /* device will clip post-transformed vertex primitives */ +#define D3DPMISCCAPS_TSSARGTEMP 0x00000400L /* device supports D3DTA_TEMP for temporary register */ +#define D3DPMISCCAPS_BLENDOP 0x00000800L /* device supports D3DRS_BLENDOP */ +#define D3DPMISCCAPS_NULLREFERENCE 0x00001000L /* Reference Device that doesnt render */ + +// +// LineCaps +// +#define D3DLINECAPS_TEXTURE 0x00000001L +#define D3DLINECAPS_ZTEST 0x00000002L +#define D3DLINECAPS_BLEND 0x00000004L +#define D3DLINECAPS_ALPHACMP 0x00000008L +#define D3DLINECAPS_FOG 0x00000010L + +// +// RasterCaps +// +#define D3DPRASTERCAPS_DITHER 0x00000001L +#define D3DPRASTERCAPS_PAT 0x00000008L +#define D3DPRASTERCAPS_ZTEST 0x00000010L +#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L +#define D3DPRASTERCAPS_FOGTABLE 0x00000100L +#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L +#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L +#define D3DPRASTERCAPS_ZBIAS 0x00004000L +#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L +#define D3DPRASTERCAPS_FOGRANGE 0x00010000L +#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L +#define D3DPRASTERCAPS_WBUFFER 0x00040000L +#define D3DPRASTERCAPS_WFOG 0x00100000L +#define D3DPRASTERCAPS_ZFOG 0x00200000L +#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ +#define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000L + +// +// ZCmpCaps, AlphaCmpCaps +// +#define D3DPCMPCAPS_NEVER 0x00000001L +#define D3DPCMPCAPS_LESS 0x00000002L +#define D3DPCMPCAPS_EQUAL 0x00000004L +#define D3DPCMPCAPS_LESSEQUAL 0x00000008L +#define D3DPCMPCAPS_GREATER 0x00000010L +#define D3DPCMPCAPS_NOTEQUAL 0x00000020L +#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L +#define D3DPCMPCAPS_ALWAYS 0x00000080L + +// +// SourceBlendCaps, DestBlendCaps +// +#define D3DPBLENDCAPS_ZERO 0x00000001L +#define D3DPBLENDCAPS_ONE 0x00000002L +#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L +#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L +#define D3DPBLENDCAPS_SRCALPHA 0x00000010L +#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L +#define D3DPBLENDCAPS_DESTALPHA 0x00000040L +#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L +#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L +#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L +#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L +#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L +#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L + +// +// ShadeCaps +// +#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L +#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L +#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L +#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L + +// +// TextureCaps +// +#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ +#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ +#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ +#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ +#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ +#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ +// Device can use non-POW2 textures if: +// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage +// 2) D3DRS_WRAP(N) is zero for this texture's coordinates +// 3) mip mapping is not enabled (use magnification filter only) +#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L +#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ +#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ +#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */ +#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */ +#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */ +#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ +#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ +#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ + +// +// TextureFilterCaps +// +#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ +#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L +#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L +#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */ +#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L +#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ +#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L +#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L +#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L +#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L + +// +// TextureAddressCaps +// +#define D3DPTADDRESSCAPS_WRAP 0x00000001L +#define D3DPTADDRESSCAPS_MIRROR 0x00000002L +#define D3DPTADDRESSCAPS_CLAMP 0x00000004L +#define D3DPTADDRESSCAPS_BORDER 0x00000008L +#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L +#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L + +// +// StencilCaps +// +#define D3DSTENCILCAPS_KEEP 0x00000001L +#define D3DSTENCILCAPS_ZERO 0x00000002L +#define D3DSTENCILCAPS_REPLACE 0x00000004L +#define D3DSTENCILCAPS_INCRSAT 0x00000008L +#define D3DSTENCILCAPS_DECRSAT 0x00000010L +#define D3DSTENCILCAPS_INVERT 0x00000020L +#define D3DSTENCILCAPS_INCR 0x00000040L +#define D3DSTENCILCAPS_DECR 0x00000080L + +// +// TextureOpCaps +// +#define D3DTEXOPCAPS_DISABLE 0x00000001L +#define D3DTEXOPCAPS_SELECTARG1 0x00000002L +#define D3DTEXOPCAPS_SELECTARG2 0x00000004L +#define D3DTEXOPCAPS_MODULATE 0x00000008L +#define D3DTEXOPCAPS_MODULATE2X 0x00000010L +#define D3DTEXOPCAPS_MODULATE4X 0x00000020L +#define D3DTEXOPCAPS_ADD 0x00000040L +#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L +#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L +#define D3DTEXOPCAPS_SUBTRACT 0x00000200L +#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L +#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L +#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L +#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L +#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L +#define D3DTEXOPCAPS_PREMODULATE 0x00010000L +#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L +#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L +#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L +#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L +#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L +#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L +#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L +#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L +#define D3DTEXOPCAPS_LERP 0x02000000L + +// +// FVFCaps +// +#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ +#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ +#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ + +// +// VertexProcessingCaps +// +#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ +#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ +#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ +#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */ +#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */ +#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */ +#define D3DVTXPCAPS_NO_VSDT_UBYTE4 0x00000080L /* device does not support D3DVSDT_UBYTE4 */ + +#pragma pack() + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D8CAPS_H_ */ + diff --git a/win32/directx/d3d8types.h b/win32/directx/d3d8types.h new file mode 100644 index 0000000..0303762 --- /dev/null +++ b/win32/directx/d3d8types.h @@ -0,0 +1,1684 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8types.h + * Content: Direct3D capabilities include file + * + ***************************************************************************/ + +#ifndef _D3D8TYPES_H_ +#define _D3D8TYPES_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + +#include + +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4201) // anonymous unions warning +#if defined(_X86_) || defined(_IA64_) +#pragma pack(4) +#endif + +// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8 +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +// maps unsigned 8 bits/channel to D3DCOLOR +#define D3DCOLOR_ARGB(a,r,g,b) \ + ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b) +#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) + +// maps floating point channels (0.f to 1.f range) to D3DCOLOR +#define D3DCOLOR_COLORVALUE(r,g,b,a) \ + D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f)) + + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef D3DCOLORVALUE_DEFINED +typedef struct _D3DCOLORVALUE { + float r; + float g; + float b; + float a; +} D3DCOLORVALUE; +#define D3DCOLORVALUE_DEFINED +#endif + +#ifndef D3DRECT_DEFINED +typedef struct _D3DRECT { + LONG x1; + LONG y1; + LONG x2; + LONG y2; +} D3DRECT; +#define D3DRECT_DEFINED +#endif + +#ifndef D3DMATRIX_DEFINED +typedef struct _D3DMATRIX { + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + + }; + float m[4][4]; + }; +} D3DMATRIX; +#define D3DMATRIX_DEFINED +#endif + +typedef struct _D3DVIEWPORT8 { + DWORD X; + DWORD Y; /* Viewport Top left */ + DWORD Width; + DWORD Height; /* Viewport Dimensions */ + float MinZ; /* Min/max of clip Volume */ + float MaxZ; +} D3DVIEWPORT8; + +/* + * Values for clip fields. + */ + +// Max number of user clipping planes, supported in D3D. +#define D3DMAXUSERCLIPPLANES 32 + +// These bits could be ORed together to use with D3DRS_CLIPPLANEENABLE +// +#define D3DCLIPPLANE0 (1 << 0) +#define D3DCLIPPLANE1 (1 << 1) +#define D3DCLIPPLANE2 (1 << 2) +#define D3DCLIPPLANE3 (1 << 3) +#define D3DCLIPPLANE4 (1 << 4) +#define D3DCLIPPLANE5 (1 << 5) + +// The following bits are used in the ClipUnion and ClipIntersection +// members of the D3DCLIPSTATUS8 +// + +#define D3DCS_LEFT 0x00000001L +#define D3DCS_RIGHT 0x00000002L +#define D3DCS_TOP 0x00000004L +#define D3DCS_BOTTOM 0x00000008L +#define D3DCS_FRONT 0x00000010L +#define D3DCS_BACK 0x00000020L +#define D3DCS_PLANE0 0x00000040L +#define D3DCS_PLANE1 0x00000080L +#define D3DCS_PLANE2 0x00000100L +#define D3DCS_PLANE3 0x00000200L +#define D3DCS_PLANE4 0x00000400L +#define D3DCS_PLANE5 0x00000800L + +#define D3DCS_ALL (D3DCS_LEFT | \ + D3DCS_RIGHT | \ + D3DCS_TOP | \ + D3DCS_BOTTOM | \ + D3DCS_FRONT | \ + D3DCS_BACK | \ + D3DCS_PLANE0 | \ + D3DCS_PLANE1 | \ + D3DCS_PLANE2 | \ + D3DCS_PLANE3 | \ + D3DCS_PLANE4 | \ + D3DCS_PLANE5) + +typedef struct _D3DCLIPSTATUS8 { + DWORD ClipUnion; + DWORD ClipIntersection; +} D3DCLIPSTATUS8; + +typedef struct _D3DMATERIAL8 { + D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */ + D3DCOLORVALUE Ambient; /* Ambient color RGB */ + D3DCOLORVALUE Specular; /* Specular 'shininess' */ + D3DCOLORVALUE Emissive; /* Emissive color RGB */ + float Power; /* Sharpness if specular highlight */ +} D3DMATERIAL8; + +typedef enum _D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, + D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DLIGHTTYPE; + +typedef struct _D3DLIGHT8 { + D3DLIGHTTYPE Type; /* Type of light source */ + D3DCOLORVALUE Diffuse; /* Diffuse color of light */ + D3DCOLORVALUE Specular; /* Specular color of light */ + D3DCOLORVALUE Ambient; /* Ambient color of light */ + D3DVECTOR Position; /* Position in world space */ + D3DVECTOR Direction; /* Direction in world space */ + float Range; /* Cutoff range */ + float Falloff; /* Falloff */ + float Attenuation0; /* Constant attenuation */ + float Attenuation1; /* Linear attenuation */ + float Attenuation2; /* Quadratic attenuation */ + float Theta; /* Inner angle of spotlight cone */ + float Phi; /* Outer angle of spotlight cone */ +} D3DLIGHT8; + +/* + * Options for clearing + */ +#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */ +#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */ +#define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */ + +/* + * The following defines the rendering states + */ + +typedef enum _D3DSHADEMODE { + D3DSHADE_FLAT = 1, + D3DSHADE_GOURAUD = 2, + D3DSHADE_PHONG = 3, + D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSHADEMODE; + +typedef enum _D3DFILLMODE { + D3DFILL_POINT = 1, + D3DFILL_WIREFRAME = 2, + D3DFILL_SOLID = 3, + D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFILLMODE; + +typedef struct _D3DLINEPATTERN { + WORD wRepeatFactor; + WORD wLinePattern; +} D3DLINEPATTERN; + +typedef enum _D3DBLEND { + D3DBLEND_ZERO = 1, + D3DBLEND_ONE = 2, + D3DBLEND_SRCCOLOR = 3, + D3DBLEND_INVSRCCOLOR = 4, + D3DBLEND_SRCALPHA = 5, + D3DBLEND_INVSRCALPHA = 6, + D3DBLEND_DESTALPHA = 7, + D3DBLEND_INVDESTALPHA = 8, + D3DBLEND_DESTCOLOR = 9, + D3DBLEND_INVDESTCOLOR = 10, + D3DBLEND_SRCALPHASAT = 11, + D3DBLEND_BOTHSRCALPHA = 12, + D3DBLEND_BOTHINVSRCALPHA = 13, + D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLEND; + +typedef enum _D3DBLENDOP { + D3DBLENDOP_ADD = 1, + D3DBLENDOP_SUBTRACT = 2, + D3DBLENDOP_REVSUBTRACT = 3, + D3DBLENDOP_MIN = 4, + D3DBLENDOP_MAX = 5, + D3DBLENDOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DBLENDOP; + +typedef enum _D3DTEXTUREADDRESS { + D3DTADDRESS_WRAP = 1, + D3DTADDRESS_MIRROR = 2, + D3DTADDRESS_CLAMP = 3, + D3DTADDRESS_BORDER = 4, + D3DTADDRESS_MIRRORONCE = 5, + D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTUREADDRESS; + +typedef enum _D3DCULL { + D3DCULL_NONE = 1, + D3DCULL_CW = 2, + D3DCULL_CCW = 3, + D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCULL; + +typedef enum _D3DCMPFUNC { + D3DCMP_NEVER = 1, + D3DCMP_LESS = 2, + D3DCMP_EQUAL = 3, + D3DCMP_LESSEQUAL = 4, + D3DCMP_GREATER = 5, + D3DCMP_NOTEQUAL = 6, + D3DCMP_GREATEREQUAL = 7, + D3DCMP_ALWAYS = 8, + D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DCMPFUNC; + +typedef enum _D3DSTENCILOP { + D3DSTENCILOP_KEEP = 1, + D3DSTENCILOP_ZERO = 2, + D3DSTENCILOP_REPLACE = 3, + D3DSTENCILOP_INCRSAT = 4, + D3DSTENCILOP_DECRSAT = 5, + D3DSTENCILOP_INVERT = 6, + D3DSTENCILOP_INCR = 7, + D3DSTENCILOP_DECR = 8, + D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DSTENCILOP; + +typedef enum _D3DFOGMODE { + D3DFOG_NONE = 0, + D3DFOG_EXP = 1, + D3DFOG_EXP2 = 2, + D3DFOG_LINEAR = 3, + D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DFOGMODE; + +typedef enum _D3DZBUFFERTYPE { + D3DZB_FALSE = 0, + D3DZB_TRUE = 1, // Z buffering + D3DZB_USEW = 2, // W buffering + D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DZBUFFERTYPE; + +// Primitives supported by draw-primitive API +typedef enum _D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_LINESTRIP = 3, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_TRIANGLEFAN = 6, + D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DPRIMITIVETYPE; + +typedef enum _D3DTRANSFORMSTATETYPE { + D3DTS_VIEW = 2, + D3DTS_PROJECTION = 3, + D3DTS_TEXTURE0 = 16, + D3DTS_TEXTURE1 = 17, + D3DTS_TEXTURE2 = 18, + D3DTS_TEXTURE3 = 19, + D3DTS_TEXTURE4 = 20, + D3DTS_TEXTURE5 = 21, + D3DTS_TEXTURE6 = 22, + D3DTS_TEXTURE7 = 23, + D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTRANSFORMSTATETYPE; + +#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256) +#define D3DTS_WORLD D3DTS_WORLDMATRIX(0) +#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1) +#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2) +#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3) + +typedef enum _D3DRENDERSTATETYPE { + D3DRS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ + D3DRS_FILLMODE = 8, /* D3DFILLMODE */ + D3DRS_SHADEMODE = 9, /* D3DSHADEMODE */ + D3DRS_LINEPATTERN = 10, /* D3DLINEPATTERN */ + D3DRS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ + D3DRS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ + D3DRS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ + D3DRS_SRCBLEND = 19, /* D3DBLEND */ + D3DRS_DESTBLEND = 20, /* D3DBLEND */ + D3DRS_CULLMODE = 22, /* D3DCULL */ + D3DRS_ZFUNC = 23, /* D3DCMPFUNC */ + D3DRS_ALPHAREF = 24, /* D3DFIXED */ + D3DRS_ALPHAFUNC = 25, /* D3DCMPFUNC */ + D3DRS_DITHERENABLE = 26, /* TRUE to enable dithering */ + D3DRS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ + D3DRS_FOGENABLE = 28, /* TRUE to enable fog blending */ + D3DRS_SPECULARENABLE = 29, /* TRUE to enable specular */ + D3DRS_ZVISIBLE = 30, /* TRUE to enable z checking */ + D3DRS_FOGCOLOR = 34, /* D3DCOLOR */ + D3DRS_FOGTABLEMODE = 35, /* D3DFOGMODE */ + D3DRS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ + D3DRS_FOGEND = 37, /* Fog end */ + D3DRS_FOGDENSITY = 38, /* Fog density */ + D3DRS_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */ + D3DRS_ZBIAS = 47, /* LONG Z bias */ + D3DRS_RANGEFOGENABLE = 48, /* Enables range-based fog */ + D3DRS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ + D3DRS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ + D3DRS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ + D3DRS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ + D3DRS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + D3DRS_STENCILREF = 57, /* Reference value used in stencil test */ + D3DRS_STENCILMASK = 58, /* Mask value used in stencil test */ + D3DRS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ + D3DRS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ + D3DRS_WRAP0 = 128, /* wrap for 1st texture coord. set */ + D3DRS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ + D3DRS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ + D3DRS_WRAP3 = 131, /* wrap for 4th texture coord. set */ + D3DRS_WRAP4 = 132, /* wrap for 5th texture coord. set */ + D3DRS_WRAP5 = 133, /* wrap for 6th texture coord. set */ + D3DRS_WRAP6 = 134, /* wrap for 7th texture coord. set */ + D3DRS_WRAP7 = 135, /* wrap for 8th texture coord. set */ + D3DRS_CLIPPING = 136, + D3DRS_LIGHTING = 137, + D3DRS_AMBIENT = 139, + D3DRS_FOGVERTEXMODE = 140, + D3DRS_COLORVERTEX = 141, + D3DRS_LOCALVIEWER = 142, + D3DRS_NORMALIZENORMALS = 143, + D3DRS_DIFFUSEMATERIALSOURCE = 145, + D3DRS_SPECULARMATERIALSOURCE = 146, + D3DRS_AMBIENTMATERIALSOURCE = 147, + D3DRS_EMISSIVEMATERIALSOURCE = 148, + D3DRS_VERTEXBLEND = 151, + D3DRS_CLIPPLANEENABLE = 152, + D3DRS_SOFTWAREVERTEXPROCESSING = 153, + D3DRS_POINTSIZE = 154, /* float point size */ + D3DRS_POINTSIZE_MIN = 155, /* float point size min threshold */ + D3DRS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ + D3DRS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ + D3DRS_POINTSCALE_A = 158, /* float point attenuation A value */ + D3DRS_POINTSCALE_B = 159, /* float point attenuation B value */ + D3DRS_POINTSCALE_C = 160, /* float point attenuation C value */ + D3DRS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer + D3DRS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable + D3DRS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation + D3DRS_PATCHSEGMENTS = 164, // Number of segments per edge when drawing patches + D3DRS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor + D3DRS_POINTSIZE_MAX = 166, /* float point size max threshold */ + D3DRS_INDEXEDVERTEXBLENDENABLE = 167, + D3DRS_COLORWRITEENABLE = 168, // per-channel write enable + D3DRS_TWEENFACTOR = 170, // float tween factor + D3DRS_BLENDOP = 171, // D3DBLENDOP setting + D3DRS_POSITIONORDER = 172, // NPatch position interpolation order. D3DORDER_LINEAR or D3DORDER_CUBIC (default) + D3DRS_NORMALORDER = 173, // NPatch normal interpolation order. D3DORDER_LINEAR (default) or D3DORDER_QUADRATIC + + D3DRS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DRENDERSTATETYPE; + +// Values for material source +typedef enum _D3DMATERIALCOLORSOURCE +{ + D3DMCS_MATERIAL = 0, // Color from material is used + D3DMCS_COLOR1 = 1, // Diffuse vertex color is used + D3DMCS_COLOR2 = 2, // Specular vertex color is used + D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DMATERIALCOLORSOURCE; + +// Bias to apply to the texture coordinate set to apply a wrap to. +#define D3DRENDERSTATE_WRAPBIAS 128UL + +/* Flags to construct the WRAP render states */ +#define D3DWRAP_U 0x00000001L +#define D3DWRAP_V 0x00000002L +#define D3DWRAP_W 0x00000004L + +/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */ +#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U +#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V +#define D3DWRAPCOORD_2 0x00000004L // same as D3DWRAP_W +#define D3DWRAPCOORD_3 0x00000008L + +/* Flags to construct D3DRS_COLORWRITEENABLE */ +#define D3DCOLORWRITEENABLE_RED (1L<<0) +#define D3DCOLORWRITEENABLE_GREEN (1L<<1) +#define D3DCOLORWRITEENABLE_BLUE (1L<<2) +#define D3DCOLORWRITEENABLE_ALPHA (1L<<3) + +/* + * State enumerants for per-stage texture processing. + */ +typedef enum _D3DTEXTURESTAGESTATETYPE +{ + D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */ + D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */ + D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */ + D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */ + D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */ + D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */ + D3DTSS_BUMPENVMAT00 = 7, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT01 = 8, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT10 = 9, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT11 = 10, /* float (bump mapping matrix) */ + D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */ + D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */ + D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */ + D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */ + D3DTSS_MAGFILTER = 16, /* D3DTEXTUREFILTER filter to use for magnification */ + D3DTSS_MINFILTER = 17, /* D3DTEXTUREFILTER filter to use for minification */ + D3DTSS_MIPFILTER = 18, /* D3DTEXTUREFILTER filter to use between mipmaps during minification */ + D3DTSS_MIPMAPLODBIAS = 19, /* float Mipmap LOD bias */ + D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */ + D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */ + D3DTSS_BUMPENVLSCALE = 22, /* float scale for bump map luminance */ + D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */ + D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ + D3DTSS_ADDRESSW = 25, /* D3DTEXTUREADDRESS for W coordinate */ + D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */ + D3DTSS_ALPHAARG0 = 27, /* D3DTA_* third arg for triadic ops */ + D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */ + D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTURESTAGESTATETYPE; + +// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position +// and normal in the camera space) should be taken as texture coordinates +// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from +// +#define D3DTSS_TCI_PASSTHRU 0x00000000 +#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000 +#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000 +#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000 + +/* + * Enumerations for COLOROP and ALPHAOP texture blending operations set in + * texture processing stage controls in D3DTSS. + */ +typedef enum _D3DTEXTUREOP +{ + // Control + D3DTOP_DISABLE = 1, // disables stage + D3DTOP_SELECTARG1 = 2, // the default + D3DTOP_SELECTARG2 = 3, + + // Modulate + D3DTOP_MODULATE = 4, // multiply args together + D3DTOP_MODULATE2X = 5, // multiply and 1 bit + D3DTOP_MODULATE4X = 6, // multiply and 2 bits + + // Add + D3DTOP_ADD = 7, // add arguments together + D3DTOP_ADDSIGNED = 8, // add with -0.5 bias + D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit + D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation + D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product + // Arg1 + Arg2 - Arg1*Arg2 + // = Arg1 + (1-Arg1)*Arg2 + + // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) + D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha + D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha + D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR + + // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) + D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha + D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color + + // Specular mapping + D3DTOP_PREMODULATE = 17, // modulate with next texture before use + D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB + // COLOROP only + D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A + // COLOROP only + D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB + // COLOROP only + D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A + // COLOROP only + + // Bump mapping + D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation + D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel + + // This can do either diffuse or specular bump mapping with correct input. + // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B) + // where each component has been scaled and offset to make it signed. + // The result is replicated into all four (including alpha) channels. + // This is a valid COLOROP only. + D3DTOP_DOTPRODUCT3 = 24, + + // Triadic ops + D3DTOP_MULTIPLYADD = 25, // Arg0 + Arg1*Arg2 + D3DTOP_LERP = 26, // (Arg0)*Arg1 + (1-Arg0)*Arg2 + + D3DTOP_FORCE_DWORD = 0x7fffffff, +} D3DTEXTUREOP; + +/* + * Values for COLORARG0,1,2, ALPHAARG0,1,2, and RESULTARG texture blending + * operations set in texture processing stage controls in D3DRENDERSTATE. + */ +#define D3DTA_SELECTMASK 0x0000000f // mask for arg selector +#define D3DTA_DIFFUSE 0x00000000 // select diffuse color (read only) +#define D3DTA_CURRENT 0x00000001 // select stage destination register (read/write) +#define D3DTA_TEXTURE 0x00000002 // select texture color (read only) +#define D3DTA_TFACTOR 0x00000003 // select D3DRS_TEXTUREFACTOR (read only) +#define D3DTA_SPECULAR 0x00000004 // select specular color (read only) +#define D3DTA_TEMP 0x00000005 // select temporary register color (read/write) +#define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x (read modifier) +#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components (read modifier) + +// +// Values for D3DTSS_***FILTER texture stage states +// +typedef enum _D3DTEXTUREFILTERTYPE +{ + D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) + D3DTEXF_POINT = 1, // nearest + D3DTEXF_LINEAR = 2, // linear interpolation + D3DTEXF_ANISOTROPIC = 3, // anisotropic + D3DTEXF_FLATCUBIC = 4, // cubic + D3DTEXF_GAUSSIANCUBIC = 5, // different cubic kernel + D3DTEXF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DTEXTUREFILTERTYPE; + +/* Bits for Flags in ProcessVertices call */ + +#define D3DPV_DONOTCOPYDATA (1 << 0) + +//------------------------------------------------------------------- + +// Flexible vertex format bits +// +#define D3DFVF_RESERVED0 0x001 +#define D3DFVF_POSITION_MASK 0x00E +#define D3DFVF_XYZ 0x002 +#define D3DFVF_XYZRHW 0x004 +#define D3DFVF_XYZB1 0x006 +#define D3DFVF_XYZB2 0x008 +#define D3DFVF_XYZB3 0x00a +#define D3DFVF_XYZB4 0x00c +#define D3DFVF_XYZB5 0x00e + +#define D3DFVF_NORMAL 0x010 +#define D3DFVF_PSIZE 0x020 +#define D3DFVF_DIFFUSE 0x040 +#define D3DFVF_SPECULAR 0x080 + +#define D3DFVF_TEXCOUNT_MASK 0xf00 +#define D3DFVF_TEXCOUNT_SHIFT 8 +#define D3DFVF_TEX0 0x000 +#define D3DFVF_TEX1 0x100 +#define D3DFVF_TEX2 0x200 +#define D3DFVF_TEX3 0x300 +#define D3DFVF_TEX4 0x400 +#define D3DFVF_TEX5 0x500 +#define D3DFVF_TEX6 0x600 +#define D3DFVF_TEX7 0x700 +#define D3DFVF_TEX8 0x800 + +#define D3DFVF_LASTBETA_UBYTE4 0x1000 + +#define D3DFVF_RESERVED2 0xE000 // 4 reserved bits + +//--------------------------------------------------------------------- +// Vertex Shaders +// + +/* + +Vertex Shader Declaration + +The declaration portion of a vertex shader defines the static external +interface of the shader. The information in the declaration includes: + +- Assignments of vertex shader input registers to data streams. These +assignments bind a specific vertex register to a single component within a +vertex stream. A vertex stream element is identified by a byte offset +within the stream and a type. The type specifies the arithmetic data type +plus the dimensionality (1, 2, 3, or 4 values). Stream data which is +less than 4 values are always expanded out to 4 values with zero or more +0.F values and one 1.F value. + +- Assignment of vertex shader input registers to implicit data from the +primitive tessellator. This controls the loading of vertex data which is +not loaded from a stream, but rather is generated during primitive +tessellation prior to the vertex shader. + +- Loading data into the constant memory at the time a shader is set as the +current shader. Each token specifies values for one or more contiguous 4 +DWORD constant registers. This allows the shader to update an arbitrary +subset of the constant memory, overwriting the device state (which +contains the current values of the constant memory). Note that these +values can be subsequently overwritten (between DrawPrimitive calls) +during the time a shader is bound to a device via the +SetVertexShaderConstant method. + + +Declaration arrays are single-dimensional arrays of DWORDs composed of +multiple tokens each of which is one or more DWORDs. The single-DWORD +token value 0xFFFFFFFF is a special token used to indicate the end of the +declaration array. The single DWORD token value 0x00000000 is a NOP token +with is ignored during the declaration parsing. Note that 0x00000000 is a +valid value for DWORDs following the first DWORD for multiple word tokens. + +[31:29] TokenType + 0x0 - NOP (requires all DWORD bits to be zero) + 0x1 - stream selector + 0x2 - stream data definition (map to vertex input memory) + 0x3 - vertex input memory from tessellator + 0x4 - constant memory from shader + 0x5 - extension + 0x6 - reserved + 0x7 - end-of-array (requires all DWORD bits to be 1) + +NOP Token (single DWORD token) + [31:29] 0x0 + [28:00] 0x0 + +Stream Selector (single DWORD token) + [31:29] 0x1 + [28] indicates whether this is a tessellator stream + [27:04] 0x0 + [03:00] stream selector (0..15) + +Stream Data Definition (single DWORD token) + Vertex Input Register Load + [31:29] 0x2 + [28] 0x0 + [27:20] 0x0 + [19:16] type (dimensionality and data type) + [15:04] 0x0 + [03:00] vertex register address (0..15) + Data Skip (no register load) + [31:29] 0x2 + [28] 0x1 + [27:20] 0x0 + [19:16] count of DWORDS to skip over (0..15) + [15:00] 0x0 + Vertex Input Memory from Tessellator Data (single DWORD token) + [31:29] 0x3 + [28] indicates whether data is normals or u/v + [27:24] 0x0 + [23:20] vertex register address (0..15) + [19:16] type (dimensionality) + [15:04] 0x0 + [03:00] vertex register address (0..15) + +Constant Memory from Shader (multiple DWORD token) + [31:29] 0x4 + [28:25] count of 4*DWORD constants to load (0..15) + [24:07] 0x0 + [06:00] constant memory address (0..95) + +Extension Token (single or multiple DWORD token) + [31:29] 0x5 + [28:24] count of additional DWORDs in token (0..31) + [23:00] extension-specific information + +End-of-array token (single DWORD token) + [31:29] 0x7 + [28:00] 0x1fffffff + +The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element. +Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant. +The token sequence: +Stream Select: stream=0 +Stream Data Definition (Load): type=FLOAT3; register=3 +Stream Data Definition (Load): type=FLOAT3; register=4 +Stream Data Definition (Skip): count=2 +Stream Data Definition (Load): type=FLOAT2; register=7 + +defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data. +Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed. + +*/ + +typedef enum _D3DVSD_TOKENTYPE +{ + D3DVSD_TOKEN_NOP = 0, // NOP or extension + D3DVSD_TOKEN_STREAM, // stream selector + D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory) + D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator + D3DVSD_TOKEN_CONSTMEM, // constant memory from shader + D3DVSD_TOKEN_EXT, // extension + D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1) + D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum +} D3DVSD_TOKENTYPE; + +#define D3DVSD_TOKENTYPESHIFT 29 +#define D3DVSD_TOKENTYPEMASK (7 << D3DVSD_TOKENTYPESHIFT) + +#define D3DVSD_STREAMNUMBERSHIFT 0 +#define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT) + +#define D3DVSD_DATALOADTYPESHIFT 28 +#define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT) + +#define D3DVSD_DATATYPESHIFT 16 +#define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT) + +#define D3DVSD_SKIPCOUNTSHIFT 16 +#define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT) + +#define D3DVSD_VERTEXREGSHIFT 0 +#define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT) + +#define D3DVSD_VERTEXREGINSHIFT 20 +#define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT) + +#define D3DVSD_CONSTCOUNTSHIFT 25 +#define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT) + +#define D3DVSD_CONSTADDRESSSHIFT 0 +#define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT) + +#define D3DVSD_CONSTRSSHIFT 16 +#define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT) + +#define D3DVSD_EXTCOUNTSHIFT 24 +#define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT) + +#define D3DVSD_EXTINFOSHIFT 0 +#define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT) + +#define D3DVSD_MAKETOKENTYPE(tokenType) ((tokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK) + +// macros for generation of CreateVertexShader Declaration token array + +// Set current stream +// _StreamNumber [0..(MaxStreams-1)] stream to get data from +// +#define D3DVSD_STREAM( _StreamNumber ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (_StreamNumber)) + +// Set tessellator stream +// +#define D3DVSD_STREAMTESSSHIFT 28 +#define D3DVSD_STREAMTESSMASK (1 << D3DVSD_STREAMTESSSHIFT) +#define D3DVSD_STREAM_TESS( ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK)) + +// bind single vertex register to vertex element from vertex stream +// +// _VertexRegister [0..15] address of the vertex register +// _Type [D3DVSDT_*] dimensionality and arithmetic data type + +#define D3DVSD_REG( _VertexRegister, _Type ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | \ + ((_Type) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) + +// Skip _DWORDCount DWORDs in vertex +// +#define D3DVSD_SKIP( _DWORDCount ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | \ + ((_DWORDCount) << D3DVSD_SKIPCOUNTSHIFT)) + +// load data into vertex shader constant memory +// +// _ConstantAddress [0..95] - address of constant array to begin filling data +// _Count [0..15] - number of constant vectors to load (4 DWORDs each) +// followed by 4*_Count DWORDS of data +// +#define D3DVSD_CONST( _ConstantAddress, _Count ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | \ + ((_Count) << D3DVSD_CONSTCOUNTSHIFT) | (_ConstantAddress)) + +// enable tessellator generated normals +// +// _VertexRegisterIn [0..15] address of vertex register whose input stream +// will be used in normal computation +// _VertexRegisterOut [0..15] address of vertex register to output the normal to +// +#define D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | \ + ((_VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | \ + ((0x02) << D3DVSD_DATATYPESHIFT) | (_VertexRegisterOut)) + +// enable tessellator generated surface parameters +// +// _VertexRegister [0..15] address of vertex register to output parameters +// +#define D3DVSD_TESSUV( _VertexRegister ) \ + (D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | \ + ((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister)) + +// Generates END token +// +#define D3DVSD_END() 0xFFFFFFFF + +// Generates NOP token +#define D3DVSD_NOP() 0x00000000 + +// bit declarations for _Type fields +#define D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.) +#define D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.) +#define D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.) +#define D3DVSDT_FLOAT4 0x03 // 4D float +#define D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range + // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) +#define D3DVSDT_UBYTE4 0x05 // 4D unsigned byte +#define D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.) +#define D3DVSDT_SHORT4 0x07 // 4D signed short + +// assignments of vertex input registers for fixed function vertex shader +// +#define D3DVSDE_POSITION 0 +#define D3DVSDE_BLENDWEIGHT 1 +#define D3DVSDE_BLENDINDICES 2 +#define D3DVSDE_NORMAL 3 +#define D3DVSDE_PSIZE 4 +#define D3DVSDE_DIFFUSE 5 +#define D3DVSDE_SPECULAR 6 +#define D3DVSDE_TEXCOORD0 7 +#define D3DVSDE_TEXCOORD1 8 +#define D3DVSDE_TEXCOORD2 9 +#define D3DVSDE_TEXCOORD3 10 +#define D3DVSDE_TEXCOORD4 11 +#define D3DVSDE_TEXCOORD5 12 +#define D3DVSDE_TEXCOORD6 13 +#define D3DVSDE_TEXCOORD7 14 +#define D3DVSDE_POSITION2 15 +#define D3DVSDE_NORMAL2 16 + +// Maximum supported number of texture coordinate sets +#define D3DDP_MAXTEXCOORD 8 + + +// +// Instruction Token Bit Definitions +// +#define D3DSI_OPCODE_MASK 0x0000FFFF + +typedef enum _D3DSHADER_INSTRUCTION_OPCODE_TYPE +{ + D3DSIO_NOP = 0, // PS/VS + D3DSIO_MOV , // PS/VS + D3DSIO_ADD , // PS/VS + D3DSIO_SUB , // PS + D3DSIO_MAD , // PS/VS + D3DSIO_MUL , // PS/VS + D3DSIO_RCP , // VS + D3DSIO_RSQ , // VS + D3DSIO_DP3 , // PS/VS + D3DSIO_DP4 , // PS/VS + D3DSIO_MIN , // VS + D3DSIO_MAX , // VS + D3DSIO_SLT , // VS + D3DSIO_SGE , // VS + D3DSIO_EXP , // VS + D3DSIO_LOG , // VS + D3DSIO_LIT , // VS + D3DSIO_DST , // VS + D3DSIO_LRP , // PS + D3DSIO_FRC , // VS + D3DSIO_M4x4 , // VS + D3DSIO_M4x3 , // VS + D3DSIO_M3x4 , // VS + D3DSIO_M3x3 , // VS + D3DSIO_M3x2 , // VS + + D3DSIO_TEXCOORD = 64, // PS + D3DSIO_TEXKILL , // PS + D3DSIO_TEX , // PS + D3DSIO_TEXBEM , // PS + D3DSIO_TEXBEML , // PS + D3DSIO_TEXREG2AR , // PS + D3DSIO_TEXREG2GB , // PS + D3DSIO_TEXM3x2PAD , // PS + D3DSIO_TEXM3x2TEX , // PS + D3DSIO_TEXM3x3PAD , // PS + D3DSIO_TEXM3x3TEX , // PS + D3DSIO_TEXM3x3DIFF , // PS + D3DSIO_TEXM3x3SPEC , // PS + D3DSIO_TEXM3x3VSPEC , // PS + D3DSIO_EXPP , // VS + D3DSIO_LOGP , // VS + D3DSIO_CND , // PS + D3DSIO_DEF , // PS + D3DSIO_TEXREG2RGB , // PS + D3DSIO_TEXDP3TEX , // PS + D3DSIO_TEXM3x2DEPTH , // PS + D3DSIO_TEXDP3 , // PS + D3DSIO_TEXM3x3 , // PS + D3DSIO_TEXDEPTH , // PS + D3DSIO_CMP , // PS + D3DSIO_BEM , // PS + + D3DSIO_PHASE = 0xFFFD, + D3DSIO_COMMENT = 0xFFFE, + D3DSIO_END = 0xFFFF, + + D3DSIO_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DSHADER_INSTRUCTION_OPCODE_TYPE; + +// +// Co-Issue Instruction Modifier - if set then this instruction is to be +// issued in parallel with the previous instruction(s) for which this bit +// is not set. +// +#define D3DSI_COISSUE 0x40000000 + +// +// Parameter Token Bit Definitions +// +#define D3DSP_REGNUM_MASK 0x00001FFF + +// destination parameter write mask +#define D3DSP_WRITEMASK_0 0x00010000 // Component 0 (X;Red) +#define D3DSP_WRITEMASK_1 0x00020000 // Component 1 (Y;Green) +#define D3DSP_WRITEMASK_2 0x00040000 // Component 2 (Z;Blue) +#define D3DSP_WRITEMASK_3 0x00080000 // Component 3 (W;Alpha) +#define D3DSP_WRITEMASK_ALL 0x000F0000 // All Components + +// destination parameter modifiers +#define D3DSP_DSTMOD_SHIFT 20 +#define D3DSP_DSTMOD_MASK 0x00F00000 + +typedef enum _D3DSHADER_PARAM_DSTMOD_TYPE +{ + D3DSPDM_NONE = 0<>8)&0xFF) +#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) + +// destination/source parameter register type +#define D3DSI_COMMENTSIZE_SHIFT 16 +#define D3DSI_COMMENTSIZE_MASK 0x7FFF0000 +#define D3DSHADER_COMMENT(_DWordSize) \ + ((((_DWordSize)<= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4201) +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D8TYPES(P)_H_ */ + diff --git a/win32/directx/d3dx8.h b/win32/directx/d3dx8.h new file mode 100644 index 0000000..89f602d --- /dev/null +++ b/win32/directx/d3dx8.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8.h +// Content: D3DX utility library +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8_H__ +#define __D3DX8_H__ + +#include "d3d8.h" +#include + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + +#define D3DX_DEFAULT ULONG_MAX +#define D3DX_DEFAULT_FLOAT FLT_MAX + +#include "d3dx8math.h" +#include "d3dx8core.h" +#include "d3dx8tex.h" +#include "d3dx8mesh.h" +#include "d3dx8shape.h" +#include "d3dx8effect.h" + + +#endif //__D3DX8_H__ + diff --git a/win32/directx/d3dx8.lib b/win32/directx/d3dx8.lib new file mode 100644 index 0000000..8305ff4 Binary files /dev/null and b/win32/directx/d3dx8.lib differ diff --git a/win32/directx/d3dx8core.h b/win32/directx/d3dx8core.h new file mode 100644 index 0000000..7db338f --- /dev/null +++ b/win32/directx/d3dx8core.h @@ -0,0 +1,563 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8core.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8CORE_H__ +#define __D3DX8CORE_H__ + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXBuffer: +// ------------ +// The buffer object is used by D3DX to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBuffer ID3DXBuffer; +typedef interface ID3DXBuffer *LPD3DXBUFFER; + +// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} +DEFINE_GUID(IID_ID3DXBuffer, +0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); + +#undef INTERFACE +#define INTERFACE ID3DXBuffer + +DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBuffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; +}; + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXFont: +// ---------- +// Font objects contain the textures and resources needed to render +// a specific font on a specific device. +// +// Begin - +// Prepartes device for drawing text. This is optional.. if DrawText +// is called outside of Begin/End, it will call Begin and End for you. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +// +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXFont ID3DXFont; +typedef interface ID3DXFont *LPD3DXFONT; + + +// {89FAD6A5-024D-49af-8FE7-F51123B85E25} +DEFINE_GUID( IID_ID3DXFont, +0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); + + +#undef INTERFACE +#define INTERFACE ID3DXFont + +DECLARE_INTERFACE_(ID3DXFont, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFont + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; + + STDMETHOD(Begin)(THIS) PURE; + STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateFont( + LPDIRECT3DDEVICE8 pDevice, + HFONT hFont, + LPD3DXFONT* ppFont); + + +HRESULT WINAPI + D3DXCreateFontIndirect( + LPDIRECT3DDEVICE8 pDevice, + CONST LOGFONT* pLogFont, + LPD3DXFONT* ppFont); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXSprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites +// +// Draw, DrawAffine, DrawTransform - +// Draws a sprite in screen-space. Before transformation, the sprite is +// the size of SrcRect, with its top-left corner at the origin (0,0). +// The color and alpha channels are modulated by Color. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXSprite ID3DXSprite; +typedef interface ID3DXSprite *LPD3DXSPRITE; + + +// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} +DEFINE_GUID( IID_ID3DXSprite, +0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); + + +#undef INTERFACE +#define INTERFACE ID3DXSprite + +DECLARE_INTERFACE_(ID3DXSprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSprite + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + + STDMETHOD(Begin)(THIS) PURE; + + STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; + + STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, + D3DCOLOR Color) PURE; + + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXSPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToSurface: +// --------------------- +// This object abstracts rendering to surfaces. These surfaces do not +// necessarily need to be render targets. If they are not, a compatible +// render target is used, and the result copied into surface at end scene. +// +// BeginScene, EndScene - +// Call BeginScene() and EndScene() at the beginning and ending of your +// scene. These calls will setup and restore render targets, viewports, +// etc.. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTS_DESC +{ + UINT Width; + UINT Height; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTS_DESC; + + +typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; +typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; + + +// {82DF5B90-E34E-496e-AC1C-62117A6A5913} +DEFINE_GUID( IID_ID3DXRenderToSurface, +0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToSurface + +DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToSurface + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; + + STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(EndScene)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToSurface( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRENDERTOSURFACE* ppRenderToSurface); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToEnvMap: +// -------------------- +// This object abstracts rendering to environment maps. These surfaces +// do not necessarily need to be render targets. If they are not, a +// compatible render target is used, and the result copied into the +// environment map at end scene. +// +// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - +// This function initiates the rendering of the environment map. As +// parameters, you pass the textures in which will get filled in with +// the resulting environment map. +// +// Face - +// Call this function to initiate the drawing of each face. For each +// environment map, you will call this six times.. once for each face +// in D3DCUBEMAP_FACES. +// +// End - +// This will restore all render targets, and if needed compose all the +// rendered faces into the environment map surfaces. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTE_DESC +{ + UINT Size; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; +} D3DXRTE_DESC; + + +typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; +typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; + +// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} +DEFINE_GUID( IID_ID3DXRenderToEnvMap, +0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToEnvMap + +DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToEnvMap + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; + + STDMETHOD(BeginCube)(THIS_ + LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; + + STDMETHOD(BeginSphere)(THIS_ + LPDIRECT3DTEXTURE8 pTex) PURE; + + STDMETHOD(BeginHemisphere)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(BeginParabolic)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToEnvMap( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRenderToEnvMap* ppRenderToEnvMap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Shader assemblers: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DXASM flags: +// -------------- +// +// D3DXASM_DEBUG +// Generate debug info. +// +// D3DXASM_SKIPVALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when assembling shaders +// you KNOW will work. (ie. have assembled before without this option.) +//------------------------------------------------------------------------- + +#define D3DXASM_DEBUG (1 << 0) +#define D3DXASM_SKIPVALIDATION (1 << 1) + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXAssembleShader: +// ------------------- +// Assembles an ascii description of a vertex or pixel shader into +// binary form. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// Flags +// D3DXASM_xxx flags +// ppConstants +// Returns an ID3DXBuffer object containing constant declarations. +// ppCompiledShader +// Returns an ID3DXBuffer object containing the object code. +// ppCompilationErrors +// Returns an ID3DXBuffer object containing ascii error messages +//------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXAssembleShaderFromFileA( + LPCSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromFileW( + LPCWSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW +#else +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA +#endif + +HRESULT WINAPI + D3DXAssembleShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW +#else +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA +#endif + +HRESULT WINAPI + D3DXAssembleShader( + LPCVOID pSrcData, + UINT SrcDataLen, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Misc APIs: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXGetErrorString: +// ------------------ +// Returns the error string for given an hresult. Interprets all D3DX and +// D3D hresults. +// +// Parameters: +// hr +// The error code to be deciphered. +// pBuffer +// Pointer to the buffer to be filled in. +// BufferLen +// Count of characters in buffer. Any error message longer than this +// length will be truncated to fit. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetErrorStringA( + HRESULT hr, + LPSTR pBuffer, + UINT BufferLen); + +HRESULT WINAPI + D3DXGetErrorStringW( + HRESULT hr, + LPWSTR pBuffer, + UINT BufferLen); + +#ifdef UNICODE +#define D3DXGetErrorString D3DXGetErrorStringW +#else +#define D3DXGetErrorString D3DXGetErrorStringA +#endif + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8CORE_H__ diff --git a/win32/directx/d3dx8effect.h b/win32/directx/d3dx8effect.h new file mode 100644 index 0000000..96fc382 --- /dev/null +++ b/win32/directx/d3dx8effect.h @@ -0,0 +1,226 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8effect.h +// Content: D3DX effect types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8EFFECT_H__ +#define __D3DX8EFFECT_H__ + + +#define D3DXFX_DONOTSAVESTATE (1 << 0) + + +typedef enum _D3DXPARAMETERTYPE +{ + D3DXPT_DWORD = 0, + D3DXPT_FLOAT = 1, + D3DXPT_VECTOR = 2, + D3DXPT_MATRIX = 3, + D3DXPT_TEXTURE = 4, + D3DXPT_VERTEXSHADER = 5, + D3DXPT_PIXELSHADER = 6, + D3DXPT_CONSTANT = 7, + D3DXPT_STRING = 8, + D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ + +} D3DXPARAMETERTYPE; + + +typedef struct _D3DXEFFECT_DESC +{ + UINT Parameters; + UINT Techniques; + +} D3DXEFFECT_DESC; + + +typedef struct _D3DXPARAMETER_DESC +{ + LPCSTR Name; + LPCSTR Index; + D3DXPARAMETERTYPE Type; + +} D3DXPARAMETER_DESC; + + +typedef struct _D3DXTECHNIQUE_DESC +{ + LPCSTR Name; + LPCSTR Index; + UINT Passes; + +} D3DXTECHNIQUE_DESC; + + +typedef struct _D3DXPASS_DESC +{ + LPCSTR Name; + LPCSTR Index; + +} D3DXPASS_DESC; + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffect /////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffect ID3DXEffect; +typedef interface ID3DXEffect *LPD3DXEFFECT; + +// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} +DEFINE_GUID( IID_ID3DXEffect, +0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); + + +#undef INTERFACE +#define INTERFACE ID3DXEffect + +DECLARE_INTERFACE_(ID3DXEffect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXEffect + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; + STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; + + STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; + STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; + + STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; + STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; + STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; + STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; + STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; + STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; + + STDMETHOD(Validate)(THIS) PURE; + STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; + STDMETHOD(Pass)(THIS_ UINT Pass) PURE; + STDMETHOD(End)(THIS) PURE; + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXCreateEffect: +// ----------------- +// Creates an effect from an ascii or binaray effect description. +// +// Parameters: +// pDevice +// Pointer of the device on which to create the effect +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// ppEffect +// Returns a buffer containing created effect. +// ppCompilationErrors +// Returns a buffer containing any error messages which occurred during +// compile. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW +#else +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW +#else +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffect( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8EFFECT_H__ diff --git a/win32/directx/d3dx8math.h b/win32/directx/d3dx8math.h new file mode 100644 index 0000000..4677954 --- /dev/null +++ b/win32/directx/d3dx8math.h @@ -0,0 +1,1215 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MATH_H__ +#define __D3DX8MATH_H__ + +#include +#pragma warning(disable:4201) // anonymous unions warning + + + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + +//=========================================================================== +// +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +// +//=========================================================================== +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {} + _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} + _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) {} + void* operator new(size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + void* operator new[](size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete(void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete[](void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) + { + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; + }; +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + +#if _MSC_VER >= 1300 // VC7 +#define _ALIGN_16 __declspec(align(16)) +#else +#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. +#endif + +#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 + +typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DCOLORVALUE& ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator DWORD () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + operator D3DCOLORVALUE* (); + operator CONST D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator CONST D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixfDeterminant + ( CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {E3357330-CC5E-11d2-A434-00A0C90629A8} +DEFINE_GUID( IID_ID3DXMatrixStack, +0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Obtain the current matrix at the top of the stack + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +#include "d3dx8math.inl" + +#pragma warning(default:4201) + +#endif // __D3DX8MATH_H__ diff --git a/win32/directx/d3dx8math.inl b/win32/directx/d3dx8math.inl new file mode 100644 index 0000000..c1f465c --- /dev/null +++ b/win32/directx/d3dx8math.inl @@ -0,0 +1,1757 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.inl +// Content: D3DX math inline functions +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8MATH_INL__ +#define __D3DX8MATH_INL__ + + +//=========================================================================== +// +// Inline Class Methods +// +//=========================================================================== + +#ifdef __cplusplus + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; +} + +D3DXINLINE +D3DXVECTOR2::D3DXVECTOR2( FLOAT fx, FLOAT fy ) +{ + x = fx; + y = fy; +} + +// casting +D3DXINLINE +D3DXVECTOR2::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + +// assignment operators +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator += ( CONST D3DXVECTOR2& v ) +{ + x += v.x; + y += v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator -= ( CONST D3DXVECTOR2& v ) +{ + x -= v.x; + y -= v.y; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR2& +D3DXVECTOR2::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + return *this; +} + +// unary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + +// binary operators +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator + ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator - ( CONST D3DXVECTOR2& v ) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator * ( FLOAT f ) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +D3DXINLINE D3DXVECTOR2 +D3DXVECTOR2::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR2(x * fInv, y * fInv); +} + + +D3DXINLINE D3DXVECTOR2 +operator * ( FLOAT f, CONST D3DXVECTOR2& v ) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator == ( CONST D3DXVECTOR2& v ) const +{ + return x == v.x && y == v.y; +} + +D3DXINLINE BOOL +D3DXVECTOR2::operator != ( CONST D3DXVECTOR2& v ) const +{ + return x != v.x || y != v.y; +} + + + + +//-------------------------- +// 3D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( CONST D3DVECTOR& v ) +{ + x = v.x; + y = v.y; + z = v.z; +} + +D3DXINLINE +D3DXVECTOR3::D3DXVECTOR3( FLOAT fx, FLOAT fy, FLOAT fz ) +{ + x = fx; + y = fy; + z = fz; +} + + +// casting +D3DXINLINE +D3DXVECTOR3::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator += ( CONST D3DXVECTOR3& v ) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator -= ( CONST D3DXVECTOR3& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR3& +D3DXVECTOR3::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + + +// binary operators +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator + ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator - ( CONST D3DXVECTOR3& v ) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator * ( FLOAT f ) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +D3DXINLINE D3DXVECTOR3 +D3DXVECTOR3::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR3(x * fInv, y * fInv, z * fInv); +} + + +D3DXINLINE D3DXVECTOR3 +operator * ( FLOAT f, CONST struct D3DXVECTOR3& v ) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + + +D3DXINLINE BOOL +D3DXVECTOR3::operator == ( CONST D3DXVECTOR3& v ) const +{ + return x == v.x && y == v.y && z == v.z; +} + +D3DXINLINE BOOL +D3DXVECTOR3::operator != ( CONST D3DXVECTOR3& v ) const +{ + return x != v.x || y != v.y || z != v.z; +} + + + +//-------------------------- +// 4D Vector +//-------------------------- +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( CONST FLOAT *pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXVECTOR4::D3DXVECTOR4( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXVECTOR4::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXVECTOR4::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator += ( CONST D3DXVECTOR4& v ) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator -= ( CONST D3DXVECTOR4& v ) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXVECTOR4& +D3DXVECTOR4::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator + ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator - ( CONST D3DXVECTOR4& v ) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator * ( FLOAT f ) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXVECTOR4 +D3DXVECTOR4::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXVECTOR4(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXVECTOR4 +operator * ( FLOAT f, CONST D3DXVECTOR4& v ) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + + +D3DXINLINE BOOL +D3DXVECTOR4::operator == ( CONST D3DXVECTOR4& v ) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +D3DXINLINE BOOL +D3DXVECTOR4::operator != ( CONST D3DXVECTOR4& v ) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + + +//-------------------------- +// Matrix +//-------------------------- +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + memcpy(&_11, pf, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( CONST D3DMATRIX& mat ) +{ + memcpy(&_11, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE +D3DXMATRIX::D3DXMATRIX( FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44 ) +{ + _11 = f11; _12 = f12; _13 = f13; _14 = f14; + _21 = f21; _22 = f22; _23 = f23; _24 = f24; + _31 = f31; _32 = f32; _33 = f33; _34 = f34; + _41 = f41; _42 = f42; _43 = f43; _44 = f44; +} + + + +// access grants +D3DXINLINE FLOAT& +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) +{ + return m[iRow][iCol]; +} + +D3DXINLINE FLOAT +D3DXMATRIX::operator () ( UINT iRow, UINT iCol ) const +{ + return m[iRow][iCol]; +} + + +// casting operators +D3DXINLINE +D3DXMATRIX::operator FLOAT* () +{ + return (FLOAT *) &_11; +} + +D3DXINLINE +D3DXMATRIX::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &_11; +} + + +// assignment operators +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( CONST D3DXMATRIX& mat ) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator += ( CONST D3DXMATRIX& mat ) +{ + _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; + _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; + _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; + _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator -= ( CONST D3DXMATRIX& mat ) +{ + _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; + _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; + _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; + _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator *= ( FLOAT f ) +{ + _11 *= f; _12 *= f; _13 *= f; _14 *= f; + _21 *= f; _22 *= f; _23 *= f; _24 *= f; + _31 *= f; _32 *= f; _33 *= f; _34 *= f; + _41 *= f; _42 *= f; _43 *= f; _44 *= f; + return *this; +} + +D3DXINLINE D3DXMATRIX& +D3DXMATRIX::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + _11 *= fInv; _12 *= fInv; _13 *= fInv; _14 *= fInv; + _21 *= fInv; _22 *= fInv; _23 *= fInv; _24 *= fInv; + _31 *= fInv; _32 *= fInv; _33 *= fInv; _34 *= fInv; + _41 *= fInv; _42 *= fInv; _43 *= fInv; _44 *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-_11, -_12, -_13, -_14, + -_21, -_22, -_23, -_24, + -_31, -_32, -_33, -_34, + -_41, -_42, -_43, -_44); +} + + +// binary operators +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( CONST D3DXMATRIX& mat ) const +{ + D3DXMATRIX matT; + D3DXMatrixMultiply(&matT, this, &mat); + return matT; +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator + ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, + _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, + _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, + _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator - ( CONST D3DXMATRIX& mat ) const +{ + return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, + _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, + _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, + _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator * ( FLOAT f ) const +{ + return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, + _21 * f, _22 * f, _23 * f, _24 * f, + _31 * f, _32 * f, _33 * f, _34 * f, + _41 * f, _42 * f, _43 * f, _44 * f); +} + +D3DXINLINE D3DXMATRIX +D3DXMATRIX::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXMATRIX(_11 * fInv, _12 * fInv, _13 * fInv, _14 * fInv, + _21 * fInv, _22 * fInv, _23 * fInv, _24 * fInv, + _31 * fInv, _32 * fInv, _33 * fInv, _34 * fInv, + _41 * fInv, _42 * fInv, _43 * fInv, _44 * fInv); +} + + +D3DXINLINE D3DXMATRIX +operator * ( FLOAT f, CONST D3DXMATRIX& mat ) +{ + return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, + f * mat._21, f * mat._22, f * mat._23, f * mat._24, + f * mat._31, f * mat._32, f * mat._33, f * mat._34, + f * mat._41, f * mat._42, f * mat._43, f * mat._44); +} + + +D3DXINLINE BOOL +D3DXMATRIX::operator == ( CONST D3DXMATRIX& mat ) const +{ + return 0 == memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + +D3DXINLINE BOOL +D3DXMATRIX::operator != ( CONST D3DXMATRIX& mat ) const +{ + return 0 != memcmp(this, &mat, sizeof(D3DXMATRIX)); +} + + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +D3DXINLINE +D3DXQUATERNION::D3DXQUATERNION( FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw ) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + + +// casting +D3DXINLINE +D3DXQUATERNION::operator FLOAT* () +{ + return (FLOAT *) &x; +} + +D3DXINLINE +D3DXQUATERNION::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &x; +} + + +// assignment operators +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator += ( CONST D3DXQUATERNION& q ) +{ + x += q.x; + y += q.y; + z += q.z; + w += q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator -= ( CONST D3DXQUATERNION& q ) +{ + x -= q.x; + y -= q.y; + z -= q.z; + w -= q.w; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( CONST D3DXQUATERNION& q ) +{ + D3DXQuaternionMultiply(this, this, &q); + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator *= ( FLOAT f ) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +D3DXINLINE D3DXQUATERNION& +D3DXQUATERNION::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + x *= fInv; + y *= fInv; + z *= fInv; + w *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + + +// binary operators +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator + ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x + q.x, y + q.y, z + q.z, w + q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator - ( CONST D3DXQUATERNION& q ) const +{ + return D3DXQUATERNION(x - q.x, y - q.y, z - q.z, w - q.w); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( CONST D3DXQUATERNION& q ) const +{ + D3DXQUATERNION qT; + D3DXQuaternionMultiply(&qT, this, &q); + return qT; +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator * ( FLOAT f ) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +D3DXINLINE D3DXQUATERNION +D3DXQUATERNION::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXQUATERNION(x * fInv, y * fInv, z * fInv, w * fInv); +} + + +D3DXINLINE D3DXQUATERNION +operator * (FLOAT f, CONST D3DXQUATERNION& q ) +{ + return D3DXQUATERNION(f * q.x, f * q.y, f * q.z, f * q.w); +} + + +D3DXINLINE BOOL +D3DXQUATERNION::operator == ( CONST D3DXQUATERNION& q ) const +{ + return x == q.x && y == q.y && z == q.z && w == q.w; +} + +D3DXINLINE BOOL +D3DXQUATERNION::operator != ( CONST D3DXQUATERNION& q ) const +{ + return x != q.x || y != q.y || z != q.z || w != q.w; +} + + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE +D3DXPLANE::D3DXPLANE( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +D3DXINLINE +D3DXPLANE::D3DXPLANE( FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd ) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + + +// casting +D3DXINLINE +D3DXPLANE::operator FLOAT* () +{ + return (FLOAT *) &a; +} + +D3DXINLINE +D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT *) &a; +} + + +// unary operators +D3DXINLINE D3DXPLANE +D3DXPLANE::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXPLANE +D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + + +// binary operators +D3DXINLINE BOOL +D3DXPLANE::operator == ( CONST D3DXPLANE& p ) const +{ + return a == p.a && b == p.b && c == p.c && d == p.d; +} + +D3DXINLINE BOOL +D3DXPLANE::operator != ( CONST D3DXPLANE& p ) const +{ + return a != p.a || b != p.b || c != p.c || d != p.d; +} + + + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( DWORD dw ) +{ + CONST FLOAT f = 1.0f / 255.0f; + r = f * (FLOAT) (unsigned char) (dw >> 16); + g = f * (FLOAT) (unsigned char) (dw >> 8); + b = f * (FLOAT) (unsigned char) (dw >> 0); + a = f * (FLOAT) (unsigned char) (dw >> 24); +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST FLOAT* pf ) +{ +#ifdef D3DX_DEBUG + if(!pf) + return; +#endif + + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( CONST D3DCOLORVALUE& c ) +{ + r = c.r; + g = c.g; + b = c.b; + a = c.a; +} + +D3DXINLINE +D3DXCOLOR::D3DXCOLOR( FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa ) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + + +// casting +D3DXINLINE +D3DXCOLOR::operator DWORD () const +{ + DWORD dwR = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD) (r * 255.0f + 0.5f); + DWORD dwG = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD) (g * 255.0f + 0.5f); + DWORD dwB = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD) (b * 255.0f + 0.5f); + DWORD dwA = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD) (a * 255.0f + 0.5f); + + return (dwA << 24) | (dwR << 16) | (dwG << 8) | dwB; +} + + +D3DXINLINE +D3DXCOLOR::operator FLOAT * () +{ + return (FLOAT *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST FLOAT * () const +{ + return (CONST FLOAT *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE * () +{ + return (D3DCOLORVALUE *) &r; +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE * () const +{ + return (CONST D3DCOLORVALUE *) &r; +} + + +D3DXINLINE +D3DXCOLOR::operator D3DCOLORVALUE& () +{ + return *((D3DCOLORVALUE *) &r); +} + +D3DXINLINE +D3DXCOLOR::operator CONST D3DCOLORVALUE& () const +{ + return *((CONST D3DCOLORVALUE *) &r); +} + + +// assignment operators +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator += ( CONST D3DXCOLOR& c ) +{ + r += c.r; + g += c.g; + b += c.b; + a += c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator -= ( CONST D3DXCOLOR& c ) +{ + r -= c.r; + g -= c.g; + b -= c.b; + a -= c.a; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator *= ( FLOAT f ) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +D3DXINLINE D3DXCOLOR& +D3DXCOLOR::operator /= ( FLOAT f ) +{ + FLOAT fInv = 1.0f / f; + r *= fInv; + g *= fInv; + b *= fInv; + a *= fInv; + return *this; +} + + +// unary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + () const +{ + return *this; +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + + +// binary operators +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator + ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r + c.r, g + c.g, b + c.b, a + c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator - ( CONST D3DXCOLOR& c ) const +{ + return D3DXCOLOR(r - c.r, g - c.g, b - c.b, a - c.a); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator * ( FLOAT f ) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +D3DXINLINE D3DXCOLOR +D3DXCOLOR::operator / ( FLOAT f ) const +{ + FLOAT fInv = 1.0f / f; + return D3DXCOLOR(r * fInv, g * fInv, b * fInv, a * fInv); +} + + +D3DXINLINE D3DXCOLOR +operator * (FLOAT f, CONST D3DXCOLOR& c ) +{ + return D3DXCOLOR(f * c.r, f * c.g, f * c.b, f * c.a); +} + + +D3DXINLINE BOOL +D3DXCOLOR::operator == ( CONST D3DXCOLOR& c ) const +{ + return r == c.r && g == c.g && b == c.b && a == c.a; +} + +D3DXINLINE BOOL +D3DXCOLOR::operator != ( CONST D3DXCOLOR& c ) const +{ + return r != c.r || g != c.g || b != c.b || a != c.a; +} + + +#endif //__cplusplus + + + +//=========================================================================== +// +// Inline functions +// +//=========================================================================== + + +//-------------------------- +// 2D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y); +#endif +} + +D3DXINLINE FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y; +} + +D3DXINLINE FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y; +} + +D3DXINLINE FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->y - pV1->y * pV2->x; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + return pOut; +} + + +//-------------------------- +// 3D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z); +#endif +} + +D3DXINLINE FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z; +} + +D3DXINLINE FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + v.x = pV1->y * pV2->z - pV1->z * pV2->y; + v.y = pV1->z * pV2->x - pV1->x * pV2->z; + v.z = pV1->x * pV2->y - pV1->y * pV2->x; + + *pOut = v; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + return pOut; +} + + +//-------------------------- +// 4D Vector +//-------------------------- + +D3DXINLINE FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#else + return (FLOAT) sqrt(pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w); +#endif +} + +D3DXINLINE FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ) +{ +#ifdef D3DX_DEBUG + if(!pV) + return 0.0f; +#endif + + return pV->x * pV->x + pV->y * pV->y + pV->z * pV->z + pV->w * pV->w; +} + +D3DXINLINE FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ) +{ +#ifdef D3DX_DEBUG + if(!pV1 || !pV2) + return 0.0f; +#endif + + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + pV2->x; + pOut->y = pV1->y + pV2->y; + pOut->z = pV1->z + pV2->z; + pOut->w = pV1->w + pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + pOut->w = pV1->w - pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x < pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y < pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z < pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w < pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x > pV2->x ? pV1->x : pV2->x; + pOut->y = pV1->y > pV2->y ? pV1->y : pV2->y; + pOut->z = pV1->z > pV2->z ? pV1->z : pV2->z; + pOut->w = pV1->w > pV2->w ? pV1->w : pV2->w; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV) + return NULL; +#endif + + pOut->x = pV->x * s; + pOut->y = pV->y * s; + pOut->z = pV->z * s; + pOut->w = pV->w * s; + return pOut; +} + +D3DXINLINE D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pV1 || !pV2) + return NULL; +#endif + + pOut->x = pV1->x + s * (pV2->x - pV1->x); + pOut->y = pV1->y + s * (pV2->y - pV1->y); + pOut->z = pV1->z + s * (pV2->z - pV1->z); + pOut->w = pV1->w + s * (pV2->w - pV1->w); + return pOut; +} + + +//-------------------------- +// 4D Matrix +//-------------------------- + +D3DXINLINE D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->m[0][1] = pOut->m[0][2] = pOut->m[0][3] = + pOut->m[1][0] = pOut->m[1][2] = pOut->m[1][3] = + pOut->m[2][0] = pOut->m[2][1] = pOut->m[2][3] = + pOut->m[3][0] = pOut->m[3][1] = pOut->m[3][2] = 0.0f; + + pOut->m[0][0] = pOut->m[1][1] = pOut->m[2][2] = pOut->m[3][3] = 1.0f; + return pOut; +} + + +D3DXINLINE BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ) +{ +#ifdef D3DX_DEBUG + if(!pM) + return FALSE; +#endif + + return pM->m[0][0] == 1.0f && pM->m[0][1] == 0.0f && pM->m[0][2] == 0.0f && pM->m[0][3] == 0.0f && + pM->m[1][0] == 0.0f && pM->m[1][1] == 1.0f && pM->m[1][2] == 0.0f && pM->m[1][3] == 0.0f && + pM->m[2][0] == 0.0f && pM->m[2][1] == 0.0f && pM->m[2][2] == 1.0f && pM->m[2][3] == 0.0f && + pM->m[3][0] == 0.0f && pM->m[3][1] == 0.0f && pM->m[3][2] == 0.0f && pM->m[3][3] == 1.0f; +} + + +//-------------------------- +// Quaternion +//-------------------------- + +D3DXINLINE FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + +#ifdef __cplusplus + return sqrtf(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#else + return (FLOAT) sqrt(pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w); +#endif +} + +D3DXINLINE FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return 0.0f; +#endif + + return pQ->x * pQ->x + pQ->y * pQ->y + pQ->z * pQ->z + pQ->w * pQ->w; +} + +D3DXINLINE FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ) +{ +#ifdef D3DX_DEBUG + if(!pQ1 || !pQ2) + return 0.0f; +#endif + + return pQ1->x * pQ2->x + pQ1->y * pQ2->y + pQ1->z * pQ2->z + pQ1->w * pQ2->w; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ) +{ +#ifdef D3DX_DEBUG + if(!pOut) + return NULL; +#endif + + pOut->x = pOut->y = pOut->z = 0.0f; + pOut->w = 1.0f; + return pOut; +} + +D3DXINLINE BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pQ) + return FALSE; +#endif + + return pQ->x == 0.0f && pQ->y == 0.0f && pQ->z == 0.0f && pQ->w == 1.0f; +} + + +D3DXINLINE D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pQ) + return NULL; +#endif + + pOut->x = -pQ->x; + pOut->y = -pQ->y; + pOut->z = -pQ->z; + pOut->w = pQ->w; + return pOut; +} + + +//-------------------------- +// Plane +//-------------------------- + +D3DXINLINE FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w; +} + +D3DXINLINE FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d; +} + +D3DXINLINE FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV) +{ +#ifdef D3DX_DEBUG + if(!pP || !pV) + return 0.0f; +#endif + + return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z; +} + + +//-------------------------- +// Color +//-------------------------- + +D3DXINLINE D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = 1.0f - pC->r; + pOut->g = 1.0f - pC->g; + pOut->b = 1.0f - pC->b; + pOut->a = pC->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + pC2->r; + pOut->g = pC1->g + pC2->g; + pOut->b = pC1->b + pC2->b; + pOut->a = pC1->a + pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r - pC2->r; + pOut->g = pC1->g - pC2->g; + pOut->b = pC1->b - pC2->b; + pOut->a = pC1->a - pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC) + return NULL; +#endif + + pOut->r = pC->r * s; + pOut->g = pC->g * s; + pOut->b = pC->b * s; + pOut->a = pC->a * s; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r * pC2->r; + pOut->g = pC1->g * pC2->g; + pOut->b = pC1->b * pC2->b; + pOut->a = pC1->a * pC2->a; + return pOut; +} + +D3DXINLINE D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s) +{ +#ifdef D3DX_DEBUG + if(!pOut || !pC1 || !pC2) + return NULL; +#endif + + pOut->r = pC1->r + s * (pC2->r - pC1->r); + pOut->g = pC1->g + s * (pC2->g - pC1->g); + pOut->b = pC1->b + s * (pC2->b - pC1->b); + pOut->a = pC1->a + s * (pC2->a - pC1->a); + return pOut; +} + + +#endif // __D3DX8MATH_INL__ diff --git a/win32/directx/d3dx8mesh.h b/win32/directx/d3dx8mesh.h new file mode 100644 index 0000000..d4cadd9 --- /dev/null +++ b/win32/directx/d3dx8mesh.h @@ -0,0 +1,760 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8mesh.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MESH_H__ +#define __D3DX8MESH_H__ + +#include "dxfile.h" // defines LPDIRECTXFILEDATA + +// {2A835771-BF4D-43f4-8E14-82A809F17D8A} +DEFINE_GUID(IID_ID3DXBaseMesh, +0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); + +// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} +DEFINE_GUID(IID_ID3DXMesh, +0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); + +// {19FBE386-C282-4659-97BD-CB869B084A6C} +DEFINE_GUID(IID_ID3DXPMesh, +0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); + +// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} +DEFINE_GUID(IID_ID3DXSPMesh, +0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); + +// {8DB06ECC-EBFC-408a-9404-3074B4773515} +DEFINE_GUID(IID_ID3DXSkinMesh, +0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); + +// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +enum _D3DXMESH { + D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. + D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. + D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER + D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. + D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. + D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + + D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + + D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh + + // Helper options + D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM + D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED + D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY + D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC + D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + +}; + +// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +enum _D3DXMESHSIMP +{ + D3DXMESHSIMP_VERTEX = 0x1, + D3DXMESHSIMP_FACE = 0x2, + +}; + +enum _MAX_FVF_DECL_SIZE +{ + MAX_FVF_DECL_SIZE = 20 +}; + +typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; +typedef struct ID3DXMesh *LPD3DXMESH; +typedef struct ID3DXPMesh *LPD3DXPMESH; +typedef struct ID3DXSPMesh *LPD3DXSPMESH; +typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; + +typedef struct _D3DXATTRIBUTERANGE +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; +} D3DXATTRIBUTERANGE; + +typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus +struct D3DXMATERIAL +{ + D3DMATERIAL8 MatD3D; + LPSTR pTextureFilename; +}; +typedef struct D3DXMATERIAL *LPD3DXMATERIAL; +#ifdef __cplusplus +} +#endif //__cplusplus + +typedef struct _D3DXATTRIBUTEWEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Tex[8]; +} D3DXATTRIBUTEWEIGHTS; + +typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; + +enum _D3DXWELDEPSILONSFLAGS +{ + D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + // vertices so that both components identical AND if all components "equal" + // remove one of the vertices + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal + // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + // useful to modify vertices to be equal, but not allow vertices to be removed +}; + +typedef struct _D3DXWELDEPSILONS +{ + FLOAT SkinWeights; + FLOAT Normal; + FLOAT Tex[8]; + DWORD Flags; +} D3DXWELDEPSILONS; + +typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; + + +#undef INTERFACE +#define INTERFACE ID3DXBaseMesh + +DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXMesh + +DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXMesh + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; + +}; + + +#undef INTERFACE +#define INTERFACE ID3DXPMesh + +DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXPMesh + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; + STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; + + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + + STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; + STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + + STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXSPMesh + +DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSPMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; + STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; +}; + +#define UNUSED16 (0xffff) +#define UNUSED32 (0xffffffff) + +// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +enum _D3DXMESHOPT { + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE +}; + +// Subset of the mesh that has the same attribute and bone combination. +// This subset can be rendered in a single draw call +typedef struct _D3DXBONECOMBINATION +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; + DWORD* BoneId; +} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; + + +#undef INTERFACE +#define INTERFACE ID3DXSkinMesh + +DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + // ID3DXSkinMesh + STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; + STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; + STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; + STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; + STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; + STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; + + STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + DWORD paletteSize, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, + FLOAT minWeight, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateSPMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + LPD3DXSPMESH* ppSMesh); + +// clean a mesh up for simplification, try to make manifold +HRESULT WINAPI + D3DXCleanMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + LPD3DXMESH* ppMeshOut, + DWORD* pAdjacencyOut, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXValidMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacency, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXGeneratePMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXPMESH* ppPMesh); + +HRESULT WINAPI + D3DXSimplifyMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + +HRESULT WINAPI + D3DXComputeNormals( + LPD3DXBASEMESH pMesh, + CONST DWORD *pAdjacency); + +HRESULT WINAPI + D3DXCreateBuffer( + DWORD NumBytes, + LPD3DXBUFFER *ppBuffer); + + +HRESULT WINAPI + D3DXLoadMeshFromX( + LPSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXInMemory( + PBYTE Memory, + DWORD SizeOfMemory, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXResource( + HMODULE Module, + LPCTSTR Name, + LPCTSTR Type, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXSaveMeshToX( + LPSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXMATERIAL pMaterials, + DWORD NumMaterials, + DWORD Format + ); + +HRESULT WINAPI + D3DXCreatePMeshFromStream( + IStream *pStream, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + DWORD* pNumMaterials, + LPD3DXPMESH *ppPMesh); + +HRESULT WINAPI + D3DXCreateSkinMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFromMesh( + LPD3DXMESH pMesh, + DWORD numBones, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXof( + LPDIRECTXFILEDATA pXofObjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadSkinMeshFromXof( + LPDIRECTXFILEDATA pxofobjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER* ppAdjacency, + LPD3DXBUFFER* ppMaterials, + DWORD *pMatOut, + LPD3DXBUFFER* ppBoneNames, + LPD3DXBUFFER* ppBoneTransforms, + LPD3DXSKINMESH* ppMesh); + +HRESULT WINAPI + D3DXTessellateNPatches( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, + BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppAdjacencyOut); + +UINT WINAPI + D3DXGetFVFVertexSize(DWORD FVF); + +HRESULT WINAPI + D3DXDeclaratorFromFVF( + DWORD FVF, + DWORD Declaration[MAX_FVF_DECL_SIZE]); + +HRESULT WINAPI + D3DXFVFFromDeclarator( + CONST DWORD *pDeclarator, + DWORD *pFVF); + +HRESULT WINAPI + D3DXWeldVertices( + CONST LPD3DXMESH pMesh, + LPD3DXWELDEPSILONS pEpsilons, + CONST DWORD *pAdjacencyIn, + DWORD *pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap); + +typedef struct _D3DXINTERSECTINFO +{ + DWORD FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; + + +HRESULT WINAPI + D3DXIntersect( + LPD3DXBASEMESH pMesh, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + +HRESULT WINAPI + D3DXIntersectSubset( + LPD3DXBASEMESH pMesh, + DWORD AttribId, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + + +HRESULT WINAPI D3DXSplitMesh + ( + CONST LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, + CONST DWORD MaxSize, + CONST DWORD Options, + DWORD *pMeshesOut, + LPD3DXBUFFER *ppMeshArrayOut, + LPD3DXBUFFER *ppAdjacencyArrayOut, + LPD3DXBUFFER *ppFaceRemapArrayOut, + LPD3DXBUFFER *ppVertRemapArrayOut + ); + +BOOL D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), +}; + + +#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF + +HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, + DWORD TexStage, + LPD3DXMESH OutMesh, + DWORD TexStageUVec, + DWORD TexStageVVec, + DWORD Wrap, + DWORD *Adjacency); + +HRESULT WINAPI +D3DXConvertMeshSubsetToSingleStrip +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices +); + +HRESULT WINAPI +D3DXConvertMeshSubsetToStrips +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices, + LPD3DXBUFFER *ppStripLengths, + DWORD *pNumStrips +); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8MESH_H__ + + diff --git a/win32/directx/d3dx8shape.h b/win32/directx/d3dx8shape.h new file mode 100644 index 0000000..c4d3630 --- /dev/null +++ b/win32/directx/d3dx8shape.h @@ -0,0 +1,220 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8shapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8SHAPES_H__ +#define __D3DX8SHAPES_H__ + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: +// ------------------ +// Creates a mesh containing an n-sided polygon. The polygon is centered +// at the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Length Length of each side. +// Sides Number of sides the polygon has. (Must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Length, + UINT Sides, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateBox: +// -------------- +// Creates a mesh containing an axis-aligned box. The box is centered at +// the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Width Width of box (along X-axis) +// Height Height of box (along Y-axis) +// Depth Depth of box (along Z-axis) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Width, + FLOAT Height, + FLOAT Depth, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: +// ------------------- +// Creates a mesh containing a cylinder. The generated cylinder is +// centered at the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius1 Radius at -Z end (should be >= 0.0f) +// Radius2 Radius at +Z end (should be >= 0.0f) +// Length Length of cylinder (along Z-axis) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateSphere: +// ----------------- +// Creates a mesh containing a sphere. The sphere is centered at the +// origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius Radius of the sphere (should be >= 0.0f) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: +// ---------------- +// Creates a mesh containing a torus. The generated torus is centered at +// the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// InnerRadius Inner radius of the torus (should be >= 0.0f) +// OuterRadius Outer radius of the torue (should be >= 0.0f) +// Sides Number of sides in a cross-section (must be >= 3) +// Rings Number of rings making up the torus (must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus( + LPDIRECT3DDEVICE8 pDevice, + FLOAT InnerRadius, + FLOAT OuterRadius, + UINT Sides, + UINT Rings, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: +// ----------------- +// Creates a mesh containing a teapot. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateText: +// --------------- +// Creates a mesh containing the specified text using the font associated +// with the device context. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// hDC Device context, with desired font selected +// pText Text to generate +// Deviation Maximum chordal deviation from true font outlines +// Extrusion Amount to extrude text in -Z direction +// ppMesh The mesh object which will be created +// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextA( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +HRESULT WINAPI + D3DXCreateTextW( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCWSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +#ifdef UNICODE +#define D3DXCreateText D3DXCreateTextW +#else +#define D3DXCreateText D3DXCreateTextA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8SHAPES_H__ diff --git a/win32/directx/d3dx8tex.h b/win32/directx/d3dx8tex.h new file mode 100644 index 0000000..2bdfce8 --- /dev/null +++ b/win32/directx/d3dx8tex.h @@ -0,0 +1,1592 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8tex.h +// Content: D3DX texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8TEX_H__ +#define __D3DX8TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR +// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | +// D3DX_FILTER_MIRROR_V +// D3DX_FILTER_DITHER +// Dithers the resulting image. +// +//---------------------------------------------------------------------------- + +#define D3DX_FILTER_NONE (1 << 0) +#define D3DX_FILTER_POINT (2 << 0) +#define D3DX_FILTER_LINEAR (3 << 0) +#define D3DX_FILTER_TRIANGLE (4 << 0) +#define D3DX_FILTER_BOX (5 << 0) + +#define D3DX_FILTER_MIRROR_U (1 << 16) +#define D3DX_FILTER_MIRROR_V (2 << 16) +#define D3DX_FILTER_MIRROR_W (4 << 16) +#define D3DX_FILTER_MIRROR (7 << 16) +#define D3DX_FILTER_DITHER (8 << 16) + + +//---------------------------------------------------------------------------- +// D3DX_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DXComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR +// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V +// D3DX_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +#define D3DX_NORMALMAP_MIRROR_U (1 << 16) +#define D3DX_NORMALMAP_MIRROR_V (2 << 16) +#define D3DX_NORMALMAP_MIRROR (3 << 16) +#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) +#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) + + + + +//---------------------------------------------------------------------------- +// D3DX_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX_CHANNEL_RED +// Indicates the red channel should be used +// D3DX_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +#define D3DX_CHANNEL_RED (1 << 0) +#define D3DX_CHANNEL_BLUE (1 << 1) +#define D3DX_CHANNEL_GREEN (1 << 2) +#define D3DX_CHANNEL_ALPHA (1 << 3) +#define D3DX_CHANNEL_LUMINANCE (1 << 4) + + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_FILEFORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DXIMAGE_FILEFORMAT +{ + D3DXIFF_BMP = 0, + D3DXIFF_JPG = 1, + D3DXIFF_TGA = 2, + D3DXIFF_PNG = 3, + D3DXIFF_DDS = 4, + D3DXIFF_PPM = 5, + D3DXIFF_DIB = 6, + D3DXIFF_FORCE_DWORD = 0x7fffffff + +} D3DXIMAGE_FILEFORMAT; + + +//---------------------------------------------------------------------------- +// LPD3DXFILL2D and LPD3DXFILL3D: +// ------------------------------ +// Function types used by the texture fill functions. +// +// Parameters: +// pOut +// Pointer to a vector which the function uses to return its result. +// X,Y,Z,W will be mapped to R,G,B,A respectivly. +// pTexCoord +// Pointer to a vector containing the coordinates of the texel currently +// being evaluated. Textures and VolumeTexture texcoord components +// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. +// pTexelSize +// Pointer to a vector containing the dimensions of the current texel. +// pData +// Pointer to user data. +// +//---------------------------------------------------------------------------- + +typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); +typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DXIMAGE_FILEFORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DXIMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + D3DFORMAT Format; + D3DRESOURCETYPE ResourceType; + D3DXIMAGE_FILEFORMAT ImageFileFormat; + +} D3DXIMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +; +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource: +// ------------------------------ +// Fills in a D3DXIMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetImageInfoFromFileA( + LPCSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromFileW( + LPCWSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW +#else +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW +#else +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO* pSrcInfo); + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Surface APIs //////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromFile/Resource: +// --------------------------------- +// Load surface from a file or resource +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcRect +// Source rectangle, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromFileA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromFileW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCWSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW +#else +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + +#ifdef UNICODE +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW +#else +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromFileInMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromSurface: +// --------------------------- +// Load surface from another surface (with color conversion) +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcSurface +// Source surface +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for entire surface +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromSurface( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromMemory: +// -------------------------- +// Load surface from memory. +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcMemory +// Pointer to the top-left corner of the source image in memory +// SrcFormat +// Pixel format of the source image. +// SrcPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the width of one row of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcPitch, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFile: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +HRESULT WINAPI + D3DXSaveSurfaceToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +#ifdef UNICODE +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW +#else +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Volume APIs ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromFile/Resource: +// -------------------------------- +// Load volume from a file or resource +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcBox +// Source box, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromFileA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromFileW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCWSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW +#else +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA +#endif + + +HRESULT WINAPI + D3DXLoadVolumeFromResourceA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromResourceW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW +#else +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadVolumeFromFileInMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromVolume: +// ------------------------- +// Load volume from another volume (with color conversion) +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcVolume +// Source volume +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for entire volume +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromVolume( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromMemory: +// ------------------------- +// Load volume from memory. +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcMemory +// Pointer to the top-left corner of the source volume in memory +// SrcFormat +// Pixel format of the source volume. +// SrcRowPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one row of cells, in bytes. +// SrcSlicePitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one slice of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcRowPitch, + UINT SrcSlicePitch, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFile: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +HRESULT WINAPI + D3DXSaveVolumeToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +#ifdef UNICODE +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW +#else +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: +// ----------------------------- +// Checks texture creation parameters. If parameters are invalid, this +// function returns corrected parameters. +// +// Parameters: +// +// pDevice +// The D3D device to be used +// pWidth, pHeight, pDepth, pSize +// Desired size in pixels, or NULL. Returns corrected size. +// pNumMipLevels +// Number of desired mipmap levels, or NULL. Returns corrected number. +// Usage +// Texture usage flags +// pFormat +// Desired pixel format, or NULL. Returns corrected format. +// Pool +// Memory pool to be used to create texture +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCheckTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckCubeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pSize, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckVolumeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pDepth, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + + +//---------------------------------------------------------------------------- +// D3DXCreateTexture: +// ------------------ +// Create an empty texture +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// Width, Height, Depth, Size +// size in pixels; these must be non-zero +// MipLevels +// number of mip levels desired; if zero or D3DX_DEFAULT, a complete +// mipmap chain will be created. +// Usage +// Texture usage flags +// Format +// Pixel format. +// Pool +// Memory pool to be used to create texture +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureFromFile/Resource: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// Width, Height, Depth, Size +// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken +// from the file. +// MipLevels +// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap +// chain will be created. +// Usage +// Texture usage flags +// Format +// Desired pixel format. If D3DFMT_UNKNOWN, the format will be +// taken from the file. +// Pool +// Memory pool to be used to create texture +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// MipFilter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// pPalette +// 256 color palette to be filled in, or NULL +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + + +// FromFile + +HRESULT WINAPI + D3DXCreateTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW +#else +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW +#else +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW +#else +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA +#endif + + +// FromResource + +HRESULT WINAPI + D3DXCreateTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW +#else +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW +#else +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW +#else +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA +#endif + + +// FromFileEx + +HRESULT WINAPI + D3DXCreateTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW +#else +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW +#else +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW +#else +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA +#endif + + +// FromResourceEx + +HRESULT WINAPI + D3DXCreateTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW +#else +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW +#else +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW +#else +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + +// FromFileInMemoryEx + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXSaveTextureToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +HRESULT WINAPI + D3DXSaveTextureToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +#ifdef UNICODE +#define D3DXSaveTextureToFile D3DXSaveTextureToFileW +#else +#define D3DXSaveTextureToFile D3DXSaveTextureToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Misc Texture APIs ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXFilterTexture: +// ------------------ +// Filters mipmaps levels of a texture. +// +// Parameters: +// pBaseTexture +// The texture object to be filtered +// pPalette +// 256 color palette to be used, or NULL for non-palettized formats +// SrcLevel +// The level whose image is used to generate the subsequent levels. +// Filter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFilterTexture( + LPDIRECT3DBASETEXTURE8 pBaseTexture, + CONST PALETTEENTRY* pPalette, + UINT SrcLevel, + DWORD Filter); + +#define D3DXFilterCubeTexture D3DXFilterTexture +#define D3DXFilterVolumeTexture D3DXFilterTexture + + + +//---------------------------------------------------------------------------- +// D3DXFillTexture: +// ---------------- +// Uses a user provided function to fill each texel of each mip level of a +// given texture. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pFunction +// Pointer to user provided evalutor function which will be used to +// compute the value of each texel. +// pData +// Pointer to an arbitrary block of user defined data. This pointer +// will be passed to the function provided in pFunction +//----------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTexture( + LPDIRECT3DTEXTURE8 pTexture, + LPD3DXFILL2D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillCubeTexture( + LPDIRECT3DCUBETEXTURE8 pCubeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillVolumeTexture( + LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pTexture +// Pointer to the destination texture +// pSrcTexture +// Pointer to the source heightmap texture +// pSrcPalette +// Source palette of 256 colors, or NULL +// Flags +// D3DX_NORMALMAP flags +// Channel +// D3DX_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXComputeNormalMap( + LPDIRECT3DTEXTURE8 pTexture, + LPDIRECT3DTEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8TEX_H__ diff --git a/win32/directx/ddraw.h b/win32/directx/ddraw.h new file mode 100644 index 0000000..0f204f8 --- /dev/null +++ b/win32/directx/ddraw.h @@ -0,0 +1,5792 @@ +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: ddraw.h + * Content: DirectDraw include file + * + ***************************************************************************/ + +#ifndef __DDRAW_INCLUDED__ +#define __DDRAW_INCLUDED__ + +//Disable the nameless union warning when building internally +#undef ENABLE_NAMELESS_UNION_PRAGMA +#ifdef DIRECTX_REDIST +#define ENABLE_NAMELESS_UNION_PRAGMA +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(disable:4201) +#endif + +/* + * If you wish an application built against the newest version of DirectDraw + * to run against an older DirectDraw run time then define DIRECTDRAW_VERSION + * to be the earlies version of DirectDraw you wish to run against. For, + * example if you wish an application to run against a DX 3 runtime define + * DIRECTDRAW_VERSION to be 0x0300. + */ +#ifndef DIRECTDRAW_VERSION +#define DIRECTDRAW_VERSION 0x0700 +#endif /* DIRECTDRAW_VERSION */ + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#define COM_NO_WINDOWS_H +#include +#else +#define IUnknown void +#if !defined( NT_BUILD_ENVIRONMENT ) && !defined(WINNT) + #define CO_E_NOTINITIALIZED 0x800401F0L +#endif +#endif + +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +#ifdef __cplusplus +extern "C" { +#endif + +// +// For compilers that don't support nameless unions, do a +// +// #define NONAMELESSUNION +// +// before #include +// +#ifndef DUMMYUNIONNAMEN +#if defined(__cplusplus) || !defined(NONAMELESSUNION) +#define DUMMYUNIONNAMEN(n) +#else +#define DUMMYUNIONNAMEN(n) u##n +#endif +#endif + +#ifndef MAKEFOURCC + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) +#endif //defined(MAKEFOURCC) + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +/* + * GUIDS used by DirectDraw objects + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) + +DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 ); +DEFINE_GUID( CLSID_DirectDraw7, 0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); +DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); +DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); +DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); +DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); + +#endif + +/*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*/ + +struct IDirectDraw; +struct IDirectDrawSurface; +struct IDirectDrawPalette; +struct IDirectDrawClipper; + +typedef struct IDirectDraw FAR *LPDIRECTDRAW; +typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2; +typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4; +typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; +typedef struct IDirectDrawSurface FAR *LPDIRECTDRAWSURFACE; +typedef struct IDirectDrawSurface2 FAR *LPDIRECTDRAWSURFACE2; +typedef struct IDirectDrawSurface3 FAR *LPDIRECTDRAWSURFACE3; +typedef struct IDirectDrawSurface4 FAR *LPDIRECTDRAWSURFACE4; +typedef struct IDirectDrawSurface7 FAR *LPDIRECTDRAWSURFACE7; +typedef struct IDirectDrawPalette FAR *LPDIRECTDRAWPALETTE; +typedef struct IDirectDrawClipper FAR *LPDIRECTDRAWCLIPPER; +typedef struct IDirectDrawColorControl FAR *LPDIRECTDRAWCOLORCONTROL; +typedef struct IDirectDrawGammaControl FAR *LPDIRECTDRAWGAMMACONTROL; + +typedef struct _DDFXROP FAR *LPDDFXROP; +typedef struct _DDSURFACEDESC FAR *LPDDSURFACEDESC; +typedef struct _DDSURFACEDESC2 FAR *LPDDSURFACEDESC2; +typedef struct _DDCOLORCONTROL FAR *LPDDCOLORCONTROL; + +/* + * API's + */ +#if (defined (WIN32) || defined( _WIN32 ) ) && !defined( _NO_COM ) +//#if defined( _WIN32 ) && !defined( _NO_ENUM ) + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID); + extern HRESULT WINAPI DirectDrawEnumerateW( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext ); + extern HRESULT WINAPI DirectDrawEnumerateA( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext ); + /* + * Protect against old SDKs + */ + #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); + #endif + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID, HMONITOR); + extern HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + extern HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXW)( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + + #ifdef UNICODE + typedef LPDDENUMCALLBACKW LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateW + typedef LPDDENUMCALLBACKEXW LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXW LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExW + #else + typedef LPDDENUMCALLBACKA LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateA + typedef LPDDENUMCALLBACKEXA LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXA LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExA + #endif + extern HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateClipper( DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); +#endif +/* + * Flags for DirectDrawEnumerateEx + * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to + * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. + * By default, only the primary display device is enumerated. + * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) + */ + +/* + * This flag causes enumeration of any GDI display devices which are part of + * the Windows Desktop + */ +#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L + +/* + * This flag causes enumeration of any GDI display devices which are not + * part of the Windows Desktop + */ +#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002L + +/* + * This flag causes enumeration of non-display devices + */ +#define DDENUM_NONDISPLAYDEVICES 0x00000004L + + +#define REGSTR_KEY_DDHW_DESCRIPTION "Description" +#define REGSTR_KEY_DDHW_DRIVERNAME "DriverName" +#define REGSTR_PATH_DDHW "Hardware\\DirectDrawDrivers" + +#define DDCREATE_HARDWAREONLY 0x00000001l +#define DDCREATE_EMULATIONONLY 0x00000002l + +#if defined(WINNT) || !defined(WIN32) +typedef long HRESULT; +#endif + +//#ifndef WINNT +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID); +//#endif + +/* + * Generic pixel format with 8-bit RGB and alpha components + */ +typedef struct _DDARGB +{ + BYTE blue; + BYTE green; + BYTE red; + BYTE alpha; +} DDARGB; + +typedef DDARGB FAR *LPDDARGB; + +/* + * This version of the structure remains for backwards source compatibility. + * The DDARGB structure is the one that should be used for all DirectDraw APIs. + */ +typedef struct _DDRGBA +{ + BYTE red; + BYTE green; + BYTE blue; + BYTE alpha; +} DDRGBA; + +typedef DDRGBA FAR *LPDDRGBA; + + +/* + * DDCOLORKEY + */ +typedef struct _DDCOLORKEY +{ + DWORD dwColorSpaceLowValue; // low boundary of color space that is to + // be treated as Color Key, inclusive + DWORD dwColorSpaceHighValue; // high boundary of color space that is + // to be treated as Color Key, inclusive +} DDCOLORKEY; + +typedef DDCOLORKEY FAR* LPDDCOLORKEY; + +/* + * DDBLTFX + * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. + */ +typedef struct _DDBLTFX +{ + DWORD dwSize; // size of structure + DWORD dwDDFX; // FX operations + DWORD dwROP; // Win32 raster operations + DWORD dwDDROP; // Raster operations new for DirectDraw + DWORD dwRotationAngle; // Rotation angle for blt + DWORD dwZBufferOpCode; // ZBuffer compares + DWORD dwZBufferLow; // Low limit of Z buffer + DWORD dwZBufferHigh; // High limit of Z buffer + DWORD dwZBufferBaseDest; // Destination base value + DWORD dwZDestConstBitDepth; // Bit depth used to specify Z constant for destination + union + { + DWORD dwZDestConst; // Constant to use as Z buffer for dest + LPDIRECTDRAWSURFACE lpDDSZBufferDest; // Surface to use as Z buffer for dest + } DUMMYUNIONNAMEN(1); + DWORD dwZSrcConstBitDepth; // Bit depth used to specify Z constant for source + union + { + DWORD dwZSrcConst; // Constant to use as Z buffer for src + LPDIRECTDRAWSURFACE lpDDSZBufferSrc; // Surface to use as Z buffer for src + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Alpha for edge blending + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(3); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwFillColor; // color in RGB or Palettized + DWORD dwFillDepth; // depth value for z-buffer + DWORD dwFillPixel; // pixel value for RGBA or RGBZ + LPDIRECTDRAWSURFACE lpDDSPattern; // Surface to use as pattern + } DUMMYUNIONNAMEN(5); + DDCOLORKEY ddckDestColorkey; // DestColorkey override + DDCOLORKEY ddckSrcColorkey; // SrcColorkey override +} DDBLTFX; + +typedef DDBLTFX FAR* LPDDBLTFX; + + + +/* + * DDSCAPS + */ +typedef struct _DDSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDSCAPS; + +typedef DDSCAPS FAR* LPDDSCAPS; + + +/* + * DDOSCAPS + */ +typedef struct _DDOSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDOSCAPS; + +typedef DDOSCAPS FAR* LPDDOSCAPS; + +/* + * This structure is used internally by DirectDraw. + */ +typedef struct _DDSCAPSEX +{ + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPSEX, FAR * LPDDSCAPSEX; + +/* + * DDSCAPS2 + */ +typedef struct _DDSCAPS2 +{ + DWORD dwCaps; // capabilities of surface wanted + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPS2; + +typedef DDSCAPS2 FAR* LPDDSCAPS2; + +/* + * DDCAPS + */ +#define DD_ROP_SPACE (256/32) // space required to store ROP array +/* + * NOTE: Our choosen structure number scheme is to append a single digit to + * the end of the structure giving the version that structure is associated + * with. + */ + +/* + * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally + * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. + * New applications should use the DDCAPS structure defined below. + */ +typedef struct _DDCAPS_DX1 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMinHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved +} DDCAPS_DX1; + +typedef DDCAPS_DX1 FAR* LPDDCAPS_DX1; + +/* + * This structure is the DDCAPS structure as it was in version 2 and 3 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX3 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved + DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts + DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts + DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts + DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts + DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts + DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts + DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts + DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts + DWORD dwSSBCaps; // driver specific capabilities for System->System blts + DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts + DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts + DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts + DWORD dwReserved4; // reserved + DWORD dwReserved5; // reserved + DWORD dwReserved6; // reserved +} DDCAPS_DX3; +typedef DDCAPS_DX3 FAR* LPDDCAPS_DX3; + +/* + * This structure is the DDCAPS structure as it was in version 5 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX5 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +// Members added for DX5: +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +} DDCAPS_DX5; +typedef DDCAPS_DX5 FAR* LPDDCAPS_DX5; + +typedef struct _DDCAPS_DX6 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha caps +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX6; +typedef DDCAPS_DX6 FAR* LPDDCAPS_DX6; + +typedef struct _DDCAPS_DX7 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX7; +typedef DDCAPS_DX7 FAR* LPDDCAPS_DX7; + + +#if DIRECTDRAW_VERSION <= 0x300 + typedef DDCAPS_DX3 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x500 + typedef DDCAPS_DX5 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x600 + typedef DDCAPS_DX6 DDCAPS; +#else + typedef DDCAPS_DX7 DDCAPS; +#endif + +typedef DDCAPS FAR* LPDDCAPS; + + + +/* + * DDPIXELFORMAT + */ +typedef struct _DDPIXELFORMAT +{ + DWORD dwSize; // size of structure + DWORD dwFlags; // pixel format flags + DWORD dwFourCC; // (FOURCC code) + union + { + DWORD dwRGBBitCount; // how many bits per pixel + DWORD dwYUVBitCount; // how many bits per pixel + DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) + DWORD dwAlphaBitDepth; // how many bits for alpha channels + DWORD dwLuminanceBitCount; // how many bits per pixel + DWORD dwBumpBitCount; // how many bits per "buxel", total + DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture + // format list and if DDPF_D3DFORMAT is set + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwRBitMask; // mask for red bit + DWORD dwYBitMask; // mask for Y bits + DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) + DWORD dwLuminanceBitMask; // mask for luminance bits + DWORD dwBumpDuBitMask; // mask for bump map U delta bits + DWORD dwOperations; // DDPF_D3DFORMAT Operations + } DUMMYUNIONNAMEN(2); + union + { + DWORD dwGBitMask; // mask for green bits + DWORD dwUBitMask; // mask for U bits + DWORD dwZBitMask; // mask for Z bits + DWORD dwBumpDvBitMask; // mask for bump map V delta bits + struct + { + WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT + WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT + } MultiSampleCaps; + + } DUMMYUNIONNAMEN(3); + union + { + DWORD dwBBitMask; // mask for blue bits + DWORD dwVBitMask; // mask for V bits + DWORD dwStencilBitMask; // mask for stencil bits + DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwRGBAlphaBitMask; // mask for alpha channel + DWORD dwYUVAlphaBitMask; // mask for alpha channel + DWORD dwLuminanceAlphaBitMask;// mask for alpha channel + DWORD dwRGBZBitMask; // mask for Z channel + DWORD dwYUVZBitMask; // mask for Z channel + } DUMMYUNIONNAMEN(5); +} DDPIXELFORMAT; + +typedef DDPIXELFORMAT FAR* LPDDPIXELFORMAT; + +/* + * DDOVERLAYFX + */ +typedef struct _DDOVERLAYFX +{ + DWORD dwSize; // size of structure + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Constant to use as alpha for edge blend + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as alpha channel for dest + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as alpha channel for dest + } DUMMYUNIONNAMEN(1); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as alpha channel for src + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as alpha channel for src + } DUMMYUNIONNAMEN(2); + DDCOLORKEY dckDestColorkey; // DestColorkey override + DDCOLORKEY dckSrcColorkey; // DestColorkey override + DWORD dwDDFX; // Overlay FX + DWORD dwFlags; // flags +} DDOVERLAYFX; + +typedef DDOVERLAYFX FAR *LPDDOVERLAYFX; + + +/* + * DDBLTBATCH: BltBatch entry structure + */ +typedef struct _DDBLTBATCH +{ + LPRECT lprDest; + LPDIRECTDRAWSURFACE lpDDSSrc; + LPRECT lprSrc; + DWORD dwFlags; + LPDDBLTFX lpDDBltFx; +} DDBLTBATCH; + +typedef DDBLTBATCH FAR * LPDDBLTBATCH; + + +/* + * DDGAMMARAMP + */ +typedef struct _DDGAMMARAMP +{ + WORD red[256]; + WORD green[256]; + WORD blue[256]; +} DDGAMMARAMP; +typedef DDGAMMARAMP FAR * LPDDGAMMARAMP; + +/* + * This is the structure within which DirectDraw returns data about the current graphics driver and chipset + */ + +#define MAX_DDDEVICEID_STRING 512 + +typedef struct tagDDDEVICEIDENTIFIER +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; +} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER; + +typedef struct tagDDDEVICEIDENTIFIER2 +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; + + /* + * This element is used to determine the Windows Hardware Quality Lab (WHQL) + * certification level for this driver/device pair. + */ + DWORD dwWHQLLevel; + +} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2; + +/* + * Flags for the IDirectDraw4::GetDeviceIdentifier method + */ + +/* + * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped + * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the + * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is + * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities + * of the DirectDraw object involved. + */ +#define DDGDI_GETHOSTIDENTIFIER 0x00000001L + +/* + * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel + */ +#define GET_WHQL_YEAR( dwWHQLLevel ) \ + ( (dwWHQLLevel) / 0x10000 ) +#define GET_WHQL_MONTH( dwWHQLLevel ) \ + ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) +#define GET_WHQL_DAY( dwWHQLLevel ) \ + ( (dwWHQLLevel) & 0xff ) + + +/* + * callbacks + */ +typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext ); +#ifdef STREAMING +typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD); +#endif + + +/* + * INTERACES FOLLOW: + * IDirectDraw + * IDirectDrawClipper + * IDirectDrawPalette + * IDirectDrawSurface + */ + +/* + * IDirectDraw + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw +DECLARE_INTERFACE_( IDirectDraw, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->lpVtbl->SetDisplayMode(p, a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#else +#define IDirectDraw_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw_AddRef(p) (p)->AddRef() +#define IDirectDraw_Release(p) (p)->Release() +#define IDirectDraw_Compact(p) (p)->Compact() +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->SetDisplayMode(a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw2 +DECLARE_INTERFACE_( IDirectDraw2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS, LPDWORD, LPDWORD) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw2_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw2_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw2_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw2_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw2_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#else +#define IDirectDraw2_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw2_AddRef(p) (p)->AddRef() +#define IDirectDraw2_Release(p) (p)->Release() +#define IDirectDraw2_Compact(p) (p)->Compact() +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw2_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw2_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw2_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw4 +DECLARE_INTERFACE_( IDirectDraw4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER, DWORD ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw4_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw4_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw4_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw4_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw4_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw4_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#else +#define IDirectDraw4_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw4_AddRef(p) (p)->AddRef() +#define IDirectDraw4_Release(p) (p)->Release() +#define IDirectDraw4_Compact(p) (p)->Compact() +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw4_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw4_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw4_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw4_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw7 +DECLARE_INTERFACE_( IDirectDraw7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK7 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2, DWORD ) PURE; + STDMETHOD(StartModeTest)(THIS_ LPSIZE, DWORD, DWORD ) PURE; + STDMETHOD(EvaluateMode)(THIS_ DWORD, DWORD * ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw7_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw7_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw7_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw7_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw7_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw7_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(p,a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(p,a,b) +#else +#define IDirectDraw7_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw7_AddRef(p) (p)->AddRef() +#define IDirectDraw7_Release(p) (p)->Release() +#define IDirectDraw7_Compact(p) (p)->Compact() +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw7_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw7_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw7_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw7_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(a,b) +#endif + +#endif + + +/* + * IDirectDrawPalette + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawPalette +DECLARE_INTERFACE_( IDirectDrawPalette, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawPalette methods ***/ + STDMETHOD(GetCaps)(THIS_ LPDWORD) PURE; + STDMETHOD(GetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD, LPPALETTEENTRY) PURE; + STDMETHOD(SetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawPalette_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawPalette_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->lpVtbl->Initialize(p, a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) +#else +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawPalette_AddRef(p) (p)->AddRef() +#define IDirectDrawPalette_Release(p) (p)->Release() +#define IDirectDrawPalette_GetCaps(p, a) (p)->GetCaps(a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->GetEntries(a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->Initialize(a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->SetEntries(a, b, c, d) +#endif + +#endif + + +/* + * IDirectDrawClipper + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawClipper +DECLARE_INTERFACE_( IDirectDrawClipper, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawClipper methods ***/ + STDMETHOD(GetClipList)(THIS_ LPRECT, LPRGNDATA, LPDWORD) PURE; + STDMETHOD(GetHWnd)(THIS_ HWND FAR *) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD) PURE; + STDMETHOD(IsClipListChanged)(THIS_ BOOL FAR *) PURE; + STDMETHOD(SetClipList)(THIS_ LPRGNDATA,DWORD) PURE; + STDMETHOD(SetHWnd)(THIS_ DWORD, HWND ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawClipper_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawClipper_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->lpVtbl->GetClipList(p, a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->lpVtbl->GetHWnd(p, a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->lpVtbl->Initialize(p, a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->lpVtbl->IsClipListChanged(p, a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->lpVtbl->SetClipList(p, a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->lpVtbl->SetHWnd(p, a, b) +#else +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawClipper_AddRef(p) (p)->AddRef() +#define IDirectDrawClipper_Release(p) (p)->Release() +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->GetClipList(a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->GetHWnd(a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->Initialize(a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->IsClipListChanged(a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->SetClipList(a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->SetHWnd(a, b) +#endif + +#endif + +/* + * IDirectDrawSurface and related interfaces + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawSurface +DECLARE_INTERFACE_( IDirectDrawSurface, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#else +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface_Release(p) (p)->Release() +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface_Restore(p) (p)->Restore() +#define IDirectDrawSurface_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#endif + +/* + * IDirectDrawSurface2 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface2 +DECLARE_INTERFACE_( IDirectDrawSurface2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE2, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE2, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE2 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE2,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE2) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface2_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface2_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#else +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface2_Release(p) (p)->Release() +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface2_Restore(p) (p)->Restore() +#define IDirectDrawSurface2_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->PageUnlock(a) +#endif + +/* + * IDirectDrawSurface3 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface3 +DECLARE_INTERFACE_( IDirectDrawSurface3, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE3, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE3, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE3 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE3,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE3) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the V3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC, DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface3_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface3_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface3_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#else +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface3_Release(p) (p)->Release() +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface3_Restore(p) (p)->Restore() +#define IDirectDrawSurface3_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#endif + +/* + * IDirectDrawSurface4 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface4 +DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE4, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE4, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE4,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE4) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface4_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface4_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#else +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface4_Release(p) (p)->Release() +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface4_Restore(p) (p)->Restore() +#define IDirectDrawSurface4_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#endif + +/* + * IDirectDrawSurface7 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface7 +DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE7,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE7) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; + /*** Moved Texture7 methods here ***/ + STDMETHOD(SetPriority)(THIS_ DWORD) PURE; + STDMETHOD(GetPriority)(THIS_ LPDWORD) PURE; + STDMETHOD(SetLOD)(THIS_ DWORD) PURE; + STDMETHOD(GetLOD)(THIS_ LPDWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface7_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface7_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#define IDirectDrawSurface7_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->lpVtbl->GetPriority(p,a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->lpVtbl->GetLOD(p,a) +#else +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface7_Release(p) (p)->Release() +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface7_Restore(p) (p)->Restore() +#define IDirectDrawSurface7_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#define IDirectDrawSurface7_SetPriority(p,a) (p)->SetPriority(a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->GetPriority(a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->SetLOD(a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->GetLOD(a) +#endif + + +/* + * IDirectDrawColorControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawColorControl +DECLARE_INTERFACE_( IDirectDrawColorControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawColorControl methods ***/ + STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; + STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawColorControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->lpVtbl->GetColorControls(p, a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->lpVtbl->SetColorControls(p, a) +#else +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->AddRef() +#define IDirectDrawColorControl_Release(p) (p)->Release() +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->GetColorControls(a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->SetColorControls(a) +#endif + +#endif + + +/* + * IDirectDrawGammaControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawGammaControl +DECLARE_INTERFACE_( IDirectDrawGammaControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawGammaControl methods ***/ + STDMETHOD(GetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; + STDMETHOD(SetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawGammaControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->lpVtbl->GetGammaRamp(p, a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->lpVtbl->SetGammaRamp(p, a, b) +#else +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->AddRef() +#define IDirectDrawGammaControl_Release(p) (p)->Release() +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->GetGammaRamp(a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->SetGammaRamp(a, b) +#endif + +#endif + + + +#endif + + +/* + * DDSURFACEDESC + */ +typedef struct _DDSURFACEDESC +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + DWORD dwBackBufferCount; // number of back buffers requested + union + { + DWORD dwMipMapCount; // number of mip-map levels requested + DWORD dwZBufferBitDepth; // depth of Z buffer requested + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DDSCAPS ddsCaps; // direct draw surface capabilities +} DDSURFACEDESC; + +/* + * DDSURFACEDESC2 + */ +typedef struct _DDSURFACEDESC2 +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwBackBufferCount; // number of back buffers requested + DWORD dwDepth; // the depth if this is a volume texture + } DUMMYUNIONNAMEN(5); + union + { + DWORD dwMipMapCount; // number of mip-map levels requestde + // dwZBufferBitDepth removed, use ddpfPixelFormat one instead + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + DWORD dwSrcVBHandle; // The source used in VB::Optimize + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + union + { + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces + } DUMMYUNIONNAMEN(3); + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + union + { + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DWORD dwFVF; // vertex format description of vertex buffers + } DUMMYUNIONNAMEN(4); + DDSCAPS2 ddsCaps; // direct draw surface capabilities + DWORD dwTextureStage; // stage in multitexture cascade +} DDSURFACEDESC2; + +/* + * ddsCaps field is valid. + */ +#define DDSD_CAPS 0x00000001l // default + +/* + * dwHeight field is valid. + */ +#define DDSD_HEIGHT 0x00000002l + +/* + * dwWidth field is valid. + */ +#define DDSD_WIDTH 0x00000004l + +/* + * lPitch is valid. + */ +#define DDSD_PITCH 0x00000008l + +/* + * dwBackBufferCount is valid. + */ +#define DDSD_BACKBUFFERCOUNT 0x00000020l + +/* + * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) + */ +#define DDSD_ZBUFFERBITDEPTH 0x00000040l + +/* + * dwAlphaBitDepth is valid. + */ +#define DDSD_ALPHABITDEPTH 0x00000080l + + +/* + * lpSurface is valid. + */ +#define DDSD_LPSURFACE 0x00000800l + +/* + * ddpfPixelFormat is valid. + */ +#define DDSD_PIXELFORMAT 0x00001000l + +/* + * ddckCKDestOverlay is valid. + */ +#define DDSD_CKDESTOVERLAY 0x00002000l + +/* + * ddckCKDestBlt is valid. + */ +#define DDSD_CKDESTBLT 0x00004000l + +/* + * ddckCKSrcOverlay is valid. + */ +#define DDSD_CKSRCOVERLAY 0x00008000l + +/* + * ddckCKSrcBlt is valid. + */ +#define DDSD_CKSRCBLT 0x00010000l + +/* + * dwMipMapCount is valid. + */ +#define DDSD_MIPMAPCOUNT 0x00020000l + + /* + * dwRefreshRate is valid + */ +#define DDSD_REFRESHRATE 0x00040000l + +/* + * dwLinearSize is valid + */ +#define DDSD_LINEARSIZE 0x00080000l + +/* + * dwTextureStage is valid + */ +#define DDSD_TEXTURESTAGE 0x00100000l +/* + * dwFVF is valid + */ +#define DDSD_FVF 0x00200000l +/* + * dwSrcVBHandle is valid + */ +#define DDSD_SRCVBHANDLE 0x00400000l + +/* + * dwDepth is valid + */ +#define DDSD_DEPTH 0x00800000l + +/* + * All input fields are valid. + */ +#define DDSD_ALL 0x00fff9eel + +/* + * DDOPTSURFACEDESC + */ +typedef struct _DDOPTSURFACEDESC +{ + DWORD dwSize; // size of the DDOPTSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DDSCAPS2 ddSCaps; // Common caps like: Memory type + DDOSCAPS ddOSCaps; // Common caps like: Memory type + GUID guid; // Compression technique GUID + DWORD dwCompressionRatio; // Compression ratio +} DDOPTSURFACEDESC; + +/* + * guid field is valid. + */ +#define DDOSD_GUID 0x00000001l + +/* + * dwCompressionRatio field is valid. + */ +#define DDOSD_COMPRESSION_RATIO 0x00000002l + +/* + * ddSCaps field is valid. + */ +#define DDOSD_SCAPS 0x00000004l + +/* + * ddOSCaps field is valid. + */ +#define DDOSD_OSCAPS 0x00000008l + +/* + * All input fields are valid. + */ +#define DDOSD_ALL 0x0000000fl + +/* + * The surface's optimized pixelformat is compressed + */ +#define DDOSDCAPS_OPTCOMPRESSED 0x00000001l + +/* + * The surface's optimized pixelformat is reordered + */ +#define DDOSDCAPS_OPTREORDERED 0x00000002l + +/* + * The opt surface is a monolithic mipmap + */ +#define DDOSDCAPS_MONOLITHICMIPMAP 0x00000004l + +/* + * The valid Surf caps: + * #define DDSCAPS_SYSTEMMEMORY 0x00000800l + * #define DDSCAPS_VIDEOMEMORY 0x00004000l + * #define DDSCAPS_LOCALVIDMEM 0x10000000l + * #define DDSCAPS_NONLOCALVIDMEM 0x20000000l + */ +#define DDOSDCAPS_VALIDSCAPS 0x30004800l + +/* + * The valid OptSurf caps + */ +#define DDOSDCAPS_VALIDOSCAPS 0x00000007l + + +/* + * DDCOLORCONTROL + */ +typedef struct _DDCOLORCONTROL +{ + DWORD dwSize; + DWORD dwFlags; + LONG lBrightness; + LONG lContrast; + LONG lHue; + LONG lSaturation; + LONG lSharpness; + LONG lGamma; + LONG lColorEnable; + DWORD dwReserved1; +} DDCOLORCONTROL; + + +/* + * lBrightness field is valid. + */ +#define DDCOLOR_BRIGHTNESS 0x00000001l + +/* + * lContrast field is valid. + */ +#define DDCOLOR_CONTRAST 0x00000002l + +/* + * lHue field is valid. + */ +#define DDCOLOR_HUE 0x00000004l + +/* + * lSaturation field is valid. + */ +#define DDCOLOR_SATURATION 0x00000008l + +/* + * lSharpness field is valid. + */ +#define DDCOLOR_SHARPNESS 0x00000010l + +/* + * lGamma field is valid. + */ +#define DDCOLOR_GAMMA 0x00000020l + +/* + * lColorEnable field is valid. + */ +#define DDCOLOR_COLORENABLE 0x00000040l + + + +/*============================================================================ + * + * Direct Draw Capability Flags + * + * These flags are used to describe the capabilities of a given Surface. + * All flags are bit flags. + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED1 0x00000001l + +/* + * Indicates that this surface contains alpha-only information. + * (To determine if a surface is RGBA/YUVA, the pixel format must be + * interrogated.) + */ +#define DDSCAPS_ALPHA 0x00000002l + +/* + * Indicates that this surface is a backbuffer. It is generally + * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. + * It indicates that this surface is THE back buffer of a surface + * flipping structure. DirectDraw supports N surfaces in a + * surface flipping structure. Only the surface that immediately + * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. + * The other surfaces are identified as back buffers by the presence + * of the DDSCAPS_FLIP capability, their attachment order, and the + * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER + * capabilities. The bit is sent to CreateSurface when a standalone + * back buffer is being created. This surface could be attached to + * a front buffer and/or back buffers to form a flipping surface + * structure after the CreateSurface call. See AddAttachments for + * a detailed description of the behaviors in this case. + */ +#define DDSCAPS_BACKBUFFER 0x00000004l + +/* + * Indicates a complex surface structure is being described. A + * complex surface structure results in the creation of more than + * one surface. The additional surfaces are attached to the root + * surface. The complex structure can only be destroyed by + * destroying the root. + */ +#define DDSCAPS_COMPLEX 0x00000008l + +/* + * Indicates that this surface is a part of a surface flipping structure. + * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and + * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface + * on the resulting creations. The dwBackBufferCount field in the + * DDSURFACEDESC structure must be set to at least 1 in order for + * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability + * must always be set with creating multiple surfaces through CreateSurface. + */ +#define DDSCAPS_FLIP 0x00000010l + +/* + * Indicates that this surface is THE front buffer of a surface flipping + * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP + * capability bit is set. + * If this capability is sent to CreateSurface then a standalonw front buffer + * is created. This surface will not have the DDSCAPS_FLIP capability. + * It can be attached to other back buffers to form a flipping structure. + * See AddAttachments for a detailed description of the behaviors in this + * case. + */ +#define DDSCAPS_FRONTBUFFER 0x00000020l + +/* + * Indicates that this surface is any offscreen surface that is not an overlay, + * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used + * to identify plain vanilla surfaces. + */ +#define DDSCAPS_OFFSCREENPLAIN 0x00000040l + +/* + * Indicates that this surface is an overlay. It may or may not be directly visible + * depending on whether or not it is currently being overlayed onto the primary + * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being + * overlayed at the moment. + */ +#define DDSCAPS_OVERLAY 0x00000080l + +/* + * Indicates that unique DirectDrawPalette objects can be created and + * attached to this surface. + */ +#define DDSCAPS_PALETTE 0x00000100l + +/* + * Indicates that this surface is the primary surface. The primary + * surface represents what the user is seeing at the moment. + */ +#define DDSCAPS_PRIMARYSURFACE 0x00000200l + + +/* + * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now + * obsolete. + */ +#define DDSCAPS_RESERVED3 0x00000400l +#define DDSCAPS_PRIMARYSURFACELEFT 0x00000000l + +/* + * Indicates that this surface memory was allocated in system memory + */ +#define DDSCAPS_SYSTEMMEMORY 0x00000800l + +/* + * Indicates that this surface can be used as a 3D texture. It does not + * indicate whether or not the surface is being used for that purpose. + */ +#define DDSCAPS_TEXTURE 0x00001000l + +/* + * Indicates that a surface may be a destination for 3D rendering. This + * bit must be set in order to query for a Direct3D Device Interface + * from this surface. + */ +#define DDSCAPS_3DDEVICE 0x00002000l + +/* + * Indicates that this surface exists in video memory. + */ +#define DDSCAPS_VIDEOMEMORY 0x00004000l + +/* + * Indicates that changes made to this surface are immediately visible. + * It is always set for the primary surface and is set for overlays while + * they are being overlayed and texture maps while they are being textured. + */ +#define DDSCAPS_VISIBLE 0x00008000l + +/* + * Indicates that only writes are permitted to the surface. Read accesses + * from the surface may or may not generate a protection fault, but the + * results of a read from this surface will not be meaningful. READ ONLY. + */ +#define DDSCAPS_WRITEONLY 0x00010000l + +/* + * Indicates that this surface is a z buffer. A z buffer does not contain + * displayable information. Instead it contains bit depth information that is + * used to determine which pixels are visible and which are obscured. + */ +#define DDSCAPS_ZBUFFER 0x00020000l + +/* + * Indicates surface will have a DC associated long term + */ +#define DDSCAPS_OWNDC 0x00040000l + +/* + * Indicates surface should be able to receive live video + */ +#define DDSCAPS_LIVEVIDEO 0x00080000l + +/* + * Indicates surface should be able to have a stream decompressed + * to it by the hardware. + */ +#define DDSCAPS_HWCODEC 0x00100000l + +/* + * Surface is a ModeX surface. + * + */ +#define DDSCAPS_MODEX 0x00200000l + +/* + * Indicates surface is one level of a mip-map. This surface will + * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. + * This can be done explicitly, by creating a number of surfaces and + * attaching them with AddAttachedSurface or by implicitly by CreateSurface. + * If this bit is set then DDSCAPS_TEXTURE must also be set. + */ +#define DDSCAPS_MIPMAP 0x00400000l + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED2 0x00800000l + + +/* + * Indicates that memory for the surface is not allocated until the surface + * is loaded (via the Direct3D texture Load() function). + */ +#define DDSCAPS_ALLOCONLOAD 0x04000000l + +/* + * Indicates that the surface will recieve data from a video port. + */ +#define DDSCAPS_VIDEOPORT 0x08000000l + +/* + * Indicates that a video memory surface is resident in true, local video + * memory rather than non-local video memory. If this flag is specified then + * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_NONLOCALVIDMEM. + */ +#define DDSCAPS_LOCALVIDMEM 0x10000000l + +/* + * Indicates that a video memory surface is resident in non-local video + * memory rather than true, local video memory. If this flag is specified + * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_LOCALVIDMEM. + */ +#define DDSCAPS_NONLOCALVIDMEM 0x20000000l + +/* + * Indicates that this surface is a standard VGA mode surface, and not a + * ModeX surface. (This flag will never be set in combination with the + * DDSCAPS_MODEX flag). + */ +#define DDSCAPS_STANDARDVGAMODE 0x40000000l + +/* + * Indicates that this surface will be an optimized surface. This flag is + * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface + * will be created without any underlying video memory until loaded. + */ +#define DDSCAPS_OPTIMIZED 0x80000000l + + + +/* + * This bit is reserved + */ +#define DDSCAPS2_RESERVED4 0x00000002L +#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000000L + +/* + * Indicates to the driver that this surface will be locked very frequently + * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap + * set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTDYNAMIC 0x00000004L + +/* + * Indicates to the driver that this surface can be re-ordered/retiled on + * load. This operation will not change the size of the texture. It is + * relatively fast and symmetrical, since the application may lock these + * bits (although it will take a performance hit when doing so). Surfaces + * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be + * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTSTATIC 0x00000008L + +/* + * Indicates that the client would like this texture surface to be managed by the + * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have + * DDSCAPS_TEXTURE set. + */ +#define DDSCAPS2_TEXTUREMANAGE 0x00000010L + +/* + * These bits are reserved for internal use */ +#define DDSCAPS2_RESERVED1 0x00000020L +#define DDSCAPS2_RESERVED2 0x00000040L + +/* + * Indicates to the driver that this surface will never be locked again. + * The driver is free to optimize this surface via retiling and actual compression. + * All calls to Lock() or Blts from this surface will fail. Surfaces with this + * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. + */ +#define DDSCAPS2_OPAQUE 0x00000080L + +/* + * Applications should set this bit at CreateSurface time to indicate that they + * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. + */ +#define DDSCAPS2_HINTANTIALIASING 0x00000100L + + +/* + * This flag is used at CreateSurface time to indicate that this set of + * surfaces is a cubic environment map + */ +#define DDSCAPS2_CUBEMAP 0x00000200L + +/* + * These flags preform two functions: + * - At CreateSurface time, they define which of the six cube faces are + * required by the application. + * - After creation, each face in the cubemap will have exactly one of these + * bits set. + */ +#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400L +#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800L +#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000L +#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000L +#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000L +#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000L + +/* + * This macro may be used to specify all faces of a cube map at CreateSurface time + */ +#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ + DDSCAPS2_CUBEMAP_NEGATIVEX |\ + DDSCAPS2_CUBEMAP_POSITIVEY |\ + DDSCAPS2_CUBEMAP_NEGATIVEY |\ + DDSCAPS2_CUBEMAP_POSITIVEZ |\ + DDSCAPS2_CUBEMAP_NEGATIVEZ ) + + +/* + * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards + * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface + * constructs such as Cube Maps, wherein there are more than one mipmap surface attached + * to the root surface. + * This caps bit is ignored by CreateSurface + */ +#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000L + +/* This flag indicates that the texture should be managed by D3D only */ +#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000L + +/* This flag indicates that the managed surface can be safely lost */ +#define DDSCAPS2_DONOTPERSIST 0x00040000L + +/* indicates that this surface is part of a stereo flipping chain */ +#define DDSCAPS2_STEREOSURFACELEFT 0x00080000L + + +/* + * Indicates that the surface is a volume. + * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume + */ +#define DDSCAPS2_VOLUME 0x00200000L + +/* + * Indicates that the surface may be locked multiple times by the application. + * This cap cannot be used with DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_NOTUSERLOCKABLE 0x00400000L + +/* + * Indicates that the vertex buffer data can be used to render points and + * point sprites. + */ +#define DDSCAPS2_POINTS 0x00800000L + +/* + * Indicates that the vertex buffer data can be used to render rt pactches. + */ +#define DDSCAPS2_RTPATCHES 0x01000000L + +/* + * Indicates that the vertex buffer data can be used to render n patches. + */ +#define DDSCAPS2_NPATCHES 0x02000000L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS2_RESERVED3 0x04000000L + + +/* + * Indicates that the contents of the backbuffer do not have to be preserved + * the contents of the backbuffer after they are presented. + */ +#define DDSCAPS2_DISCARDBACKBUFFER 0x10000000L + +/* + * Indicates that all surfaces in this creation chain should be given an alpha channel. + * This flag will be set on primary surface chains that may have no explicit pixel format + * (and thus take on the format of the current display mode). + * The driver should infer that all these surfaces have a format having an alpha channel. + * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) + */ +#define DDSCAPS2_ENABLEALPHACHANNEL 0x20000000L + +/* + * Indicates that all surfaces in this creation chain is extended primary surface format. + * This flag will be set on extended primary surface chains that always have explicit pixel + * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, + * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) + */ +#define DDSCAPS2_EXTENDEDFORMATPRIMARY 0x40000000L + +/* + * Indicates that all surfaces in this creation chain is additional primary surface. + * This flag will be set on primary surface chains which must present on the adapter + * id provided on dwCaps4. Typically this will be used to create secondary primary surface + * on DualView display adapter. + */ +#define DDSCAPS2_ADDITIONALPRIMARY 0x80000000L + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate number of samples per pixel + * when multisampling + */ +#define DDSCAPS3_MULTISAMPLE_MASK 0x0000001FL + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate the quality level of rendering + * for the current number of samples per pixel + */ +#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK 0x000000E0L +#define DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT 5 + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED1 0x00000100L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED2 0x00000200L + +/* + * This indicates whether this surface has light-weight miplevels + */ +#define DDSCAPS3_LIGHTWEIGHTMIPMAP 0x00000400L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_AUTOGENMIPMAP 0x00000800L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_DMAP 0x00001000L + + + /**************************************************************************** + * + * DIRECTDRAW DRIVER CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Display hardware has 3D acceleration. + */ +#define DDCAPS_3D 0x00000001l + +/* + * Indicates that DirectDraw will support only dest rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZEDEST 0x00000004l +/* + * Indicates that DirectDraw will support only source rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZESRC 0x00000010l + +/* + * Indicates that DirectDraw will create video memory surfaces that have a stride + * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. + */ +#define DDCAPS_ALIGNSTRIDE 0x00000020l + +/* + * Display hardware is capable of blt operations. + */ +#define DDCAPS_BLT 0x00000040l + +/* + * Display hardware is capable of asynchronous blt operations. + */ +#define DDCAPS_BLTQUEUE 0x00000080l + +/* + * Display hardware is capable of color space conversions during the blt operation. + */ +#define DDCAPS_BLTFOURCC 0x00000100l + +/* + * Display hardware is capable of stretching during blt operations. + */ +#define DDCAPS_BLTSTRETCH 0x00000200l + +/* + * Display hardware is shared with GDI. + */ +#define DDCAPS_GDI 0x00000400l + +/* + * Display hardware can overlay. + */ +#define DDCAPS_OVERLAY 0x00000800l + +/* + * Set if display hardware supports overlays but can not clip them. + */ +#define DDCAPS_OVERLAYCANTCLIP 0x00001000l + +/* + * Indicates that overlay hardware is capable of color space conversions during + * the overlay operation. + */ +#define DDCAPS_OVERLAYFOURCC 0x00002000l + +/* + * Indicates that stretching can be done by the overlay hardware. + */ +#define DDCAPS_OVERLAYSTRETCH 0x00004000l + +/* + * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces + * other than the primary surface. + */ +#define DDCAPS_PALETTE 0x00008000l + +/* + * Indicates that palette changes can be syncd with the veritcal refresh. + */ +#define DDCAPS_PALETTEVSYNC 0x00010000l + +/* + * Display hardware can return the current scan line. + */ +#define DDCAPS_READSCANLINE 0x00020000l + + +/* + * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete + */ +#define DDCAPS_RESERVED1 0x00040000l + +/* + * Display hardware is capable of generating a vertical blank interrupt. + */ +#define DDCAPS_VBI 0x00080000l + +/* + * Supports the use of z buffers with blt operations. + */ +#define DDCAPS_ZBLTS 0x00100000l + +/* + * Supports Z Ordering of overlays. + */ +#define DDCAPS_ZOVERLAYS 0x00200000l + +/* + * Supports color key + */ +#define DDCAPS_COLORKEY 0x00400000l + +/* + * Supports alpha surfaces + */ +#define DDCAPS_ALPHA 0x00800000l + +/* + * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) + */ +#define DDCAPS_COLORKEYHWASSIST 0x01000000l + +/* + * no hardware support at all + */ +#define DDCAPS_NOHARDWARE 0x02000000l + +/* + * Display hardware is capable of color fill with bltter + */ +#define DDCAPS_BLTCOLORFILL 0x04000000l + +/* + * Display hardware is bank switched, and potentially very slow at + * random access to VRAM. + */ +#define DDCAPS_BANKSWITCHED 0x08000000l + +/* + * Display hardware is capable of depth filling Z-buffers with bltter + */ +#define DDCAPS_BLTDEPTHFILL 0x10000000l + +/* + * Display hardware is capable of clipping while bltting. + */ +#define DDCAPS_CANCLIP 0x20000000l + +/* + * Display hardware is capable of clipping while stretch bltting. + */ +#define DDCAPS_CANCLIPSTRETCHED 0x40000000l + +/* + * Display hardware is capable of bltting to or from system memory + */ +#define DDCAPS_CANBLTSYSMEM 0x80000000l + + + /**************************************************************************** + * + * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) + * + ****************************************************************************/ + +/* + * Display hardware is certified + */ +#define DDCAPS2_CERTIFIED 0x00000001l + +/* + * Driver cannot interleave 2D operations (lock and blt) to surfaces with + * Direct3D rendering operations between calls to BeginScene() and EndScene() + */ +#define DDCAPS2_NO2DDURING3DSCENE 0x00000002l + +/* + * Display hardware contains a video port + */ +#define DDCAPS2_VIDEOPORT 0x00000004l + +/* + * The overlay can be automatically flipped according to the video port + * VSYNCs, providing automatic doubled buffered display of video port + * data using an overlay + */ +#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008l + +/* + * Overlay can display each field of interlaced data individually while + * it is interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBINTERLEAVED 0x00000010l + +/* + * Overlay can display each field of interlaced data individually while + * it is not interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020l + +/* + * The overlay surface contains color controls (brightness, sharpness, etc.) + */ +#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040l + +/* + * The primary surface contains color controls (gamma, etc.) + */ +#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080l + +/* + * RGBZ -> RGB supported for 16:16 RGB:Z + */ +#define DDCAPS2_CANDROPZ16BIT 0x00000100l + +/* + * Driver supports non-local video memory. + */ +#define DDCAPS2_NONLOCALVIDMEM 0x00000200l + +/* + * Dirver supports non-local video memory but has different capabilities for + * non-local video memory surfaces. If this bit is set then so must + * DDCAPS2_NONLOCALVIDMEM. + */ +#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400l + +/* + * Driver neither requires nor prefers surfaces to be pagelocked when performing + * blts involving system memory surfaces + */ +#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800l + +/* + * Driver can create surfaces which are wider than the primary surface + */ +#define DDCAPS2_WIDESURFACES 0x00001000l + +/* + * Driver supports bob without using a video port by handling the + * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. + */ +#define DDCAPS2_CANFLIPODDEVEN 0x00002000l + +/* + * Driver supports bob using hardware + */ +#define DDCAPS2_CANBOBHARDWARE 0x00004000l + +/* + * Driver supports bltting any FOURCC surface to another surface of the same FOURCC + */ +#define DDCAPS2_COPYFOURCC 0x00008000l + + +/* + * Driver supports loadable gamma ramps for the primary surface + */ +#define DDCAPS2_PRIMARYGAMMA 0x00020000l + +/* + * Driver can render in windowed mode. + */ +#define DDCAPS2_CANRENDERWINDOWED 0x00080000l + +/* + * A calibrator is available to adjust the gamma ramp according to the + * physical display properties so that the result will be identical on + * all calibrated systems. + */ +#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000l + +/* + * Indicates that the driver will respond to DDFLIP_INTERVALn flags + */ +#define DDCAPS2_FLIPINTERVAL 0x00200000l + +/* + * Indicates that the driver will respond to DDFLIP_NOVSYNC + */ +#define DDCAPS2_FLIPNOVSYNC 0x00400000l + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGETEXTURE 0x00800000l + +/* + * The Direct3D texture manager uses this cap to decide whether to put managed + * surfaces in non-local video memory. If the cap is set, the texture manager will + * put managed surfaces in non-local vidmem. Drivers that cannot texture from + * local vidmem SHOULD NOT set this cap. + */ +#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000l + +/* + * Indicates that the driver supports DX7 type of stereo in at least one mode (which may + * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) + * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of + * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application + * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. + */ +#define DDCAPS2_STEREO 0x02000000L + +/* + * This caps bit is intended for internal DirectDraw use. + * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. + * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and + * all the assoicated system memory blt caps must be correct). + * -It implies that the system->video blt caps in DDCAPS also apply to system to + * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops + * members of DDCAPS (DDCORECAPS) are filled in correctly. + * -Any blt from system to nonlocal memory that matches these caps bits will + * be passed to the driver. + * + * NOTE: This is intended to enable the driver itself to do efficient reordering + * of textures. This is NOT meant to imply that hardware can write into AGP memory. + * This operation is not currently supported. + */ +#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000L + +/* + * was DDCAPS2_PUREHAL + */ +#define DDCAPS2_RESERVED1 0x08000000L + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGERESOURCE 0x10000000L + +/* + * Driver supports dynamic textures. This will allow the application to set + * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. + * Video memory dynamic textures WILL be lockable by applications. It is + * expected that these locks will be very efficient (which implies that the + * driver should always maintain a linear copy, a pointer to which can be + * quickly handed out to the application). + */ +#define DDCAPS2_DYNAMICTEXTURES 0x20000000L + +/* + * Driver supports auto-generation of mipmaps. + */ +#define DDCAPS2_CANAUTOGENMIPMAP 0x40000000L + + +/**************************************************************************** + * + * DIRECTDRAW FX ALPHA CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010l + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200l + +#if DIRECTDRAW_VERSION < 0x0600 +#endif //DIRECTDRAW_VERSION + + +/**************************************************************************** + * + * DIRECTDRAW FX CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Uses arithmetic operations to stretch and shrink surfaces during blt + * rather than pixel doubling techniques. Along the Y axis. + */ +#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020l + +/* + * Uses arithmetic operations to stretch during blt + * rather than pixel doubling techniques. Along the Y axis. Only + * works for x1, x2, etc. + */ +#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010l + +/* + * Supports mirroring left to right in blt. + */ +#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040l + +/* + * Supports mirroring top to bottom in blt. + */ +#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080l + +/* + * Supports arbitrary rotation for blts. + */ +#define DDFXCAPS_BLTROTATION 0x00000100l + +/* + * Supports 90 degree rotations for blts. + */ +#define DDFXCAPS_BLTROTATION90 0x00000200l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKX 0x00000400l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKXN 0x00000800l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKY 0x00001000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKYN 0x00002000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHX 0x00004000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHXN 0x00008000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHY 0x00010000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHYN 0x00020000l + +/* + * Uses arithmetic operations to stretch and shrink surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000l + +/* + * Uses arithmetic operations to stretch surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. Only works for x1, x2, etc. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKX 0x00080000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKY 0x00200000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000l + +/* + * DirectDraw supports mirroring of overlays across the vertical axis + */ +#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000l + +/* + * DirectDraw supports mirroring of overlays across the horizontal axis + */ +#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000l + +/* + * DirectDraw supports deinterlacing of overlay surfaces + */ +#define DDFXCAPS_OVERLAYDEINTERLACE 0x20000000l + +/* + * Driver can do alpha blending for blits. + */ +#define DDFXCAPS_BLTALPHA 0x00000001l + + +/* + * Driver can do surface-reconstruction filtering for warped blits. + */ +#define DDFXCAPS_BLTFILTER DDFXCAPS_BLTARITHSTRETCHY + +/* + * Driver can do alpha blending for overlays. + */ +#define DDFXCAPS_OVERLAYALPHA 0x00000004l + + +/* + * Driver can do surface-reconstruction filtering for warped overlays. + */ +#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY + +/**************************************************************************** + * + * DIRECTDRAW STEREO VIEW CAPABILITIES + * + ****************************************************************************/ + +/* + * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete + */ + +#define DDSVCAPS_RESERVED1 0x00000001l + +/* + * This flag used to be DDSVCAPS_FLICKER, which is now obsolete + */ +#define DDSVCAPS_RESERVED2 0x00000002l + +/* + * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete + */ +#define DDSVCAPS_RESERVED3 0x00000004l + +/* + * This flag used to be DDSVCAPS_SPLIT, which is now obsolete + */ +#define DDSVCAPS_RESERVED4 0x00000008l + +/* + * The stereo view is accomplished with switching technology + */ + +#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010L + + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE CAPABILITIES + * + ****************************************************************************/ + +/* + * Index is 4 bits. There are sixteen color entries in the palette table. + */ +#define DDPCAPS_4BIT 0x00000001l + +/* + * Index is onto a 8 bit color index. This field is only valid with the + * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target + * surface is in 8bpp. Each color entry is one byte long and is an index + * into destination surface's 8bpp palette. + */ +#define DDPCAPS_8BITENTRIES 0x00000002l + +/* + * Index is 8 bits. There are 256 color entries in the palette table. + */ +#define DDPCAPS_8BIT 0x00000004l + +/* + * Indicates that this DIRECTDRAWPALETTE should use the palette color array + * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE + * object. + * This flag is obsolete. DirectDraw always initializes the color array from + * the lpDDColorArray parameter. The definition remains for source-level + * compatibility. + */ +#define DDPCAPS_INITIALIZE 0x00000000l + +/* + * This palette is the one attached to the primary surface. Changing this + * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified + * and supported. + */ +#define DDPCAPS_PRIMARYSURFACE 0x00000010l + +/* + * This palette is the one attached to the primary surface left. Changing + * this table has immediate effect on the display for the left eye unless + * DDPSETPAL_VSYNC is specified and supported. + */ +#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020l + +/* + * This palette can have all 256 entries defined + */ +#define DDPCAPS_ALLOW256 0x00000040l + +/* + * This palette can have modifications to it synced with the monitors + * refresh rate. + */ +#define DDPCAPS_VSYNC 0x00000080l + +/* + * Index is 1 bit. There are two color entries in the palette table. + */ +#define DDPCAPS_1BIT 0x00000100l + +/* + * Index is 2 bit. There are four color entries in the palette table. + */ +#define DDPCAPS_2BIT 0x00000200l + +/* + * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value + */ +#define DDPCAPS_ALPHA 0x00000400l + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE SETENTRY CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE GETENTRY CONSTANTS + * + ****************************************************************************/ + +/* 0 is the only legal value */ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS + * + ****************************************************************************/ + +/* + * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData + * must be set to sizeof(IUnknown*). DirectDraw will call AddRef through this + * pointer and Release when the private data is destroyed. This includes when + * the surface or palette is destroyed before such priovate data is destroyed. + */ +#define DDSPD_IUNKNOWNPOINTER 0x00000001L + +/* + * Private data is only valid for the current state of the object, + * as determined by the uniqueness value. + */ +#define DDSPD_VOLATILE 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPALETTE CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAW BITDEPTH CONSTANTS + * + * NOTE: These are only used to indicate supported bit depths. These + * are flags only, they are not to be used as an actual bit depth. The + * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual + * bit depths in a surface or for changing the display mode. + * + ****************************************************************************/ + +/* + * 1 bit per pixel. + */ +#define DDBD_1 0x00004000l + +/* + * 2 bits per pixel. + */ +#define DDBD_2 0x00002000l + +/* + * 4 bits per pixel. + */ +#define DDBD_4 0x00001000l + +/* + * 8 bits per pixel. + */ +#define DDBD_8 0x00000800l + +/* + * 16 bits per pixel. + */ +#define DDBD_16 0x00000400l + +/* + * 24 bits per pixel. + */ +#define DDBD_24 0X00000200l + +/* + * 32 bits per pixel. + */ +#define DDBD_32 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS + * + ****************************************************************************/ + +/* + * Set if the structure contains a color space. Not set if the structure + * contains a single color key. + */ +#define DDCKEY_COLORSPACE 0x00000001l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for blt operations. + */ +#define DDCKEY_DESTBLT 0x00000002l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for overlay operations. + */ +#define DDCKEY_DESTOVERLAY 0x00000004l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for blt operations. + */ +#define DDCKEY_SRCBLT 0x00000008l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for overlay operations. + */ +#define DDCKEY_SRCOVERLAY 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW COLOR KEY CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLT 0x00000001l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004l + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTYUV 0x00000008l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the surface + * being overlayed for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAY 0x00000010l + +/* + * Supports a color space as the color key for the destination for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020l + +/* + * Supports a color space as the color key for the destination for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040l + +/* + * Supports only one active destination color key value for visible overlay + * surfaces. + */ +#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the + * surface being overlayed for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100l + +/* + * Supports transparent blting using the color key for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLT 0x00000200l + +/* + * Supports transparent blting using a color space for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400l + +/* + * Supports transparent blting using a color space for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800l + +/* + * Supports transparent blting using the color key for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTYUV 0x00001000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAY 0x00002000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000l + +/* + * Supports only one active source color key value for visible + * overlay surfaces. + */ +#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000l + +/* + * there are no bandwidth trade-offs for using colorkey with an overlay + */ +#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000l + + +/**************************************************************************** + * + * DIRECTDRAW PIXELFORMAT FLAGS + * + ****************************************************************************/ + +/* + * The surface has alpha channel information in the pixel format. + */ +#define DDPF_ALPHAPIXELS 0x00000001l + +/* + * The pixel format contains alpha only information + */ +#define DDPF_ALPHA 0x00000002l + +/* + * The FourCC code is valid. + */ +#define DDPF_FOURCC 0x00000004l + +/* + * The surface is 4-bit color indexed. + */ +#define DDPF_PALETTEINDEXED4 0x00000008l + +/* + * The surface is indexed into a palette which stores indices + * into the destination surface's 8-bit palette. + */ +#define DDPF_PALETTEINDEXEDTO8 0x00000010l + +/* + * The surface is 8-bit color indexed. + */ +#define DDPF_PALETTEINDEXED8 0x00000020l + +/* + * The RGB data in the pixel format structure is valid. + */ +#define DDPF_RGB 0x00000040l + +/* + * The surface will accept pixel data in the format specified + * and compress it during the write. + */ +#define DDPF_COMPRESSED 0x00000080l + +/* + * The surface will accept RGB data and translate it during + * the write to YUV data. The format of the data to be written + * will be contained in the pixel format structure. The DDPF_RGB + * flag will be set. + */ +#define DDPF_RGBTOYUV 0x00000100l + +/* + * pixel format is YUV - YUV data in pixel format struct is valid + */ +#define DDPF_YUV 0x00000200l + +/* + * pixel format is a z buffer only surface + */ +#define DDPF_ZBUFFER 0x00000400l + +/* + * The surface is 1-bit color indexed. + */ +#define DDPF_PALETTEINDEXED1 0x00000800l + +/* + * The surface is 2-bit color indexed. + */ +#define DDPF_PALETTEINDEXED2 0x00001000l + +/* + * The surface contains Z information in the pixels + */ +#define DDPF_ZPIXELS 0x00002000l + +/* + * The surface contains stencil information along with Z + */ +#define DDPF_STENCILBUFFER 0x00004000l + +/* + * Premultiplied alpha format -- the color components have been + * premultiplied by the alpha component. + */ +#define DDPF_ALPHAPREMULT 0x00008000l + + +/* + * Luminance data in the pixel format is valid. + * Use this flag for luminance-only or luminance+alpha surfaces, + * the bit depth is then ddpf.dwLuminanceBitCount. + */ +#define DDPF_LUMINANCE 0x00020000l + +/* + * Luminance data in the pixel format is valid. + * Use this flag when hanging luminance off bumpmap surfaces, + * the bit mask for the luminance portion of the pixel is then + * ddpf.dwBumpLuminanceBitMask + */ +#define DDPF_BUMPLUMINANCE 0x00040000l + +/* + * Bump map dUdV data in the pixel format is valid. + */ +#define DDPF_BUMPDUDV 0x00080000l + + +/*=========================================================================== + * + * + * DIRECTDRAW CALLBACK FLAGS + * + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAW ENUMSURFACES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate all of the surfaces that meet the search criterion. + */ +#define DDENUMSURFACES_ALL 0x00000001l + +/* + * A search hit is a surface that matches the surface description. + */ +#define DDENUMSURFACES_MATCH 0x00000002l + +/* + * A search hit is a surface that does not match the surface description. + */ +#define DDENUMSURFACES_NOMATCH 0x00000004l + +/* + * Enumerate the first surface that can be created which meets the search criterion. + */ +#define DDENUMSURFACES_CANBECREATED 0x00000008l + +/* + * Enumerate the surfaces that already exist that meet the search criterion. + */ +#define DDENUMSURFACES_DOESEXIST 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW SETDISPLAYMODE FLAGS + * + ****************************************************************************/ + +/* + * The desired mode is a standard VGA mode + */ +#define DDSDM_STANDARDVGAMODE 0x00000001l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMDISPLAYMODES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees + * that a particular mode will be enumerated only once. This flag specifies whether + * the refresh rate is taken into account when determining if a mode is unique. + */ +#define DDEDM_REFRESHRATES 0x00000001l + +/* + * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA + * modes such as mode 0x13 in addition to the usual ModeX modes (which are always + * enumerated if the application has previously called SetCooperativeLevel with the + * DDSCL_ALLOWMODEX flag set). + */ +#define DDEDM_STANDARDVGAMODES 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS + * + ****************************************************************************/ + +/* + * Exclusive mode owner will be responsible for the entire primary surface. + * GDI can be ignored. used with DD + */ +#define DDSCL_FULLSCREEN 0x00000001l + +/* + * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode + */ +#define DDSCL_ALLOWREBOOT 0x00000002l + +/* + * prevents DDRAW from modifying the application window. + * prevents DDRAW from minimize/restore the application window on activation. + */ +#define DDSCL_NOWINDOWCHANGES 0x00000004l + +/* + * app wants to work as a regular Windows application + */ +#define DDSCL_NORMAL 0x00000008l + +/* + * app wants exclusive access + */ +#define DDSCL_EXCLUSIVE 0x00000010l + + +/* + * app can deal with non-windows display modes + */ +#define DDSCL_ALLOWMODEX 0x00000040l + +/* + * this window will receive the focus messages + */ +#define DDSCL_SETFOCUSWINDOW 0x00000080l + +/* + * this window is associated with the DDRAW object and will + * cover the screen in fullscreen mode + */ +#define DDSCL_SETDEVICEWINDOW 0x00000100l + +/* + * app wants DDRAW to create a window to be associated with the + * DDRAW object + */ +#define DDSCL_CREATEDEVICEWINDOW 0x00000200l + +/* + * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D + * take the global crtisec more frequently. + */ +#define DDSCL_MULTITHREADED 0x00000400l + +/* + * App specifies that it would like to keep the FPU set up for optimal Direct3D + * performance (single precision and exceptions disabled) so Direct3D + * does not need to explicitly set the FPU each time. This is assumed by + * default in DirectX 7. See also DDSCL_FPUPRESERVE + */ +#define DDSCL_FPUSETUP 0x00000800l + +/* + * App specifies that it needs either double precision FPU or FPU exceptions + * enabled. This makes Direct3D explicitly set the FPU state eah time it is + * called. Setting the flag will reduce Direct3D performance. The flag is + * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP + */ +#define DDSCL_FPUPRESERVE 0x00001000l + + +/**************************************************************************** + * + * DIRECTDRAW BLT FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel + * for the destination surface for this blt. + */ +#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha + * channel for the destination for this blt. + */ +#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel + * for the edges of the image that border the color key colors. + */ +#define DDBLT_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Do this blt asynchronously through the FIFO in the order received. If + * there is no room in the hardware FIFO fail the call. + */ +#define DDBLT_ASYNC 0x00000200l + +/* + * Uses the dwFillColor field in the DDBLTFX structure as the RGB color + * to fill the destination rectangle on the destination surface with. + */ +#define DDBLT_COLORFILL 0x00000400l + +/* + * Uses the dwDDFX field in the DDBLTFX structure to specify the effects + * to use for the blt. + */ +#define DDBLT_DDFX 0x00000800l + +/* + * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS + * that are not part of the Win32 API. + */ +#define DDBLT_DDROPS 0x00001000l + +/* + * Use the color key associated with the destination surface. + */ +#define DDBLT_KEYDEST 0x00002000l + +/* + * Use the dckDestColorkey field in the DDBLTFX structure as the color key + * for the destination surface. + */ +#define DDBLT_KEYDESTOVERRIDE 0x00004000l + +/* + * Use the color key associated with the source surface. + */ +#define DDBLT_KEYSRC 0x00008000l + +/* + * Use the dckSrcColorkey field in the DDBLTFX structure as the color key + * for the source surface. + */ +#define DDBLT_KEYSRCOVERRIDE 0x00010000l + +/* + * Use the dwROP field in the DDBLTFX structure for the raster operation + * for this blt. These ROPs are the same as the ones defined in the Win32 API. + */ +#define DDBLT_ROP 0x00020000l + +/* + * Use the dwRotationAngle field in the DDBLTFX structure as the angle + * (specified in 1/100th of a degree) to rotate the surface. + */ +#define DDBLT_ROTATIONANGLE 0x00040000l + +/* + * Z-buffered blt using the z-buffers attached to the source and destination + * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the + * z-buffer opcode. + */ +#define DDBLT_ZBUFFER 0x00080000l + +/* + * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the destination. + */ +#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000l + +/* + * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the destination. + */ +#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000l + +/* + * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the source. + */ +#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000l + +/* + * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the source. + */ +#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000l + +/* + * wait until the device is ready to handle the blt + * this will cause blt to not return DDERR_WASSTILLDRAWING + */ +#define DDBLT_WAIT 0x01000000l + +/* + * Uses the dwFillDepth field in the DDBLTFX structure as the depth value + * to fill the destination rectangle on the destination Z-buffer surface + * with. + */ +#define DDBLT_DEPTHFILL 0x02000000l + + +/* + * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not + * ready to schedule the blt at the time Blt() is called. + */ +#define DDBLT_DONOTWAIT 0x08000000l + +/* + * These flags indicate a presentation blt (i.e. a blt + * that moves surface contents from an offscreen back buffer to the primary + * surface). The driver is not allowed to "queue" more than three such blts. + * The "end" of the presentation blt is indicated, since the + * blt may be clipped, in which case the runtime will call the driver with + * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION + * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. + * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION + * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. + * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING + * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the + * pixels have been actually written to the primary surface). Once the oldest blt + * has been retired, the driver is free to schedule the current blt. + * The goal is to provide a mechanism whereby the device's hardware queue never + * gets more than 3 frames ahead of the frames being generated by the application. + * When excessive queueing occurs, applications become unusable because the application + * visibly lags user input, and such problems make windowed interactive applications impossible. + * Some drivers may not have sufficient knowledge of their hardware's FIFO to know + * when a certain blt has been retired. Such drivers should code cautiously, and + * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause + * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely + * finished- exactly as if the application had called Lock on the source surface + * before calling Blt. + * In other words, the driver is allowed and encouraged to + * generate as much latency as it can, but never more than 3 frames worth. + * Implementation detail: Drivers should count blts against the SOURCE surface, not + * against the primary surface. This enables multiple parallel windowed application + * to function more optimally. + * This flag is passed only to DX8 or higher drivers. + * + * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. + * + */ +#define DDBLT_PRESENTATION 0x10000000l +#define DDBLT_LAST_PRESENTATION 0x20000000l + +/* + * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret + * other flags according to the definitions that follow. + * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless + * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means + * DDBLT_EXTENDED_LINEAR_CONTENT. + * Only DirectX9 and higher drivers will be given extended blt flags. + * Only flags explicitly mentioned here should be re-interpreted. + * All other flags retain their original meanings. + * + * List of re-interpreted flags: + * + * Bit Hex value New meaning old meaning + * --------------------------------------------------------------- + * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG + * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND + * + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. + */ +#define DDBLT_EXTENDED_FLAGS 0x40000000l + +/* + * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. + * This flag indidcates that the source surface contains content in a + * linear color space. The driver may perform gamma correction to the + * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. + * If the device can perform such a conversion as part of the copy, + * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present + * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. + */ +#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l + + +/**************************************************************************** + * + * BLTFAST FLAGS + * + ****************************************************************************/ + +#define DDBLTFAST_NOCOLORKEY 0x00000000 +#define DDBLTFAST_SRCCOLORKEY 0x00000001 +#define DDBLTFAST_DESTCOLORKEY 0x00000002 +#define DDBLTFAST_WAIT 0x00000010 +#define DDBLTFAST_DONOTWAIT 0x00000020 + +/**************************************************************************** + * + * FLIP FLAGS + * + ****************************************************************************/ + +#define DDFLIP_WAIT 0x00000001L + +/* + * Indicates that the target surface contains the even field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_EVEN 0x00000002L + +/* + * Indicates that the target surface contains the odd field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_ODD 0x00000004L + +/* + * Causes DirectDraw to perform the physical flip immediately and return + * to the application. Typically, what was the front buffer but is now the back + * buffer will still be visible (depending on timing) until the next vertical + * retrace. Subsequent operations involving the two flipped surfaces will + * not check to see if the physical flip has finished (i.e. will not return + * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). + * This allows an application to perform Flips at a higher frequency than the + * monitor refresh rate, but may introduce visible artifacts. + * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, + * DDFLIP_NOVSYNC has no effect. + */ +#define DDFLIP_NOVSYNC 0x00000008L + + +/* + * Flip Interval Flags. These flags indicate how many vertical retraces to wait between + * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each + * surface involved in the flip until the specified number of vertical retraces has + * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, + * DDFLIP_INTERVALn has no effect. + */ + +/* + * DirectDraw will flip on every other vertical sync + */ +#define DDFLIP_INTERVAL2 0x02000000L + + +/* + * DirectDraw will flip on every third vertical sync + */ +#define DDFLIP_INTERVAL3 0x03000000L + + +/* + * DirectDraw will flip on every fourth vertical sync + */ +#define DDFLIP_INTERVAL4 0x04000000L + +/* + * DirectDraw will flip and display a main stereo surface + */ +#define DDFLIP_STEREO 0x00000010L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. + */ +#define DDFLIP_DONOTWAIT 0x00000020L + + +/**************************************************************************** + * + * DIRECTDRAW SURFACE OVERLAY FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for the + * destination overlay. + */ +#define DDOVER_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the + * destination alpha channel for this overlay. + */ +#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. + */ +#define DDOVER_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha + * channel destination for this overlay. + */ +#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha + * channel for the edges of the image that border the color key colors. + */ +#define DDOVER_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the source alpha channel for this overlay. + */ +#define DDOVER_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source + * alpha channel for this overlay. + */ +#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. + */ +#define DDOVER_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel + * source for this overlay. + */ +#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Turn this overlay off. + */ +#define DDOVER_HIDE 0x00000200l + +/* + * Use the color key associated with the destination surface. + */ +#define DDOVER_KEYDEST 0x00000400l + +/* + * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key + * for the destination surface + */ +#define DDOVER_KEYDESTOVERRIDE 0x00000800l + +/* + * Use the color key associated with the source surface. + */ +#define DDOVER_KEYSRC 0x00001000l + +/* + * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key + * for the source surface. + */ +#define DDOVER_KEYSRCOVERRIDE 0x00002000l + +/* + * Turn this overlay on. + */ +#define DDOVER_SHOW 0x00004000l + +/* + * Add a dirty rect to an emulated overlayed surface. + */ +#define DDOVER_ADDDIRTYRECT 0x00008000l + +/* + * Redraw all dirty rects on an emulated overlayed surface. + */ +#define DDOVER_REFRESHDIRTYRECTS 0x00010000l + +/* + * Redraw the entire surface on an emulated overlayed surface. + */ +#define DDOVER_REFRESHALL 0x00020000l + + +/* + * Use the overlay FX flags to define special overlay FX + */ +#define DDOVER_DDFX 0x00080000l + +/* + * Autoflip the overlay when ever the video port autoflips + */ +#define DDOVER_AUTOFLIP 0x00100000l + +/* + * Display each field of video port data individually without + * causing any jittery artifacts + */ +#define DDOVER_BOB 0x00200000l + +/* + * Indicates that bob/weave decisions should not be overridden by other + * interfaces. + */ +#define DDOVER_OVERRIDEBOBWEAVE 0x00400000l + +/* + * Indicates that the surface memory is composed of interleaved fields. + */ +#define DDOVER_INTERLEAVED 0x00800000l + +/* + * Indicates that bob will be performed using hardware rather than + * software or emulated. + */ +#define DDOVER_BOBHARDWARE 0x01000000l + +/* + * Indicates that overlay FX structure contains valid ARGB scaling factors. + */ +#define DDOVER_ARGBSCALEFACTORS 0x02000000l + +/* + * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. + */ +#define DDOVER_DEGRADEARGBSCALING 0x04000000l + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE LOCK FLAGS + * + ****************************************************************************/ + +/* + * The default. Set to indicate that Lock should return a valid memory pointer + * to the top of the specified rectangle. If no rectangle is specified then a + * pointer to the top of the surface is returned. + */ +#define DDLOCK_SURFACEMEMORYPTR 0x00000000L // default + +/* + * Set to indicate that Lock should wait until it can obtain a valid memory + * pointer before returning. If this bit is set, Lock will never return + * DDERR_WASSTILLDRAWING. + */ +#define DDLOCK_WAIT 0x00000001L + +/* + * Set if an event handle is being passed to Lock. Lock will trigger the event + * when it can return the surface memory pointer requested. + */ +#define DDLOCK_EVENT 0x00000002L + +/* + * Indicates that the surface being locked will only be read from. + */ +#define DDLOCK_READONLY 0x00000010L + +/* + * Indicates that the surface being locked will only be written to + */ +#define DDLOCK_WRITEONLY 0x00000020L + + +/* + * Indicates that a system wide lock should not be taken when this surface + * is locked. This has several advantages (cursor responsiveness, ability + * to call more Windows functions, easier debugging) when locking video + * memory surfaces. However, an application specifying this flag must + * comply with a number of conditions documented in the help file. + * Furthermore, this flag cannot be specified when locking the primary. + */ +#define DDLOCK_NOSYSLOCK 0x00000800L + +/* + * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices + * that were referred to in Draw*PrimtiveVB calls since the start of the + * frame (or the last lock without this flag) will be modified during the + * lock. This can be useful when one is only appending data to the vertex + * buffer + */ +#define DDLOCK_NOOVERWRITE 0x00001000L + +/* + * Indicates that no assumptions will be made about the contents of the + * surface or vertex buffer during this lock. + * This enables two things: + * - Direct3D or the driver may provide an alternative memory + * area as the vertex buffer. This is useful when one plans to clear the + * contents of the vertex buffer and fill in new data. + * - Drivers sometimes store surface data in a re-ordered format. + * When the application locks the surface, the driver is forced to un-re-order + * the surface data before allowing the application to see the surface contents. + * This flag is a hint to the driver that it can skip the un-re-ordering process + * since the application plans to overwrite every single pixel in the surface + * or locked rectangle (and so erase any un-re-ordered pixels anyway). + * Applications should always set this flag when they intend to overwrite the entire + * surface or locked rectangle. + */ +#define DDLOCK_DISCARDCONTENTS 0x00002000L + /* + * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS + */ +#define DDLOCK_OKTOSWAP 0x00002000L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. + */ +#define DDLOCK_DONOTWAIT 0x00004000L + +/* + * This indicates volume texture lock with front and back specified. + */ +#define DDLOCK_HASVOLUMETEXTUREBOXRECT 0x00008000L + +/* + * This indicates that the driver should not update dirty rect information for this lock. + */ +#define DDLOCK_NODIRTYUPDATE 0x00010000L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGELOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE BLT FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this blt. + */ +#define DDBLTFX_ARITHSTRETCHY 0x00000001l + +/* + * Do this blt mirroring the surface left to right. Spin the + * surface around its y-axis. + */ +#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Do this blt mirroring the surface up and down. Spin the surface + * around its x-axis. + */ +#define DDBLTFX_MIRRORUPDOWN 0x00000004l + +/* + * Schedule this blt to avoid tearing. + */ +#define DDBLTFX_NOTEARING 0x00000008l + +/* + * Do this blt rotating the surface one hundred and eighty degrees. + */ +#define DDBLTFX_ROTATE180 0x00000010l + +/* + * Do this blt rotating the surface two hundred and seventy degrees. + */ +#define DDBLTFX_ROTATE270 0x00000020l + +/* + * Do this blt rotating the surface ninety degrees. + */ +#define DDBLTFX_ROTATE90 0x00000040l + +/* + * Do this z blt using dwZBufferLow and dwZBufferHigh as range values + * specified to limit the bits copied from the source surface. + */ +#define DDBLTFX_ZBUFFERRANGE 0x00000080l + +/* + * Do this z blt adding the dwZBufferBaseDest to each of the sources z values + * before comparing it with the desting z values. + */ +#define DDBLTFX_ZBUFFERBASEDEST 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE OVERLAY FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this overlay. + */ +#define DDOVERFX_ARITHSTRETCHY 0x00000001l + +/* + * Mirror the overlay across the vertical axis + */ +#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Mirror the overlay across the horizontal axis + */ +#define DDOVERFX_MIRRORUPDOWN 0x00000004l + +/* + * Deinterlace the overlay, if possible + */ +#define DDOVERFX_DEINTERLACE 0x00000008l + + +/**************************************************************************** + * + * DIRECTDRAW WAITFORVERTICALBLANK FLAGS + * + ****************************************************************************/ + +/* + * return when the vertical blank interval begins + */ +#define DDWAITVB_BLOCKBEGIN 0x00000001l + +/* + * set up an event to trigger when the vertical blank begins + */ +#define DDWAITVB_BLOCKBEGINEVENT 0x00000002l + +/* + * return when the vertical blank interval ends and display begins + */ +#define DDWAITVB_BLOCKEND 0x00000004l + +/**************************************************************************** + * + * DIRECTDRAW GETFLIPSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to flip now? + */ +#define DDGFS_CANFLIP 0x00000001l + +/* + * is the last flip finished? + */ +#define DDGFS_ISFLIPDONE 0x00000002l + +/**************************************************************************** + * + * DIRECTDRAW GETBLTSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to blt now? + */ +#define DDGBS_CANBLT 0x00000001l + +/* + * is the blt to the surface finished? + */ +#define DDGBS_ISBLTDONE 0x00000002l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Enumerate overlays back to front. + */ +#define DDENUMOVERLAYZ_BACKTOFRONT 0x00000000l + +/* + * Enumerate overlays front to back + */ +#define DDENUMOVERLAYZ_FRONTTOBACK 0x00000001l + +/**************************************************************************** + * + * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Send overlay to front + */ +#define DDOVERZ_SENDTOFRONT 0x00000000l + +/* + * Send overlay to back + */ +#define DDOVERZ_SENDTOBACK 0x00000001l + +/* + * Move Overlay forward + */ +#define DDOVERZ_MOVEFORWARD 0x00000002l + +/* + * Move Overlay backward + */ +#define DDOVERZ_MOVEBACKWARD 0x00000003l + +/* + * Move Overlay in front of relative surface + */ +#define DDOVERZ_INSERTINFRONTOF 0x00000004l + +/* + * Move Overlay in back of relative surface + */ +#define DDOVERZ_INSERTINBACKOF 0x00000005l + + +/**************************************************************************** + * + * DIRECTDRAW SETGAMMARAMP FLAGS + * + ****************************************************************************/ + +/* + * Request calibrator to adjust the gamma ramp according to the physical + * properties of the display so that the result should appear identical + * on all systems. + */ +#define DDSGR_CALIBRATE 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW STARTMODETEST FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDSMT_ISTESTREQUIRED 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW EVALUATEMODE FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDEM_MODEPASSED 0x00000001L + +/* + * Indicates that the mode being tested has failed + */ +#define DDEM_MODEFAILED 0x00000002L + + +/*=========================================================================== + * + * + * DIRECTDRAW RETURN CODES + * + * The return values from DirectDraw Commands and Surface that return an HRESULT + * are codes from DirectDraw concerning the results of the action + * requested by DirectDraw. + * + *==========================================================================*/ + +/* + * Status is OK + * + * Issued by: DirectDraw Commands and all callbacks + */ +#define DD_OK S_OK +#define DD_FALSE S_FALSE + +/**************************************************************************** + * + * DIRECTDRAW ENUMCALLBACK RETURN VALUES + * + * EnumCallback returns are used to control the flow of the DIRECTDRAW and + * DIRECTDRAWSURFACE object enumerations. They can only be returned by + * enumeration callback routines. + * + ****************************************************************************/ + +/* + * stop the enumeration + */ +#define DDENUMRET_CANCEL 0 + +/* + * continue the enumeration + */ +#define DDENUMRET_OK 1 + +/**************************************************************************** + * + * DIRECTDRAW ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +/* + * This object is already initialized + */ +#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) + +/* + * This surface can not be attached to the requested surface. + */ +#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) + +/* + * This surface can not be detached from the requested surface. + */ +#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) + +/* + * Support is currently not available. + */ +#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) + +/* + * An exception was encountered while performing the requested operation + */ +#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) + +/* + * Generic failure. + */ +#define DDERR_GENERIC E_FAIL + +/* + * Height of rectangle provided is not a multiple of reqd alignment + */ +#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) + +/* + * Unable to match primary surface creation request with existing + * primary surface. + */ +#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) + +/* + * One or more of the caps bits passed to the callback are incorrect. + */ +#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) + +/* + * DirectDraw does not support provided Cliplist. + */ +#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) + +/* + * DirectDraw does not support the requested mode + */ +#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) + +/* + * DirectDraw received a pointer that was an invalid DIRECTDRAW object. + */ +#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) + +/* + * One or more of the parameters passed to the callback function are + * incorrect. + */ +#define DDERR_INVALIDPARAMS E_INVALIDARG + +/* + * pixel format was invalid as specified + */ +#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) + +/* + * Rectangle provided was invalid. + */ +#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) + +/* + * Operation could not be carried out because one or more surfaces are locked + */ +#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) + +/* + * There is no 3D present. + */ +#define DDERR_NO3D MAKE_DDHRESULT( 170 ) + +/* + * Operation could not be carried out because there is no alpha accleration + * hardware present or available. + */ +#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) + +/* + * Operation could not be carried out because there is no stereo + * hardware present or available. + */ +#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) + +/* + * Operation could not be carried out because there is no hardware + * present which supports stereo surfaces + */ +#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) + + + +/* + * no clip list available + */ +#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) + +/* + * Operation could not be carried out because there is no color conversion + * hardware present or available. + */ +#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) + +/* + * Create function called without DirectDraw object method SetCooperativeLevel + * being called. + */ +#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) + +/* + * Surface doesn't currently have a color key + */ +#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) + +/* + * Operation could not be carried out because there is no hardware support + * of the dest color key. + */ +#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) + +/* + * No DirectDraw support possible with current display driver + */ +#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) + +/* + * Operation requires the application to have exclusive mode but the + * application does not have exclusive mode. + */ +#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) + +/* + * Flipping visible surfaces is not supported. + */ +#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) + +/* + * There is no GDI present. + */ +#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) + +/* + * Operation could not be carried out because there is no hardware present + * or available. + */ +#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) + +/* + * Requested item was not found + */ +#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) + +/* + * Operation could not be carried out because there is no overlay hardware + * present or available. + */ +#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) + +/* + * Operation could not be carried out because the source and destination + * rectangles are on the same surface and overlap each other. + */ +#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) + +/* + * Operation could not be carried out because there is no appropriate raster + * op hardware present or available. + */ +#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) + +/* + * Operation could not be carried out because there is no rotation hardware + * present or available. + */ +#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) + +/* + * Operation could not be carried out because there is no hardware support + * for stretching + */ +#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) + +/* + * DirectDrawSurface is not in 4 bit color palette and the requested operation + * requires 4 bit color palette. + */ +#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) + +/* + * DirectDrawSurface is not in 4 bit color index palette and the requested + * operation requires 4 bit color index palette. + */ +#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) + +/* + * DirectDraw Surface is not in 8 bit color mode and the requested operation + * requires 8 bit color. + */ +#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) + +/* + * Operation could not be carried out because there is no texture mapping + * hardware present or available. + */ +#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) + +/* + * Operation could not be carried out because there is no hardware support + * for vertical blank synchronized operations. + */ +#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) + +/* + * Operation could not be carried out because there is no hardware support + * for zbuffer blting. + */ +#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) + +/* + * Overlay surfaces could not be z layered based on their BltOrder because + * the hardware does not support z layering of overlays. + */ +#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) + +/* + * The hardware needed for the requested operation has already been + * allocated. + */ +#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) + +/* + * hardware does not support clipped overlays + */ +#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) + +/* + * Can only have ony color key active at one time for overlays + */ +#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) + +/* + * Access to this palette is being refused because the palette is already + * locked by another thread. + */ +#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) + +/* + * No src color key specified for this operation. + */ +#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) + +/* + * This surface is already attached to the surface it is being attached to. + */ +#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) + +/* + * This surface is already a dependency of the surface it is being made a + * dependency of. + */ +#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) + +/* + * Access to this surface is being refused because the surface is already + * locked by another thread. + */ +#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) + +/* + * Access to this surface is being refused because no driver exists + * which can supply a pointer to the surface. + * This is most likely to happen when attempting to lock the primary + * surface when no DCI provider is present. + * Will also happen on attempts to lock an optimized surface. + */ +#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) + +/* + * Access to Surface refused because Surface is obscured. + */ +#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) + +/* + * Access to this surface is being refused because the surface is gone. + * The DIRECTDRAWSURFACE object representing this surface should + * have Restore called on it. + */ +#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) + +/* + * The requested surface is not attached. + */ +#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) + +/* + * Height requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) + +/* + * Size requested by DirectDraw is too large -- The individual height and + * width are OK. + */ +#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) + +/* + * Width requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) + +/* + * Action not supported. + */ +#define DDERR_UNSUPPORTED E_NOTIMPL + +/* + * Pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) + +/* + * Bitmask in the pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) + +/* + * The specified stream contains invalid data + */ +#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) + +/* + * vertical blank is in progress + */ +#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) + +/* + * Informs DirectDraw that the previous Blt which is transfering information + * to or from this Surface is incomplete. + */ +#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) + + +/* + * The specified surface type requires specification of the COMPLEX flag + */ +#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) + + +/* + * Rectangle provided was not horizontally aligned on reqd. boundary + */ +#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) + +/* + * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver + * identifier. + */ +#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) + +/* + * A DirectDraw object representing this driver has already been created + * for this process. + */ +#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) + +/* + * A hardware only DirectDraw object creation was attempted but the driver + * did not support any hardware. + */ +#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) + +/* + * this process already has created a primary surface + */ +#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) + +/* + * software emulation not available. + */ +#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) + +/* + * region passed to Clipper::GetClipList is too small. + */ +#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) + +/* + * an attempt was made to set a clip list for a clipper objec that + * is already monitoring an hwnd. + */ +#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) + +/* + * No clipper object attached to surface object + */ +#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) + +/* + * Clipper notification requires an HWND or + * no HWND has previously been set as the CooperativeLevel HWND. + */ +#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) + +/* + * HWND used by DirectDraw CooperativeLevel has been subclassed, + * this prevents DirectDraw from restoring state. + */ +#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) + +/* + * The CooperativeLevel HWND has already been set. + * It can not be reset while the process has surfaces or palettes created. + */ +#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) + +/* + * No palette object attached to this surface. + */ +#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) + +/* + * No hardware support for 16 or 256 color palettes. + */ +#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) + +/* + * If a clipper object is attached to the source surface passed into a + * BltFast call. + */ +#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) + +/* + * No blter. + */ +#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) + +/* + * No DirectDraw ROP hardware. + */ +#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) + +/* + * returned when GetOverlayPosition is called on a hidden overlay + */ +#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) + +/* + * returned when GetOverlayPosition is called on a overlay that UpdateOverlay + * has never been called on to establish a destionation. + */ +#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) + +/* + * returned when the position of the overlay on the destionation is no longer + * legal for that destionation. + */ +#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) + +/* + * returned when an overlay member is called for a non-overlay surface + */ +#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) + +/* + * An attempt was made to set the cooperative level when it was already + * set to exclusive. + */ +#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) + +/* + * An attempt has been made to flip a surface that is not flippable. + */ +#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) + +/* + * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly + * created. + */ +#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) + +/* + * Surface was not locked. An attempt to unlock a surface that was not + * locked at all, or by this process, has been attempted. + */ +#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) + +/* + * Windows can not create any more DCs, or a DC was requested for a paltte-indexed + * surface when the surface had no palette AND the display mode was not palette-indexed + * (in this case DirectDraw cannot select a proper palette into the DC) + */ +#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) + +/* + * No DC was ever created for this surface. + */ +#define DDERR_NODC MAKE_DDHRESULT( 586 ) + +/* + * This surface can not be restored because it was created in a different + * mode. + */ +#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) + +/* + * This surface can not be restored because it is an implicitly created + * surface. + */ +#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) + +/* + * The surface being used is not a palette-based surface + */ +#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) + + +/* + * The display is currently in an unsupported mode + */ +#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) + +/* + * Operation could not be carried out because there is no mip-map + * texture mapping hardware present or available. + */ +#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) + +/* + * The requested action could not be performed because the surface was of + * the wrong type. + */ +#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) + + +/* + * Device does not support optimized surfaces, therefore no video memory optimized surfaces + */ +#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) + +/* + * Surface is an optimized surface, but has not yet been allocated any memory + */ +#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) + +/* + * Attempt was made to create or set a device window without first setting + * the focus window + */ +#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) + +/* + * Attempt was made to set a palette on a mipmap sublevel + */ +#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) + +/* + * A DC has already been returned for this surface. Only one DC can be + * retrieved per surface. + */ +#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) + +/* + * An attempt was made to allocate non-local video memory from a device + * that does not support non-local video memory. + */ +#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) + +/* + * The attempt to page lock a surface failed. + */ +#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) + + +/* + * The attempt to page unlock a surface failed. + */ +#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) + +/* + * An attempt was made to page unlock a surface with no outstanding page locks. + */ +#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) + +/* + * There is more data available than the specified buffer size could hold + */ +#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) + +/* + * The data has expired and is therefore no longer valid. + */ +#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) + +/* + * The mode test has finished executing. + */ +#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) + +/* + * The mode test has switched to a new mode. + */ +#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) + +/* + * D3D has not yet been initialized. + */ +#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) + +/* + * The video port is not active + */ +#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) + +/* + * The monitor does not have EDID data. + */ +#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) + +/* + * The driver does not enumerate display mode refresh rates. + */ +#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) + +/* + * Surfaces created by one direct draw device cannot be used directly by + * another direct draw device. + */ +#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) + + + +/* + * An attempt was made to invoke an interface member of a DirectDraw object + * created by CoCreateInstance() before it was initialized. + */ +#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED + + +/* Alpha bit depth constants */ + + +#ifdef __cplusplus +}; +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(default:4201) +#endif + +#endif //__DDRAW_INCLUDED__ + + diff --git a/win32/directx/ddraw.lib b/win32/directx/ddraw.lib new file mode 100644 index 0000000..d7d0583 Binary files /dev/null and b/win32/directx/ddraw.lib differ diff --git a/win32/directx/dinput.h b/win32/directx/dinput.h new file mode 100644 index 0000000..bf74e16 --- /dev/null +++ b/win32/directx/dinput.h @@ -0,0 +1,4417 @@ +/**************************************************************************** + * + * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved. + * + * File: dinput.h + * Content: DirectInput include file + * + ****************************************************************************/ + +#ifndef __DINPUT_INCLUDED__ +#define __DINPUT_INCLUDED__ + +#ifndef DIJ_RINGZERO + +#ifdef _WIN32 +#define COM_NO_WINDOWS_H +#include +#endif + +#endif /* DIJ_RINGZERO */ + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/* + * To build applications for older versions of DirectInput + * + * #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ] + * + * before #include . By default, #include + * will produce a DirectX 8-compatible header file. + * + */ + +#define DIRECTINPUT_HEADER_VERSION 0x0800 +#ifndef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION +#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") +#endif + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * Class IDs + * + ****************************************************************************/ + +DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Interfaces + * + ****************************************************************************/ + +DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +/**************************************************************************** + * + * Predefined object types + * + ****************************************************************************/ + +DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined product GUIDs + * + ****************************************************************************/ + +DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined force feedback effects + * + ****************************************************************************/ + +DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Interfaces and Structures... + * + ****************************************************************************/ + +#if(DIRECTINPUT_VERSION >= 0x0500) + +/**************************************************************************** + * + * IDirectInputEffect + * + ****************************************************************************/ + +#define DIEFT_ALL 0x00000000 + +#define DIEFT_CONSTANTFORCE 0x00000001 +#define DIEFT_RAMPFORCE 0x00000002 +#define DIEFT_PERIODIC 0x00000003 +#define DIEFT_CONDITION 0x00000004 +#define DIEFT_CUSTOMFORCE 0x00000005 +#define DIEFT_HARDWARE 0x000000FF +#define DIEFT_FFATTACK 0x00000200 +#define DIEFT_FFFADE 0x00000400 +#define DIEFT_SATURATION 0x00000800 +#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 +#define DIEFT_POSNEGSATURATION 0x00002000 +#define DIEFT_DEADBAND 0x00004000 +#define DIEFT_STARTDELAY 0x00008000 +#define DIEFT_GETTYPE(n) LOBYTE(n) + +#define DI_DEGREES 100 +#define DI_FFNOMINALMAX 10000 +#define DI_SECONDS 1000000 + +typedef struct DICONSTANTFORCE { + LONG lMagnitude; +} DICONSTANTFORCE, *LPDICONSTANTFORCE; +typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; + +typedef struct DIRAMPFORCE { + LONG lStart; + LONG lEnd; +} DIRAMPFORCE, *LPDIRAMPFORCE; +typedef const DIRAMPFORCE *LPCDIRAMPFORCE; + +typedef struct DIPERIODIC { + DWORD dwMagnitude; + LONG lOffset; + DWORD dwPhase; + DWORD dwPeriod; +} DIPERIODIC, *LPDIPERIODIC; +typedef const DIPERIODIC *LPCDIPERIODIC; + +typedef struct DICONDITION { + LONG lOffset; + LONG lPositiveCoefficient; + LONG lNegativeCoefficient; + DWORD dwPositiveSaturation; + DWORD dwNegativeSaturation; + LONG lDeadBand; +} DICONDITION, *LPDICONDITION; +typedef const DICONDITION *LPCDICONDITION; + +typedef struct DICUSTOMFORCE { + DWORD cChannels; + DWORD dwSamplePeriod; + DWORD cSamples; + LPLONG rglForceData; +} DICUSTOMFORCE, *LPDICUSTOMFORCE; +typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; + + +typedef struct DIENVELOPE { + DWORD dwSize; /* sizeof(DIENVELOPE) */ + DWORD dwAttackLevel; + DWORD dwAttackTime; /* Microseconds */ + DWORD dwFadeLevel; + DWORD dwFadeTime; /* Microseconds */ +} DIENVELOPE, *LPDIENVELOPE; +typedef const DIENVELOPE *LPCDIENVELOPE; + + +/* This structure is defined for DirectX 5.0 compatibility */ +typedef struct DIEFFECT_DX5 { + DWORD dwSize; /* sizeof(DIEFFECT_DX5) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +} DIEFFECT_DX5, *LPDIEFFECT_DX5; +typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; + +typedef struct DIEFFECT { + DWORD dwSize; /* sizeof(DIEFFECT) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +#if(DIRECTINPUT_VERSION >= 0x0600) + DWORD dwStartDelay; /* Microseconds */ +#endif /* DIRECTINPUT_VERSION >= 0x0600 */ +} DIEFFECT, *LPDIEFFECT; +typedef DIEFFECT DIEFFECT_DX6; +typedef LPDIEFFECT LPDIEFFECT_DX6; +typedef const DIEFFECT *LPCDIEFFECT; + + +#if(DIRECTINPUT_VERSION >= 0x0700) +#ifndef DIJ_RINGZERO +typedef struct DIFILEEFFECT{ + DWORD dwSize; + GUID GuidEffect; + LPCDIEFFECT lpDiEffect; + CHAR szFriendlyName[MAX_PATH]; +}DIFILEEFFECT, *LPDIFILEEFFECT; +typedef const DIFILEEFFECT *LPCDIFILEEFFECT; +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); +#endif /* DIJ_RINGZERO */ +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#define DIEFF_OBJECTIDS 0x00000001 +#define DIEFF_OBJECTOFFSETS 0x00000002 +#define DIEFF_CARTESIAN 0x00000010 +#define DIEFF_POLAR 0x00000020 +#define DIEFF_SPHERICAL 0x00000040 + +#define DIEP_DURATION 0x00000001 +#define DIEP_SAMPLEPERIOD 0x00000002 +#define DIEP_GAIN 0x00000004 +#define DIEP_TRIGGERBUTTON 0x00000008 +#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 +#define DIEP_AXES 0x00000020 +#define DIEP_DIRECTION 0x00000040 +#define DIEP_ENVELOPE 0x00000080 +#define DIEP_TYPESPECIFICPARAMS 0x00000100 +#if(DIRECTINPUT_VERSION >= 0x0600) +#define DIEP_STARTDELAY 0x00000200 +#define DIEP_ALLPARAMS_DX5 0x000001FF +#define DIEP_ALLPARAMS 0x000003FF +#else /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_ALLPARAMS 0x000001FF +#endif /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_START 0x20000000 +#define DIEP_NORESTART 0x40000000 +#define DIEP_NODOWNLOAD 0x80000000 +#define DIEB_NOTRIGGER 0xFFFFFFFF + +#define DIES_SOLO 0x00000001 +#define DIES_NODOWNLOAD 0x80000000 + +#define DIEGES_PLAYING 0x00000001 +#define DIEGES_EMULATED 0x00000002 + +typedef struct DIEFFESCAPE { + DWORD dwSize; + DWORD dwCommand; + LPVOID lpvInBuffer; + DWORD cbInBuffer; + LPVOID lpvOutBuffer; + DWORD cbOutBuffer; +} DIEFFESCAPE, *LPDIEFFESCAPE; + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputEffect + +DECLARE_INTERFACE_(IDirectInputEffect, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputEffect methods ***/ + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; + STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE; + STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE; + STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(Stop)(THIS) PURE; + STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; + STDMETHOD(Download)(THIS) PURE; + STDMETHOD(Unload)(THIS) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; +}; + +typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) +#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) +#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) +#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) +#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#else +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputEffect_AddRef(p) (p)->AddRef() +#define IDirectInputEffect_Release(p) (p)->Release() +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) +#define IDirectInputEffect_Stop(p) (p)->Stop() +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) +#define IDirectInputEffect_Download(p) (p)->Download() +#define IDirectInputEffect_Unload(p) (p)->Unload() +#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +/**************************************************************************** + * + * IDirectInputDevice + * + ****************************************************************************/ + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPE_DEVICE 1 +#define DIDEVTYPE_MOUSE 2 +#define DIDEVTYPE_KEYBOARD 3 +#define DIDEVTYPE_JOYSTICK 4 + +#else +#define DI8DEVCLASS_ALL 0 +#define DI8DEVCLASS_DEVICE 1 +#define DI8DEVCLASS_POINTER 2 +#define DI8DEVCLASS_KEYBOARD 3 +#define DI8DEVCLASS_GAMECTRL 4 + +#define DI8DEVTYPE_DEVICE 0x11 +#define DI8DEVTYPE_MOUSE 0x12 +#define DI8DEVTYPE_KEYBOARD 0x13 +#define DI8DEVTYPE_JOYSTICK 0x14 +#define DI8DEVTYPE_GAMEPAD 0x15 +#define DI8DEVTYPE_DRIVING 0x16 +#define DI8DEVTYPE_FLIGHT 0x17 +#define DI8DEVTYPE_1STPERSON 0x18 +#define DI8DEVTYPE_DEVICECTRL 0x19 +#define DI8DEVTYPE_SCREENPOINTER 0x1A +#define DI8DEVTYPE_REMOTE 0x1B +#define DI8DEVTYPE_SUPPLEMENTAL 0x1C +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define DIDEVTYPE_HID 0x00010000 + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPEMOUSE_UNKNOWN 1 +#define DIDEVTYPEMOUSE_TRADITIONAL 2 +#define DIDEVTYPEMOUSE_FINGERSTICK 3 +#define DIDEVTYPEMOUSE_TOUCHPAD 4 +#define DIDEVTYPEMOUSE_TRACKBALL 5 + +#define DIDEVTYPEKEYBOARD_UNKNOWN 0 +#define DIDEVTYPEKEYBOARD_PCXT 1 +#define DIDEVTYPEKEYBOARD_OLIVETTI 2 +#define DIDEVTYPEKEYBOARD_PCAT 3 +#define DIDEVTYPEKEYBOARD_PCENH 4 +#define DIDEVTYPEKEYBOARD_NOKIA1050 5 +#define DIDEVTYPEKEYBOARD_NOKIA9140 6 +#define DIDEVTYPEKEYBOARD_NEC98 7 +#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DIDEVTYPEKEYBOARD_NEC98106 9 +#define DIDEVTYPEKEYBOARD_JAPAN106 10 +#define DIDEVTYPEKEYBOARD_JAPANAX 11 +#define DIDEVTYPEKEYBOARD_J3100 12 + +#define DIDEVTYPEJOYSTICK_UNKNOWN 1 +#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 +#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 +#define DIDEVTYPEJOYSTICK_GAMEPAD 4 +#define DIDEVTYPEJOYSTICK_RUDDER 5 +#define DIDEVTYPEJOYSTICK_WHEEL 6 +#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 + +#else +#define DI8DEVTYPEMOUSE_UNKNOWN 1 +#define DI8DEVTYPEMOUSE_TRADITIONAL 2 +#define DI8DEVTYPEMOUSE_FINGERSTICK 3 +#define DI8DEVTYPEMOUSE_TOUCHPAD 4 +#define DI8DEVTYPEMOUSE_TRACKBALL 5 +#define DI8DEVTYPEMOUSE_ABSOLUTE 6 + +#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 +#define DI8DEVTYPEKEYBOARD_PCXT 1 +#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 +#define DI8DEVTYPEKEYBOARD_PCAT 3 +#define DI8DEVTYPEKEYBOARD_PCENH 4 +#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 +#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 +#define DI8DEVTYPEKEYBOARD_NEC98 7 +#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DI8DEVTYPEKEYBOARD_NEC98106 9 +#define DI8DEVTYPEKEYBOARD_JAPAN106 10 +#define DI8DEVTYPEKEYBOARD_JAPANAX 11 +#define DI8DEVTYPEKEYBOARD_J3100 12 + +#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 + +#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEJOYSTICK_STANDARD 2 + +#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEGAMEPAD_STANDARD 2 +#define DI8DEVTYPEGAMEPAD_TILT 3 + +#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 +#define DI8DEVTYPEDRIVING_DUALPEDALS 3 +#define DI8DEVTYPEDRIVING_THREEPEDALS 4 +#define DI8DEVTYPEDRIVING_HANDHELD 5 + +#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEFLIGHT_STICK 2 +#define DI8DEVTYPEFLIGHT_YOKE 3 +#define DI8DEVTYPEFLIGHT_RC 4 + +#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPE1STPERSON_UNKNOWN 2 +#define DI8DEVTYPE1STPERSON_SIXDOF 3 +#define DI8DEVTYPE1STPERSON_SHOOTER 4 + +#define DI8DEVTYPESCREENPTR_UNKNOWN 2 +#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 +#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 +#define DI8DEVTYPESCREENPTR_TOUCH 5 + +#define DI8DEVTYPEREMOTE_UNKNOWN 2 + +#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 + +#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 +#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 +#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 +#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 +#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 +#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 +#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 +#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 +#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 +#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) +#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* This structure is defined for DirectX 3.0 compatibility */ +typedef struct DIDEVCAPS_DX3 { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVCAPS { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFSamplePeriod; + DWORD dwFFMinTimeResolution; + DWORD dwFirmwareRevision; + DWORD dwHardwareRevision; + DWORD dwFFDriverVersion; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVCAPS, *LPDIDEVCAPS; + +#define DIDC_ATTACHED 0x00000001 +#define DIDC_POLLEDDEVICE 0x00000002 +#define DIDC_EMULATED 0x00000004 +#define DIDC_POLLEDDATAFORMAT 0x00000008 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDC_FORCEFEEDBACK 0x00000100 +#define DIDC_FFATTACK 0x00000200 +#define DIDC_FFFADE 0x00000400 +#define DIDC_SATURATION 0x00000800 +#define DIDC_POSNEGCOEFFICIENTS 0x00001000 +#define DIDC_POSNEGSATURATION 0x00002000 +#define DIDC_DEADBAND 0x00004000 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#define DIDC_STARTDELAY 0x00008000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDC_ALIAS 0x00010000 +#define DIDC_PHANTOM 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIDC_HIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#define DIDFT_ALL 0x00000000 + +#define DIDFT_RELAXIS 0x00000001 +#define DIDFT_ABSAXIS 0x00000002 +#define DIDFT_AXIS 0x00000003 + +#define DIDFT_PSHBUTTON 0x00000004 +#define DIDFT_TGLBUTTON 0x00000008 +#define DIDFT_BUTTON 0x0000000C + +#define DIDFT_POV 0x00000010 +#define DIDFT_COLLECTION 0x00000040 +#define DIDFT_NODATA 0x00000080 + +#define DIDFT_ANYINSTANCE 0x00FFFF00 +#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE +#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) +#define DIDFT_GETTYPE(n) LOBYTE(n) +#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) +#define DIDFT_FFACTUATOR 0x01000000 +#define DIDFT_FFEFFECTTRIGGER 0x02000000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDFT_OUTPUT 0x10000000 +#define DIDFT_VENDORDEFINED 0x04000000 +#define DIDFT_ALIAS 0x08000000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#ifndef DIDFT_OPTIONAL +#define DIDFT_OPTIONAL 0x80000000 +#endif + +#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) +#define DIDFT_NOCOLLECTION 0x00FFFF00 + +#ifndef DIJ_RINGZERO + +typedef struct _DIOBJECTDATAFORMAT { + const GUID *pguid; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; +} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; +typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; + +typedef struct _DIDATAFORMAT { + DWORD dwSize; + DWORD dwObjSize; + DWORD dwFlags; + DWORD dwDataSize; + DWORD dwNumObjs; + LPDIOBJECTDATAFORMAT rgodf; +} DIDATAFORMAT, *LPDIDATAFORMAT; +typedef const DIDATAFORMAT *LPCDIDATAFORMAT; + +#define DIDF_ABSAXIS 0x00000001 +#define DIDF_RELAXIS 0x00000002 + +#ifdef __cplusplus +extern "C" { +#endif +extern const DIDATAFORMAT c_dfDIMouse; + +#if(DIRECTINPUT_VERSION >= 0x0700) +extern const DIDATAFORMAT c_dfDIMouse2; +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +extern const DIDATAFORMAT c_dfDIKeyboard; + +#if(DIRECTINPUT_VERSION >= 0x0500) +extern const DIDATAFORMAT c_dfDIJoystick; +extern const DIDATAFORMAT c_dfDIJoystick2; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#ifdef __cplusplus +}; +#endif + + +#if DIRECTINPUT_VERSION > 0x0700 + +typedef struct _DIACTIONA { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONA, *LPDIACTIONA ; +typedef struct _DIACTIONW { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCWSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONW, *LPDIACTIONW ; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPDIACTIONW LPDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPDIACTIONA LPDIACTION; +#endif // UNICODE + +typedef const DIACTIONA *LPCDIACTIONA; +typedef const DIACTIONW *LPCDIACTIONW; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPCDIACTIONW LPCDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPCDIACTIONA LPCDIACTION; +#endif // UNICODE +typedef const DIACTION *LPCDIACTION; + + +#define DIA_FORCEFEEDBACK 0x00000001 +#define DIA_APPMAPPED 0x00000002 +#define DIA_APPNOMAP 0x00000004 +#define DIA_NORANGE 0x00000008 +#define DIA_APPFIXED 0x00000010 + +#define DIAH_UNMAPPED 0x00000000 +#define DIAH_USERCONFIG 0x00000001 +#define DIAH_APPREQUESTED 0x00000002 +#define DIAH_HWAPP 0x00000004 +#define DIAH_HWDEFAULT 0x00000008 +#define DIAH_DEFAULT 0x00000020 +#define DIAH_ERROR 0x80000000 + +typedef struct _DIACTIONFORMATA { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONA rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + CHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATA, *LPDIACTIONFORMATA; +typedef struct _DIACTIONFORMATW { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONW rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + WCHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATW, *LPDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPDIACTIONFORMATW LPDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPDIACTIONFORMATA LPDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; +typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT; + +#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF +#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF +#define DIAFTS_UNUSEDDEVICELOW 0x00000000 +#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 + +#define DIDBAM_DEFAULT 0x00000000 +#define DIDBAM_PRESERVE 0x00000001 +#define DIDBAM_INITIALIZE 0x00000002 +#define DIDBAM_HWDEFAULTS 0x00000004 + +#define DIDSAM_DEFAULT 0x00000000 +#define DIDSAM_NOUSER 0x00000001 +#define DIDSAM_FORCESAVE 0x00000002 + +#define DICD_DEFAULT 0x00000000 +#define DICD_EDIT 0x00000001 + +/* + * The following definition is normally defined in d3dtypes.h + */ +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +typedef struct _DICOLORSET{ + DWORD dwSize; + D3DCOLOR cTextFore; + D3DCOLOR cTextHighlight; + D3DCOLOR cCalloutLine; + D3DCOLOR cCalloutHighlight; + D3DCOLOR cBorder; + D3DCOLOR cControlFill; + D3DCOLOR cHighlightFill; + D3DCOLOR cAreaFill; +} DICOLORSET, *LPDICOLORSET; +typedef const DICOLORSET *LPCDICOLORSET; + + +typedef struct _DICONFIGUREDEVICESPARAMSA{ + DWORD dwSize; + DWORD dwcUsers; + LPSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATA lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; +typedef struct _DICONFIGUREDEVICESPARAMSW{ + DWORD dwSize; + DWORD dwcUsers; + LPWSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATW lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; +typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS; + + +#define DIDIFT_CONFIGURATION 0x00000001 +#define DIDIFT_OVERLAY 0x00000002 + +#define DIDAL_CENTERED 0x00000000 +#define DIDAL_LEFTALIGNED 0x00000001 +#define DIDAL_RIGHTALIGNED 0x00000002 +#define DIDAL_MIDDLE 0x00000000 +#define DIDAL_TOPALIGNED 0x00000004 +#define DIDAL_BOTTOMALIGNED 0x00000008 + +typedef struct _DIDEVICEIMAGEINFOA { + CHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; +typedef struct _DIDEVICEIMAGEINFOW { + WCHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; +typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO; + +typedef struct _DIDEVICEIMAGEINFOHEADERA { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOA lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; +typedef struct _DIDEVICEIMAGEINFOHEADERW { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOW lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; +typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER; + +#endif /* DIRECTINPUT_VERSION > 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEOBJECTINSTANCE_DX3A { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; +typedef struct DIDEVICEOBJECTINSTANCE_DX3W { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3; +#else +typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; +typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; +typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEOBJECTINSTANCEA { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; +typedef struct DIDEVICEOBJECTINSTANCEW { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE; +#else +typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; +typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; +typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE; + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW +#else +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA +#endif // !UNICODE + +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDOI_FFACTUATOR 0x00000001 +#define DIDOI_FFEFFECTTRIGGER 0x00000002 +#define DIDOI_POLLED 0x00008000 +#define DIDOI_ASPECTPOSITION 0x00000100 +#define DIDOI_ASPECTVELOCITY 0x00000200 +#define DIDOI_ASPECTACCEL 0x00000300 +#define DIDOI_ASPECTFORCE 0x00000400 +#define DIDOI_ASPECTMASK 0x00000F00 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDOI_GUIDISUSAGE 0x00010000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPHEADER { + DWORD dwSize; + DWORD dwHeaderSize; + DWORD dwObj; + DWORD dwHow; +} DIPROPHEADER, *LPDIPROPHEADER; +typedef const DIPROPHEADER *LPCDIPROPHEADER; + +#define DIPH_DEVICE 0 +#define DIPH_BYOFFSET 1 +#define DIPH_BYID 2 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPH_BYUSAGE 3 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIMAKEUSAGEDWORD(UsagePage, Usage) \ + (DWORD)MAKELONG(Usage, UsagePage) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPDWORD { + DIPROPHEADER diph; + DWORD dwData; +} DIPROPDWORD, *LPDIPROPDWORD; +typedef const DIPROPDWORD *LPCDIPROPDWORD; + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef struct DIPROPPOINTER { + DIPROPHEADER diph; + UINT_PTR uData; +} DIPROPPOINTER, *LPDIPROPPOINTER; +typedef const DIPROPPOINTER *LPCDIPROPPOINTER; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +typedef struct DIPROPRANGE { + DIPROPHEADER diph; + LONG lMin; + LONG lMax; +} DIPROPRANGE, *LPDIPROPRANGE; +typedef const DIPROPRANGE *LPCDIPROPRANGE; + +#define DIPROPRANGE_NOMIN ((LONG)0x80000000) +#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) + +#if(DIRECTINPUT_VERSION >= 0x050a) +typedef struct DIPROPCAL { + DIPROPHEADER diph; + LONG lMin; + LONG lCenter; + LONG lMax; +} DIPROPCAL, *LPDIPROPCAL; +typedef const DIPROPCAL *LPCDIPROPCAL; + +typedef struct DIPROPCALPOV { + DIPROPHEADER diph; + LONG lMin[5]; + LONG lMax[5]; +} DIPROPCALPOV, *LPDIPROPCALPOV; +typedef const DIPROPCALPOV *LPCDIPROPCALPOV; + +typedef struct DIPROPGUIDANDPATH { + DIPROPHEADER diph; + GUID guidClass; + WCHAR wszPath[MAX_PATH]; +} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; +typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; + +typedef struct DIPROPSTRING { + DIPROPHEADER diph; + WCHAR wsz[MAX_PATH]; +} DIPROPSTRING, *LPDIPROPSTRING; +typedef const DIPROPSTRING *LPCDIPROPSTRING; + +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define MAXCPOINTSNUM 8 + +typedef struct _CPOINT +{ + LONG lP; // raw value + DWORD dwLog; // logical_value / max_logical_value * 10000 +} CPOINT, *PCPOINT; + +typedef struct DIPROPCPOINTS { + DIPROPHEADER diph; + DWORD dwCPointsNum; + CPOINT cp[MAXCPOINTSNUM]; +} DIPROPCPOINTS, *LPDIPROPCPOINTS; +typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#ifdef __cplusplus +#define MAKEDIPROP(prop) (*(const GUID *)(prop)) +#else +#define MAKEDIPROP(prop) ((REFGUID)(prop)) +#endif + +#define DIPROP_BUFFERSIZE MAKEDIPROP(1) + +#define DIPROP_AXISMODE MAKEDIPROP(2) + +#define DIPROPAXISMODE_ABS 0 +#define DIPROPAXISMODE_REL 1 + +#define DIPROP_GRANULARITY MAKEDIPROP(3) + +#define DIPROP_RANGE MAKEDIPROP(4) + +#define DIPROP_DEADZONE MAKEDIPROP(5) + +#define DIPROP_SATURATION MAKEDIPROP(6) + +#define DIPROP_FFGAIN MAKEDIPROP(7) + +#define DIPROP_FFLOAD MAKEDIPROP(8) + +#define DIPROP_AUTOCENTER MAKEDIPROP(9) + +#define DIPROPAUTOCENTER_OFF 0 +#define DIPROPAUTOCENTER_ON 1 + +#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) + +#define DIPROPCALIBRATIONMODE_COOKED 0 +#define DIPROPCALIBRATIONMODE_RAW 1 + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPROP_CALIBRATION MAKEDIPROP(11) + +#define DIPROP_GUIDANDPATH MAKEDIPROP(12) + +#define DIPROP_INSTANCENAME MAKEDIPROP(13) + +#define DIPROP_PRODUCTNAME MAKEDIPROP(14) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x05b2) +#define DIPROP_JOYSTICKID MAKEDIPROP(15) + +#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) + +#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) + +#define DIPROP_LOGICALRANGE MAKEDIPROP(19) +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIPROP_KEYNAME MAKEDIPROP(20) + +#define DIPROP_CPOINTS MAKEDIPROP(21) + +#define DIPROP_APPDATA MAKEDIPROP(22) + +#define DIPROP_SCANCODE MAKEDIPROP(23) + +#define DIPROP_VIDPID MAKEDIPROP(24) + +#define DIPROP_USERNAME MAKEDIPROP(25) + +#define DIPROP_TYPENAME MAKEDIPROP(26) +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +typedef struct DIDEVICEOBJECTDATA_DX3 { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3; +typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX; + +typedef struct DIDEVICEOBJECTDATA { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +#if(DIRECTINPUT_VERSION >= 0x0800) + UINT_PTR uAppData; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ +} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; +typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; + +#define DIGDD_PEEK 0x00000001 + +#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \ + ((int)((dwSequence1) - (dwSequence2)) cmp 0) +#define DISCL_EXCLUSIVE 0x00000001 +#define DISCL_NONEXCLUSIVE 0x00000002 +#define DISCL_FOREGROUND 0x00000004 +#define DISCL_BACKGROUND 0x00000008 +#define DISCL_NOWINKEY 0x00000010 + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEINSTANCE_DX3A { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; +typedef struct DIDEVICEINSTANCE_DX3W { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3; +#else +typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; +typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; +typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEINSTANCEA { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; +typedef struct DIDEVICEINSTANCEW { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE; +#endif // UNICODE + +typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; +typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE; +#endif // UNICODE +typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceW + +DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceA + +DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; + +#ifdef UNICODE +#define IID_IDirectInputDevice IID_IDirectInputDeviceW +#define IDirectInputDevice IDirectInputDeviceW +#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl +#else +#define IID_IDirectInputDevice IID_IDirectInputDeviceA +#define IDirectInputDevice IDirectInputDeviceA +#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl +#endif +typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#else +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice_AddRef(p) (p)->AddRef() +#define IDirectInputDevice_Release(p) (p)->Release() +#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice_Acquire(p) (p)->Acquire() +#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#endif + +#endif /* DIJ_RINGZERO */ + + +#if(DIRECTINPUT_VERSION >= 0x0500) + +#define DISFFC_RESET 0x00000001 +#define DISFFC_STOPALL 0x00000002 +#define DISFFC_PAUSE 0x00000004 +#define DISFFC_CONTINUE 0x00000008 +#define DISFFC_SETACTUATORSON 0x00000010 +#define DISFFC_SETACTUATORSOFF 0x00000020 + +#define DIGFFS_EMPTY 0x00000001 +#define DIGFFS_STOPPED 0x00000002 +#define DIGFFS_PAUSED 0x00000004 +#define DIGFFS_ACTUATORSON 0x00000010 +#define DIGFFS_ACTUATORSOFF 0x00000020 +#define DIGFFS_POWERON 0x00000040 +#define DIGFFS_POWEROFF 0x00000080 +#define DIGFFS_SAFETYSWITCHON 0x00000100 +#define DIGFFS_SAFETYSWITCHOFF 0x00000200 +#define DIGFFS_USERFFSWITCHON 0x00000400 +#define DIGFFS_USERFFSWITCHOFF 0x00000800 +#define DIGFFS_DEVICELOST 0x80000000 + +#ifndef DIJ_RINGZERO + +typedef struct DIEFFECTINFOA { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + CHAR tszName[MAX_PATH]; +} DIEFFECTINFOA, *LPDIEFFECTINFOA; +typedef struct DIEFFECTINFOW { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + WCHAR tszName[MAX_PATH]; +} DIEFFECTINFOW, *LPDIEFFECTINFOW; +#ifdef UNICODE +typedef DIEFFECTINFOW DIEFFECTINFO; +typedef LPDIEFFECTINFOW LPDIEFFECTINFO; +#else +typedef DIEFFECTINFOA DIEFFECTINFO; +typedef LPDIEFFECTINFOA LPDIEFFECTINFO; +#endif // UNICODE +typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; +typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; +typedef const DIEFFECTINFO *LPCDIEFFECTINFO; + +#define DISDD_CONTINUE 0x00000001 + +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); +#ifdef UNICODE +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW +#else +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2W + +DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2A + +DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; + +#ifdef UNICODE +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W +#define IDirectInputDevice2 IDirectInputDevice2W +#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl +#else +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A +#define IDirectInputDevice2 IDirectInputDevice2A +#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl +#endif +typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#else +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice2_AddRef(p) (p)->AddRef() +#define IDirectInputDevice2_Release(p) (p)->Release() +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice2_Acquire(p) (p)->Acquire() +#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice2_Poll(p) (p)->Poll() +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIFEF_DEFAULT 0x00000000 +#define DIFEF_INCLUDENONSTANDARD 0x00000001 +#define DIFEF_MODIFYIFNEEDED 0x00000010 + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7W + +DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7W methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7A + +DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7A methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; + +#ifdef UNICODE +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W +#define IDirectInputDevice7 IDirectInputDevice7W +#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl +#else +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A +#define IDirectInputDevice7 IDirectInputDevice7A +#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl +#endif +typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#else +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice7_AddRef(p) (p)->AddRef() +#define IDirectInputDevice7_Release(p) (p)->Release() +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice7_Acquire(p) (p)->Acquire() +#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice7_Poll(p) (p)->Poll() +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8W + +DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE; +}; + +typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8A + +DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE; +}; + +typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; + +#ifdef UNICODE +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W +#define IDirectInputDevice8 IDirectInputDevice8W +#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl +#else +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A +#define IDirectInputDevice8 IDirectInputDevice8A +#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl +#endif +typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) +#else +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice8_AddRef(p) (p)->AddRef() +#define IDirectInputDevice8_Release(p) (p)->Release() +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice8_Acquire(p) (p)->Acquire() +#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice8_Poll(p) (p)->Poll() +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +/**************************************************************************** + * + * Mouse + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct _DIMOUSESTATE { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[4]; +} DIMOUSESTATE, *LPDIMOUSESTATE; + +#if DIRECTINPUT_VERSION >= 0x0700 +typedef struct _DIMOUSESTATE2 { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[8]; +} DIMOUSESTATE2, *LPDIMOUSESTATE2; +#endif + + +#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) +#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) +#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) +#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) +#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) +#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) +#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) +#if (DIRECTINPUT_VERSION >= 0x0700) +#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) +#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) +#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) +#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) +#endif +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Keyboard + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * DirectInput keyboard scan codes + * + ****************************************************************************/ +#define DIK_ESCAPE 0x01 +#define DIK_1 0x02 +#define DIK_2 0x03 +#define DIK_3 0x04 +#define DIK_4 0x05 +#define DIK_5 0x06 +#define DIK_6 0x07 +#define DIK_7 0x08 +#define DIK_8 0x09 +#define DIK_9 0x0A +#define DIK_0 0x0B +#define DIK_MINUS 0x0C /* - on main keyboard */ +#define DIK_EQUALS 0x0D +#define DIK_BACK 0x0E /* backspace */ +#define DIK_TAB 0x0F +#define DIK_Q 0x10 +#define DIK_W 0x11 +#define DIK_E 0x12 +#define DIK_R 0x13 +#define DIK_T 0x14 +#define DIK_Y 0x15 +#define DIK_U 0x16 +#define DIK_I 0x17 +#define DIK_O 0x18 +#define DIK_P 0x19 +#define DIK_LBRACKET 0x1A +#define DIK_RBRACKET 0x1B +#define DIK_RETURN 0x1C /* Enter on main keyboard */ +#define DIK_LCONTROL 0x1D +#define DIK_A 0x1E +#define DIK_S 0x1F +#define DIK_D 0x20 +#define DIK_F 0x21 +#define DIK_G 0x22 +#define DIK_H 0x23 +#define DIK_J 0x24 +#define DIK_K 0x25 +#define DIK_L 0x26 +#define DIK_SEMICOLON 0x27 +#define DIK_APOSTROPHE 0x28 +#define DIK_GRAVE 0x29 /* accent grave */ +#define DIK_LSHIFT 0x2A +#define DIK_BACKSLASH 0x2B +#define DIK_Z 0x2C +#define DIK_X 0x2D +#define DIK_C 0x2E +#define DIK_V 0x2F +#define DIK_B 0x30 +#define DIK_N 0x31 +#define DIK_M 0x32 +#define DIK_COMMA 0x33 +#define DIK_PERIOD 0x34 /* . on main keyboard */ +#define DIK_SLASH 0x35 /* / on main keyboard */ +#define DIK_RSHIFT 0x36 +#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ +#define DIK_LMENU 0x38 /* left Alt */ +#define DIK_SPACE 0x39 +#define DIK_CAPITAL 0x3A +#define DIK_F1 0x3B +#define DIK_F2 0x3C +#define DIK_F3 0x3D +#define DIK_F4 0x3E +#define DIK_F5 0x3F +#define DIK_F6 0x40 +#define DIK_F7 0x41 +#define DIK_F8 0x42 +#define DIK_F9 0x43 +#define DIK_F10 0x44 +#define DIK_NUMLOCK 0x45 +#define DIK_SCROLL 0x46 /* Scroll Lock */ +#define DIK_NUMPAD7 0x47 +#define DIK_NUMPAD8 0x48 +#define DIK_NUMPAD9 0x49 +#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ +#define DIK_NUMPAD4 0x4B +#define DIK_NUMPAD5 0x4C +#define DIK_NUMPAD6 0x4D +#define DIK_ADD 0x4E /* + on numeric keypad */ +#define DIK_NUMPAD1 0x4F +#define DIK_NUMPAD2 0x50 +#define DIK_NUMPAD3 0x51 +#define DIK_NUMPAD0 0x52 +#define DIK_DECIMAL 0x53 /* . on numeric keypad */ +#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIK_F11 0x57 +#define DIK_F12 0x58 +#define DIK_F13 0x64 /* (NEC PC98) */ +#define DIK_F14 0x65 /* (NEC PC98) */ +#define DIK_F15 0x66 /* (NEC PC98) */ +#define DIK_KANA 0x70 /* (Japanese keyboard) */ +#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */ +#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ +#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ +#define DIK_YEN 0x7D /* (Japanese keyboard) */ +#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ +#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ +#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIK_AT 0x91 /* (NEC PC98) */ +#define DIK_COLON 0x92 /* (NEC PC98) */ +#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ +#define DIK_KANJI 0x94 /* (Japanese keyboard) */ +#define DIK_STOP 0x95 /* (NEC PC98) */ +#define DIK_AX 0x96 /* (Japan AX) */ +#define DIK_UNLABELED 0x97 /* (J3100) */ +#define DIK_NEXTTRACK 0x99 /* Next Track */ +#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ +#define DIK_RCONTROL 0x9D +#define DIK_MUTE 0xA0 /* Mute */ +#define DIK_CALCULATOR 0xA1 /* Calculator */ +#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ +#define DIK_MEDIASTOP 0xA4 /* Media Stop */ +#define DIK_VOLUMEDOWN 0xAE /* Volume - */ +#define DIK_VOLUMEUP 0xB0 /* Volume + */ +#define DIK_WEBHOME 0xB2 /* Web home */ +#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ +#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ +#define DIK_SYSRQ 0xB7 +#define DIK_RMENU 0xB8 /* right Alt */ +#define DIK_PAUSE 0xC5 /* Pause */ +#define DIK_HOME 0xC7 /* Home on arrow keypad */ +#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ +#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ +#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ +#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ +#define DIK_END 0xCF /* End on arrow keypad */ +#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ +#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ +#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ +#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ +#define DIK_LWIN 0xDB /* Left Windows key */ +#define DIK_RWIN 0xDC /* Right Windows key */ +#define DIK_APPS 0xDD /* AppMenu key */ +#define DIK_POWER 0xDE /* System Power */ +#define DIK_SLEEP 0xDF /* System Sleep */ +#define DIK_WAKE 0xE3 /* System Wake */ +#define DIK_WEBSEARCH 0xE5 /* Web Search */ +#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ +#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ +#define DIK_WEBSTOP 0xE8 /* Web Stop */ +#define DIK_WEBFORWARD 0xE9 /* Web Forward */ +#define DIK_WEBBACK 0xEA /* Web Back */ +#define DIK_MYCOMPUTER 0xEB /* My Computer */ +#define DIK_MAIL 0xEC /* Mail */ +#define DIK_MEDIASELECT 0xED /* Media Select */ + +/* + * Alternate names for keys, to facilitate transition from DOS. + */ +#define DIK_BACKSPACE DIK_BACK /* backspace */ +#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ +#define DIK_LALT DIK_LMENU /* left Alt */ +#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ +#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ +#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ +#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ +#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ +#define DIK_RALT DIK_RMENU /* right Alt */ +#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ +#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ +#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ +#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ +#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ +#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ + +/* + * Alternate names for keys originally not used on US keyboards. + */ +#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Joystick + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct DIJOYSTATE { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[32]; /* 32 buttons */ +} DIJOYSTATE, *LPDIJOYSTATE; + +typedef struct DIJOYSTATE2 { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[128]; /* 128 buttons */ + LONG lVX; /* x-axis velocity */ + LONG lVY; /* y-axis velocity */ + LONG lVZ; /* z-axis velocity */ + LONG lVRx; /* x-axis angular velocity */ + LONG lVRy; /* y-axis angular velocity */ + LONG lVRz; /* z-axis angular velocity */ + LONG rglVSlider[2]; /* extra axes velocities */ + LONG lAX; /* x-axis acceleration */ + LONG lAY; /* y-axis acceleration */ + LONG lAZ; /* z-axis acceleration */ + LONG lARx; /* x-axis angular acceleration */ + LONG lARy; /* y-axis angular acceleration */ + LONG lARz; /* z-axis angular acceleration */ + LONG rglASlider[2]; /* extra axes accelerations */ + LONG lFX; /* x-axis force */ + LONG lFY; /* y-axis force */ + LONG lFZ; /* z-axis force */ + LONG lFRx; /* x-axis torque */ + LONG lFRy; /* y-axis torque */ + LONG lFRz; /* z-axis torque */ + LONG rglFSlider[2]; /* extra axes forces */ +} DIJOYSTATE2, *LPDIJOYSTATE2; + +#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) +#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) +#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) +#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) +#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) +#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) +#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ + (n) * sizeof(LONG)) +#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ + (n) * sizeof(DWORD)) +#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) +#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) +#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) +#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) +#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) +#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) +#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) +#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) +#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) +#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) +#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) +#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) +#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) +#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) +#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) +#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) +#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) +#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) +#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) +#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) +#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) +#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) +#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) +#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) +#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) +#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) +#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) +#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) +#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) +#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) +#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) +#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) +#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) + + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * IDirectInput + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#define DIENUM_STOP 0 +#define DIENUM_CONTINUE 1 + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW +#else +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID); + +#define DIEDFL_ALLDEVICES 0x00000000 +#define DIEDFL_ATTACHEDONLY 0x00000001 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIEDFL_FORCEFEEDBACK 0x00000100 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIEDFL_INCLUDEALIASES 0x00010000 +#define DIEDFL_INCLUDEPHANTOMS 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDFL_INCLUDEHIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW +#else +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA +#endif // !UNICODE +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBS_MAPPEDPRI1 0x00000001 +#define DIEDBS_MAPPEDPRI2 0x00000002 +#define DIEDBS_RECENTDEVICE 0x00000010 +#define DIEDBS_NEWDEVICE 0x00000020 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBSFL_ATTACHEDONLY 0x00000000 +#define DIEDBSFL_THISUSER 0x00000010 +#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK +#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 +#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 +#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 +#define DIEDBSFL_VALID 0x00007110 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#undef INTERFACE +#define INTERFACE IDirectInputW + +DECLARE_INTERFACE_(IDirectInputW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputW *LPDIRECTINPUTW; + +#undef INTERFACE +#define INTERFACE IDirectInputA + +DECLARE_INTERFACE_(IDirectInputA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputA *LPDIRECTINPUTA; + +#ifdef UNICODE +#define IID_IDirectInput IID_IDirectInputW +#define IDirectInput IDirectInputW +#define IDirectInputVtbl IDirectInputWVtbl +#else +#define IID_IDirectInput IID_IDirectInputA +#define IDirectInput IDirectInputA +#define IDirectInputVtbl IDirectInputAVtbl +#endif +typedef struct IDirectInput *LPDIRECTINPUT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#else +#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput_AddRef(p) (p)->AddRef() +#define IDirectInput_Release(p) (p)->Release() +#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) +#endif + +#undef INTERFACE +#define INTERFACE IDirectInput2W + +DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2W *LPDIRECTINPUT2W; + +#undef INTERFACE +#define INTERFACE IDirectInput2A + +DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2A *LPDIRECTINPUT2A; + +#ifdef UNICODE +#define IID_IDirectInput2 IID_IDirectInput2W +#define IDirectInput2 IDirectInput2W +#define IDirectInput2Vtbl IDirectInput2WVtbl +#else +#define IID_IDirectInput2 IID_IDirectInput2A +#define IDirectInput2 IDirectInput2A +#define IDirectInput2Vtbl IDirectInput2AVtbl +#endif +typedef struct IDirectInput2 *LPDIRECTINPUT2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#else +#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput2_AddRef(p) (p)->AddRef() +#define IDirectInput2_Release(p) (p)->Release() +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#endif + + +#undef INTERFACE +#define INTERFACE IDirectInput7W + +DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + + /*** IDirectInput7W methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7W *LPDIRECTINPUT7W; + +#undef INTERFACE +#define INTERFACE IDirectInput7A + +DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + + /*** IDirectInput7A methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7A *LPDIRECTINPUT7A; + +#ifdef UNICODE +#define IID_IDirectInput7 IID_IDirectInput7W +#define IDirectInput7 IDirectInput7W +#define IDirectInput7Vtbl IDirectInput7WVtbl +#else +#define IID_IDirectInput7 IID_IDirectInput7A +#define IDirectInput7 IDirectInput7A +#define IDirectInput7Vtbl IDirectInput7AVtbl +#endif +typedef struct IDirectInput7 *LPDIRECTINPUT7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) +#else +#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput7_AddRef(p) (p)->AddRef() +#define IDirectInput7_Release(p) (p)->Release() +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) +#endif + +#if(DIRECTINPUT_VERSION >= 0x0800) +#undef INTERFACE +#define INTERFACE IDirectInput8W + +DECLARE_INTERFACE_(IDirectInput8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8W *LPDIRECTINPUT8W; + +#undef INTERFACE +#define INTERFACE IDirectInput8A + +DECLARE_INTERFACE_(IDirectInput8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8A *LPDIRECTINPUT8A; + +#ifdef UNICODE +#define IID_IDirectInput8 IID_IDirectInput8W +#define IDirectInput8 IDirectInput8W +#define IDirectInput8Vtbl IDirectInput8WVtbl +#else +#define IID_IDirectInput8 IID_IDirectInput8A +#define IDirectInput8 IDirectInput8A +#define IDirectInput8Vtbl IDirectInput8AVtbl +#endif +typedef struct IDirectInput8 *LPDIRECTINPUT8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) +#else +#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput8_AddRef(p) (p)->AddRef() +#define IDirectInput8_Release(p) (p)->Release() +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) +#endif +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if DIRECTINPUT_VERSION > 0x0700 + +extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#else +extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); +extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); +#ifdef UNICODE +#define DirectInputCreate DirectInputCreateW +#else +#define DirectInputCreate DirectInputCreateA +#endif // !UNICODE + +extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#endif /* DIRECTINPUT_VERSION > 0x700 */ + +#endif /* DIJ_RINGZERO */ + + +/**************************************************************************** + * + * Return Codes + * + ****************************************************************************/ + +/* + * The operation completed successfully. + */ +#define DI_OK S_OK + +/* + * The device exists but is not currently attached. + */ +#define DI_NOTATTACHED S_FALSE + +/* + * The device buffer overflowed. Some input was lost. + */ +#define DI_BUFFEROVERFLOW S_FALSE + +/* + * The change in device properties had no effect. + */ +#define DI_PROPNOEFFECT S_FALSE + +/* + * The operation had no effect. + */ +#define DI_NOEFFECT S_FALSE + +/* + * The device is a polled device. As a result, device buffering + * will not collect any data and event notifications will not be + * signalled until GetDeviceState is called. + */ +#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but the effect was not + * downloaded because the device is not exclusively acquired + * or because the DIEP_NODOWNLOAD flag was passed. + */ +#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but in order to change + * the parameters, the effect needed to be restarted. + */ +#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but some of them were + * beyond the capabilities of the device and were truncated. + */ +#define DI_TRUNCATED ((HRESULT)0x00000008L) + +/* + * The settings have been successfully applied but could not be + * persisted. + */ +#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) + +/* + * Equal to DI_EFFECTRESTARTED | DI_TRUNCATED. + */ +#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) + +/* + * A SUCCESS code indicating that settings cannot be modified. + */ +#define DI_WRITEPROTECT ((HRESULT)0x00000013L) + +/* + * The application requires a newer version of DirectInput. + */ +#define DIERR_OLDDIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) + +/* + * The application was written for an unsupported prerelease version + * of DirectInput. + */ +#define DIERR_BETADIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) + +/* + * The object could not be created due to an incompatible driver version + * or mismatched or incomplete driver components. + */ +#define DIERR_BADDRIVERVER \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) + +/* + * The device or device instance or effect is not registered with DirectInput. + */ +#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG + +/* + * The requested object does not exist. + */ +#define DIERR_NOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * The requested object does not exist. + */ +#define DIERR_OBJECTNOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * An invalid parameter was passed to the returning function, + * or the object was not in a state that admitted the function + * to be called. + */ +#define DIERR_INVALIDPARAM E_INVALIDARG + +/* + * The specified interface is not supported by the object + */ +#define DIERR_NOINTERFACE E_NOINTERFACE + +/* + * An undetermined error occured inside the DInput subsystem + */ +#define DIERR_GENERIC E_FAIL + +/* + * The DInput subsystem couldn't allocate sufficient memory to complete the + * caller's request. + */ +#define DIERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * The function called is not supported at this time + */ +#define DIERR_UNSUPPORTED E_NOTIMPL + +/* + * This object has not been initialized + */ +#define DIERR_NOTINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) + +/* + * This object is already initialized + */ +#define DIERR_ALREADYINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) + +/* + * This object does not support aggregation + */ +#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +/* + * Another app has a higher priority level, preventing this call from + * succeeding. + */ +#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED + +/* + * Access to the device has been lost. It must be re-acquired. + */ +#define DIERR_INPUTLOST \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) + +/* + * The operation cannot be performed while the device is acquired. + */ +#define DIERR_ACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) + +/* + * The operation cannot be performed unless the device is acquired. + */ +#define DIERR_NOTACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) + +/* + * The specified property cannot be changed. + */ +#define DIERR_READONLY E_ACCESSDENIED + +/* + * The device already has an event notification associated with it. + */ +#define DIERR_HANDLEEXISTS E_ACCESSDENIED + +/* + * Data is not yet available. + */ +#ifndef E_PENDING +#define E_PENDING 0x8000000AL +#endif + +/* + * Unable to IDirectInputJoyConfig_Acquire because the user + * does not have sufficient privileges to change the joystick + * configuration. + */ +#define DIERR_INSUFFICIENTPRIVS 0x80040200L + +/* + * The device is full. + */ +#define DIERR_DEVICEFULL 0x80040201L + +/* + * Not all the requested information fit into the buffer. + */ +#define DIERR_MOREDATA 0x80040202L + +/* + * The effect is not downloaded. + */ +#define DIERR_NOTDOWNLOADED 0x80040203L + +/* + * The device cannot be reinitialized because there are still effects + * attached to it. + */ +#define DIERR_HASEFFECTS 0x80040204L + +/* + * The operation cannot be performed unless the device is acquired + * in DISCL_EXCLUSIVE mode. + */ +#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L + +/* + * The effect could not be downloaded because essential information + * is missing. For example, no axes have been associated with the + * effect, or no type-specific information has been created. + */ +#define DIERR_INCOMPLETEEFFECT 0x80040206L + +/* + * Attempted to read buffered device data from a device that is + * not buffered. + */ +#define DIERR_NOTBUFFERED 0x80040207L + +/* + * An attempt was made to modify parameters of an effect while it is + * playing. Not all hardware devices support altering the parameters + * of an effect while it is playing. + */ +#define DIERR_EFFECTPLAYING 0x80040208L + +/* + * The operation could not be completed because the device is not + * plugged in. + */ +#define DIERR_UNPLUGGED 0x80040209L + +/* + * SendDeviceData failed because more information was requested + * to be sent than can be sent to the device. Some devices have + * restrictions on how much data can be sent to them. (For example, + * there might be a limit on the number of buttons that can be + * pressed at once.) + */ +#define DIERR_REPORTFULL 0x8004020AL + + +/* + * A mapper file function failed because reading or writing the user or IHV + * settings file failed. + */ +#define DIERR_MAPFILEFAIL 0x8004020BL + + +/*--- DINPUT Mapper Definitions: New for Dx8 ---*/ + + +/*--- Keyboard + Physical Keyboard Device ---*/ + +#define DIKEYBOARD_ESCAPE 0x81000401 +#define DIKEYBOARD_1 0x81000402 +#define DIKEYBOARD_2 0x81000403 +#define DIKEYBOARD_3 0x81000404 +#define DIKEYBOARD_4 0x81000405 +#define DIKEYBOARD_5 0x81000406 +#define DIKEYBOARD_6 0x81000407 +#define DIKEYBOARD_7 0x81000408 +#define DIKEYBOARD_8 0x81000409 +#define DIKEYBOARD_9 0x8100040A +#define DIKEYBOARD_0 0x8100040B +#define DIKEYBOARD_MINUS 0x8100040C /* - on main keyboard */ +#define DIKEYBOARD_EQUALS 0x8100040D +#define DIKEYBOARD_BACK 0x8100040E /* backspace */ +#define DIKEYBOARD_TAB 0x8100040F +#define DIKEYBOARD_Q 0x81000410 +#define DIKEYBOARD_W 0x81000411 +#define DIKEYBOARD_E 0x81000412 +#define DIKEYBOARD_R 0x81000413 +#define DIKEYBOARD_T 0x81000414 +#define DIKEYBOARD_Y 0x81000415 +#define DIKEYBOARD_U 0x81000416 +#define DIKEYBOARD_I 0x81000417 +#define DIKEYBOARD_O 0x81000418 +#define DIKEYBOARD_P 0x81000419 +#define DIKEYBOARD_LBRACKET 0x8100041A +#define DIKEYBOARD_RBRACKET 0x8100041B +#define DIKEYBOARD_RETURN 0x8100041C /* Enter on main keyboard */ +#define DIKEYBOARD_LCONTROL 0x8100041D +#define DIKEYBOARD_A 0x8100041E +#define DIKEYBOARD_S 0x8100041F +#define DIKEYBOARD_D 0x81000420 +#define DIKEYBOARD_F 0x81000421 +#define DIKEYBOARD_G 0x81000422 +#define DIKEYBOARD_H 0x81000423 +#define DIKEYBOARD_J 0x81000424 +#define DIKEYBOARD_K 0x81000425 +#define DIKEYBOARD_L 0x81000426 +#define DIKEYBOARD_SEMICOLON 0x81000427 +#define DIKEYBOARD_APOSTROPHE 0x81000428 +#define DIKEYBOARD_GRAVE 0x81000429 /* accent grave */ +#define DIKEYBOARD_LSHIFT 0x8100042A +#define DIKEYBOARD_BACKSLASH 0x8100042B +#define DIKEYBOARD_Z 0x8100042C +#define DIKEYBOARD_X 0x8100042D +#define DIKEYBOARD_C 0x8100042E +#define DIKEYBOARD_V 0x8100042F +#define DIKEYBOARD_B 0x81000430 +#define DIKEYBOARD_N 0x81000431 +#define DIKEYBOARD_M 0x81000432 +#define DIKEYBOARD_COMMA 0x81000433 +#define DIKEYBOARD_PERIOD 0x81000434 /* . on main keyboard */ +#define DIKEYBOARD_SLASH 0x81000435 /* / on main keyboard */ +#define DIKEYBOARD_RSHIFT 0x81000436 +#define DIKEYBOARD_MULTIPLY 0x81000437 /* * on numeric keypad */ +#define DIKEYBOARD_LMENU 0x81000438 /* left Alt */ +#define DIKEYBOARD_SPACE 0x81000439 +#define DIKEYBOARD_CAPITAL 0x8100043A +#define DIKEYBOARD_F1 0x8100043B +#define DIKEYBOARD_F2 0x8100043C +#define DIKEYBOARD_F3 0x8100043D +#define DIKEYBOARD_F4 0x8100043E +#define DIKEYBOARD_F5 0x8100043F +#define DIKEYBOARD_F6 0x81000440 +#define DIKEYBOARD_F7 0x81000441 +#define DIKEYBOARD_F8 0x81000442 +#define DIKEYBOARD_F9 0x81000443 +#define DIKEYBOARD_F10 0x81000444 +#define DIKEYBOARD_NUMLOCK 0x81000445 +#define DIKEYBOARD_SCROLL 0x81000446 /* Scroll Lock */ +#define DIKEYBOARD_NUMPAD7 0x81000447 +#define DIKEYBOARD_NUMPAD8 0x81000448 +#define DIKEYBOARD_NUMPAD9 0x81000449 +#define DIKEYBOARD_SUBTRACT 0x8100044A /* - on numeric keypad */ +#define DIKEYBOARD_NUMPAD4 0x8100044B +#define DIKEYBOARD_NUMPAD5 0x8100044C +#define DIKEYBOARD_NUMPAD6 0x8100044D +#define DIKEYBOARD_ADD 0x8100044E /* + on numeric keypad */ +#define DIKEYBOARD_NUMPAD1 0x8100044F +#define DIKEYBOARD_NUMPAD2 0x81000450 +#define DIKEYBOARD_NUMPAD3 0x81000451 +#define DIKEYBOARD_NUMPAD0 0x81000452 +#define DIKEYBOARD_DECIMAL 0x81000453 /* . on numeric keypad */ +#define DIKEYBOARD_OEM_102 0x81000456 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIKEYBOARD_F11 0x81000457 +#define DIKEYBOARD_F12 0x81000458 +#define DIKEYBOARD_F13 0x81000464 /* (NEC PC98) */ +#define DIKEYBOARD_F14 0x81000465 /* (NEC PC98) */ +#define DIKEYBOARD_F15 0x81000466 /* (NEC PC98) */ +#define DIKEYBOARD_KANA 0x81000470 /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C1 0x81000473 /* /? on Brazilian keyboard */ +#define DIKEYBOARD_CONVERT 0x81000479 /* (Japanese keyboard) */ +#define DIKEYBOARD_NOCONVERT 0x8100047B /* (Japanese keyboard) */ +#define DIKEYBOARD_YEN 0x8100047D /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C2 0x8100047E /* Numpad . on Brazilian keyboard */ +#define DIKEYBOARD_NUMPADEQUALS 0x8100048D /* = on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_PREVTRACK 0x81000490 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIKEYBOARD_AT 0x81000491 /* (NEC PC98) */ +#define DIKEYBOARD_COLON 0x81000492 /* (NEC PC98) */ +#define DIKEYBOARD_UNDERLINE 0x81000493 /* (NEC PC98) */ +#define DIKEYBOARD_KANJI 0x81000494 /* (Japanese keyboard) */ +#define DIKEYBOARD_STOP 0x81000495 /* (NEC PC98) */ +#define DIKEYBOARD_AX 0x81000496 /* (Japan AX) */ +#define DIKEYBOARD_UNLABELED 0x81000497 /* (J3100) */ +#define DIKEYBOARD_NEXTTRACK 0x81000499 /* Next Track */ +#define DIKEYBOARD_NUMPADENTER 0x8100049C /* Enter on numeric keypad */ +#define DIKEYBOARD_RCONTROL 0x8100049D +#define DIKEYBOARD_MUTE 0x810004A0 /* Mute */ +#define DIKEYBOARD_CALCULATOR 0x810004A1 /* Calculator */ +#define DIKEYBOARD_PLAYPAUSE 0x810004A2 /* Play / Pause */ +#define DIKEYBOARD_MEDIASTOP 0x810004A4 /* Media Stop */ +#define DIKEYBOARD_VOLUMEDOWN 0x810004AE /* Volume - */ +#define DIKEYBOARD_VOLUMEUP 0x810004B0 /* Volume + */ +#define DIKEYBOARD_WEBHOME 0x810004B2 /* Web home */ +#define DIKEYBOARD_NUMPADCOMMA 0x810004B3 /* , on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_DIVIDE 0x810004B5 /* / on numeric keypad */ +#define DIKEYBOARD_SYSRQ 0x810004B7 +#define DIKEYBOARD_RMENU 0x810004B8 /* right Alt */ +#define DIKEYBOARD_PAUSE 0x810004C5 /* Pause */ +#define DIKEYBOARD_HOME 0x810004C7 /* Home on arrow keypad */ +#define DIKEYBOARD_UP 0x810004C8 /* UpArrow on arrow keypad */ +#define DIKEYBOARD_PRIOR 0x810004C9 /* PgUp on arrow keypad */ +#define DIKEYBOARD_LEFT 0x810004CB /* LeftArrow on arrow keypad */ +#define DIKEYBOARD_RIGHT 0x810004CD /* RightArrow on arrow keypad */ +#define DIKEYBOARD_END 0x810004CF /* End on arrow keypad */ +#define DIKEYBOARD_DOWN 0x810004D0 /* DownArrow on arrow keypad */ +#define DIKEYBOARD_NEXT 0x810004D1 /* PgDn on arrow keypad */ +#define DIKEYBOARD_INSERT 0x810004D2 /* Insert on arrow keypad */ +#define DIKEYBOARD_DELETE 0x810004D3 /* Delete on arrow keypad */ +#define DIKEYBOARD_LWIN 0x810004DB /* Left Windows key */ +#define DIKEYBOARD_RWIN 0x810004DC /* Right Windows key */ +#define DIKEYBOARD_APPS 0x810004DD /* AppMenu key */ +#define DIKEYBOARD_POWER 0x810004DE /* System Power */ +#define DIKEYBOARD_SLEEP 0x810004DF /* System Sleep */ +#define DIKEYBOARD_WAKE 0x810004E3 /* System Wake */ +#define DIKEYBOARD_WEBSEARCH 0x810004E5 /* Web Search */ +#define DIKEYBOARD_WEBFAVORITES 0x810004E6 /* Web Favorites */ +#define DIKEYBOARD_WEBREFRESH 0x810004E7 /* Web Refresh */ +#define DIKEYBOARD_WEBSTOP 0x810004E8 /* Web Stop */ +#define DIKEYBOARD_WEBFORWARD 0x810004E9 /* Web Forward */ +#define DIKEYBOARD_WEBBACK 0x810004EA /* Web Back */ +#define DIKEYBOARD_MYCOMPUTER 0x810004EB /* My Computer */ +#define DIKEYBOARD_MAIL 0x810004EC /* Mail */ +#define DIKEYBOARD_MEDIASELECT 0x810004ED /* Media Select */ + + +/*--- MOUSE + Physical Mouse Device ---*/ + +#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X ) /* X Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y ) /* Y Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X ) /* X Axis */ +#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y ) /* Y Axis */ +#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z ) /* Z Axis */ +#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0) /* Button 0 */ +#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1) /* Button 1 */ +#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2) /* Button 2 */ +#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3) /* Button 3 */ +#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4) /* Button 4 */ +#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5) /* Button 5 */ +#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6) /* Button 6 */ +#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7) /* Button 7 */ + + +/*--- VOICE + Physical Dplay Voice Device ---*/ + +#define DIVOICE_CHANNEL1 0x83000401 +#define DIVOICE_CHANNEL2 0x83000402 +#define DIVOICE_CHANNEL3 0x83000403 +#define DIVOICE_CHANNEL4 0x83000404 +#define DIVOICE_CHANNEL5 0x83000405 +#define DIVOICE_CHANNEL6 0x83000406 +#define DIVOICE_CHANNEL7 0x83000407 +#define DIVOICE_CHANNEL8 0x83000408 +#define DIVOICE_TEAM 0x83000409 +#define DIVOICE_ALL 0x8300040A +#define DIVOICE_RECORDMUTE 0x8300040B +#define DIVOICE_PLAYBACKMUTE 0x8300040C +#define DIVOICE_TRANSMIT 0x8300040D + +#define DIVOICE_VOICECOMMAND 0x83000410 + + +/*--- Driving Simulator - Racing + Vehicle control is primary objective ---*/ +#define DIVIRTUAL_DRIVING_RACE 0x01000000 +#define DIAXIS_DRIVINGR_STEER 0x01008A01 /* Steering */ +#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202 /* Accelerate */ +#define DIAXIS_DRIVINGR_BRAKE 0x01041203 /* Brake-Axis */ +#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGR_VIEW 0x01001C03 /* Cycle through view options */ +#define DIBUTTON_DRIVINGR_MENU 0x010004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601 /* Look around */ +#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04 /* Brake-button */ +#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGR_AIDS 0x01004406 /* Driver correction aids */ +#define DIBUTTON_DRIVINGR_MAP 0x01004407 /* Display Driving Map */ +#define DIBUTTON_DRIVINGR_BOOST 0x01004408 /* Turbo Boost */ +#define DIBUTTON_DRIVINGR_PIT 0x01004409 /* Pit stop notification */ +#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Combat + Combat from within a vehicle is primary objective ---*/ +#define DIVIRTUAL_DRIVING_COMBAT 0x02000000 +#define DIAXIS_DRIVINGC_STEER 0x02008A01 /* Steering */ +#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202 /* Accelerate */ +#define DIAXIS_DRIVINGC_BRAKE 0x02041203 /* Brake-axis */ +#define DIBUTTON_DRIVINGC_FIRE 0x02000C01 /* Fire */ +#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGC_TARGET 0x02000C03 /* Select next available target */ +#define DIBUTTON_DRIVINGC_MENU 0x020004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601 /* Look around */ +#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGC_AIDS 0x02004407 /* Driver correction aids */ +#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08 /* Brake-button */ +#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09 /* Alternative fire button */ +#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Tank + Combat from withing a tank is primary objective ---*/ +#define DIVIRTUAL_DRIVING_TANK 0x03000000 +#define DIAXIS_DRIVINGT_STEER 0x03008A01 /* Turn tank left / right */ +#define DIAXIS_DRIVINGT_BARREL 0x03010202 /* Raise / lower barrel */ +#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203 /* Accelerate */ +#define DIAXIS_DRIVINGT_ROTATE 0x03020204 /* Turn barrel left / right */ +#define DIBUTTON_DRIVINGT_FIRE 0x03000C01 /* Fire */ +#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGT_TARGET 0x03000C03 /* Selects next available target */ +#define DIBUTTON_DRIVINGT_MENU 0x030004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601 /* Look around */ +#define DIAXIS_DRIVINGT_BRAKE 0x03045205 /* Brake-axis */ +#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06 /* Some devices combine accelerate and brake in a single axis */ +#define DIBUTTON_DRIVINGT_VIEW 0x03005C04 /* Cycle through view options */ +#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06 /* Brake-button */ +#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07 /* Alternative fire button */ +#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0 /* Fallback Barrel up button */ +#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8 /* Fallback Barrel down button */ +#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4 /* Fallback Rotate left button */ +#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC /* Fallback Rotate right button */ +#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Civilian + Plane control is the primary objective ---*/ +#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000 +#define DIAXIS_FLYINGC_BANK 0x04008A01 /* Roll ship left / right */ +#define DIAXIS_FLYINGC_PITCH 0x04010A02 /* Nose up / down */ +#define DIAXIS_FLYINGC_THROTTLE 0x04039203 /* Throttle */ +#define DIBUTTON_FLYINGC_VIEW 0x04002401 /* Cycle through view options */ +#define DIBUTTON_FLYINGC_DISPLAY 0x04002402 /* Select next dashboard / heads up display option */ +#define DIBUTTON_FLYINGC_GEAR 0x04002C03 /* Gear up / down */ +#define DIBUTTON_FLYINGC_MENU 0x040004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601 /* Look around */ +#define DIAXIS_FLYINGC_BRAKE 0x04046A04 /* Apply Brake */ +#define DIAXIS_FLYINGC_RUDDER 0x04025205 /* Yaw ship left/right */ +#define DIAXIS_FLYINGC_FLAPS 0x04055A06 /* Flaps */ +#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0 /* Fallback brake button */ +#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGC_DEVICE 0x040044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGC_PAUSE 0x040044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Military + Aerial combat is the primary objective ---*/ +#define DIVIRTUAL_FLYING_MILITARY 0x05000000 +#define DIAXIS_FLYINGM_BANK 0x05008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGM_PITCH 0x05010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGM_THROTTLE 0x05039203 /* Throttle - faster / slower */ +#define DIBUTTON_FLYINGM_FIRE 0x05000C01 /* Fire */ +#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02 /* Select next weapon */ +#define DIBUTTON_FLYINGM_TARGET 0x05000C03 /* Selects next available target */ +#define DIBUTTON_FLYINGM_MENU 0x050004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601 /* Look around */ +#define DIBUTTON_FLYINGM_COUNTER 0x05005C04 /* Activate counter measures */ +#define DIAXIS_FLYINGM_RUDDER 0x05024A04 /* Rudder - Yaw ship left/right */ +#define DIAXIS_FLYINGM_BRAKE 0x05046205 /* Brake-axis */ +#define DIBUTTON_FLYINGM_VIEW 0x05006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGM_DISPLAY 0x05006406 /* Select next dashboard option */ +#define DIAXIS_FLYINGM_FLAPS 0x05055206 /* Flaps */ +#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09 /* Alternative fire button */ +#define DIBUTTON_FLYINGM_GEAR 0x0500640A /* Gear up / down */ +#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0 /* Fallback brake button */ +#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGM_DEVICE 0x050044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGM_PAUSE 0x050044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Combat Helicopter + Combat from helicopter is primary objective ---*/ +#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000 +#define DIAXIS_FLYINGH_BANK 0x06008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGH_PITCH 0x06010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03 /* Collective - Blade pitch/power */ +#define DIBUTTON_FLYINGH_FIRE 0x06001401 /* Fire */ +#define DIBUTTON_FLYINGH_WEAPONS 0x06001402 /* Select next weapon */ +#define DIBUTTON_FLYINGH_TARGET 0x06001403 /* Selects next available target */ +#define DIBUTTON_FLYINGH_MENU 0x060004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601 /* Look around */ +#define DIAXIS_FLYINGH_TORQUE 0x06025A04 /* Torque - Rotate ship around left / right axis */ +#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05 /* Throttle */ +#define DIBUTTON_FLYINGH_COUNTER 0x06005404 /* Activate counter measures */ +#define DIBUTTON_FLYINGH_VIEW 0x06006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGH_GEAR 0x06006406 /* Gear up / down */ +#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07 /* Alternative fire button */ +#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGH_DEVICE 0x060044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGH_PAUSE 0x060044FC /* Start / Pause / Restart game */ + +/*--- Space Simulator - Combat + Space Simulator with weapons ---*/ +#define DIVIRTUAL_SPACESIM 0x07000000 +#define DIAXIS_SPACESIM_LATERAL 0x07008201 /* Move ship left / right */ +#define DIAXIS_SPACESIM_MOVE 0x07010202 /* Move ship forward/backward */ +#define DIAXIS_SPACESIM_THROTTLE 0x07038203 /* Throttle - Engine speed */ +#define DIBUTTON_SPACESIM_FIRE 0x07000401 /* Fire */ +#define DIBUTTON_SPACESIM_WEAPONS 0x07000402 /* Select next weapon */ +#define DIBUTTON_SPACESIM_TARGET 0x07000403 /* Selects next available target */ +#define DIBUTTON_SPACESIM_MENU 0x070004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601 /* Look around */ +#define DIAXIS_SPACESIM_CLIMB 0x0701C204 /* Climb - Pitch ship up/down */ +#define DIAXIS_SPACESIM_ROTATE 0x07024205 /* Rotate - Turn ship left/right */ +#define DIBUTTON_SPACESIM_VIEW 0x07004404 /* Cycle through view options */ +#define DIBUTTON_SPACESIM_DISPLAY 0x07004405 /* Select next dashboard / heads up display option */ +#define DIBUTTON_SPACESIM_RAISE 0x07004406 /* Raise ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_LOWER 0x07004407 /* Lower ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_GEAR 0x07004408 /* Gear up / down */ +#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409 /* Alternative fire button */ +#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4 /* Fallback move left button */ +#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC /* Fallback move right button */ +#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0 /* Fallback move forward button */ +#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8 /* Fallback move backwards button */ +#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0 /* Fallback throttle up button */ +#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8 /* Fallback throttle down button */ +#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4 /* Fallback turn left button */ +#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC /* Fallback turn right button */ +#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC /* Fallback Glance Right button */ +#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_SPACESIM_DEVICE 0x070044FE /* Show input device and controls */ +#define DIBUTTON_SPACESIM_PAUSE 0x070044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person + Hand to Hand combat is primary objective ---*/ +#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000 +#define DIAXIS_FIGHTINGH_LATERAL 0x08008201 /* Sidestep left/right */ +#define DIAXIS_FIGHTINGH_MOVE 0x08010202 /* Move forward/backward */ +#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401 /* Punch */ +#define DIBUTTON_FIGHTINGH_KICK 0x08000402 /* Kick */ +#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403 /* Block */ +#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404 /* Crouch */ +#define DIBUTTON_FIGHTINGH_JUMP 0x08000405 /* Jump */ +#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406 /* Apply first special move */ +#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407 /* Apply second special move */ +#define DIBUTTON_FIGHTINGH_MENU 0x080004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FIGHTINGH_SELECT 0x08004408 /* Select special move */ +#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601 /* Look around */ +#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409 /* Shows next on-screen display option */ +#define DIAXIS_FIGHTINGH_ROTATE 0x08024203 /* Rotate - Turn body left/right */ +#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A /* Dodge */ +#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4 /* Fallback left sidestep button */ +#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC /* Fallback right sidestep button */ +#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0 /* Fallback forward button */ +#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8 /* Fallback backward button */ +#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE /* Show input device and controls */ +#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person Shooting + Navigation and combat are primary objectives ---*/ +#define DIVIRTUAL_FIGHTING_FPS 0x09000000 +#define DIAXIS_FPS_ROTATE 0x09008201 /* Rotate character left/right */ +#define DIAXIS_FPS_MOVE 0x09010202 /* Move forward/backward */ +#define DIBUTTON_FPS_FIRE 0x09000401 /* Fire */ +#define DIBUTTON_FPS_WEAPONS 0x09000402 /* Select next weapon */ +#define DIBUTTON_FPS_APPLY 0x09000403 /* Use item */ +#define DIBUTTON_FPS_SELECT 0x09000404 /* Select next inventory item */ +#define DIBUTTON_FPS_CROUCH 0x09000405 /* Crouch/ climb down/ swim down */ +#define DIBUTTON_FPS_JUMP 0x09000406 /* Jump/ climb up/ swim up */ +#define DIAXIS_FPS_LOOKUPDOWN 0x09018203 /* Look up / down */ +#define DIBUTTON_FPS_STRAFE 0x09000407 /* Enable strafing while active */ +#define DIBUTTON_FPS_MENU 0x090004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FPS_GLANCE 0x09004601 /* Look around */ +#define DIBUTTON_FPS_DISPLAY 0x09004408 /* Shows next on-screen display option/ map */ +#define DIAXIS_FPS_SIDESTEP 0x09024204 /* Sidestep */ +#define DIBUTTON_FPS_DODGE 0x09004409 /* Dodge */ +#define DIBUTTON_FPS_GLANCEL 0x0900440A /* Glance Left */ +#define DIBUTTON_FPS_GLANCER 0x0900440B /* Glance Right */ +#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C /* Alternative fire button */ +#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4 /* Fallback rotate left button */ +#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC /* Fallback rotate right button */ +#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0 /* Fallback forward button */ +#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8 /* Fallback backward button */ +#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0 /* Fallback look up button */ +#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8 /* Fallback look down button */ +#define DIBUTTON_FPS_STEP_LEFT_LINK 0x090244E4 /* Fallback step left button */ +#define DIBUTTON_FPS_STEP_RIGHT_LINK 0x090244EC /* Fallback step right button */ +#define DIBUTTON_FPS_DEVICE 0x090044FE /* Show input device and controls */ +#define DIBUTTON_FPS_PAUSE 0x090044FC /* Start / Pause / Restart game */ + +/*--- Fighting - Third Person action + Perspective of camera is behind the main character ---*/ +#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000 +#define DIAXIS_TPS_TURN 0x0A020201 /* Turn left/right */ +#define DIAXIS_TPS_MOVE 0x0A010202 /* Move forward/backward */ +#define DIBUTTON_TPS_RUN 0x0A000401 /* Run or walk toggle switch */ +#define DIBUTTON_TPS_ACTION 0x0A000402 /* Action Button */ +#define DIBUTTON_TPS_SELECT 0x0A000403 /* Select next weapon */ +#define DIBUTTON_TPS_USE 0x0A000404 /* Use inventory item currently selected */ +#define DIBUTTON_TPS_JUMP 0x0A000405 /* Character Jumps */ +#define DIBUTTON_TPS_MENU 0x0A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_TPS_GLANCE 0x0A004601 /* Look around */ +#define DIBUTTON_TPS_VIEW 0x0A004406 /* Select camera view */ +#define DIBUTTON_TPS_STEPLEFT 0x0A004407 /* Character takes a left step */ +#define DIBUTTON_TPS_STEPRIGHT 0x0A004408 /* Character takes a right step */ +#define DIAXIS_TPS_STEP 0x0A00C203 /* Character steps left/right */ +#define DIBUTTON_TPS_DODGE 0x0A004409 /* Character dodges or ducks */ +#define DIBUTTON_TPS_INVENTORY 0x0A00440A /* Cycle through inventory */ +#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4 /* Fallback turn left button */ +#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC /* Fallback turn right button */ +#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0 /* Fallback forward button */ +#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8 /* Fallback backward button */ +#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0 /* Fallback look up button */ +#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8 /* Fallback look down button */ +#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4 /* Fallback glance up button */ +#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC /* Fallback glance right button */ +#define DIBUTTON_TPS_DEVICE 0x0A0044FE /* Show input device and controls */ +#define DIBUTTON_TPS_PAUSE 0x0A0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Role Playing + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000 +#define DIAXIS_STRATEGYR_LATERAL 0x0B008201 /* sidestep - left/right */ +#define DIAXIS_STRATEGYR_MOVE 0x0B010202 /* move forward/backward */ +#define DIBUTTON_STRATEGYR_GET 0x0B000401 /* Acquire item */ +#define DIBUTTON_STRATEGYR_APPLY 0x0B000402 /* Use selected item */ +#define DIBUTTON_STRATEGYR_SELECT 0x0B000403 /* Select nextitem */ +#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404 /* Attack */ +#define DIBUTTON_STRATEGYR_CAST 0x0B000405 /* Cast Spell */ +#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406 /* Crouch */ +#define DIBUTTON_STRATEGYR_JUMP 0x0B000407 /* Jump */ +#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601 /* Look around */ +#define DIBUTTON_STRATEGYR_MAP 0x0B004408 /* Cycle through map options */ +#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409 /* Shows next on-screen display option */ +#define DIAXIS_STRATEGYR_ROTATE 0x0B024203 /* Turn body left/right */ +#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8 /* Fallback move backward button */ +#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4 /* Fallback turn body left button */ +#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC /* Fallback turn body right button */ +#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Turn based + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_TURN 0x0C000000 +#define DIAXIS_STRATEGYT_LATERAL 0x0C008201 /* Sidestep left/right */ +#define DIAXIS_STRATEGYT_MOVE 0x0C010202 /* Move forward/backwards */ +#define DIBUTTON_STRATEGYT_SELECT 0x0C000401 /* Select unit or object */ +#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402 /* Cycle through instructions */ +#define DIBUTTON_STRATEGYT_APPLY 0x0C000403 /* Apply selected instruction */ +#define DIBUTTON_STRATEGYT_TEAM 0x0C000404 /* Select next team / cycle through all */ +#define DIBUTTON_STRATEGYT_TURN 0x0C000405 /* Indicate turn over */ +#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406 /* Zoom - in / out */ +#define DIBUTTON_STRATEGYT_MAP 0x0C004407 /* cycle through map options */ +#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408 /* shows next on-screen display options */ +#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8 /* Fallback move back button */ +#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hunting + Hunting ---*/ +#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000 +#define DIAXIS_HUNTING_LATERAL 0x0D008201 /* sidestep left/right */ +#define DIAXIS_HUNTING_MOVE 0x0D010202 /* move forward/backwards */ +#define DIBUTTON_HUNTING_FIRE 0x0D000401 /* Fire selected weapon */ +#define DIBUTTON_HUNTING_AIM 0x0D000402 /* Select aim/move */ +#define DIBUTTON_HUNTING_WEAPON 0x0D000403 /* Select next weapon */ +#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404 /* Look through Binoculars */ +#define DIBUTTON_HUNTING_CALL 0x0D000405 /* Make animal call */ +#define DIBUTTON_HUNTING_MAP 0x0D000406 /* View Map */ +#define DIBUTTON_HUNTING_SPECIAL 0x0D000407 /* Special game operation */ +#define DIBUTTON_HUNTING_MENU 0x0D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601 /* Look around */ +#define DIBUTTON_HUNTING_DISPLAY 0x0D004408 /* show next on-screen display option */ +#define DIAXIS_HUNTING_ROTATE 0x0D024203 /* Turn body left/right */ +#define DIBUTTON_HUNTING_CROUCH 0x0D004409 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_HUNTING_JUMP 0x0D00440A /* Jump/ Climb up / Swim up */ +#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B /* Alternative fire button */ +#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0 /* Fallback move forward button */ +#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8 /* Fallback move back button */ +#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4 /* Fallback turn body left button */ +#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC /* Fallback turn body right button */ +#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE /* Show input device and controls */ +#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Fishing + Catching Fish is primary objective ---*/ +#define DIVIRTUAL_SPORTS_FISHING 0x0E000000 +#define DIAXIS_FISHING_LATERAL 0x0E008201 /* sidestep left/right */ +#define DIAXIS_FISHING_MOVE 0x0E010202 /* move forward/backwards */ +#define DIBUTTON_FISHING_CAST 0x0E000401 /* Cast line */ +#define DIBUTTON_FISHING_TYPE 0x0E000402 /* Select cast type */ +#define DIBUTTON_FISHING_BINOCULAR 0x0E000403 /* Look through Binocular */ +#define DIBUTTON_FISHING_BAIT 0x0E000404 /* Select type of Bait */ +#define DIBUTTON_FISHING_MAP 0x0E000405 /* View Map */ +#define DIBUTTON_FISHING_MENU 0x0E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FISHING_GLANCE 0x0E004601 /* Look around */ +#define DIBUTTON_FISHING_DISPLAY 0x0E004406 /* Show next on-screen display option */ +#define DIAXIS_FISHING_ROTATE 0x0E024203 /* Turn character left / right */ +#define DIBUTTON_FISHING_CROUCH 0x0E004407 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_FISHING_JUMP 0x0E004408 /* Jump/ Climb up / Swim up */ +#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0 /* Fallback move forward button */ +#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8 /* Fallback move back button */ +#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4 /* Fallback turn body left button */ +#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC /* Fallback turn body right button */ +#define DIBUTTON_FISHING_DEVICE 0x0E0044FE /* Show input device and controls */ +#define DIBUTTON_FISHING_PAUSE 0x0E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Batting + Batter control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000 +#define DIAXIS_BASEBALLB_LATERAL 0x0F008201 /* Aim left / right */ +#define DIAXIS_BASEBALLB_MOVE 0x0F010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLB_SELECT 0x0F000401 /* cycle through swing options */ +#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402 /* normal swing */ +#define DIBUTTON_BASEBALLB_POWER 0x0F000403 /* swing for the fence */ +#define DIBUTTON_BASEBALLB_BUNT 0x0F000404 /* bunt */ +#define DIBUTTON_BASEBALLB_STEAL 0x0F000405 /* Base runner attempts to steal a base */ +#define DIBUTTON_BASEBALLB_BURST 0x0F000406 /* Base runner invokes burst of speed */ +#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407 /* Base runner slides into base */ +#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408 /* Contact swing */ +#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409 /* Base runner goes back to a base */ +#define DIBUTTON_BASEBALLB_BOX 0x0F00440A /* Enter or exit batting box */ +#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Pitching + Pitcher control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000 +#define DIAXIS_BASEBALLP_LATERAL 0x10008201 /* Aim left / right */ +#define DIAXIS_BASEBALLP_MOVE 0x10010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLP_SELECT 0x10000401 /* cycle through pitch selections */ +#define DIBUTTON_BASEBALLP_PITCH 0x10000402 /* throw pitch */ +#define DIBUTTON_BASEBALLP_BASE 0x10000403 /* select base to throw to */ +#define DIBUTTON_BASEBALLP_THROW 0x10000404 /* throw to base */ +#define DIBUTTON_BASEBALLP_FAKE 0x10000405 /* Fake a throw to a base */ +#define DIBUTTON_BASEBALLP_MENU 0x100004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLP_WALK 0x10004406 /* Throw intentional walk / pitch out */ +#define DIBUTTON_BASEBALLP_LOOK 0x10004407 /* Look at runners on bases */ +#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Fielding + Fielder control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000 +#define DIAXIS_BASEBALLF_LATERAL 0x11008201 /* Aim left / right */ +#define DIAXIS_BASEBALLF_MOVE 0x11010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLF_NEAREST 0x11000401 /* Switch to fielder nearest to the ball */ +#define DIBUTTON_BASEBALLF_THROW1 0x11000402 /* Make conservative throw */ +#define DIBUTTON_BASEBALLF_THROW2 0x11000403 /* Make aggressive throw */ +#define DIBUTTON_BASEBALLF_BURST 0x11000404 /* Invoke burst of speed */ +#define DIBUTTON_BASEBALLF_JUMP 0x11000405 /* Jump to catch ball */ +#define DIBUTTON_BASEBALLF_DIVE 0x11000406 /* Dive to catch ball */ +#define DIBUTTON_BASEBALLF_MENU 0x110004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407 /* Shift the infield positioning */ +#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408 /* Shift the outfield positioning */ +#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4 /* Fallback aim left button */ +#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC /* Fallback aim right button */ +#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000 +#define DIAXIS_BBALLO_LATERAL 0x12008201 /* left / right */ +#define DIAXIS_BBALLO_MOVE 0x12010202 /* up / down */ +#define DIBUTTON_BBALLO_SHOOT 0x12000401 /* shoot basket */ +#define DIBUTTON_BBALLO_DUNK 0x12000402 /* dunk basket */ +#define DIBUTTON_BBALLO_PASS 0x12000403 /* throw pass */ +#define DIBUTTON_BBALLO_FAKE 0x12000404 /* fake shot or pass */ +#define DIBUTTON_BBALLO_SPECIAL 0x12000405 /* apply special move */ +#define DIBUTTON_BBALLO_PLAYER 0x12000406 /* select next player */ +#define DIBUTTON_BBALLO_BURST 0x12000407 /* invoke burst */ +#define DIBUTTON_BBALLO_CALL 0x12000408 /* call for ball / pass to me */ +#define DIBUTTON_BBALLO_MENU 0x120004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLO_GLANCE 0x12004601 /* scroll view */ +#define DIBUTTON_BBALLO_SCREEN 0x12004409 /* Call for screen */ +#define DIBUTTON_BBALLO_PLAY 0x1200440A /* Call for specific offensive play */ +#define DIBUTTON_BBALLO_JAB 0x1200440B /* Initiate fake drive to basket */ +#define DIBUTTON_BBALLO_POST 0x1200440C /* Perform post move */ +#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D /* Time Out */ +#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E /* substitute one player for another */ +#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLO_DEVICE 0x120044FE /* Show input device and controls */ +#define DIBUTTON_BBALLO_PAUSE 0x120044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000 +#define DIAXIS_BBALLD_LATERAL 0x13008201 /* left / right */ +#define DIAXIS_BBALLD_MOVE 0x13010202 /* up / down */ +#define DIBUTTON_BBALLD_JUMP 0x13000401 /* jump to block shot */ +#define DIBUTTON_BBALLD_STEAL 0x13000402 /* attempt to steal ball */ +#define DIBUTTON_BBALLD_FAKE 0x13000403 /* fake block or steal */ +#define DIBUTTON_BBALLD_SPECIAL 0x13000404 /* apply special move */ +#define DIBUTTON_BBALLD_PLAYER 0x13000405 /* select next player */ +#define DIBUTTON_BBALLD_BURST 0x13000406 /* invoke burst */ +#define DIBUTTON_BBALLD_PLAY 0x13000407 /* call for specific defensive play */ +#define DIBUTTON_BBALLD_MENU 0x130004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLD_GLANCE 0x13004601 /* scroll view */ +#define DIBUTTON_BBALLD_TIMEOUT 0x13004408 /* Time Out */ +#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409 /* substitute one player for another */ +#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLD_DEVICE 0x130044FE /* Show input device and controls */ +#define DIBUTTON_BBALLD_PAUSE 0x130044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Play + Play selection ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000 +#define DIBUTTON_FOOTBALLP_PLAY 0x14000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLP_SELECT 0x14000402 /* select play */ +#define DIBUTTON_FOOTBALLP_HELP 0x14000403 /* Bring up pop-up help */ +#define DIBUTTON_FOOTBALLP_MENU 0x140004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - QB + Offense: Quarterback / Kicker ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000 +#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLQ_MOVE 0x15010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401 /* Select */ +#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402 /* snap ball - start play */ +#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403 /* jump over defender */ +#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404 /* Dive/Slide */ +#define DIBUTTON_FOOTBALLQ_PASS 0x15000405 /* throws pass to receiver */ +#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406 /* pump fake pass or fake kick */ +#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407 /* Fake snap */ +#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408 /* Send receivers in motion */ +#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409 /* Change offensive play at line of scrimmage */ +#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Offense + Offense - Runner ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000 +#define DIAXIS_FOOTBALLO_LATERAL 0x16008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLO_MOVE 0x16010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLO_JUMP 0x16000401 /* jump or hurdle over defender */ +#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402 /* holds out left arm */ +#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403 /* holds out right arm */ +#define DIBUTTON_FOOTBALLO_THROW 0x16000404 /* throw pass or lateral ball to another runner */ +#define DIBUTTON_FOOTBALLO_SPIN 0x16000405 /* Spin to avoid defenders */ +#define DIBUTTON_FOOTBALLO_MENU 0x160004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLO_JUKE 0x16004406 /* Use special move to avoid defenders */ +#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407 /* Lower shoulder to run over defenders */ +#define DIBUTTON_FOOTBALLO_TURBO 0x16004408 /* Speed burst past defenders */ +#define DIBUTTON_FOOTBALLO_DIVE 0x16004409 /* Dive over defenders */ +#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B /* substitute one player for another */ +#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000 +#define DIAXIS_FOOTBALLD_LATERAL 0x17008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLD_MOVE 0x17010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLD_PLAY 0x17000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLD_SELECT 0x17000402 /* select player closest to the ball */ +#define DIBUTTON_FOOTBALLD_JUMP 0x17000403 /* jump to intercept or block */ +#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404 /* tackler runner */ +#define DIBUTTON_FOOTBALLD_FAKE 0x17000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406 /* Initiate special tackle */ +#define DIBUTTON_FOOTBALLD_MENU 0x170004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLD_SPIN 0x17004407 /* Spin to beat offensive line */ +#define DIBUTTON_FOOTBALLD_SWIM 0x17004408 /* Swim to beat the offensive line */ +#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409 /* Bull rush the offensive line */ +#define DIBUTTON_FOOTBALLD_RIP 0x1700440A /* Rip the offensive line */ +#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B /* Change defensive play at the line of scrimmage */ +#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D /* substitute one player for another */ +#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC /* Start / Pause / Restart game */ + +/*--- Sports - Golf + ---*/ +#define DIVIRTUAL_SPORTS_GOLF 0x18000000 +#define DIAXIS_GOLF_LATERAL 0x18008201 /* Move / Aim: left / right */ +#define DIAXIS_GOLF_MOVE 0x18010202 /* Move / Aim: up / down */ +#define DIBUTTON_GOLF_SWING 0x18000401 /* swing club */ +#define DIBUTTON_GOLF_SELECT 0x18000402 /* cycle between: club / swing strength / ball arc / ball spin */ +#define DIBUTTON_GOLF_UP 0x18000403 /* increase selection */ +#define DIBUTTON_GOLF_DOWN 0x18000404 /* decrease selection */ +#define DIBUTTON_GOLF_TERRAIN 0x18000405 /* shows terrain detail */ +#define DIBUTTON_GOLF_FLYBY 0x18000406 /* view the hole via a flyby */ +#define DIBUTTON_GOLF_MENU 0x180004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_GOLF_SCROLL 0x18004601 /* scroll view */ +#define DIBUTTON_GOLF_ZOOM 0x18004407 /* Zoom view in / out */ +#define DIBUTTON_GOLF_TIMEOUT 0x18004408 /* Call for time out */ +#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409 /* substitute one player for another */ +#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC /* Fallback sidestep right button */ +#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0 /* Fallback move forward button */ +#define DIBUTTON_GOLF_BACK_LINK 0x180144E8 /* Fallback move back button */ +#define DIBUTTON_GOLF_DEVICE 0x180044FE /* Show input device and controls */ +#define DIBUTTON_GOLF_PAUSE 0x180044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000 +#define DIAXIS_HOCKEYO_LATERAL 0x19008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYO_MOVE 0x19010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYO_SHOOT 0x19000401 /* Shoot */ +#define DIBUTTON_HOCKEYO_PASS 0x19000402 /* pass the puck */ +#define DIBUTTON_HOCKEYO_BURST 0x19000403 /* invoke speed burst */ +#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404 /* invoke special move */ +#define DIBUTTON_HOCKEYO_FAKE 0x19000405 /* hold down to fake pass or kick */ +#define DIBUTTON_HOCKEYO_MENU 0x190004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601 /* scroll view */ +#define DIBUTTON_HOCKEYO_ZOOM 0x19004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408 /* Call for time out */ +#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000 +#define DIAXIS_HOCKEYD_LATERAL 0x1A008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYD_MOVE 0x1A010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401 /* control player closest to the puck */ +#define DIBUTTON_HOCKEYD_STEAL 0x1A000402 /* attempt steal */ +#define DIBUTTON_HOCKEYD_BURST 0x1A000403 /* speed burst or body check */ +#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404 /* block puck */ +#define DIBUTTON_HOCKEYD_FAKE 0x1A000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601 /* scroll view */ +#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408 /* Call for time out */ +#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Goalie + Goal tending ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000 +#define DIAXIS_HOCKEYG_LATERAL 0x1B008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYG_MOVE 0x1B010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYG_PASS 0x1B000401 /* pass puck */ +#define DIBUTTON_HOCKEYG_POKE 0x1B000402 /* poke / check / hack */ +#define DIBUTTON_HOCKEYG_STEAL 0x1B000403 /* attempt steal */ +#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404 /* block puck */ +#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601 /* scroll view */ +#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407 /* Call for time out */ +#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408 /* substitute one player for another */ +#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Mountain Biking + ---*/ +#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000 +#define DIAXIS_BIKINGM_TURN 0x1C008201 /* left / right */ +#define DIAXIS_BIKINGM_PEDAL 0x1C010202 /* Pedal faster / slower / brake */ +#define DIBUTTON_BIKINGM_JUMP 0x1C000401 /* jump over obstacle */ +#define DIBUTTON_BIKINGM_CAMERA 0x1C000402 /* switch camera view */ +#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403 /* perform first special move */ +#define DIBUTTON_BIKINGM_SELECT 0x1C000404 /* Select */ +#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405 /* perform second special move */ +#define DIBUTTON_BIKINGM_MENU 0x1C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601 /* scroll view */ +#define DIBUTTON_BIKINGM_ZOOM 0x1C004406 /* Zoom view in / out */ +#define DIAXIS_BIKINGM_BRAKE 0x1C044203 /* Brake axis */ +#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4 /* Fallback turn left button */ +#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC /* Fallback turn right button */ +#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0 /* Fallback pedal faster button */ +#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8 /* Fallback pedal slower button */ +#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8 /* Fallback brake button */ +#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE /* Show input device and controls */ +#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC /* Start / Pause / Restart game */ + +/*--- Sports: Skiing / Snowboarding / Skateboarding + ---*/ +#define DIVIRTUAL_SPORTS_SKIING 0x1D000000 +#define DIAXIS_SKIING_TURN 0x1D008201 /* left / right */ +#define DIAXIS_SKIING_SPEED 0x1D010202 /* faster / slower */ +#define DIBUTTON_SKIING_JUMP 0x1D000401 /* Jump */ +#define DIBUTTON_SKIING_CROUCH 0x1D000402 /* crouch down */ +#define DIBUTTON_SKIING_CAMERA 0x1D000403 /* switch camera view */ +#define DIBUTTON_SKIING_SPECIAL1 0x1D000404 /* perform first special move */ +#define DIBUTTON_SKIING_SELECT 0x1D000405 /* Select */ +#define DIBUTTON_SKIING_SPECIAL2 0x1D000406 /* perform second special move */ +#define DIBUTTON_SKIING_MENU 0x1D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SKIING_GLANCE 0x1D004601 /* scroll view */ +#define DIBUTTON_SKIING_ZOOM 0x1D004407 /* Zoom view in / out */ +#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4 /* Fallback turn left button */ +#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC /* Fallback turn right button */ +#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0 /* Fallback increase speed button */ +#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8 /* Fallback decrease speed button */ +#define DIBUTTON_SKIING_DEVICE 0x1D0044FE /* Show input device and controls */ +#define DIBUTTON_SKIING_PAUSE 0x1D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000 +#define DIAXIS_SOCCERO_LATERAL 0x1E008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERO_MOVE 0x1E010202 /* Move / Aim: up / down */ +#define DIAXIS_SOCCERO_BEND 0x1E018203 /* Bend to soccer shot/pass */ +#define DIBUTTON_SOCCERO_SHOOT 0x1E000401 /* Shoot the ball */ +#define DIBUTTON_SOCCERO_PASS 0x1E000402 /* Pass */ +#define DIBUTTON_SOCCERO_FAKE 0x1E000403 /* Fake */ +#define DIBUTTON_SOCCERO_PLAYER 0x1E000404 /* Select next player */ +#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405 /* Apply special move */ +#define DIBUTTON_SOCCERO_SELECT 0x1E000406 /* Select special move */ +#define DIBUTTON_SOCCERO_MENU 0x1E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601 /* scroll view */ +#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407 /* Substitute one player for another */ +#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408 /* Shoot the ball low */ +#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409 /* Shoot the ball high */ +#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A /* Make a thru pass */ +#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B /* Sprint / turbo boost */ +#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C /* Obtain control of the ball */ +#define DIBUTTON_SOCCERO_HEAD 0x1E00440D /* Attempt to head the ball */ +#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000 +#define DIAXIS_SOCCERD_LATERAL 0x1F008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERD_MOVE 0x1F010202 /* Move / Aim: up / down */ +#define DIBUTTON_SOCCERD_BLOCK 0x1F000401 /* Attempt to block shot */ +#define DIBUTTON_SOCCERD_STEAL 0x1F000402 /* Attempt to steal ball */ +#define DIBUTTON_SOCCERD_FAKE 0x1F000403 /* Fake a block or a steal */ +#define DIBUTTON_SOCCERD_PLAYER 0x1F000404 /* Select next player */ +#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405 /* Apply special move */ +#define DIBUTTON_SOCCERD_SELECT 0x1F000406 /* Select special move */ +#define DIBUTTON_SOCCERD_SLIDE 0x1F000407 /* Attempt a slide tackle */ +#define DIBUTTON_SOCCERD_MENU 0x1F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601 /* scroll view */ +#define DIBUTTON_SOCCERD_FOUL 0x1F004408 /* Initiate a foul / hard-foul */ +#define DIBUTTON_SOCCERD_HEAD 0x1F004409 /* Attempt a Header */ +#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A /* Attempt to clear the ball down the field */ +#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B /* Make the goalie charge out of the box */ +#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C /* Substitute one player for another */ +#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Racquet + Tennis - Table-Tennis - Squash ---*/ +#define DIVIRTUAL_SPORTS_RACQUET 0x20000000 +#define DIAXIS_RACQUET_LATERAL 0x20008201 /* Move / Aim: left / right */ +#define DIAXIS_RACQUET_MOVE 0x20010202 /* Move / Aim: up / down */ +#define DIBUTTON_RACQUET_SWING 0x20000401 /* Swing racquet */ +#define DIBUTTON_RACQUET_BACKSWING 0x20000402 /* Swing backhand */ +#define DIBUTTON_RACQUET_SMASH 0x20000403 /* Smash shot */ +#define DIBUTTON_RACQUET_SPECIAL 0x20000404 /* Special shot */ +#define DIBUTTON_RACQUET_SELECT 0x20000405 /* Select special shot */ +#define DIBUTTON_RACQUET_MENU 0x200004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_RACQUET_GLANCE 0x20004601 /* scroll view */ +#define DIBUTTON_RACQUET_TIMEOUT 0x20004406 /* Call for time out */ +#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407 /* Substitute one player for another */ +#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0 /* Fallback move forward button */ +#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8 /* Fallback move back button */ +#define DIBUTTON_RACQUET_DEVICE 0x200044FE /* Show input device and controls */ +#define DIBUTTON_RACQUET_PAUSE 0x200044FC /* Start / Pause / Restart game */ + +/*--- Arcade- 2D + Side to Side movement ---*/ +#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000 +#define DIAXIS_ARCADES_LATERAL 0x21008201 /* left / right */ +#define DIAXIS_ARCADES_MOVE 0x21010202 /* up / down */ +#define DIBUTTON_ARCADES_THROW 0x21000401 /* throw object */ +#define DIBUTTON_ARCADES_CARRY 0x21000402 /* carry object */ +#define DIBUTTON_ARCADES_ATTACK 0x21000403 /* attack */ +#define DIBUTTON_ARCADES_SPECIAL 0x21000404 /* apply special move */ +#define DIBUTTON_ARCADES_SELECT 0x21000405 /* select special move */ +#define DIBUTTON_ARCADES_MENU 0x210004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADES_VIEW 0x21004601 /* scroll view left / right / up / down */ +#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADES_DEVICE 0x210044FE /* Show input device and controls */ +#define DIBUTTON_ARCADES_PAUSE 0x210044FC /* Start / Pause / Restart game */ + +/*--- Arcade - Platform Game + Character moves around on screen ---*/ +#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000 +#define DIAXIS_ARCADEP_LATERAL 0x22008201 /* Left / right */ +#define DIAXIS_ARCADEP_MOVE 0x22010202 /* Up / down */ +#define DIBUTTON_ARCADEP_JUMP 0x22000401 /* Jump */ +#define DIBUTTON_ARCADEP_FIRE 0x22000402 /* Fire */ +#define DIBUTTON_ARCADEP_CROUCH 0x22000403 /* Crouch */ +#define DIBUTTON_ARCADEP_SPECIAL 0x22000404 /* Apply special move */ +#define DIBUTTON_ARCADEP_SELECT 0x22000405 /* Select special move */ +#define DIBUTTON_ARCADEP_MENU 0x220004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADEP_VIEW 0x22004601 /* Scroll view */ +#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406 /* Alternative fire button */ +#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADEP_DEVICE 0x220044FE /* Show input device and controls */ +#define DIBUTTON_ARCADEP_PAUSE 0x220044FC /* Start / Pause / Restart game */ + +/*--- CAD - 2D Object Control + Controls to select and move objects in 2D ---*/ +#define DIVIRTUAL_CAD_2DCONTROL 0x23000000 +#define DIAXIS_2DCONTROL_LATERAL 0x23008201 /* Move view left / right */ +#define DIAXIS_2DCONTROL_MOVE 0x23010202 /* Move view up / down */ +#define DIAXIS_2DCONTROL_INOUT 0x23018203 /* Zoom - in / out */ +#define DIBUTTON_2DCONTROL_SELECT 0x23000401 /* Select Object */ +#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402 /* Do first special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403 /* Select special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404 /* Do second special operation */ +#define DIBUTTON_2DCONTROL_MENU 0x230004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601 /* Hat switch */ +#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204 /* Rotate view clockwise / counterclockwise */ +#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405 /* Shows next on-screen display options */ +#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE /* Show input device and controls */ +#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D object control + Controls to select and move objects within a 3D environment ---*/ +#define DIVIRTUAL_CAD_3DCONTROL 0x24000000 +#define DIAXIS_3DCONTROL_LATERAL 0x24008201 /* Move view left / right */ +#define DIAXIS_3DCONTROL_MOVE 0x24010202 /* Move view up / down */ +#define DIAXIS_3DCONTROL_INOUT 0x24018203 /* Zoom - in / out */ +#define DIBUTTON_3DCONTROL_SELECT 0x24000401 /* Select Object */ +#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402 /* Do first special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403 /* Select special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404 /* Do second special operation */ +#define DIBUTTON_3DCONTROL_MENU 0x240004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601 /* Hat switch */ +#define DIAXIS_3DCONTROL_ROTATEX 0x24034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206 /* Rotate view left / right */ +#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405 /* Show next on-screen display options */ +#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE /* Show input device and controls */ +#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Navigation - Fly through + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_FLYBY 0x25000000 +#define DIAXIS_CADF_LATERAL 0x25008201 /* move view left / right */ +#define DIAXIS_CADF_MOVE 0x25010202 /* move view up / down */ +#define DIAXIS_CADF_INOUT 0x25018203 /* in / out */ +#define DIBUTTON_CADF_SELECT 0x25000401 /* Select Object */ +#define DIBUTTON_CADF_SPECIAL1 0x25000402 /* do first special operation */ +#define DIBUTTON_CADF_SPECIAL 0x25000403 /* Select special operation */ +#define DIBUTTON_CADF_SPECIAL2 0x25000404 /* do second special operation */ +#define DIBUTTON_CADF_MENU 0x250004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADF_HATSWITCH 0x25004601 /* Hat switch */ +#define DIAXIS_CADF_ROTATEX 0x25034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADF_ROTATEY 0x2502C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADF_ROTATEZ 0x25024206 /* Rotate view left / right */ +#define DIBUTTON_CADF_DISPLAY 0x25004405 /* shows next on-screen display options */ +#define DIBUTTON_CADF_DEVICE 0x250044FE /* Show input device and controls */ +#define DIBUTTON_CADF_PAUSE 0x250044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Model Control + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_MODEL 0x26000000 +#define DIAXIS_CADM_LATERAL 0x26008201 /* move view left / right */ +#define DIAXIS_CADM_MOVE 0x26010202 /* move view up / down */ +#define DIAXIS_CADM_INOUT 0x26018203 /* in / out */ +#define DIBUTTON_CADM_SELECT 0x26000401 /* Select Object */ +#define DIBUTTON_CADM_SPECIAL1 0x26000402 /* do first special operation */ +#define DIBUTTON_CADM_SPECIAL 0x26000403 /* Select special operation */ +#define DIBUTTON_CADM_SPECIAL2 0x26000404 /* do second special operation */ +#define DIBUTTON_CADM_MENU 0x260004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADM_HATSWITCH 0x26004601 /* Hat switch */ +#define DIAXIS_CADM_ROTATEX 0x26034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADM_ROTATEY 0x2602C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADM_ROTATEZ 0x26024206 /* Rotate view left / right */ +#define DIBUTTON_CADM_DISPLAY 0x26004405 /* shows next on-screen display options */ +#define DIBUTTON_CADM_DEVICE 0x260044FE /* Show input device and controls */ +#define DIBUTTON_CADM_PAUSE 0x260044FC /* Start / Pause / Restart game */ + +/*--- Control - Media Equipment + Remote ---*/ +#define DIVIRTUAL_REMOTE_CONTROL 0x27000000 +#define DIAXIS_REMOTE_SLIDER 0x27050201 /* Slider for adjustment: volume / color / bass / etc */ +#define DIBUTTON_REMOTE_MUTE 0x27000401 /* Set volume on current device to zero */ +#define DIBUTTON_REMOTE_SELECT 0x27000402 /* Next/previous: channel/ track / chapter / picture / station */ +#define DIBUTTON_REMOTE_PLAY 0x27002403 /* Start or pause entertainment on current device */ +#define DIBUTTON_REMOTE_CUE 0x27002404 /* Move through current media */ +#define DIBUTTON_REMOTE_REVIEW 0x27002405 /* Move through current media */ +#define DIBUTTON_REMOTE_CHANGE 0x27002406 /* Select next device */ +#define DIBUTTON_REMOTE_RECORD 0x27002407 /* Start recording the current media */ +#define DIBUTTON_REMOTE_MENU 0x270004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_REMOTE_SLIDER2 0x27054202 /* Slider for adjustment: volume */ +#define DIBUTTON_REMOTE_TV 0x27005C08 /* Select TV */ +#define DIBUTTON_REMOTE_CABLE 0x27005C09 /* Select cable box */ +#define DIBUTTON_REMOTE_CD 0x27005C0A /* Select CD player */ +#define DIBUTTON_REMOTE_VCR 0x27005C0B /* Select VCR */ +#define DIBUTTON_REMOTE_TUNER 0x27005C0C /* Select tuner */ +#define DIBUTTON_REMOTE_DVD 0x27005C0D /* Select DVD player */ +#define DIBUTTON_REMOTE_ADJUST 0x27005C0E /* Enter device adjustment menu */ +#define DIBUTTON_REMOTE_DIGIT0 0x2700540F /* Digit 0 */ +#define DIBUTTON_REMOTE_DIGIT1 0x27005410 /* Digit 1 */ +#define DIBUTTON_REMOTE_DIGIT2 0x27005411 /* Digit 2 */ +#define DIBUTTON_REMOTE_DIGIT3 0x27005412 /* Digit 3 */ +#define DIBUTTON_REMOTE_DIGIT4 0x27005413 /* Digit 4 */ +#define DIBUTTON_REMOTE_DIGIT5 0x27005414 /* Digit 5 */ +#define DIBUTTON_REMOTE_DIGIT6 0x27005415 /* Digit 6 */ +#define DIBUTTON_REMOTE_DIGIT7 0x27005416 /* Digit 7 */ +#define DIBUTTON_REMOTE_DIGIT8 0x27005417 /* Digit 8 */ +#define DIBUTTON_REMOTE_DIGIT9 0x27005418 /* Digit 9 */ +#define DIBUTTON_REMOTE_DEVICE 0x270044FE /* Show input device and controls */ +#define DIBUTTON_REMOTE_PAUSE 0x270044FC /* Start / Pause / Restart game */ + +/*--- Control- Web + Help or Browser ---*/ +#define DIVIRTUAL_BROWSER_CONTROL 0x28000000 +#define DIAXIS_BROWSER_LATERAL 0x28008201 /* Move on screen pointer */ +#define DIAXIS_BROWSER_MOVE 0x28010202 /* Move on screen pointer */ +#define DIBUTTON_BROWSER_SELECT 0x28000401 /* Select current item */ +#define DIAXIS_BROWSER_VIEW 0x28018203 /* Move view up/down */ +#define DIBUTTON_BROWSER_REFRESH 0x28000402 /* Refresh */ +#define DIBUTTON_BROWSER_MENU 0x280004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BROWSER_SEARCH 0x28004403 /* Use search tool */ +#define DIBUTTON_BROWSER_STOP 0x28004404 /* Cease current update */ +#define DIBUTTON_BROWSER_HOME 0x28004405 /* Go directly to "home" location */ +#define DIBUTTON_BROWSER_FAVORITES 0x28004406 /* Mark current site as favorite */ +#define DIBUTTON_BROWSER_NEXT 0x28004407 /* Select Next page */ +#define DIBUTTON_BROWSER_PREVIOUS 0x28004408 /* Select Previous page */ +#define DIBUTTON_BROWSER_HISTORY 0x28004409 /* Show/Hide History */ +#define DIBUTTON_BROWSER_PRINT 0x2800440A /* Print current page */ +#define DIBUTTON_BROWSER_DEVICE 0x280044FE /* Show input device and controls */ +#define DIBUTTON_BROWSER_PAUSE 0x280044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Giant Walking Robot + Walking tank with weapons ---*/ +#define DIVIRTUAL_DRIVING_MECHA 0x29000000 +#define DIAXIS_MECHA_STEER 0x29008201 /* Turns mecha left/right */ +#define DIAXIS_MECHA_TORSO 0x29010202 /* Tilts torso forward/backward */ +#define DIAXIS_MECHA_ROTATE 0x29020203 /* Turns torso left/right */ +#define DIAXIS_MECHA_THROTTLE 0x29038204 /* Engine Speed */ +#define DIBUTTON_MECHA_FIRE 0x29000401 /* Fire */ +#define DIBUTTON_MECHA_WEAPONS 0x29000402 /* Select next weapon group */ +#define DIBUTTON_MECHA_TARGET 0x29000403 /* Select closest enemy available target */ +#define DIBUTTON_MECHA_REVERSE 0x29000404 /* Toggles throttle in/out of reverse */ +#define DIBUTTON_MECHA_ZOOM 0x29000405 /* Zoom in/out targeting reticule */ +#define DIBUTTON_MECHA_JUMP 0x29000406 /* Fires jump jets */ +#define DIBUTTON_MECHA_MENU 0x290004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_MECHA_CENTER 0x29004407 /* Center torso to legs */ +#define DIHATSWITCH_MECHA_GLANCE 0x29004601 /* Look around */ +#define DIBUTTON_MECHA_VIEW 0x29004408 /* Cycle through view options */ +#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409 /* Alternative fire button */ +#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4 /* Fallback steer left button */ +#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC /* Fallback steer right button */ +#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0 /* Fallback tilt torso forward button */ +#define DIBUTTON_MECHA_BACK_LINK 0x290144E8 /* Fallback tilt toroso backward button */ +#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4 /* Fallback rotate toroso right button */ +#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC /* Fallback rotate torso left button */ +#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0 /* Fallback increase engine speed */ +#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8 /* Fallback decrease engine speed */ +#define DIBUTTON_MECHA_DEVICE 0x290044FE /* Show input device and controls */ +#define DIBUTTON_MECHA_PAUSE 0x290044FC /* Start / Pause / Restart game */ + +/* + * "ANY" semantics can be used as a last resort to get mappings for actions + * that match nothing in the chosen virtual genre. These semantics will be + * mapped at a lower priority that virtual genre semantics. Also, hardware + * vendors will not be able to provide sensible mappings for these unless + * they provide application specific mappings. + */ +#define DIAXIS_ANY_X_1 0xFF00C201 +#define DIAXIS_ANY_X_2 0xFF00C202 +#define DIAXIS_ANY_Y_1 0xFF014201 +#define DIAXIS_ANY_Y_2 0xFF014202 +#define DIAXIS_ANY_Z_1 0xFF01C201 +#define DIAXIS_ANY_Z_2 0xFF01C202 +#define DIAXIS_ANY_R_1 0xFF024201 +#define DIAXIS_ANY_R_2 0xFF024202 +#define DIAXIS_ANY_U_1 0xFF02C201 +#define DIAXIS_ANY_U_2 0xFF02C202 +#define DIAXIS_ANY_V_1 0xFF034201 +#define DIAXIS_ANY_V_2 0xFF034202 +#define DIAXIS_ANY_A_1 0xFF03C201 +#define DIAXIS_ANY_A_2 0xFF03C202 +#define DIAXIS_ANY_B_1 0xFF044201 +#define DIAXIS_ANY_B_2 0xFF044202 +#define DIAXIS_ANY_C_1 0xFF04C201 +#define DIAXIS_ANY_C_2 0xFF04C202 +#define DIAXIS_ANY_S_1 0xFF054201 +#define DIAXIS_ANY_S_2 0xFF054202 + +#define DIAXIS_ANY_1 0xFF004201 +#define DIAXIS_ANY_2 0xFF004202 +#define DIAXIS_ANY_3 0xFF004203 +#define DIAXIS_ANY_4 0xFF004204 + +#define DIPOV_ANY_1 0xFF004601 +#define DIPOV_ANY_2 0xFF004602 +#define DIPOV_ANY_3 0xFF004603 +#define DIPOV_ANY_4 0xFF004604 + +#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance ) + + +#ifdef __cplusplus +}; +#endif + +#endif /* __DINPUT_INCLUDED__ */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current sdk files + * + ****************************************************************************/ + +#ifdef _INC_MMSYSTEM +#ifndef MMNOJOY + +#ifndef __VJOYDX_INCLUDED__ +#define __VJOYDX_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flag to indicate that the dwReserved2 field of the JOYINFOEX structure + * contains mini-driver specific data to be passed by VJoyD to the mini- + * driver instead of doing a poll. + */ +#define JOY_PASSDRIVERDATA 0x10000000l + +/* + * Informs the joystick driver that the configuration has been changed + * and should be reloaded from the registery. + * dwFlags is reserved and should be set to zero + */ +WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags ); + +#ifndef DIJ_RINGZERO +/* + * Invoke the joystick control panel directly, using the passed window handle + * as the parent of the dialog. This API is only supported for compatibility + * purposes; new applications should use the RunControlPanel method of a + * device interface for a game controller. + * The API is called by using the function pointer returned by + * GetProcAddress( hCPL, TEXT("ShowJoyCPL") ) where hCPL is a HMODULE returned + * by LoadLibrary( TEXT("joy.cpl") ). The typedef is provided to allow + * declaration and casting of an appropriately typed variable. + */ +void WINAPI ShowJoyCPL( HWND hWnd ); +typedef void (WINAPI* LPFNSHOWJOYCPL)( HWND hWnd ); +#endif /* DIJ_RINGZERO */ + + +/* + * Hardware Setting indicating that the device is a headtracker + */ +#define JOY_HWS_ISHEADTRACKER 0x02000000l + +/* + * Hardware Setting indicating that the VxD is used to replace + * the standard analog polling + */ +#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l + +/* + * Hardware Setting indicating that the driver needs a standard + * gameport in order to communicate with the device. + */ +#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l + +/* + * Hardware Setting indicating that VJoyD should not load this + * driver, it will be loaded externally and will register with + * VJoyD of it's own accord. + */ +#define JOY_HWS_AUTOLOAD 0x10000000l + +/* + * Hardware Setting indicating that the driver acquires any + * resources needed without needing a devnode through VJoyD. + */ +#define JOY_HWS_NODEVNODE 0x20000000l + + +/* + * Hardware Setting indicating that the device is a gameport bus + */ +#define JOY_HWS_ISGAMEPORTBUS 0x80000000l +#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l + +/* + * Usage Setting indicating that the settings are volatile and + * should be removed if still present on a reboot. + */ +#define JOY_US_VOLATILE 0x00000008L + +#ifdef __cplusplus +}; +#endif + +#endif /* __VJOYDX_INCLUDED__ */ + +#endif /* not MMNOJOY */ +#endif /* _INC_MMSYSTEM */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current ddk files + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#ifdef _INC_MMDDK +#ifndef MMNOJOYDEV + +#ifndef __VJOYDXD_INCLUDED__ +#define __VJOYDXD_INCLUDED__ +/* + * Poll type in which the do_other field of the JOYOEMPOLLDATA + * structure contains mini-driver specific data passed from an app. + */ +#define JOY_OEMPOLL_PASSDRIVERDATA 7 + +#endif /* __VJOYDXD_INCLUDED__ */ + +#endif /* not MMNOJOYDEV */ +#endif /* _INC_MMDDK */ + +#endif /* DIJ_RINGZERO */ + diff --git a/win32/directx/dinput.lib b/win32/directx/dinput.lib new file mode 100644 index 0000000..3abb454 Binary files /dev/null and b/win32/directx/dinput.lib differ diff --git a/win32/directx/dsound.h b/win32/directx/dsound.h new file mode 100644 index 0000000..c088b63 --- /dev/null +++ b/win32/directx/dsound.h @@ -0,0 +1,2358 @@ +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: dsound.h + * Content: DirectSound include file + * + **************************************************************************/ + +#define COM_NO_WINDOWS_H +#include +#include + +#ifndef DIRECTSOUND_VERSION +#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#ifndef __DSOUND_INCLUDED__ +#define __DSOUND_INCLUDED__ + +/* Type definitions shared with Direct3D */ + +#ifndef DX_SHARED_DEFINES + +typedef float D3DVALUE, *LPD3DVALUE; + +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +#ifndef LPD3DCOLOR_DEFINED +typedef DWORD *LPD3DCOLOR; +#define LPD3DCOLOR_DEFINED +#endif + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef LPD3DVECTOR_DEFINED +typedef D3DVECTOR *LPD3DVECTOR; +#define LPD3DVECTOR_DEFINED +#endif + +#define DX_SHARED_DEFINES +#endif // DX_SHARED_DEFINES + +#define _FACDS 0x878 /* DirectSound's facility code */ +#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) + +// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} +DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + +// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} +DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); + +// DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} +DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +// DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} +DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); + +// DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} +DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); + + +// DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + + +// +// Forward declarations for interfaces. +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +// + +#ifdef __cplusplus +struct IDirectSound; +struct IDirectSoundBuffer; +struct IDirectSound3DListener; +struct IDirectSound3DBuffer; +struct IDirectSoundCapture; +struct IDirectSoundCaptureBuffer; +struct IDirectSoundNotify; +#endif // __cplusplus + + +// +// DirectSound 8.0 interfaces. +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#ifdef __cplusplus +struct IDirectSound8; +struct IDirectSoundBuffer8; +struct IDirectSoundCaptureBuffer8; +struct IDirectSoundFXGargle; +struct IDirectSoundFXChorus; +struct IDirectSoundFXFlanger; +struct IDirectSoundFXEcho; +struct IDirectSoundFXDistortion; +struct IDirectSoundFXCompressor; +struct IDirectSoundFXParamEq; +struct IDirectSoundFXWavesReverb; +struct IDirectSoundFXI3DL2Reverb; +struct IDirectSoundCaptureFXAec; +struct IDirectSoundCaptureFXNoiseSuppress; +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +// IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the +// only DirectSound 7.0 interfaces with changed functionality in version 8.0. +// The other level 8 interfaces as equivalent to their level 7 counterparts: + +#define IDirectSoundCapture8 IDirectSoundCapture +#define IDirectSound3DListener8 IDirectSound3DListener +#define IDirectSound3DBuffer8 IDirectSound3DBuffer +#define IDirectSoundNotify8 IDirectSoundNotify +#define IDirectSoundFXGargle8 IDirectSoundFXGargle +#define IDirectSoundFXChorus8 IDirectSoundFXChorus +#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger +#define IDirectSoundFXEcho8 IDirectSoundFXEcho +#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion +#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor +#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq +#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb +#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb +#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec +#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress +#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSound *LPDIRECTSOUND; +typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; +typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; +typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; +typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; +typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; +typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; + + +#if DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; +typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; +typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; +typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; +typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; +typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; +typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; +typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; +typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; +typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; +typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +typedef struct IDirectSound8 *LPDIRECTSOUND8; +typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; +typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; +typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; +typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; +typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; +typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; +typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; +typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; +typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; +typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; +typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; +typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; +typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; +typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; +typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; +typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; +typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; +typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IID definitions for the unchanged DirectSound 8.0 interfaces +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture +#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener +#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer +#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify +#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle +#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus +#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger +#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho +#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion +#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor +#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq +#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb +#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb +#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec +#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress +#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Compatibility typedefs +// + +#ifndef _LPCWAVEFORMATEX_DEFINED +#define _LPCWAVEFORMATEX_DEFINED +typedef const WAVEFORMATEX *LPCWAVEFORMATEX; +#endif // _LPCWAVEFORMATEX_DEFINED + +#ifndef __LPCGUID_DEFINED__ +#define __LPCGUID_DEFINED__ +typedef const GUID *LPCGUID; +#endif // __LPCGUID_DEFINED__ + +typedef LPDIRECTSOUND *LPLPDIRECTSOUND; +typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; +typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; +typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; +typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; +typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; +typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; + +#if DIRECTSOUND_VERSION >= 0x0800 +typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; +typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; +typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; +typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Structures +// + +typedef struct _DSCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwMinSecondarySampleRate; + DWORD dwMaxSecondarySampleRate; + DWORD dwPrimaryBuffers; + DWORD dwMaxHwMixingAllBuffers; + DWORD dwMaxHwMixingStaticBuffers; + DWORD dwMaxHwMixingStreamingBuffers; + DWORD dwFreeHwMixingAllBuffers; + DWORD dwFreeHwMixingStaticBuffers; + DWORD dwFreeHwMixingStreamingBuffers; + DWORD dwMaxHw3DAllBuffers; + DWORD dwMaxHw3DStaticBuffers; + DWORD dwMaxHw3DStreamingBuffers; + DWORD dwFreeHw3DAllBuffers; + DWORD dwFreeHw3DStaticBuffers; + DWORD dwFreeHw3DStreamingBuffers; + DWORD dwTotalHwMemBytes; + DWORD dwFreeHwMemBytes; + DWORD dwMaxContigFreeHwMemBytes; + DWORD dwUnlockTransferRateHwBuffers; + DWORD dwPlayCpuOverheadSwBuffers; + DWORD dwReserved1; + DWORD dwReserved2; +} DSCAPS, *LPDSCAPS; + +typedef const DSCAPS *LPCDSCAPS; + +typedef struct _DSBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwUnlockTransferRate; + DWORD dwPlayCpuOverhead; +} DSBCAPS, *LPDSBCAPS; + +typedef const DSBCAPS *LPCDSBCAPS; + +#if DIRECTSOUND_VERSION >= 0x0800 + + typedef struct _DSEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSFXClass; + DWORD_PTR dwReserved1; + DWORD_PTR dwReserved2; + } DSEFFECTDESC, *LPDSEFFECTDESC; + typedef const DSEFFECTDESC *LPCDSEFFECTDESC; + + #define DSFX_LOCHARDWARE 0x00000001 + #define DSFX_LOCSOFTWARE 0x00000002 + + enum + { + DSFXR_PRESENT, // 0 + DSFXR_LOCHARDWARE, // 1 + DSFXR_LOCSOFTWARE, // 2 + DSFXR_UNALLOCATED, // 3 + DSFXR_FAILED, // 4 + DSFXR_UNKNOWN, // 5 + DSFXR_SENDLOOP // 6 + }; + + typedef struct _DSCEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSCFXClass; + GUID guidDSCFXInstance; + DWORD dwReserved1; + DWORD dwReserved2; + } DSCEFFECTDESC, *LPDSCEFFECTDESC; + typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; + + #define DSCFX_LOCHARDWARE 0x00000001 + #define DSCFX_LOCSOFTWARE 0x00000002 + + #define DSCFXR_LOCHARDWARE 0x00000010 + #define DSCFXR_LOCSOFTWARE 0x00000020 + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct _DSBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0700 + GUID guid3DAlgorithm; +#endif +} DSBUFFERDESC, *LPDSBUFFERDESC; + +typedef const DSBUFFERDESC *LPCDSBUFFERDESC; + +// Older version of this structure: + +typedef struct _DSBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSBUFFERDESC1, *LPDSBUFFERDESC1; + +typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; + +typedef struct _DS3DBUFFER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + DWORD dwInsideConeAngle; + DWORD dwOutsideConeAngle; + D3DVECTOR vConeOrientation; + LONG lConeOutsideVolume; + D3DVALUE flMinDistance; + D3DVALUE flMaxDistance; + DWORD dwMode; +} DS3DBUFFER, *LPDS3DBUFFER; + +typedef const DS3DBUFFER *LPCDS3DBUFFER; + +typedef struct _DS3DLISTENER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + D3DVECTOR vOrientFront; + D3DVECTOR vOrientTop; + D3DVALUE flDistanceFactor; + D3DVALUE flRolloffFactor; + D3DVALUE flDopplerFactor; +} DS3DLISTENER, *LPDS3DLISTENER; + +typedef const DS3DLISTENER *LPCDS3DLISTENER; + +typedef struct _DSCCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwFormats; + DWORD dwChannels; +} DSCCAPS, *LPDSCCAPS; + +typedef const DSCCAPS *LPCDSCCAPS; + +typedef struct _DSCBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSCBUFFERDESC1, *LPDSCBUFFERDESC1; + +typedef struct _DSCBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0800 + DWORD dwFXCount; + LPDSCEFFECTDESC lpDSCFXDesc; +#endif +} DSCBUFFERDESC, *LPDSCBUFFERDESC; + +typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; + +typedef struct _DSCBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; +} DSCBCAPS, *LPDSCBCAPS; + +typedef const DSCBCAPS *LPCDSCBCAPS; + +typedef struct _DSBPOSITIONNOTIFY +{ + DWORD dwOffset; + HANDLE hEventNotify; +} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; + +typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; + +// +// DirectSound API +// + +typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); +typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); + +extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +#if DIRECTSOUND_VERSION >= 0x0800 +extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, + LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, + DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, + LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); +#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate + +extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#ifdef UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKW +#define DirectSoundEnumerate DirectSoundEnumerateW +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW +#else // UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKA +#define DirectSoundEnumerate DirectSoundEnumerateA +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA +#endif // UNICODE + +// +// IUnknown +// + +#if !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->lpVtbl->Release(p) +#endif // IUnknown_Release +#else // !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->AddRef() +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->Release() +#endif // IUnknown_Release +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#ifndef __IReferenceClock_INTERFACE_DEFINED__ +#define __IReferenceClock_INTERFACE_DEFINED__ + +typedef LONGLONG REFERENCE_TIME; +typedef REFERENCE_TIME *LPREFERENCE_TIME; + +DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); + +#undef INTERFACE +#define INTERFACE IReferenceClock + +DECLARE_INTERFACE_(IReferenceClock, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IReferenceClock methods + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; + STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, + HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, + HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; +}; + +#endif // __IReferenceClock_INTERFACE_DEFINED__ + +#ifndef IReferenceClock_QueryInterface + +#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IReferenceClock_AddRef(p) IUnknown_AddRef(p) +#define IReferenceClock_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->GetTime(a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // IReferenceClock_QueryInterface + +// +// IDirectSound +// + +DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound + +DECLARE_INTERFACE_(IDirectSound, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) +#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectSound_Compact(p) (p)->Compact() +#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) +#define IDirectSound_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound8 +// + +DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); + +#undef INTERFACE +#define INTERFACE IDirectSound8 + +DECLARE_INTERFACE_(IDirectSound8, IDirectSound) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; + + // IDirectSound8 methods + STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; +}; + +#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) +#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) +#define IDirectSound8_Release(p) IDirectSound_Release(p) +#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) +#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) +#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) +#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) +#define IDirectSound8_Compact(p) IDirectSound_Compact(p) +#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) +#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) +#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer +// + +DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer + +DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; +}; + +#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) +#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) +#define IDirectSoundBuffer_Stop(p) (p)->Stop() +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->Restore() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer8 + +DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; + + // IDirectSoundBuffer8 methods + STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; + STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; +}; + +// Special GUID meaning "select all objects" for use in GetObjectInPath() +DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); + +#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) +#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) +#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) +#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) +#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) +#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) +#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) +#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) +#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) +#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) +#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) +#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) +#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) +#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) +#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) +#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound3DListener +// + +DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DListener + +DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DListener methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; + STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; + STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; + STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; + STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; + STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; + STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, + D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(CommitDeferredSettings) (THIS) PURE; +}; + +#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DListener_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSound3DBuffer +// + +DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DBuffer + +DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DBuffer methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; + STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; + STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; + STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; + STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; + STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; + STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; + STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; + STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; + STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; + STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; + STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; +}; + +#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCapture +// + +DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCapture + +DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCapture methods + STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCapture_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureBuffer +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; +}; + +#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundCaptureBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer8 + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + + // IDirectSoundCaptureBuffer8 methods + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; + STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; +}; + +#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) +#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) +#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) +#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) +#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) +#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundNotify +// + +DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundNotify + +DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundNotify methods + STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; +}; + +#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundNotify_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IKsPropertySet +// + +#ifndef _IKsPropertySet_ +#define _IKsPropertySet_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IKsPropertySet; +#endif // __cplusplus + +typedef struct IKsPropertySet *LPKSPROPERTYSET; + +#define KSPROPERTY_SUPPORT_GET 0x00000001 +#define KSPROPERTY_SUPPORT_SET 0x00000002 + +DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); + +#undef INTERFACE +#define INTERFACE IKsPropertySet + +DECLARE_INTERFACE_(IKsPropertySet, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IKsPropertySet methods + STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; + STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength) PURE; + STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; +}; + +#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) +#define IKsPropertySet_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IKsPropertySet_ + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundFXGargle +// + +DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); + +typedef struct _DSFXGargle +{ + DWORD dwRateHz; // Rate of modulation in hz + DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx +} DSFXGargle, *LPDSFXGargle; + +#define DSFXGARGLE_WAVE_TRIANGLE 0 +#define DSFXGARGLE_WAVE_SQUARE 1 + +typedef const DSFXGargle *LPCDSFXGargle; + +#define DSFXGARGLE_RATEHZ_MIN 1 +#define DSFXGARGLE_RATEHZ_MAX 1000 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXGargle + +DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXGargle methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; +}; + +#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXChorus +// + +DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); + +typedef struct _DSFXChorus +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx + FLOAT fDelay; + LONG lPhase; +} DSFXChorus, *LPDSFXChorus; + +typedef const DSFXChorus *LPCDSFXChorus; + +#define DSFXCHORUS_WAVE_TRIANGLE 0 +#define DSFXCHORUS_WAVE_SIN 1 + +#define DSFXCHORUS_WETDRYMIX_MIN 0.0f +#define DSFXCHORUS_WETDRYMIX_MAX 100.0f +#define DSFXCHORUS_DEPTH_MIN 0.0f +#define DSFXCHORUS_DEPTH_MAX 100.0f +#define DSFXCHORUS_FEEDBACK_MIN -99.0f +#define DSFXCHORUS_FEEDBACK_MAX 99.0f +#define DSFXCHORUS_FREQUENCY_MIN 0.0f +#define DSFXCHORUS_FREQUENCY_MAX 10.0f +#define DSFXCHORUS_DELAY_MIN 0.0f +#define DSFXCHORUS_DELAY_MAX 20.0f +#define DSFXCHORUS_PHASE_MIN 0 +#define DSFXCHORUS_PHASE_MAX 4 + +#define DSFXCHORUS_PHASE_NEG_180 0 +#define DSFXCHORUS_PHASE_NEG_90 1 +#define DSFXCHORUS_PHASE_ZERO 2 +#define DSFXCHORUS_PHASE_90 3 +#define DSFXCHORUS_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXChorus + +DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXChorus methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; +}; + +#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXFlanger +// + +DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); + +typedef struct _DSFXFlanger +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; + FLOAT fDelay; + LONG lPhase; +} DSFXFlanger, *LPDSFXFlanger; + +typedef const DSFXFlanger *LPCDSFXFlanger; + +#define DSFXFLANGER_WAVE_TRIANGLE 0 +#define DSFXFLANGER_WAVE_SIN 1 + +#define DSFXFLANGER_WETDRYMIX_MIN 0.0f +#define DSFXFLANGER_WETDRYMIX_MAX 100.0f +#define DSFXFLANGER_FREQUENCY_MIN 0.0f +#define DSFXFLANGER_FREQUENCY_MAX 10.0f +#define DSFXFLANGER_DEPTH_MIN 0.0f +#define DSFXFLANGER_DEPTH_MAX 100.0f +#define DSFXFLANGER_PHASE_MIN 0 +#define DSFXFLANGER_PHASE_MAX 4 +#define DSFXFLANGER_FEEDBACK_MIN -99.0f +#define DSFXFLANGER_FEEDBACK_MAX 99.0f +#define DSFXFLANGER_DELAY_MIN 0.0f +#define DSFXFLANGER_DELAY_MAX 4.0f + +#define DSFXFLANGER_PHASE_NEG_180 0 +#define DSFXFLANGER_PHASE_NEG_90 1 +#define DSFXFLANGER_PHASE_ZERO 2 +#define DSFXFLANGER_PHASE_90 3 +#define DSFXFLANGER_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXFlanger + +DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXFlanger methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; +}; + +#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXEcho +// + +DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); + +typedef struct _DSFXEcho +{ + FLOAT fWetDryMix; + FLOAT fFeedback; + FLOAT fLeftDelay; + FLOAT fRightDelay; + LONG lPanDelay; +} DSFXEcho, *LPDSFXEcho; + +typedef const DSFXEcho *LPCDSFXEcho; + +#define DSFXECHO_WETDRYMIX_MIN 0.0f +#define DSFXECHO_WETDRYMIX_MAX 100.0f +#define DSFXECHO_FEEDBACK_MIN 0.0f +#define DSFXECHO_FEEDBACK_MAX 100.0f +#define DSFXECHO_LEFTDELAY_MIN 1.0f +#define DSFXECHO_LEFTDELAY_MAX 2000.0f +#define DSFXECHO_RIGHTDELAY_MIN 1.0f +#define DSFXECHO_RIGHTDELAY_MAX 2000.0f +#define DSFXECHO_PANDELAY_MIN 0 +#define DSFXECHO_PANDELAY_MAX 1 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXEcho + +DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXEcho methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; +}; + +#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXDistortion +// + +DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); + +typedef struct _DSFXDistortion +{ + FLOAT fGain; + FLOAT fEdge; + FLOAT fPostEQCenterFrequency; + FLOAT fPostEQBandwidth; + FLOAT fPreLowpassCutoff; +} DSFXDistortion, *LPDSFXDistortion; + +typedef const DSFXDistortion *LPCDSFXDistortion; + +#define DSFXDISTORTION_GAIN_MIN -60.0f +#define DSFXDISTORTION_GAIN_MAX 0.0f +#define DSFXDISTORTION_EDGE_MIN 0.0f +#define DSFXDISTORTION_EDGE_MAX 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXDistortion + +DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXDistortion methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; +}; + +#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXCompressor +// + +DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); + +typedef struct _DSFXCompressor +{ + FLOAT fGain; + FLOAT fAttack; + FLOAT fRelease; + FLOAT fThreshold; + FLOAT fRatio; + FLOAT fPredelay; +} DSFXCompressor, *LPDSFXCompressor; + +typedef const DSFXCompressor *LPCDSFXCompressor; + +#define DSFXCOMPRESSOR_GAIN_MIN -60.0f +#define DSFXCOMPRESSOR_GAIN_MAX 60.0f +#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f +#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f +#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f +#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f +#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f +#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f +#define DSFXCOMPRESSOR_RATIO_MIN 1.0f +#define DSFXCOMPRESSOR_RATIO_MAX 100.0f +#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f +#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXCompressor + +DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXCompressor methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; +}; + +#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXParamEq +// + +DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); + +typedef struct _DSFXParamEq +{ + FLOAT fCenter; + FLOAT fBandwidth; + FLOAT fGain; +} DSFXParamEq, *LPDSFXParamEq; + +typedef const DSFXParamEq *LPCDSFXParamEq; + +#define DSFXPARAMEQ_CENTER_MIN 80.0f +#define DSFXPARAMEQ_CENTER_MAX 16000.0f +#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f +#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f +#define DSFXPARAMEQ_GAIN_MIN -15.0f +#define DSFXPARAMEQ_GAIN_MAX 15.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXParamEq + +DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXParamEq methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; +}; + +#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXI3DL2Reverb +// + +DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); + +typedef struct _DSFXI3DL2Reverb +{ + LONG lRoom; // [-10000, 0] default: -1000 mB + LONG lRoomHF; // [-10000, 0] default: 0 mB + FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 + FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s + FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 + LONG lReflections; // [-10000, 1000] default: -2602 mB + FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s + LONG lReverb; // [-10000, 2000] default: 200 mB + FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s + FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % + FLOAT flDensity; // [0.0, 100.0] default: 100.0 % + FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz +} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; + +typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; + +#define DSFX_I3DL2REVERB_ROOM_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOM_MAX 0 +#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) + +#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOMHF_MAX 0 +#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) + +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f + +#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f +#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f + +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f + +#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) +#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 +#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) + +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f + +#define DSFX_I3DL2REVERB_REVERB_MIN (-10000) +#define DSFX_I3DL2REVERB_REVERB_MAX 2000 +#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) + +#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f +#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f + +#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f +#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f +#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f +#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f +#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f + +#define DSFX_I3DL2REVERB_QUALITY_MIN 0 +#define DSFX_I3DL2REVERB_QUALITY_MAX 3 +#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXI3DL2Reverb + +DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXI3DL2Reverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; + STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; + STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; + STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; + STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; +}; + +#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXWavesReverb +// + +DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); + +typedef struct _DSFXWavesReverb +{ + FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB + FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db + FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms + FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 +} DSFXWavesReverb, *LPDSFXWavesReverb; + +typedef const DSFXWavesReverb *LPCDSFXWavesReverb; + +#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f +#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f +#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f +#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f +#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f +#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXWavesReverb + +DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXWavesReverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; +}; + +#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureFXAec +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); + +typedef struct _DSCFXAec +{ + BOOL fEnable; + BOOL fNoiseFill; + DWORD dwMode; +} DSCFXAec, *LPDSCFXAec; + +typedef const DSCFXAec *LPCDSCFXAec; + +// These match the AEC_MODE_* constants in the DDK's ksmedia.h file +#define DSCFX_AEC_MODE_PASS_THROUGH 0x0 +#define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 +#define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 + +// These match the AEC_STATUS_* constants in ksmedia.h +#define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 +#define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 +#define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 +#define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXAec + +DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXAec methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundCaptureFXNoiseSuppress +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); + +typedef struct _DSCFXNoiseSuppress +{ + BOOL fEnable; +} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; + +typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXNoiseSuppress + +DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXNoiseSuppress methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundFullDuplex +// + +#ifndef _IDirectSoundFullDuplex_ +#define _IDirectSoundFullDuplex_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); + +#undef INTERFACE +#define INTERFACE IDirectSoundFullDuplex + +DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFullDuplex methods + STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; +}; + +#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IDirectSoundFullDuplex_ + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Return Codes +// + +// The function completed successfully +#define DS_OK S_OK + +// The call succeeded, but we had to substitute the 3D algorithm +#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) + +// The call failed because resources (such as a priority level) +// were already being used by another caller +#define DSERR_ALLOCATED MAKE_DSHRESULT(10) + +// The control (vol, pan, etc.) requested by the caller is not available +#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) + +// An invalid parameter was passed to the returning function +#define DSERR_INVALIDPARAM E_INVALIDARG + +// This call is not valid for the current state of this object +#define DSERR_INVALIDCALL MAKE_DSHRESULT(50) + +// An undetermined error occurred inside the DirectSound subsystem +#define DSERR_GENERIC E_FAIL + +// The caller does not have the priority level required for the function to +// succeed +#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) + +// Not enough free memory is available to complete the operation +#define DSERR_OUTOFMEMORY E_OUTOFMEMORY + +// The specified WAVE format is not supported +#define DSERR_BADFORMAT MAKE_DSHRESULT(100) + +// The function called is not supported at this time +#define DSERR_UNSUPPORTED E_NOTIMPL + +// No sound driver is available for use +#define DSERR_NODRIVER MAKE_DSHRESULT(120) + +// This object is already initialized +#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) + +// This object does not support aggregation +#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +// The buffer memory has been lost, and must be restored +#define DSERR_BUFFERLOST MAKE_DSHRESULT(150) + +// Another app has a higher priority level, preventing this call from +// succeeding +#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) + +// This object has not been initialized +#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) + +// The requested COM interface is not available +#define DSERR_NOINTERFACE E_NOINTERFACE + +// Access is denied +#define DSERR_ACCESSDENIED E_ACCESSDENIED + +// Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds +#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) + +// Attempt to use DirectSound 8 functionality on an older DirectSound object +#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) + +// A circular loop of send effects was detected +#define DSERR_SENDLOOP MAKE_DSHRESULT(200) + +// The GUID specified in an audiopath file does not match a valid MIXIN buffer +#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) + +// The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) +#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) + +// The effects requested could not be found on the system, or they were found +// but in the wrong order, or in the wrong hardware/software locations. +#define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) + +// +// Flags +// + +#define DSCAPS_PRIMARYMONO 0x00000001 +#define DSCAPS_PRIMARYSTEREO 0x00000002 +#define DSCAPS_PRIMARY8BIT 0x00000004 +#define DSCAPS_PRIMARY16BIT 0x00000008 +#define DSCAPS_CONTINUOUSRATE 0x00000010 +#define DSCAPS_EMULDRIVER 0x00000020 +#define DSCAPS_CERTIFIED 0x00000040 +#define DSCAPS_SECONDARYMONO 0x00000100 +#define DSCAPS_SECONDARYSTEREO 0x00000200 +#define DSCAPS_SECONDARY8BIT 0x00000400 +#define DSCAPS_SECONDARY16BIT 0x00000800 + +#define DSSCL_NORMAL 0x00000001 +#define DSSCL_PRIORITY 0x00000002 +#define DSSCL_EXCLUSIVE 0x00000003 +#define DSSCL_WRITEPRIMARY 0x00000004 + +#define DSSPEAKER_DIRECTOUT 0x00000000 +#define DSSPEAKER_HEADPHONE 0x00000001 +#define DSSPEAKER_MONO 0x00000002 +#define DSSPEAKER_QUAD 0x00000003 +#define DSSPEAKER_STEREO 0x00000004 +#define DSSPEAKER_SURROUND 0x00000005 +#define DSSPEAKER_5POINT1 0x00000006 +#define DSSPEAKER_7POINT1 0x00000007 + +#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees +#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees +#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees +#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees + +#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) +#define DSSPEAKER_CONFIG(a) ((BYTE)(a)) +#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) + +#define DSBCAPS_PRIMARYBUFFER 0x00000001 +#define DSBCAPS_STATIC 0x00000002 +#define DSBCAPS_LOCHARDWARE 0x00000004 +#define DSBCAPS_LOCSOFTWARE 0x00000008 +#define DSBCAPS_CTRL3D 0x00000010 +#define DSBCAPS_CTRLFREQUENCY 0x00000020 +#define DSBCAPS_CTRLPAN 0x00000040 +#define DSBCAPS_CTRLVOLUME 0x00000080 +#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 +#define DSBCAPS_CTRLFX 0x00000200 +#define DSBCAPS_STICKYFOCUS 0x00004000 +#define DSBCAPS_GLOBALFOCUS 0x00008000 +#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 +#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 +#define DSBCAPS_LOCDEFER 0x00040000 + +#define DSBPLAY_LOOPING 0x00000001 +#define DSBPLAY_LOCHARDWARE 0x00000002 +#define DSBPLAY_LOCSOFTWARE 0x00000004 +#define DSBPLAY_TERMINATEBY_TIME 0x00000008 +#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 +#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 + +#define DSBSTATUS_PLAYING 0x00000001 +#define DSBSTATUS_BUFFERLOST 0x00000002 +#define DSBSTATUS_LOOPING 0x00000004 +#define DSBSTATUS_LOCHARDWARE 0x00000008 +#define DSBSTATUS_LOCSOFTWARE 0x00000010 +#define DSBSTATUS_TERMINATED 0x00000020 + +#define DSBLOCK_FROMWRITECURSOR 0x00000001 +#define DSBLOCK_ENTIREBUFFER 0x00000002 + +#define DSBFREQUENCY_ORIGINAL 0 +#define DSBFREQUENCY_MIN 100 +#if DIRECTSOUND_VERSION >= 0x0900 +#define DSBFREQUENCY_MAX 200000 +#else +#define DSBFREQUENCY_MAX 100000 +#endif + +#define DSBPAN_LEFT -10000 +#define DSBPAN_CENTER 0 +#define DSBPAN_RIGHT 10000 + +#define DSBVOLUME_MIN -10000 +#define DSBVOLUME_MAX 0 + +#define DSBSIZE_MIN 4 +#define DSBSIZE_MAX 0x0FFFFFFF +#define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes + +#define DS3DMODE_NORMAL 0x00000000 +#define DS3DMODE_HEADRELATIVE 0x00000001 +#define DS3DMODE_DISABLE 0x00000002 + +#define DS3D_IMMEDIATE 0x00000000 +#define DS3D_DEFERRED 0x00000001 + +#define DS3D_MINDISTANCEFACTOR FLT_MIN +#define DS3D_MAXDISTANCEFACTOR FLT_MAX +#define DS3D_DEFAULTDISTANCEFACTOR 1.0f + +#define DS3D_MINROLLOFFFACTOR 0.0f +#define DS3D_MAXROLLOFFFACTOR 10.0f +#define DS3D_DEFAULTROLLOFFFACTOR 1.0f + +#define DS3D_MINDOPPLERFACTOR 0.0f +#define DS3D_MAXDOPPLERFACTOR 10.0f +#define DS3D_DEFAULTDOPPLERFACTOR 1.0f + +#define DS3D_DEFAULTMINDISTANCE 1.0f +#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f + +#define DS3D_MINCONEANGLE 0 +#define DS3D_MAXCONEANGLE 360 +#define DS3D_DEFAULTCONEANGLE 360 + +#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX + +// IDirectSoundCapture attributes + +#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER +#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED +#define DSCCAPS_MULTIPLECAPTURE 0x00000001 + +// IDirectSoundCaptureBuffer attributes + +#define DSCBCAPS_WAVEMAPPED 0x80000000 + +#if DIRECTSOUND_VERSION >= 0x0800 +#define DSCBCAPS_CTRLFX 0x00000200 +#endif + + +#define DSCBLOCK_ENTIREBUFFER 0x00000001 + +#define DSCBSTATUS_CAPTURING 0x00000001 +#define DSCBSTATUS_LOOPING 0x00000002 + +#define DSCBSTART_LOOPING 0x00000001 + +#define DSBPN_OFFSETSTOP 0xFFFFFFFF + +#define DS_CERTIFIED 0x00000000 +#define DS_UNCERTIFIED 0x00000001 + + +// +// Flags for the I3DL2 effects +// + +// +// I3DL2 Material Presets +// + +enum +{ + DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, + DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, + DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, + DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, + DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, + DSFX_I3DL2_MATERIAL_PRESET_CURTAIN +}; + +#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f +#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f +#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f +#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f +#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f +#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f +#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f +#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f + +enum +{ + DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, + DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, + DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, + DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, + DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, + DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, + DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, + DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, + DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, + DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, + DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, + DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, + DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, + DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, + DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, + DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, + DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE +}; + +// +// I3DL2 Reverberation Presets Values +// + +#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f + +// +// Examples simulating 'musical' reverb presets +// +// Name Decay time Description +// Small Room 1.1s A small size room with a length of 5m or so. +// Medium Room 1.3s A medium size room with a length of 10m or so. +// Large Room 1.5s A large size room suitable for live performances. +// Medium Hall 1.8s A medium size concert hall. +// Large Hall 1.8s A large size concert hall suitable for a full orchestra. +// Plate 1.3s A plate reverb simulation. +// + +#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f + +// +// DirectSound3D Algorithms +// + +// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} +#define DS3DALG_DEFAULT GUID_NULL + +// No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// DirectSound Internal Effect Algorithms +// + + +// Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} +DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); + +// Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} +DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); + +// Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} +DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); + +// Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} +DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); + +// Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} +DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); + +// Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} +DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); + +// Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} +DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); + +// I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} +DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); + +// Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} +DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); + +// +// DirectSound Capture Effect Algorithms +// + + +// Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} +// Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); + +// Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} +DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); + +// System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} +DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); + +// Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} +// Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); + +// Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} +DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); + +// System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} +DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#endif // __DSOUND_INCLUDED__ + + + +#ifdef __cplusplus +}; +#endif // __cplusplus + + diff --git a/win32/directx/dsound.lib b/win32/directx/dsound.lib new file mode 100644 index 0000000..6e9604d Binary files /dev/null and b/win32/directx/dsound.lib differ diff --git a/win32/directx/dxfile.h b/win32/directx/dxfile.h new file mode 100644 index 0000000..5a981ce --- /dev/null +++ b/win32/directx/dxfile.h @@ -0,0 +1,240 @@ +/*************************************************************************** + * + * Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. + * + * File: dxfile.h + * + * Content: DirectX File public header file + * + ***************************************************************************/ + +#ifndef __DXFILE_H__ +#define __DXFILE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef DWORD DXFILEFORMAT; + +#define DXFILEFORMAT_BINARY 0 +#define DXFILEFORMAT_TEXT 1 +#define DXFILEFORMAT_COMPRESSED 2 + +typedef DWORD DXFILELOADOPTIONS; + +#define DXFILELOAD_FROMFILE 0x00L +#define DXFILELOAD_FROMRESOURCE 0x01L +#define DXFILELOAD_FROMMEMORY 0x02L +#define DXFILELOAD_FROMSTREAM 0x04L +#define DXFILELOAD_FROMURL 0x08L + +typedef struct _DXFILELOADRESOURCE { + HMODULE hModule; + LPCTSTR lpName; + LPCTSTR lpType; +}DXFILELOADRESOURCE, *LPDXFILELOADRESOURCE; + +typedef struct _DXFILELOADMEMORY { + LPVOID lpMemory; + DWORD dSize; +}DXFILELOADMEMORY, *LPDXFILELOADMEMORY; + +/* + * DirectX File object types. + */ + +#ifndef WIN_TYPES +#define WIN_TYPES(itype, ptype) typedef interface itype *LP##ptype, **LPLP##ptype +#endif + +WIN_TYPES(IDirectXFile, DIRECTXFILE); +WIN_TYPES(IDirectXFileEnumObject, DIRECTXFILEENUMOBJECT); +WIN_TYPES(IDirectXFileSaveObject, DIRECTXFILESAVEOBJECT); +WIN_TYPES(IDirectXFileObject, DIRECTXFILEOBJECT); +WIN_TYPES(IDirectXFileData, DIRECTXFILEDATA); +WIN_TYPES(IDirectXFileDataReference, DIRECTXFILEDATAREFERENCE); +WIN_TYPES(IDirectXFileBinary, DIRECTXFILEBINARY); + +/* + * API for creating IDirectXFile interface. + */ + +STDAPI DirectXFileCreate(LPDIRECTXFILE *lplpDirectXFile); + +/* + * The methods for IUnknown + */ + +#define IUNKNOWN_METHODS(kind) \ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \ + STDMETHOD_(ULONG, AddRef) (THIS) kind; \ + STDMETHOD_(ULONG, Release) (THIS) kind + +/* + * The methods for IDirectXFileObject + */ + +#define IDIRECTXFILEOBJECT_METHODS(kind) \ + STDMETHOD(GetName) (THIS_ LPSTR, LPDWORD) kind; \ + STDMETHOD(GetId) (THIS_ LPGUID) kind + +/* + * DirectX File interfaces. + */ + +#undef INTERFACE +#define INTERFACE IDirectXFile + +DECLARE_INTERFACE_(IDirectXFile, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(CreateEnumObject) (THIS_ LPVOID, DXFILELOADOPTIONS, + LPDIRECTXFILEENUMOBJECT *) PURE; + STDMETHOD(CreateSaveObject) (THIS_ LPCSTR, DXFILEFORMAT, + LPDIRECTXFILESAVEOBJECT *) PURE; + STDMETHOD(RegisterTemplates) (THIS_ LPVOID, DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileEnumObject + +DECLARE_INTERFACE_(IDirectXFileEnumObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(GetNextDataObject) (THIS_ LPDIRECTXFILEDATA *) PURE; + STDMETHOD(GetDataObjectById) (THIS_ REFGUID, LPDIRECTXFILEDATA *) PURE; + STDMETHOD(GetDataObjectByName) (THIS_ LPCSTR, LPDIRECTXFILEDATA *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileSaveObject + +DECLARE_INTERFACE_(IDirectXFileSaveObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + STDMETHOD(SaveTemplates) (THIS_ DWORD, const GUID **) PURE; + STDMETHOD(CreateDataObject) (THIS_ REFGUID, LPCSTR, const GUID *, + DWORD, LPVOID, LPDIRECTXFILEDATA *) PURE; + STDMETHOD(SaveData) (THIS_ LPDIRECTXFILEDATA) PURE; +}; + + +#undef INTERFACE +#define INTERFACE IDirectXFileObject + +DECLARE_INTERFACE_(IDirectXFileObject, IUnknown) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileData + +DECLARE_INTERFACE_(IDirectXFileData, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(GetData) (THIS_ LPCSTR, DWORD *, void **) PURE; + STDMETHOD(GetType) (THIS_ const GUID **) PURE; + STDMETHOD(GetNextObject) (THIS_ LPDIRECTXFILEOBJECT *) PURE; + STDMETHOD(AddDataObject) (THIS_ LPDIRECTXFILEDATA) PURE; + STDMETHOD(AddDataReference) (THIS_ LPCSTR, const GUID *) PURE; + STDMETHOD(AddBinaryObject) (THIS_ LPCSTR, const GUID *, LPCSTR, LPVOID, DWORD) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileDataReference + +DECLARE_INTERFACE_(IDirectXFileDataReference, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(Resolve) (THIS_ LPDIRECTXFILEDATA *) PURE; +}; + +#undef INTERFACE +#define INTERFACE IDirectXFileBinary + +DECLARE_INTERFACE_(IDirectXFileBinary, IDirectXFileObject) +{ + IUNKNOWN_METHODS(PURE); + IDIRECTXFILEOBJECT_METHODS(PURE); + + STDMETHOD(GetSize) (THIS_ DWORD *) PURE; + STDMETHOD(GetMimeType) (THIS_ LPCSTR *) PURE; + STDMETHOD(Read) (THIS_ LPVOID, DWORD, LPDWORD) PURE; +}; + +/* + * DirectXFile Object Class Id (for CoCreateInstance()) + */ + +DEFINE_GUID(CLSID_CDirectXFile, 0x4516ec43, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3); + +/* + * DirectX File Interface GUIDs. + */ + +DEFINE_GUID(IID_IDirectXFile, 0x3d82ab40, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileEnumObject, 0x3d82ab41, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileSaveObject, 0x3d82ab42, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileObject, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileData, 0x3d82ab44, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileDataReference, 0x3d82ab45, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); +DEFINE_GUID(IID_IDirectXFileBinary, 0x3d82ab46, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + +/* + * DirectX File Header template's GUID. + */ + +DEFINE_GUID(TID_DXFILEHeader, 0x3d82ab43, 0x62da, 0x11cf, 0xab, 0x39, 0x0, 0x20, 0xaf, 0x71, 0xe4, 0x33); + + +/* + * DirectX File errors. + */ + +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +#define DXFILE_OK 0 + +#define DXFILEERR_BADOBJECT MAKE_DDHRESULT(850) +#define DXFILEERR_BADVALUE MAKE_DDHRESULT(851) +#define DXFILEERR_BADTYPE MAKE_DDHRESULT(852) +#define DXFILEERR_BADSTREAMHANDLE MAKE_DDHRESULT(853) +#define DXFILEERR_BADALLOC MAKE_DDHRESULT(854) +#define DXFILEERR_NOTFOUND MAKE_DDHRESULT(855) +#define DXFILEERR_NOTDONEYET MAKE_DDHRESULT(856) +#define DXFILEERR_FILENOTFOUND MAKE_DDHRESULT(857) +#define DXFILEERR_RESOURCENOTFOUND MAKE_DDHRESULT(858) +#define DXFILEERR_URLNOTFOUND MAKE_DDHRESULT(859) +#define DXFILEERR_BADRESOURCE MAKE_DDHRESULT(860) +#define DXFILEERR_BADFILETYPE MAKE_DDHRESULT(861) +#define DXFILEERR_BADFILEVERSION MAKE_DDHRESULT(862) +#define DXFILEERR_BADFILEFLOATSIZE MAKE_DDHRESULT(863) +#define DXFILEERR_BADFILECOMPRESSIONTYPE MAKE_DDHRESULT(864) +#define DXFILEERR_BADFILE MAKE_DDHRESULT(865) +#define DXFILEERR_PARSEERROR MAKE_DDHRESULT(866) +#define DXFILEERR_NOTEMPLATE MAKE_DDHRESULT(867) +#define DXFILEERR_BADARRAYSIZE MAKE_DDHRESULT(868) +#define DXFILEERR_BADDATAREFERENCE MAKE_DDHRESULT(869) +#define DXFILEERR_INTERNALERROR MAKE_DDHRESULT(870) +#define DXFILEERR_NOMOREOBJECTS MAKE_DDHRESULT(871) +#define DXFILEERR_BADINTRINSICS MAKE_DDHRESULT(872) +#define DXFILEERR_NOMORESTREAMHANDLES MAKE_DDHRESULT(873) +#define DXFILEERR_NOMOREDATA MAKE_DDHRESULT(874) +#define DXFILEERR_BADCACHEFILE MAKE_DDHRESULT(875) +#define DXFILEERR_NOINTERNET MAKE_DDHRESULT(876) + + +#ifdef __cplusplus +}; +#endif + +#endif /* _DXFILE_H_ */ + \ No newline at end of file diff --git a/win32/directx/dxguid.lib b/win32/directx/dxguid.lib new file mode 100644 index 0000000..f251a92 Binary files /dev/null and b/win32/directx/dxguid.lib differ diff --git a/win32/gba.sln b/win32/gba.sln new file mode 100644 index 0000000..9041656 --- /dev/null +++ b/win32/gba.sln @@ -0,0 +1,22 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GBA", "GBA.vcproj", "{200824A0-CDBA-45D7-83B8-E5A8468792EC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + ReleaseNoDev|Win32 = ReleaseNoDev|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.Debug|Win32.Build.0 = Debug|Win32 + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.Release|Win32.ActiveCfg = Release|Win32 + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.Release|Win32.Build.0 = Release|Win32 + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.ReleaseNoDev|Win32.ActiveCfg = ReleaseNoDev|Win32 + {200824A0-CDBA-45D7-83B8-E5A8468792EC}.ReleaseNoDev|Win32.Build.0 = ReleaseNoDev|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/win32/include/cximage/xfile.h b/win32/include/cximage/xfile.h new file mode 100644 index 0000000..2613e83 --- /dev/null +++ b/win32/include/cximage/xfile.h @@ -0,0 +1,64 @@ +/* + * File: xfile.h + * Purpose: General Purpose File Class + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxFile (c) 11/May/2002 Davide Pizzolato - www.xdp.it + * CxFile version 2.00 23/Aug/2002 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__xfile_h) +#define __xfile_h + +#ifdef WIN32 + #include +#endif + +#include +#include + +#include "ximadefs.h" + +class DLL_EXP CxFile +{ +public: + CxFile(void) { }; + virtual ~CxFile() { }; + + virtual bool Close() = 0; + virtual size_t Read(void *buffer, size_t size, size_t count) = 0; + virtual size_t Write(const void *buffer, size_t size, size_t count) = 0; + virtual bool Seek(long offset, int origin) = 0; + virtual long Tell() = 0; + virtual long Size() = 0; + virtual bool Flush() = 0; + virtual bool Eof() = 0; + virtual long Error() = 0; + virtual bool PutC(unsigned char c) + { + // Default implementation + size_t nWrote = Write(&c, 1, 1); + return (bool)(nWrote == 1); + } + virtual long GetC() = 0; +}; + +#endif //__xfile_h diff --git a/win32/include/cximage/ximabmp.h b/win32/include/cximage/ximabmp.h new file mode 100644 index 0000000..0503f7a --- /dev/null +++ b/win32/include/cximage/ximabmp.h @@ -0,0 +1,94 @@ +/* + * File: ximabmp.h + * Purpose: BMP Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageBMP (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes + * + * original CImageBMP and CImageIterator implementation are: + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ + +#if !defined(__ximaBMP_h) +#define __ximaBMP_h + +#include "ximage.h" + +const int RLE_COMMAND = 0; +const int RLE_ENDOFLINE = 0; +const int RLE_ENDOFBITMAP = 1; +const int RLE_DELTA = 2; + +#if !defined(BI_RLE8) + #define BI_RLE8 1L +#endif +#if !defined(BI_RLE4) + #define BI_RLE4 2L +#endif + +#if CXIMAGE_SUPPORT_BMP + +class CxImageBMP: public CxImage +{ +public: + CxImageBMP(): CxImage(CXIMAGE_FORMAT_BMP) {}; + + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE + +protected: + bool DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib); +}; + +#define BFT_ICON 0x4349 /* 'IC' */ +#define BFT_BITMAP 0x4d42 /* 'BM' */ +#define BFT_CURSOR 0x5450 /* 'PT' */ + +#ifndef WIDTHBYTES +#define WIDTHBYTES(i) ((unsigned)((i+31)&(~31))/8) /* ULONG aligned ! */ +#endif + +#define DibWidthBytesN(lpbi, n) (UINT)WIDTHBYTES((UINT)(lpbi)->biWidth * (UINT)(n)) +#define DibWidthBytes(lpbi) DibWidthBytesN(lpbi, (lpbi)->biBitCount) + +#define DibSizeImage(lpbi) ((lpbi)->biSizeImage == 0 \ + ? ((DWORD)(UINT)DibWidthBytes(lpbi) * (DWORD)(UINT)(lpbi)->biHeight) \ + : (lpbi)->biSizeImage) + +#define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \ + ? (int)(1 << (int)(lpbi)->biBitCount) \ + : (int)(lpbi)->biClrUsed) + +#define FixBitmapInfo(lpbi) if ((lpbi)->biSizeImage == 0) \ + (lpbi)->biSizeImage = DibSizeImage(lpbi); \ + if ((lpbi)->biClrUsed == 0) \ + (lpbi)->biClrUsed = DibNumColors(lpbi); \ + +#endif + +#endif diff --git a/win32/include/cximage/ximadefs.h b/win32/include/cximage/ximadefs.h new file mode 100644 index 0000000..b6d424a --- /dev/null +++ b/win32/include/cximage/ximadefs.h @@ -0,0 +1,165 @@ +#if !defined(__ximadefs_h) +#define __ximadefs_h + +#if defined(_AFXDLL)||defined(_USRDLL) + #define DLL_EXP __declspec(dllexport) +#elif defined(_MSC_VER)&&(_MSC_VER<1200) + #define DLL_EXP __declspec(dllimport) +#else + #define DLL_EXP +#endif + +#if CXIMAGE_SUPPORT_JP2 || CXIMAGE_SUPPORT_JPC || CXIMAGE_SUPPORT_PGX || CXIMAGE_SUPPORT_PNM || CXIMAGE_SUPPORT_RAS + #define CXIMAGE_SUPPORT_JASPER 1 +#else + #define CXIMAGE_SUPPORT_JASPER 0 +#endif + +#if CXIMAGE_SUPPORT_DSP +#undef CXIMAGE_SUPPORT_TRANSFORMATION + #define CXIMAGE_SUPPORT_TRANSFORMATION 1 +#endif + +#if CXIMAGE_SUPPORT_TRANSFORMATION || CXIMAGE_SUPPORT_TIF || CXIMAGE_SUPPORT_TGA || CXIMAGE_SUPPORT_BMP || CXIMAGE_SUPPORT_WINDOWS + #define CXIMAGE_SUPPORT_BASICTRANSFORMATIONS 1 +#endif + +#if CXIMAGE_SUPPORT_WINCE + #undef CXIMAGE_SUPPORT_WMF + #define CXIMAGE_SUPPORT_WMF 0 + #undef CXIMAGE_SUPPORT_WINDOWS + #define CXIMAGE_SUPPORT_WINDOWS 0 +#endif + +#ifndef WIN32 + #undef CXIMAGE_SUPPORT_WINDOWS + #define CXIMAGE_SUPPORT_WINDOWS 0 +#endif + +#ifndef min +#define min(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef max +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + + +#ifdef WIN32 +#include +//#include +#endif + +#include +#include + + +#ifdef __BORLANDC__ +#define _complex complex +#define _cabs cabs +#endif + + +#ifndef WIN32 + +#include +#include +#include + +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; +typedef unsigned int UINT; + +typedef DWORD COLORREF; +typedef unsigned int HANDLE; +typedef void* HRGN; + +#define BOOL bool +#define TRUE true +#define FALSE false + +typedef struct tagRECT +{ + long left; + long top; + long right; + long bottom; +} RECT; + +typedef struct tagPOINT +{ + long x; + long y; +} POINT; + +typedef struct tagRGBQUAD { + BYTE rgbBlue; + BYTE rgbGreen; + BYTE rgbRed; + BYTE rgbReserved; +} RGBQUAD; + +#pragma pack(1) + +typedef struct tagBITMAPINFOHEADER{ + DWORD biSize; + long biWidth; + long biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + long biXPelsPerMeter; + long biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; +} BITMAPINFOHEADER; + +typedef struct tagBITMAPFILEHEADER { + WORD bfType; + DWORD bfSize; + WORD bfReserved1; + WORD bfReserved2; + DWORD bfOffBits; +} BITMAPFILEHEADER; + +typedef struct tagBITMAPCOREHEADER { + DWORD bcSize; + WORD bcWidth; + WORD bcHeight; + WORD bcPlanes; + WORD bcBitCount; +} BITMAPCOREHEADER; + +typedef struct tagRGBTRIPLE { + BYTE rgbtBlue; + BYTE rgbtGreen; + BYTE rgbtRed; +} RGBTRIPLE; + +#pragma pack() + +#define BI_RGB 0L +#define BI_RLE8 1L +#define BI_RLE4 2L +#define BI_BITFIELDS 3L + +#define GetRValue(rgb) ((BYTE)(rgb)) +#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8)) +#define GetBValue(rgb) ((BYTE)((rgb)>>16)) +#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) + +#ifndef _COMPLEX_DEFINED + +typedef struct tagcomplex { + double x,y; +} _complex; + +#endif + +#define _cabs(c) sqrt(c.x*c.x+c.y*c.y) + +#endif + + +#endif //__ximadefs diff --git a/win32/include/cximage/ximage.h b/win32/include/cximage/ximage.h new file mode 100644 index 0000000..8070967 --- /dev/null +++ b/win32/include/cximage/ximage.h @@ -0,0 +1,547 @@ +/* + * File: ximage.h + * Purpose: General Purpose Image Class + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * original CImage and CImageIterator implementation are: + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__CXIMAGE_H) +#define __CXIMAGE_H + +#if _MSC_VER > 1000 +#pragma once +#endif + +///////////////////////////////////////////////////////////////////////////// +// CxImage supported features +#define CXIMAGE_SUPPORT_ALPHA 1 +#define CXIMAGE_SUPPORT_SELECTION 0 +#define CXIMAGE_SUPPORT_TRANSFORMATION 0 +#define CXIMAGE_SUPPORT_DSP 0 +#define CXIMAGE_SUPPORT_LAYERS 0 + +#define CXIMAGE_SUPPORT_DECODE 1 +#define CXIMAGE_SUPPORT_ENCODE 0 // +#define CXIMAGE_SUPPORT_WINDOWS 1 +#define CXIMAGE_SUPPORT_WINCE 0 // + +///////////////////////////////////////////////////////////////////////////// +// CxImage supported formats +#define CXIMAGE_SUPPORT_BMP 1 +#define CXIMAGE_SUPPORT_GIF 0 +#define CXIMAGE_SUPPORT_JPG 1 +#define CXIMAGE_SUPPORT_PNG 1 +#define CXIMAGE_SUPPORT_MNG 0 +#define CXIMAGE_SUPPORT_ICO 0 +#define CXIMAGE_SUPPORT_TIF 0 +#define CXIMAGE_SUPPORT_TGA 0 +#define CXIMAGE_SUPPORT_PCX 0 +#define CXIMAGE_SUPPORT_WBMP 0 +#define CXIMAGE_SUPPORT_WMF 0 +#define CXIMAGE_SUPPORT_J2K 0 // Beta, use JP2 +#define CXIMAGE_SUPPORT_JBG 0 // GPL'd see ../jbig/copying.txt & ../jbig/patents.htm + +#define CXIMAGE_SUPPORT_JP2 0 +#define CXIMAGE_SUPPORT_JPC 0 +#define CXIMAGE_SUPPORT_PGX 0 +#define CXIMAGE_SUPPORT_PNM 0 +#define CXIMAGE_SUPPORT_RAS 0 + +///////////////////////////////////////////////////////////////////////////// + +#include // For UNICODE support +#include "xfile.h" +#include "xiofile.h" +#include "xmemfile.h" + +#include "ximadefs.h" // adjust some #define + +///////////////////////////////////////////////////////////////////////////// +// CxImage formats enumerator +enum ENUM_CXIMAGE_FORMATS{ +CXIMAGE_FORMAT_UNKNOWN, +#if CXIMAGE_SUPPORT_BMP +CXIMAGE_FORMAT_BMP, +#endif +#if CXIMAGE_SUPPORT_GIF +CXIMAGE_FORMAT_GIF, +#endif +#if CXIMAGE_SUPPORT_JPG +CXIMAGE_FORMAT_JPG, +#endif +#if CXIMAGE_SUPPORT_PNG +CXIMAGE_FORMAT_PNG, +#endif +#if CXIMAGE_SUPPORT_MNG +CXIMAGE_FORMAT_MNG, +#endif +#if CXIMAGE_SUPPORT_ICO +CXIMAGE_FORMAT_ICO, +#endif +#if CXIMAGE_SUPPORT_TIF +CXIMAGE_FORMAT_TIF, +#endif +#if CXIMAGE_SUPPORT_TGA +CXIMAGE_FORMAT_TGA, +#endif +#if CXIMAGE_SUPPORT_PCX +CXIMAGE_FORMAT_PCX, +#endif +#if CXIMAGE_SUPPORT_WBMP +CXIMAGE_FORMAT_WBMP, +#endif +#if CXIMAGE_SUPPORT_WMF +CXIMAGE_FORMAT_WMF, +#endif +#if CXIMAGE_SUPPORT_J2K +CXIMAGE_FORMAT_J2K, +#endif +#if CXIMAGE_SUPPORT_JBG +CXIMAGE_FORMAT_JBG, +#endif +#if CXIMAGE_SUPPORT_JP2 +CXIMAGE_FORMAT_JP2, +#endif +#if CXIMAGE_SUPPORT_JPC +CXIMAGE_FORMAT_JPC, +#endif +#if CXIMAGE_SUPPORT_PGX +CXIMAGE_FORMAT_PGX, +#endif +#if CXIMAGE_SUPPORT_PNM +CXIMAGE_FORMAT_PNM, +#endif +#if CXIMAGE_SUPPORT_RAS +CXIMAGE_FORMAT_RAS, +#endif +CMAX_IMAGE_FORMATS +}; + +//color to grey mapping +//#define RGB2GRAY(r,g,b) (((b)*114 + (g)*587 + (r)*299)/1000) +#define RGB2GRAY(r,g,b) (((b)*117 + (g)*601 + (r)*306) >> 10) + +struct rgb_color { BYTE r,g,b; }; + + +// text placement data +// members must be initialized with the InitTextInfo(&this) function. +typedef struct DLL_EXP tagCxTextInfo +{ + char text[4096]; // text + LOGFONT lfont; // font and codepage data + COLORREF fcolor; // foreground color + long align; // DT_CENTER, DT_RIGHT, DT_LEFT aligment for multiline text + BYTE opaque; // text has background or hasn't. Default is true. + // data for background (ignored if .opaque==FALSE) + COLORREF bcolor; // background color + float b_opacity; // opacity value for background between 0.0-1.0 Default is 0. (opaque) + BYTE b_outline; // outline width for background (zero: no outline) + BYTE b_round; // rounding radius for background rectangle. % of the height, between 0-50. Default is 10. + // (backgr. always has a frame: width = 3 pixel + 10% of height by default.) +} CXTEXTINFO; + +///////////////////////////////////////////////////////////////////////////// +// CxImage class +///////////////////////////////////////////////////////////////////////////// +class DLL_EXP CxImage +{ +//extensible information collector +typedef struct tagCxImageInfo { + DWORD dwEffWidth; //DWORD aligned scan line width + BYTE* pImage; //THE IMAGE BITS + CxImage* pGhost; //if this is a ghost, pGhost points to the body + CxImage* pParent; //if this is a layer, pParent points to the body + DWORD dwType; //original image format + char szLastError[256]; //debugging + long nProgress; //monitor + long nEscape; //escape + long nBkgndIndex; //used for GIF, PNG, MNG + RGBQUAD nBkgndColor; //used for RGB transparency + BYTE nQuality; //used for JPEG + BYTE nScale; //used for JPEG + long nFrame; //used for TIF, GIF, MNG : actual frame + long nNumFrames; //used for TIF, GIF, MNG : total number of frames + DWORD dwFrameDelay; //used for GIF, MNG + long xDPI; //horizontal resolution + long yDPI; //vertical resolution + RECT rSelectionBox; //bounding rectangle + BYTE nAlphaMax; //max opacity (fade) + bool bAlphaPaletteEnabled; //true if alpha values in the palette are enabled. + bool bEnabled; //enables the painting functions + long xOffset; + long yOffset; + DWORD dwCodecOption; //for GIF, TIF : 0=def.1=unc,2=fax3,3=fax4,4=pack,5=jpg + RGBQUAD last_c; //for GetNearestIndex optimization + BYTE last_c_index; + bool last_c_isvalid; + long nNumLayers; + DWORD dwFlags; // 0x??00000 = reserved, 0x00??0000 = blend mode, 0x0000???? = layer id - user flags + +} CXIMAGEINFO; + +public: + //constructors + CxImage(DWORD imagetype = 0); + CxImage(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0); + CxImage(const CxImage &src, bool copypixels = true, bool copyselection = true, bool copyalpha = true); + CxImage(const TCHAR * filename, DWORD imagetype); // For UNICODE support: char -> TCHAR +// CxImage(const char * filename, DWORD imagetype); + CxImage(FILE * stream, DWORD imagetype); + CxImage(CxFile * stream, DWORD imagetype); + CxImage(BYTE * buffer, DWORD size, DWORD imagetype); + virtual ~CxImage() { Destroy(); }; + CxImage& operator = (const CxImage&); + + //initializzation + void* Create(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0); + bool Destroy(); + void Clear(BYTE bval=0); + void Copy(const CxImage &src, bool copypixels = true, bool copyselection = true, bool copyalpha = true); + bool Transfer(CxImage &from); + bool CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage); + bool CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage); + + //Attributes + long GetSize(); + BYTE* GetBits(DWORD row = 0); + BYTE GetColorType(); + void* GetDIB() const {return pDib;} + DWORD GetHeight() const {return head.biHeight;} + DWORD GetWidth() const {return head.biWidth;} + DWORD GetEffWidth() const {return info.dwEffWidth;} + DWORD GetNumColors() const {return head.biClrUsed;} + WORD GetBpp() const {return head.biBitCount;} + DWORD GetType() const {return info.dwType;} + char* GetLastError() {return info.szLastError;} + const TCHAR* GetVersion(); + + DWORD GetFrameDelay() const {return info.dwFrameDelay;} + void SetFrameDelay(DWORD d) {info.dwFrameDelay=d;} + + void GetOffset(long *x,long *y) {*x=info.xOffset; *y=info.yOffset;} + void SetOffset(long x,long y) {info.xOffset=x; info.yOffset=y;} + + BYTE GetJpegQuality() const {return info.nQuality;} + void SetJpegQuality(BYTE q) {info.nQuality = q;} + + // used for scaling down during JPEG decoding valid numbers are 1, 2, 4, 8 + BYTE GetJpegScale() const {return info.nScale;} + void SetJpegScale(BYTE q) {info.nScale = q;} + + long GetXDPI() const {return info.xDPI;} + long GetYDPI() const {return info.yDPI;} + void SetXDPI(long dpi); + void SetYDPI(long dpi); + + DWORD GetClrImportant() const {return head.biClrImportant;} + void SetClrImportant(DWORD ncolors = 0); + + long GetProgress() const {return info.nProgress;} + long GetEscape() const {return info.nEscape;} + void SetProgress(long p) {info.nProgress = p;} + void SetEscape(long i) {info.nEscape = i;} + + long GetTransIndex() const {return info.nBkgndIndex;} + RGBQUAD GetTransColor(); + void SetTransIndex(long idx) {info.nBkgndIndex = idx;} + void SetTransColor(RGBQUAD rgb) {rgb.rgbReserved=0; info.nBkgndColor = rgb;} + bool IsTransparent() const {return info.nBkgndIndex>=0;} // + + DWORD GetCodecOption() const {return info.dwCodecOption;} + void SetCodecOption(DWORD opt) {info.dwCodecOption = opt;} + + DWORD GetFlags() const {return info.dwFlags;} + void SetFlags(DWORD flags, bool bLockReservedFlags = true); + + //void* GetUserData() const {return info.pUserData;} + //void SetUserData(void* pUserData) {info.pUserData = pUserData;} + + //palette operations + bool IsGrayScale(); + bool IsIndexed() {return head.biClrUsed!=0;} + DWORD GetPaletteSize(); + RGBQUAD* GetPalette() const; + RGBQUAD GetPaletteColor(BYTE idx); + bool GetPaletteColor(BYTE i, BYTE* r, BYTE* g, BYTE* b); + BYTE GetNearestIndex(RGBQUAD c); + void BlendPalette(COLORREF cr,long perc); + void SetGrayPalette(); + void SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b); + void SetPalette(RGBQUAD* pPal,DWORD nColors=256); + void SetPalette(rgb_color *rgb,DWORD nColors=256); + void SetPaletteColor(BYTE idx, BYTE r, BYTE g, BYTE b, BYTE alpha=0); + void SetPaletteColor(BYTE idx, RGBQUAD c); + void SetPaletteColor(BYTE idx, COLORREF cr); + void SwapIndex(BYTE idx1, BYTE idx2); + void SetStdPalette(); + + //pixel operations + bool IsInside(long x, long y); + bool IsTransparent(long x,long y); + RGBQUAD GetPixelColor(long x,long y, bool bGetAlpha = true); + BYTE GetPixelIndex(long x,long y); + BYTE GetPixelGray(long x, long y); + void SetPixelColor(long x,long y,RGBQUAD c, bool bSetAlpha = false); + void SetPixelColor(long x,long y,COLORREF cr); + void SetPixelIndex(long x,long y,BYTE i); + void DrawLine(int StartX, int EndX, int StartY, int EndY, RGBQUAD color, bool bSetAlpha=false); + void DrawLine(int StartX, int EndX, int StartY, int EndY, COLORREF cr); + + + //painting operations +#if CXIMAGE_SUPPORT_WINCE + long Blt(HDC pDC, long x=0, long y=0); +#endif +#if CXIMAGE_SUPPORT_WINDOWS + HBITMAP MakeBitmap(HDC hdc = NULL); + HANDLE CopyToHandle(); + bool CreateFromHANDLE(HANDLE hMem); //Windows objects (clipboard) + bool CreateFromHBITMAP(HBITMAP hbmp, HPALETTE hpal=0); //Windows resource + bool CreateFromHICON(HICON hico); + long Draw(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0); + long Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL) { return Draw(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pClipRect); } + long Stretch(HDC hdc, long xoffset, long yoffset, long xsize, long ysize, DWORD dwRop = SRCCOPY); + long Stretch(HDC hdc, const RECT& rect, DWORD dwRop = SRCCOPY) { return Stretch(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwRop); } + long Tile(HDC hdc, RECT *rc); + long Draw2(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1); + long Draw2(HDC hdc, const RECT& rect) { return Draw2(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } + //long DrawString(HDC hdc, long x, long y, const char* text, RGBQUAD color, const char* font, long lSize=0, long lWeight=400, BYTE bItalic=0, BYTE bUnderline=0, bool bSetAlpha=false); + long DrawString(HDC hdc, long x, long y, const TCHAR* text, RGBQUAD color, const TCHAR* font, long lSize=0, long lWeight=400, BYTE bItalic=0, BYTE bUnderline=0, bool bSetAlpha=false); + // extensions + long DrawStringEx(HDC hdc, long x, long y, CXTEXTINFO *pTextType, bool bSetAlpha=false ); + void InitTextInfo( CXTEXTINFO *txt ); +#endif //CXIMAGE_SUPPORT_WINDOWS + + // file operations +#if CXIMAGE_SUPPORT_DECODE +#ifdef WIN32 + //bool Load(LPCWSTR filename, DWORD imagetype=0); + bool LoadResource(HRSRC hRes, DWORD imagetype, HMODULE hModule=NULL); +#endif + // For UNICODE support: char -> TCHAR + bool Load(const TCHAR* filename, DWORD imagetype=0); + //bool Load(const char * filename, DWORD imagetype=0); + bool Decode(FILE * hFile, DWORD imagetype); + bool Decode(CxFile * hFile, DWORD imagetype); + bool Decode(BYTE * buffer, DWORD size, DWORD imagetype); +#endif //CXIMAGE_SUPPORT_DECODE + +#if CXIMAGE_SUPPORT_ENCODE +protected: + bool EncodeSafeCheck(CxFile *hFile); +public: +#ifdef WIN32 + //bool Save(LPCWSTR filename, DWORD imagetype=0); +#endif + // For UNICODE support: char -> TCHAR + bool Save(const TCHAR* filename, DWORD imagetype=0); + //bool Save(const char * filename, DWORD imagetype=0); + bool Encode(FILE * hFile, DWORD imagetype); + bool Encode(CxFile * hFile, DWORD imagetype); + bool Encode(CxFile * hFile, CxImage ** pImages, int pagecount, DWORD imagetype); + bool Encode(FILE *hFile, CxImage ** pImages, int pagecount, DWORD imagetype); + bool Encode(BYTE * &buffer, long &size, DWORD imagetype); +#endif //CXIMAGE_SUPPORT_ENCODE + + //misc. + bool IsValid() const {return pDib!=0;} + bool IsEnabled() const {return info.bEnabled;} + void Enable(bool enable=true){info.bEnabled=enable;} + + // frame operations + long GetNumFrames() const {return info.nNumFrames;} + long GetFrame() const {return info.nFrame;} + void SetFrame(long nFrame) {info.nFrame=nFrame;} + +#if CXIMAGE_SUPPORT_BASICTRANSFORMATIONS + bool GrayScale(); + bool Flip(); + bool Mirror(); + bool Negative(); + bool RotateLeft(CxImage* iDst = NULL); + bool RotateRight(CxImage* iDst = NULL); +#endif //CXIMAGE_SUPPORT_BASICTRANSFORMATIONS + +#if CXIMAGE_SUPPORT_TRANSFORMATION + // image operations + bool Rotate(float angle, CxImage* iDst = NULL); + bool Rotate180(CxImage* iDst = NULL); + bool Resample(long newx, long newy, int mode = 1, CxImage* iDst = NULL); + bool DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal = 0, DWORD clrimportant = 0); + bool IncreaseBpp(DWORD nbit); + bool Dither(long method = 0); + bool Crop(long left, long top, long right, long bottom, CxImage* iDst = NULL); + bool Crop(const RECT& rect, CxImage* iDst = NULL) { return Crop(rect.left, rect.top, rect.right, rect.bottom, iDst); } + bool CropRotatedRectangle( long topx, long topy, long width, long height, float angle, CxImage* iDst = NULL); + bool Skew(float xgain, float ygain, long xpivot=0, long ypivot=0); + bool Expand(long left, long top, long right, long bottom, RGBQUAD canvascolor, CxImage* iDst = 0); + bool Expand(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0); + bool Thumbnail(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0); + bool CircleTransform(int type,long rmax=0,float Koeff=1.0f); + +protected: + float b3spline(float x); +public: +#endif //CXIMAGE_SUPPORT_TRANSFORMATION + +#if CXIMAGE_SUPPORT_DSP + bool Contour(); + bool HistogramStretch(long method = 0); + bool HistogramEqualize(); + bool HistogramNormalize(); + bool HistogramRoot(); + bool HistogramLog(); + long Histogram(long* red, long* green = 0, long* blue = 0, long* gray = 0, long colorspace = 0); + bool Jitter(long radius=2); + bool Repair(float radius = 0.25f, long niterations = 1, long colorspace = 0); + bool Combine(CxImage* r,CxImage* g,CxImage* b,CxImage* a, long colorspace = 0); + bool FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage* dstImag, long direction = 1, bool bForceFFT = true, bool bMagnitude = true); + bool Noise(long level); + bool Median(long Ksize=3); + bool Gamma(float gamma); + bool ShiftRGB(long r, long g, long b); + bool Threshold(BYTE level); + bool Colorize(BYTE hue, BYTE sat); + bool Light(long brightness, long contrast = 0); + float Mean(); + bool Filter(long* kernel, long Ksize, long Kfactor, long Koffset); + bool Erode(long Ksize=2); + bool Dilate(long Ksize=2); + void HuePalette(float correction=1); + enum ImageOpType { OpAdd, OpAnd, OpXor, OpOr, OpMask, OpSrcCopy, OpDstCopy, OpSub, OpSrcBlend }; + void Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset = 0, long lYOffset = 0); + void MixFrom(CxImage & imagesrc2, long lXOffset, long lYOffset); + bool UnsharpMask(float radius = 5.0, float amount = 0.5, int threshold = 0); + bool Lut(BYTE* pLut); + bool Lut(BYTE* pLutR, BYTE* pLutG, BYTE* pLutB, BYTE* pLutA = 0); + +protected: + bool IsPowerof2(long x); + bool FFT(int dir,int m,double *x,double *y); + bool DFT(int dir,long m,double *x1,double *y1,double *x2,double *y2); + bool RepairChannel(CxImage *ch, float radius); + // + int gen_convolve_matrix (float radius, float **cmatrix_p); + float* gen_lookup_table (float *cmatrix, int cmatrix_length); + void blur_line (float *ctable, float *cmatrix, int cmatrix_length, BYTE* cur_col, BYTE* dest_col, int y, long bytes); +public: + //color conversion utilities + bool SplitRGB(CxImage* r,CxImage* g,CxImage* b); + bool SplitYUV(CxImage* y,CxImage* u,CxImage* v); + bool SplitHSL(CxImage* h,CxImage* s,CxImage* l); + bool SplitYIQ(CxImage* y,CxImage* i,CxImage* q); + bool SplitXYZ(CxImage* x,CxImage* y,CxImage* z); + bool SplitCMYK(CxImage* c,CxImage* m,CxImage* y,CxImage* k); + RGBQUAD HSLtoRGB(COLORREF cHSLColor); + RGBQUAD RGBtoHSL(RGBQUAD lRGBColor); + RGBQUAD HSLtoRGB(RGBQUAD lHSLColor); + RGBQUAD YUVtoRGB(RGBQUAD lYUVColor); + RGBQUAD RGBtoYUV(RGBQUAD lRGBColor); + RGBQUAD YIQtoRGB(RGBQUAD lYIQColor); + RGBQUAD RGBtoYIQ(RGBQUAD lRGBColor); + RGBQUAD XYZtoRGB(RGBQUAD lXYZColor); + RGBQUAD RGBtoXYZ(RGBQUAD lRGBColor); +#endif //CXIMAGE_SUPPORT_DSP + RGBQUAD RGBtoRGBQUAD(COLORREF cr); + COLORREF RGBQUADtoRGB (RGBQUAD c); + +#if CXIMAGE_SUPPORT_SELECTION + //selection + bool SelectionClear(); + bool SelectionCreate(); + bool SelectionDelete(); + bool SelectionInvert(); + bool SelectionAddRect(RECT r); + bool SelectionAddEllipse(RECT r); + bool SelectionAddPolygon(POINT *points, long npoints); + bool SelectionAddColor(RGBQUAD c); + bool SelectionAddPixel(int x, int y); + bool SelectionCopy(CxImage &from); + bool SelectionIsInside(long x, long y); + bool SelectionIsValid(){return pSelection!=0;} + void SelectionGetBox(RECT& r){memcpy(&r,&info.rSelectionBox,sizeof(RECT));} + bool SelectionToHRGN(HRGN& region); +#endif //CXIMAGE_SUPPORT_SELECTION + +#if CXIMAGE_SUPPORT_ALPHA + //Alpha + void AlphaClear(); + void AlphaCreate(); + void AlphaDelete(); + void AlphaInvert(); + bool AlphaMirror(); + bool AlphaFlip(); + bool AlphaCopy(CxImage &from); + bool AlphaSplit(CxImage *dest); + void AlphaStrip(); + void AlphaSet(BYTE level); + bool AlphaSet(CxImage &from); + void AlphaSet(long x,long y,BYTE level); + BYTE AlphaGet(long x,long y); + BYTE AlphaGetMax() const {return info.nAlphaMax;} + void AlphaSetMax(BYTE nAlphaMax) {info.nAlphaMax=nAlphaMax;} + bool AlphaIsValid(){return pAlpha!=0;} + BYTE* AlphaGetBits() const {return pAlpha;} + + void AlphaPaletteClear(); + void AlphaPaletteEnable(bool enable=true){info.bAlphaPaletteEnabled=enable;} + bool AlphaPaletteIsEnabled(){return info.bAlphaPaletteEnabled;} + bool AlphaPaletteIsValid(); + bool AlphaPaletteSplit(CxImage *dest); +#endif //CXIMAGE_SUPPORT_ALPHA + +#if CXIMAGE_SUPPORT_LAYERS + bool LayerCreate(long position = -1); + bool LayerDelete(long position = -1); + void LayerDeleteAll(); + CxImage* GetLayer(long position); + CxImage* GetParent() const {return info.pParent;} + long GetNumLayers() const {return info.nNumLayers;} +#endif //CXIMAGE_SUPPORT_LAYERS + +protected: + void Startup(DWORD imagetype = 0); + void CopyInfo(const CxImage &src); + void Ghost(CxImage *src); + void RGBtoBGR(BYTE *buffer, int length); + float HueToRGB(float n1,float n2, float hue); + void Bitfield2RGB(BYTE *src, WORD redmask, WORD greenmask, WORD bluemask, BYTE bpp); + static int CompareColors(const void *elem1, const void *elem2); + + void* pDib; //contains the header, the palette, the pixels + BITMAPINFOHEADER head; //standard header + CXIMAGEINFO info; //extended information + BYTE* pSelection; //selected region + BYTE* pAlpha; //alpha channel + CxImage** pLayers; //generic layers +}; +//////////////////////////////////////////////////////////////////////////// + +#define CXIMAGE_MAX_MEMORY 256000000 + +#define CXIMAGE_ERR_NOFILE "null file handler" +#define CXIMAGE_ERR_NOIMAGE "null image!!!" +//////////////////////////////////////////////////////////////////////////// +#endif // !defined(__CXIMAGE_H) diff --git a/win32/include/cximage/ximagif.h b/win32/include/cximage/ximagif.h new file mode 100644 index 0000000..38ff831 --- /dev/null +++ b/win32/include/cximage/ximagif.h @@ -0,0 +1,262 @@ +/* + * File: ximagif.h + * Purpose: GIF Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageGIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes + * + * original CImageGIF and CImageIterator implementation are: + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * 6/15/97 Randy Spann: Added GIF87a writing support + * R.Spann@ConnRiver.net + * + * DECODE.C - An LZW decoder for GIF + * Copyright (C) 1987, by Steven A. Bennett + * Copyright (C) 1994, C++ version by Alejandro Aguilar Sierra + * + * In accordance with the above, I want to credit Steve Wilhite who wrote + * the code which this is heavily inspired by... + * + * GIF and 'Graphics Interchange Format' are trademarks (tm) of + * Compuserve, Incorporated, an H&R Block Company. + * + * Release Notes: This file contains a decoder routine for GIF images + * which is similar, structurally, to the original routine by Steve Wilhite. + * It is, however, somewhat noticably faster in most cases. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ + +#if !defined(__ximaGIF_h) +#define __ximaGIF_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_GIF + +typedef short int code_int; + +/* Various error codes used by decoder */ +#define OUT_OF_MEMORY -10 +#define BAD_CODE_SIZE -20 +#define READ_ERROR -1 +#define WRITE_ERROR -2 +#define OPEN_ERROR -3 +#define CREATE_ERROR -4 +#define MAX_CODES 4095 +#define GIFBUFTAM 16384 +#define TRANSPARENCY_CODE 0xF9 + +//LZW GIF Image compression +#define MAXBITSCODES 12 +#define HSIZE 5003 /* 80% occupancy */ +#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) +#define HashTabOf(i) htab[i] +#define CodeTabOf(i) codetab[i] + + +class CImageIterator; +class DLL_EXP CxImageGIF: public CxImage +{ +#pragma pack(1) + +typedef struct tag_gifgce{ + BYTE transpcolflag:1; + BYTE userinputflag:1; + BYTE dispmeth:3; + BYTE res:3; + WORD delaytime; + BYTE transpcolindex; +} struct_gifgce; + +typedef struct tag_dscgif{ /* Logic Screen Descriptor */ + char header[6]; /* Firma and version */ + WORD scrwidth; + WORD scrheight; + char pflds; + char bcindx; + char pxasrat; +} struct_dscgif; + +typedef struct tag_image{ /* Image Descriptor */ + WORD l; + WORD t; + WORD w; + WORD h; + BYTE pf; +} struct_image; + +typedef struct tag_TabCol{ /* Tabla de colores */ + short colres; /* color resolution */ + short sogct; /* size of global color table */ + rgb_color paleta[256]; /* paleta */ +} struct_TabCol; + +typedef struct tag_RLE{ + int rl_pixel; + int rl_basecode; + int rl_count; + int rl_table_pixel; + int rl_table_max; + int just_cleared; + int out_bits; + int out_bits_init; + int out_count; + int out_bump; + int out_bump_init; + int out_clear; + int out_clear_init; + int max_ocodes; + int code_clear; + int code_eof; + unsigned int obuf; + int obits; + unsigned char oblock[256]; + int oblen; +} struct_RLE; +#pragma pack() + +public: + CxImageGIF(): CxImage(CXIMAGE_FORMAT_GIF) {m_loops=0; m_dispmeth=0; m_comment[0]='\0';} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_GIF);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_GIF);} + + bool Decode(CxFile * fp); + bool Decode(FILE *fp) { CxIOFile file(fp); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * fp); + bool Encode(CxFile * fp, CxImage ** pImages, int pagecount, bool bLocalColorMap = false); + bool Encode(FILE *fp) { CxIOFile file(fp); return Encode(&file); } + bool Encode(FILE *fp, CxImage ** pImages, int pagecount, bool bLocalColorMap = false) + { CxIOFile file(fp); return Encode(&file, pImages, pagecount, bLocalColorMap); } +#endif // CXIMAGE_SUPPORT_ENCODE + + void SetLoops(int loops); + long GetLoops(); + void SetComment(const char* sz_comment_in); + void GetComment(char* sz_comment_out); + void SetDisposalMethod(int dm); + long GetDisposalMethod(); + +protected: + bool DecodeExtension(CxFile *fp); + void EncodeHeader(CxFile *fp); + void EncodeLoopExtension(CxFile *fp); + void EncodeExtension(CxFile *fp); + void EncodeBody(CxFile *fp, bool bLocalColorMap = false); + void EncodeComment(CxFile *fp); + bool EncodeRGB(CxFile *fp); + void GifMix(CxImage & imgsrc2, long lxOffset, long lyOffset); + + struct_gifgce gifgce; + + int curx, cury; + long CountDown; + unsigned long cur_accum; + int cur_bits; + int interlaced, iypos, istep, iheight, ipass; + int ibf; + int ibfmax; + BYTE buf[GIFBUFTAM + 1]; +// Implementation + int GifNextPixel (); + void Putword (int w, CxFile* fp ); + void compressNONE (int init_bits, CxFile* outfile); + void compressLZW (int init_bits, CxFile* outfile); + void output (code_int code ); + void cl_hash (long hsize); + void char_out (int c); + void flush_char (); + short init_exp(short size); + short get_next_code(CxFile*); + short decoder(CxFile*, CImageIterator* iter, short linewidth, int &bad_code_count); + int get_byte(CxFile*); + int out_line(CImageIterator* iter, unsigned char *pixels, int linelen); + int get_num_frames(CxFile *f,struct_TabCol* TabColSrc); + + short curr_size; /* The current code size */ + short clear; /* Value for a clear code */ + short ending; /* Value for a ending code */ + short newcodes; /* First available code */ + short top_slot; /* Highest code for current size */ + short slot; /* Last read code */ + + /* The following static variables are used + * for seperating out codes */ + short navail_bytes; /* # bytes left in block */ + short nbits_left; /* # bits left in current BYTE */ + BYTE b1; /* Current BYTE */ + BYTE byte_buff[257]; /* Current block */ + BYTE *pbytes; /* Pointer to next BYTE in block */ + /* The reason we have these seperated like this instead of using + * a structure like the original Wilhite code did, is because this + * stuff generally produces significantly faster code when compiled... + * This code is full of similar speedups... (For a good book on writing + * C for speed or for space optomisation, see Efficient C by Tom Plum, + * published by Plum-Hall Associates...) + */ + BYTE stack[MAX_CODES + 1]; /* Stack for storing pixels */ + BYTE suffix[MAX_CODES + 1]; /* Suffix table */ + WORD prefix[MAX_CODES + 1]; /* Prefix linked list */ + +//LZW GIF Image compression routines + long htab [HSIZE]; + unsigned short codetab [HSIZE]; + int n_bits; /* number of bits/code */ + code_int maxcode; /* maximum code, given n_bits */ + code_int free_ent; /* first unused entry */ + int clear_flg; + int g_init_bits; + CxFile* g_outfile; + int ClearCode; + int EOFCode; + + int a_count; + char accum[256]; + + char m_comment[256]; + int m_loops; + int m_dispmeth; + +//RLE compression routines + void compressRLE( int init_bits, CxFile* outfile); + void rle_clear(struct_RLE* rle); + void rle_flush(struct_RLE* rle); + void rle_flush_withtable(int count, struct_RLE* rle); + void rle_flush_clearorrep(int count, struct_RLE* rle); + void rle_flush_fromclear(int count,struct_RLE* rle); + void rle_output_plain(int c,struct_RLE* rle); + void rle_reset_out_clear(struct_RLE* rle); + unsigned int rle_compute_triangle_count(unsigned int count, unsigned int nrepcodes); + unsigned int rle_isqrt(unsigned int x); + void rle_write_block(struct_RLE* rle); + void rle_block_out(unsigned char c, struct_RLE* rle); + void rle_block_flush(struct_RLE* rle); + void rle_output(int val, struct_RLE* rle); + void rle_output_flush(struct_RLE* rle); +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximaico.h b/win32/include/cximage/ximaico.h new file mode 100644 index 0000000..5d541dd --- /dev/null +++ b/win32/include/cximage/ximaico.h @@ -0,0 +1,71 @@ +/* + * File: ximaico.h + * Purpose: ICON Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageICO (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Parts of the code come from FreeImage 2 + * Design and implementation by Floris van den Berg + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaICO_h) +#define __ximaICO_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_ICO + +class CxImageICO: public CxImage +{ +typedef struct tagIconDirectoryEntry { + BYTE bWidth; + BYTE bHeight; + BYTE bColorCount; + BYTE bReserved; + WORD wPlanes; + WORD wBitCount; + DWORD dwBytesInRes; + DWORD dwImageOffset; +} ICONDIRENTRY; + +typedef struct tagIconDir { + WORD idReserved; + WORD idType; + WORD idCount; +} ICONHEADER; + +public: + CxImageICO(): CxImage(CXIMAGE_FORMAT_ICO) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_ICO);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_ICO);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximaiter.h b/win32/include/cximage/ximaiter.h new file mode 100644 index 0000000..7b1564a --- /dev/null +++ b/win32/include/cximage/ximaiter.h @@ -0,0 +1,252 @@ +/* + * File: ImaIter.h + * Purpose: Declaration of the Platform Independent Image Base Class + * Author: Alejandro Aguilar Sierra + * Created: 1995 + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * 07/08/2001 Davide Pizzolato - www.xdp.it + * - removed slow loops + * - added safe checks + * + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ + +#if !defined(__ImaIter_h) +#define __ImaIter_h + +#include "ximage.h" +#include "ximadefs.h" + +class CImageIterator +{ +friend class CxImage; +protected: + int Itx, Ity; // Counters + int Stepx, Stepy; + BYTE* IterImage; // Image pointer + CxImage *ima; +public: + // Constructors + CImageIterator ( void ); + CImageIterator ( CxImage *image ); + operator CxImage* (); + + // Iterators + BOOL ItOK (); + void Reset (); + void Upset (); + void SetRow(BYTE *buf, int n); + void GetRow(BYTE *buf, int n); + BYTE GetByte( ) { return IterImage[Itx]; } + void SetByte(BYTE b) { IterImage[Itx] = b; } + BYTE* GetRow(void); + BYTE* GetRow(int n); + BOOL NextRow(); + BOOL PrevRow(); + BOOL NextByte(); + BOOL PrevByte(); + + void SetSteps(int x, int y=0) { Stepx = x; Stepy = y; } + void GetSteps(int *x, int *y) { *x = Stepx; *y = Stepy; } + BOOL NextStep(); + BOOL PrevStep(); + + void SetY(int y); /* AD - for interlace */ + int GetY() {return Ity;} + BOOL GetCol(BYTE* pCol, DWORD x); + BOOL SetCol(BYTE* pCol, DWORD x); +}; + +///////////////////////////////////////////////////////////////////// +inline +CImageIterator::CImageIterator(void) +{ + ima = 0; + IterImage = 0; + Itx = Ity = 0; + Stepx = Stepy = 0; +} +///////////////////////////////////////////////////////////////////// +inline +CImageIterator::CImageIterator(CxImage *imageImpl): ima(imageImpl) +{ + if (ima) IterImage = ima->GetBits(); + Itx = Ity = 0; + Stepx = Stepy = 0; +} +///////////////////////////////////////////////////////////////////// +inline +CImageIterator::operator CxImage* () +{ + return ima; +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::ItOK () +{ + if (ima) return ima->IsInside(Itx, Ity); + else return FALSE; +} +///////////////////////////////////////////////////////////////////// +inline void CImageIterator::Reset() +{ + if (ima) IterImage = ima->GetBits(); + else IterImage=0; + Itx = Ity = 0; +} +///////////////////////////////////////////////////////////////////// +inline void CImageIterator::Upset() +{ + Itx = 0; + Ity = ima->GetHeight()-1; + IterImage = ima->GetBits() + ima->GetEffWidth()*(ima->GetHeight()-1); +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::NextRow() +{ + if (++Ity >= (int)ima->GetHeight()) return 0; + IterImage += ima->GetEffWidth(); + return 1; +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::PrevRow() +{ + if (--Ity < 0) return 0; + IterImage -= ima->GetEffWidth(); + return 1; +} +/* AD - for interlace */ +inline void CImageIterator::SetY(int y) +{ + if ((y < 0) || (y > (int)ima->GetHeight())) return; + Ity = y; + IterImage = ima->GetBits() + ima->GetEffWidth()*y; +} +///////////////////////////////////////////////////////////////////// +inline void CImageIterator::SetRow(BYTE *buf, int n) +{ + if (n<0) n = (int)ima->GetEffWidth(); + else n = min(n,(int)ima->GetEffWidth()); + + if (IterImage) memcpy(IterImage,buf,n); +} +///////////////////////////////////////////////////////////////////// +inline void CImageIterator::GetRow(BYTE *buf, int n) +{ + if ((buf!=NULL)&&(n>0)) memcpy(buf,IterImage,n); +} +///////////////////////////////////////////////////////////////////// +inline BYTE* CImageIterator::GetRow() +{ + return IterImage; +} +///////////////////////////////////////////////////////////////////// +inline BYTE* CImageIterator::GetRow(int n) +{ + SetY(n); + return IterImage; +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::NextByte() +{ + if (++Itx < (int)ima->GetEffWidth()) return 1; + else + if (++Ity < (int)ima->GetHeight()){ + IterImage += ima->GetEffWidth(); + Itx = 0; + return 1; + } else + return 0; +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::PrevByte() +{ + if (--Itx >= 0) return 1; + else + if (--Ity >= 0){ + IterImage -= ima->GetEffWidth(); + Itx = 0; + return 1; + } else + return 0; +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::NextStep() +{ + Itx += Stepx; + if (Itx < (int)ima->GetEffWidth()) return 1; + else { + Ity += Stepy; + if (Ity < (int)ima->GetHeight()){ + IterImage += ima->GetEffWidth(); + Itx = 0; + return 1; + } else + return 0; + } +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::PrevStep() +{ + Itx -= Stepx; + if (Itx >= 0) return 1; + else { + Ity -= Stepy; + if (Ity >= 0 && Ity < (int)ima->GetHeight()) { + IterImage -= ima->GetEffWidth(); + Itx = 0; + return 1; + } else + return 0; + } +} +///////////////////////////////////////////////////////////////////// +inline BOOL CImageIterator::GetCol(BYTE* pCol, DWORD x) +{ + if ((pCol==0)||(ima->GetBpp()<8)||(x>=ima->GetWidth())) + return 0; + DWORD h = ima->GetHeight(); + DWORD line = ima->GetEffWidth(); + BYTE bytes = ima->GetBpp()>>3; + BYTE* pSrc; + for (DWORD y=0;yGetBits(y) + x*bytes; + for (BYTE w=0;wGetBpp()<8)||(x>=ima->GetWidth())) + return 0; + DWORD h = ima->GetHeight(); + DWORD line = ima->GetEffWidth(); + BYTE bytes = ima->GetBpp()>>3; + BYTE* pSrc; + for (DWORD y=0;yGetBits(y) + x*bytes; + for (BYTE w=0;wobj_) jas_free(stream->obj_); + stream->obj_ = pFile; + stream->ops_->close_ = JasClose; + stream->ops_->read_ = JasRead; + stream->ops_->seek_ = JasSeek; + stream->ops_->write_ = JasWrite; + } + static int JasRead(jas_stream_obj_t *obj, char *buf, int cnt) + { return ((CxFile*)obj)->Read(buf,1,cnt); } + static int JasWrite(jas_stream_obj_t *obj, char *buf, int cnt) + { return ((CxFile*)obj)->Write(buf,1,cnt); } + static long JasSeek(jas_stream_obj_t *obj, long offset, int origin) + { return ((CxFile*)obj)->Seek(offset,origin); } + static int JasClose(jas_stream_obj_t *obj) + { return 1; } + }; + +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximajbg.h b/win32/include/cximage/ximajbg.h new file mode 100644 index 0000000..0451c66 --- /dev/null +++ b/win32/include/cximage/ximajbg.h @@ -0,0 +1,60 @@ +/* + * File: ximajbg.h + * Purpose: JBG Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageJBG (c) 18/Aug/2002 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * based on LIBJBG Copyright (c) 2002, Markus Kuhn - All rights reserved. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaJBG_h) +#define __ximaJBG_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_JBG + +extern "C" { +#include "../jbig/jbig.h" +}; + +class CxImageJBG: public CxImage +{ +public: + CxImageJBG(): CxImage(CXIMAGE_FORMAT_JBG) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_JBG);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_JBG);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE +protected: + static void jbig_data_out(BYTE *buffer, unsigned int len, void *file) + {((CxFile*)file)->Write(buffer,len,1);} +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximajpg.h b/win32/include/cximage/ximajpg.h new file mode 100644 index 0000000..8053758 --- /dev/null +++ b/win32/include/cximage/ximajpg.h @@ -0,0 +1,321 @@ +/* + * File: ximajpg.h + * Purpose: JPG Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageJPG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes + * + * Special thanks to Chris Shearer Cooper for CxFileJpg tips & code + * + * EXIF support based on jhead-1.8 by Matthias Wandel + * + * original CImageJPG and CImageIterator implementation are: + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * This software is based in part on the work of the Independent JPEG Group. + * Copyright (C) 1991-1998, Thomas G. Lane. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaJPEG_h) +#define __ixmaJPEG_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_JPG + +#define CXIMAGEJPG_SUPPORT_EXIF 1 + +extern "C" { + #include "../jpeg/jpeglib.h" + #include "../jpeg/jerror.h" +} + +class DLL_EXP CxImageJPG: public CxImage +{ +public: + CxImageJPG(); + ~CxImageJPG() {}; + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_JPG);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_JPG);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE + +/* + * EXIF support based on jhead-1.8 by Matthias Wandel + */ + +#if CXIMAGEJPG_SUPPORT_EXIF + +#define MAX_COMMENT 1000 +#define MAX_SECTIONS 20 + +typedef struct tag_ExifInfo { + char Version [5]; + char CameraMake [32]; + char CameraModel [40]; + char DateTime [20]; + int Height, Width; + int Orientation; + int IsColor; + int Process; + int FlashUsed; + float FocalLength; + float ExposureTime; + float ApertureFNumber; + float Distance; + float CCDWidth; + float ExposureBias; + int Whitebalance; + int MeteringMode; + int ExposureProgram; + int ISOequivalent; + int CompressionLevel; + float FocalplaneXRes; + float FocalplaneYRes; + float FocalplaneUnits; + float Xresolution; + float Yresolution; + float ResolutionUnit; + float Brightness; + char Comments[MAX_COMMENT]; + + unsigned char * ThumbnailPointer; /* Pointer at the thumbnail */ + unsigned ThumbnailSize; /* Size of thumbnail. */ + + bool IsExif; +} EXIFINFO; + +//-------------------------------------------------------------------------- +// JPEG markers consist of one or more 0xFF bytes, followed by a marker +// code byte (which is not an FF). Here are the marker codes of interest +// in this program. (See jdmarker.c for a more complete list.) +//-------------------------------------------------------------------------- + +#define M_SOF0 0xC0 // Start Of Frame N +#define M_SOF1 0xC1 // N indicates which compression process +#define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use +#define M_SOF3 0xC3 +#define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers +#define M_SOF6 0xC6 +#define M_SOF7 0xC7 +#define M_SOF9 0xC9 +#define M_SOF10 0xCA +#define M_SOF11 0xCB +#define M_SOF13 0xCD +#define M_SOF14 0xCE +#define M_SOF15 0xCF +#define M_SOI 0xD8 // Start Of Image (beginning of datastream) +#define M_EOI 0xD9 // End Of Image (end of datastream) +#define M_SOS 0xDA // Start Of Scan (begins compressed data) +#define M_JFIF 0xE0 // Jfif marker +#define M_EXIF 0xE1 // Exif marker +#define M_COM 0xFE // COMment + +class CxExifInfo +{ + +typedef struct tag_Section_t{ + BYTE* Data; + int Type; + unsigned Size; +} Section_t; + +public: + EXIFINFO* m_exifinfo; + char m_szLastError[256]; + CxExifInfo(EXIFINFO* info = NULL); + ~CxExifInfo(); + bool DecodeExif(CxFile * hFile); +protected: + bool process_EXIF(unsigned char * CharBuf, unsigned int length); + void process_COM (const BYTE * Data, int length); + void process_SOFn (const BYTE * Data, int marker); + int Get16u(void * Short); + int Get16m(void * Short); + long Get32s(void * Long); + unsigned long Get32u(void * Long); + double ConvertAnyFormat(void * ValuePtr, int Format); + bool ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength, + EXIFINFO * const pInfo, unsigned char ** const LastExifRefdP); + int ExifImageWidth; + int MotorolaOrder; + Section_t Sections[MAX_SECTIONS]; + int SectionsRead; + bool freeinfo; +}; + + EXIFINFO m_exifinfo; + bool DecodeExif(CxFile * hFile); + bool DecodeExif(FILE * hFile) { CxIOFile file(hFile); return DecodeExif(&file); } + +#endif //CXIMAGEJPG_SUPPORT_EXIF + +//////////////////////////////////////////////////////////////////////////////////////// +////////////////////// C x F i l e J p g //////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////// + +// thanks to Chris Shearer Cooper +class CxFileJpg : public jpeg_destination_mgr, public jpeg_source_mgr + { +public: + enum { eBufSize = 4096 }; + + CxFileJpg(CxFile* pFile) + { + m_pFile = pFile; + + init_destination = InitDestination; + empty_output_buffer = EmptyOutputBuffer; + term_destination = TermDestination; + + init_source = InitSource; + fill_input_buffer = FillInputBuffer; + skip_input_data = SkipInputData; + resync_to_restart = jpeg_resync_to_restart; // use default method + term_source = TermSource; + next_input_byte = NULL; //* => next byte to read from buffer + bytes_in_buffer = 0; //* # of bytes remaining in buffer + + m_pBuffer = new unsigned char[eBufSize]; + } + ~CxFileJpg() + { + delete [] m_pBuffer; + } + + static void InitDestination(j_compress_ptr cinfo) + { + CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; + pDest->next_output_byte = pDest->m_pBuffer; + pDest->free_in_buffer = eBufSize; + } + + static boolean EmptyOutputBuffer(j_compress_ptr cinfo) + { + CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; + if (pDest->m_pFile->Write(pDest->m_pBuffer,1,eBufSize)!=(size_t)eBufSize) + ERREXIT(cinfo, JERR_FILE_WRITE); + pDest->next_output_byte = pDest->m_pBuffer; + pDest->free_in_buffer = eBufSize; + return TRUE; + } + + static void TermDestination(j_compress_ptr cinfo) + { + CxFileJpg* pDest = (CxFileJpg*)cinfo->dest; + size_t datacount = eBufSize - pDest->free_in_buffer; + /* Write any data remaining in the buffer */ + if (datacount > 0) { + if (!pDest->m_pFile->Write(pDest->m_pBuffer,1,datacount)) + ERREXIT(cinfo, JERR_FILE_WRITE); + } + pDest->m_pFile->Flush(); + /* Make sure we wrote the output file OK */ + if (pDest->m_pFile->Error()) ERREXIT(cinfo, JERR_FILE_WRITE); + return; + } + + static void InitSource(j_decompress_ptr cinfo) + { + CxFileJpg* pSource = (CxFileJpg*)cinfo->src; + pSource->m_bStartOfFile = TRUE; + } + + static boolean FillInputBuffer(j_decompress_ptr cinfo) + { + size_t nbytes; + CxFileJpg* pSource = (CxFileJpg*)cinfo->src; + nbytes = pSource->m_pFile->Read(pSource->m_pBuffer,1,eBufSize); + if (nbytes <= 0){ + if (pSource->m_bStartOfFile) //* Treat empty input file as fatal error + ERREXIT(cinfo, JERR_INPUT_EMPTY); + WARNMS(cinfo, JWRN_JPEG_EOF); + // Insert a fake EOI marker + pSource->m_pBuffer[0] = (JOCTET) 0xFF; + pSource->m_pBuffer[1] = (JOCTET) JPEG_EOI; + nbytes = 2; + } + pSource->next_input_byte = pSource->m_pBuffer; + pSource->bytes_in_buffer = nbytes; + pSource->m_bStartOfFile = FALSE; + return TRUE; + } + + static void SkipInputData(j_decompress_ptr cinfo, long num_bytes) + { + CxFileJpg* pSource = (CxFileJpg*)cinfo->src; + if (num_bytes > 0){ + while (num_bytes > (long)pSource->bytes_in_buffer){ + num_bytes -= (long)pSource->bytes_in_buffer; + FillInputBuffer(cinfo); + // note we assume that fill_input_buffer will never return FALSE, + // so suspension need not be handled. + } + pSource->next_input_byte += (size_t) num_bytes; + pSource->bytes_in_buffer -= (size_t) num_bytes; + } + } + + static void TermSource(j_decompress_ptr cinfo) + { + return; + } +protected: + CxFile *m_pFile; + unsigned char *m_pBuffer; + bool m_bStartOfFile; +}; + +public: + enum CODEC_OPTION + { + ENCODE_BASELINE = 0x1, + ENCODE_ARITHMETIC = 0x2, + ENCODE_GRAYSCALE = 0x4, + ENCODE_OPTIMIZE = 0x8, + ENCODE_PROGRESSIVE = 0x10, + ENCODE_LOSSLESS = 0x20, + ENCODE_SMOOTHING = 0x40, + DECODE_GRAYSCALE = 0x80, + DECODE_QUANTIZE = 0x100, + DECODE_DITHER = 0x200, + DECODE_ONEPASS = 0x400, + DECODE_NOSMOOTH = 0x800 + }; + + int m_nPredictor; + int m_nPointTransform; + int m_nSmoothing; + int m_nQuantize; + J_DITHER_MODE m_nDither; + +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximamng.h b/win32/include/cximage/ximamng.h new file mode 100644 index 0000000..6fd13f4 --- /dev/null +++ b/win32/include/cximage/ximamng.h @@ -0,0 +1,102 @@ +/* + * File: ximamng.h + * Purpose: Declaration of the MNG Image Class + * Author: Davide Pizzolato - www.xdp.it + * Created: 2001 + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageMNG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Frank Haug for suggestions and code. + * + * original mng.cpp code created by Nikolaus Brennig, November 14th, 2000. + * + * LIBMNG Copyright (c) 2000,2001 Gerard Juyn (gerard@libmng.com) + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ + +#if !defined(__ximaMNG_h) +#define __ximaMNG_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_MNG + +//#define MNG_NO_CMS +#define MNG_SUPPORT_DISPLAY +#define MNG_SUPPORT_READ +#define MNG_SUPPORT_WRITE +#define MNG_ACCESS_CHUNKS +#define MNG_STORE_CHUNKS + +extern "C" { +#include "../mng/libmng.h" +#include "../mng/libmng_data.h" +} + +//unsigned long _stdcall RunMNGThread(void *lpParam); + +typedef struct tagmngstuff +{ + CxFile *file; + BYTE *image; + HANDLE thread; + mng_uint32 delay; + mng_uint32 width; + mng_uint32 height; + mng_uint32 effwdt; + mng_int16 bpp; + mng_bool animation; + mng_bool animation_enabled; + float speed; + long nBkgndIndex; + RGBQUAD nBkgndColor; +} mngstuff; + +class CxImageMNG: public CxImage +{ +public: + CxImageMNG(); + ~CxImageMNG(); + + bool Load(const char * imageFileName); + bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_MNG);} + + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE + + long Resume(); + void SetSpeed(float speed); + + mng_handle hmng; + mngstuff mnginfo; +protected: + void WritePNG(mng_handle hMNG, int Frame, int FrameCount ); + void SetCallbacks(mng_handle mng); +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximapcx.h b/win32/include/cximage/ximapcx.h new file mode 100644 index 0000000..8324bae --- /dev/null +++ b/win32/include/cximage/ximapcx.h @@ -0,0 +1,80 @@ +/* + * File: ximapcx.h + * Purpose: PCX Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImagePCX (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Parts of the code come from Paintlib + * Copyright (c) 1996-1998 Ulrich von Zadow + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaPCX_h) +#define __ximaPCX_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_PCX + +class CxImagePCX: public CxImage +{ +// PCX Image File +#pragma pack(1) +typedef struct tagPCXHEADER +{ + char Manufacturer; // always 0X0A + char Version; // version number + char Encoding; // always 1 + char BitsPerPixel; // color bits + WORD Xmin, Ymin; // image origin + WORD Xmax, Ymax; // image dimensions + WORD Hres, Vres; // resolution values + BYTE ColorMap[16][3]; // color palette + char Reserved; + char ColorPlanes; // color planes + WORD BytesPerLine; // line buffer size + WORD PaletteType; // grey or color palette + char Filter[58]; +} PCXHEADER; +#pragma pack() + +public: + CxImagePCX(): CxImage(CXIMAGE_FORMAT_PCX) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PCX);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PCX);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE +protected: + void PCX_PlanesToPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel); + void PCX_UnpackPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel); + void PCX_PackPixels(const long p,BYTE &c, BYTE &n, CxFile &f); + void PCX_PackPlanes(BYTE* buff, const long size, CxFile &f); + void PCX_PixelsToPlanes(BYTE* raw, long width, BYTE* buf, long plane); +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximapng.h b/win32/include/cximage/ximapng.h new file mode 100644 index 0000000..d67a450 --- /dev/null +++ b/win32/include/cximage/ximapng.h @@ -0,0 +1,90 @@ +/* + * File: ximapng.h + * Purpose: PNG Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImagePNG (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes + * + * original CImagePNG and CImageIterator implementation are: + * Copyright: (c) 1995, Alejandro Aguilar Sierra + * + * libpng version 1.2.1 - December 12, 2001 + * Copyright (c) 1998-2001 Glenn Randers-Pehrson + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaPNG_h) +#define __ximaPNG_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_PNG + +extern "C" { +#include "../png/png.h" +} + +class CxImagePNG: public CxImage +{ +public: + CxImagePNG(): CxImage(CXIMAGE_FORMAT_PNG) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PNG);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PNG);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE + +protected: + void ima_png_error(png_struct *png_ptr, char *message); + void expand2to4bpp(BYTE* prow); + + static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) + { + CxFile* hFile = (CxFile*)png_ptr->io_ptr; + if (hFile->Read(data,1,length) != length) png_error(png_ptr, "Read Error"); + } + + static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t length) + { + CxFile* hFile = (CxFile*)png_ptr->io_ptr; + if (hFile->Write(data,1,length) != length) png_error(png_ptr, "Write Error"); + } + + static void user_flush_data(png_structp png_ptr) + { + CxFile* hFile = (CxFile*)png_ptr->io_ptr; + if (!hFile->Flush()) png_error(png_ptr, "Flush Error"); + } + static void user_error_fn(png_structp png_ptr,png_const_charp error_msg) + { + strncpy((char*)png_ptr->error_ptr,error_msg,255); + longjmp(png_ptr->jmpbuf, 1); + } +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximatga.h b/win32/include/cximage/ximatga.h new file mode 100644 index 0000000..0bdfa57 --- /dev/null +++ b/win32/include/cximage/ximatga.h @@ -0,0 +1,77 @@ +/* + * File: ximatga.h + * Purpose: TARGA Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageTGA (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Parts of the code come from Paintlib + * Copyright (c) 1996-1998 Ulrich von Zadow + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaTGA_h) +#define __ximaTGA_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_TGA + +class CxImageTGA: public CxImage +{ +#pragma pack(1) +typedef struct tagTgaHeader +{ + BYTE IdLength; // Image ID Field Length + BYTE CmapType; // Color Map Type + BYTE ImageType; // Image Type + + WORD CmapIndex; // First Entry Index + WORD CmapLength; // Color Map Length + BYTE CmapEntrySize; // Color Map Entry Size + + WORD X_Origin; // X-origin of Image + WORD Y_Origin; // Y-origin of Image + WORD ImageWidth; // Image Width + WORD ImageHeight; // Image Height + BYTE PixelDepth; // Pixel Depth + BYTE ImagDesc; // Image Descriptor +} TGAHEADER; +#pragma pack() + +public: + CxImageTGA(): CxImage(CXIMAGE_FORMAT_TGA) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TGA);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TGA);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE +protected: + BYTE ExpandCompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, BYTE rleLeftover); + void ExpandUncompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, int xoffset); +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximatif.h b/win32/include/cximage/ximatif.h new file mode 100644 index 0000000..997ef05 --- /dev/null +++ b/win32/include/cximage/ximatif.h @@ -0,0 +1,85 @@ +/* + * File: ximatif.h + * Purpose: TIFF Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageTIF (c) 07/Aug/2001 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * Special thanks to Troels Knakkergaard for new features, enhancements and bugfixes + * + * Special thanks to Abe for MultiPageTIFF code. + * + * Parts of the code come from FreeImage 2 + * Design and implementation by + * - Floris van den Berg (flvdberg@wxs.nl) + * - Hervé Drolon (drolon@iut.univ-lehavre.fr) + * - Markus Loibl (markus.loibl@epost.de) + * - Luca Piergentili (l.pierge@terra.es) + * + * LibTIFF is: + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ + + + +#if !defined(__ximatif_h) +#define __ximatif_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_TIF + +#include "../tiff/tiffio.h" + +class DLL_EXP CxImageTIF: public CxImage +{ +public: + CxImageTIF(): CxImage(CXIMAGE_FORMAT_TIF) {m_tif2=NULL; m_multipage=false; m_pages=0;} + ~CxImageTIF(); + + TIFF* TIFFOpenEx(CxFile * hFile); + void TIFFCloseEx(TIFF* tif); + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TIF);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TIF);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile, bool bAppend=false); + bool Encode(CxFile * hFile, CxImage ** pImages, int pagecount); + bool Encode(FILE *hFile, bool bAppend=false) { CxIOFile file(hFile); return Encode(&file,bAppend); } + bool Encode(FILE *hFile, CxImage ** pImages, int pagecount) + { CxIOFile file(hFile); return Encode(&file, pImages, pagecount); } +#endif // CXIMAGE_SUPPORT_ENCODE + +protected: + void TileToStrip(uint8* out, uint8* in, uint32 rows, uint32 cols, int outskew, int inskew); + bool EncodeBody(TIFF *m_tif, bool multipage=false, int page=0, int pagecount=0); + TIFF *m_tif2; + bool m_multipage; + int m_pages; +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximawbmp.h b/win32/include/cximage/ximawbmp.h new file mode 100644 index 0000000..b014470 --- /dev/null +++ b/win32/include/cximage/ximawbmp.h @@ -0,0 +1,60 @@ +/* + * File: ximawbmp.h + * Purpose: WBMP Image Class Loader and Writer + */ +/* === C R E D I T S & D I S C L A I M E R S ============== + * CxImageWBMP (c) 12/Jul/2002 Davide Pizzolato - www.xdp.it + * Permission is given by the author to freely redistribute and include + * this code in any program as long as this credit is given where due. + * + * CxImage version 5.99a 08/Feb/2004 + * See the file history.htm for the complete bugfix and news report. + * + * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY + * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES + * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE + * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED + * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT + * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL + * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER + * THIS DISCLAIMER. + * + * Use at your own risk! + * ========================================================== + */ +#if !defined(__ximaWBMP_h) +#define __ximaWBMP_h + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_WBMP + +class CxImageWBMP: public CxImage +{ +#pragma pack(1) +typedef struct tagWbmpHeader +{ + BYTE Type; // 0 + BYTE FixHeader; // 0 + BYTE ImageWidth; // Image Width + BYTE ImageHeight; // Image Height +} WBMPHEADER; +#pragma pack() +public: + CxImageWBMP(): CxImage(CXIMAGE_FORMAT_WBMP) {} + +// bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_WBMP);} +// bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_WBMP);} + bool Decode(CxFile * hFile); + bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE +}; + +#endif + +#endif diff --git a/win32/include/cximage/ximawmf.h b/win32/include/cximage/ximawmf.h new file mode 100644 index 0000000..75e119a --- /dev/null +++ b/win32/include/cximage/ximawmf.h @@ -0,0 +1,154 @@ +/* +********************************************************************* + * File: ximawmf.h + * Purpose: Windows Metafile Class Loader and Writer + * Author: Volker Horch - vhorch@gmx.de + * created: 13-Jun-2002 +********************************************************************* + */ + +/* +********************************************************************* + Notes by Author: +********************************************************************* + + Limitations: + ============ + + a) Transparency: + + A Metafile is vector graphics, which has transparency by design. + This class always converts into a Bitmap format. Transparency is + supported, but there is no good way to find out, which parts + of the Metafile are transparent. There are two ways how we can + handle this: + + - Clear the Background of the Bitmap with the background color + you like (i have used COLOR_WINDOW) and don't support transparency. + + below #define XMF_SUPPORT_TRANSPARENCY 0 + #define XMF_COLOR_BACK RGB(Background color you like) + + - Clear the Background of the Bitmap with a very unusual color + (which one ?) and use this color as the transparent color + + below #define XMF_SUPPORT_TRANSPARENCY 1 + #define XMF_COLOR_TRANSPARENT_R ... + #define XMF_COLOR_TRANSPARENT_G ... + #define XMF_COLOR_TRANSPARENT_B ... + + b) Resolution + + Once we have converted the Metafile into a Bitmap and we zoom in + or out, the image may not look very good. If we still had the + original Metafile, zooming would produce good results always. + + c) Size + + Although the filesize of a Metafile may be very small, it might + produce a Bitmap with a bombastic size. Assume you have a Metafile + with an image size of 6000*4000, which contains just one Metafile + record ((e.g. a line from (0,0) to (6000, 4000)). The filesize + of this Metafile would be let's say 100kB. If we convert it to + a 6000*4000 Bitmap with 24 Bits/Pixes, the Bitmap would consume + about 68MB of memory. + + I have choosen, to limit the size of the Bitmap to max. + screensize, to avoid memory problems. + + If you want something else, + modify #define XMF_MAXSIZE_CX / XMF_MAXSIZE_CY below + +********************************************************************* +*/ + +#ifndef _XIMAWMF_H +#define _XIMAWMF_H + +#include "ximage.h" + +#if CXIMAGE_SUPPORT_WMF && CXIMAGE_SUPPORT_WINDOWS + +class CxImageWMF: public CxImage +{ + +#pragma pack(1) + +typedef struct tagRECT16 +{ + short int left; + short int top; + short int right; + short int bottom; +} RECT16; + +// taken from Windos 3.11 SDK Documentation (Programmer's Reference Volume 4: Resources) +typedef struct tagMETAFILEHEADER +{ + DWORD key; // always 0x9ac6cdd7 + WORD reserved1; // reserved = 0 + RECT16 bbox; // bounding rectangle in metafile units as defined in "inch" + WORD inch; // number of metafile units per inch (should be < 1440) + DWORD reserved2; // reserved = 0 + WORD checksum; // sum of the first 10 WORDS (using XOR operator) +} METAFILEHEADER; + +#pragma pack() + +public: + CxImageWMF(): CxImage(CXIMAGE_FORMAT_WMF) { } + + bool Decode(CxFile * hFile, long nForceWidth=0, long nForceHeight=0); + bool Decode(FILE *hFile, long nForceWidth=0, long nForceHeight=0) + { CxIOFile file(hFile); return Decode(&file,nForceWidth,nForceHeight); } + +#if CXIMAGE_SUPPORT_ENCODE + bool Encode(CxFile * hFile); + bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); } +#endif // CXIMAGE_SUPPORT_ENCODE + +protected: + void ShrinkMetafile(int &cx, int &cy); + BOOL CheckMetafileHeader(METAFILEHEADER *pmetafileheader); + HENHMETAFILE ConvertWmfFiletoEmf(CxFile *pFile, METAFILEHEADER *pmetafileheader); + HENHMETAFILE ConvertEmfFiletoEmf(CxFile *pFile, ENHMETAHEADER *pemfh); + +}; + +#define METAFILEKEY 0x9ac6cdd7L + +// Background color definition (if no transparency). see Notes above +#define XMF_COLOR_BACK GetSysColor(COLOR_WINDOW) +// alternatives +//#define XMF_COLOR_BACK RGB(192, 192, 192) // lite gray +//#define XMF_COLOR_BACK RGB( 0, 0, 0) // black +//#define XMF_COLOR_BACK RGB(255, 255, 255) // white + + +// transparency support. see Notes above +#define XMF_SUPPORT_TRANSPARENCY 0 +#define XMF_COLOR_TRANSPARENT_R 211 +#define XMF_COLOR_TRANSPARENT_G 121 +#define XMF_COLOR_TRANSPARENT_B 112 +// don't change +#define XMF_COLOR_TRANSPARENT RGB (XMF_COLOR_TRANSPARENT_R, \ + XMF_COLOR_TRANSPARENT_G, \ + XMF_COLOR_TRANSPARENT_B) +// don't change +#define XMF_RGBQUAD_TRANSPARENT XMF_COLOR_TRANSPARENT_B, \ + XMF_COLOR_TRANSPARENT_G, \ + XMF_COLOR_TRANSPARENT_R, \ + 0 +// max. size. see Notes above +// alternatives +//#define XMF_MAXSIZE_CX (GetSystemMetrics(SM_CXSCREEN)-10) +//#define XMF_MAXSIZE_CY (GetSystemMetrics(SM_CYSCREEN)-50) +//#define XMF_MAXSIZE_CX (2*GetSystemMetrics(SM_CXSCREEN)/3) +//#define XMF_MAXSIZE_CY (2*GetSystemMetrics(SM_CYSCREEN)/3) +#define XMF_MAXSIZE_CX 4000 +#define XMF_MAXSIZE_CY 4000 + + +#endif + +#endif diff --git a/win32/include/cximage/xiofile.h b/win32/include/cximage/xiofile.h new file mode 100644 index 0000000..46c15f2 --- /dev/null +++ b/win32/include/cximage/xiofile.h @@ -0,0 +1,112 @@ +#if !defined(__xiofile_h) +#define __xiofile_h + +#include "xfile.h" + +class DLL_EXP CxIOFile : public CxFile + { +public: + CxIOFile(FILE* fp = NULL) + { + m_fp = fp; + m_bCloseFile = (bool)(fp==0); + } + + ~CxIOFile() + { + Close(); + } +////////////////////////////////////////////////////////// + bool Open(const char *filename, const char *mode) + { + if (m_fp) return false; // Can't re-open without closing first + + m_fp = fopen(filename, mode); + if (!m_fp) return false; + + m_bCloseFile = true; + + return true; + } +////////////////////////////////////////////////////////// + virtual bool Close() + { + int iErr = 0; + if ( (m_fp) && (m_bCloseFile) ){ + iErr = fclose(m_fp); + m_fp = NULL; + } + return (bool)(iErr==0); + } +////////////////////////////////////////////////////////// + virtual size_t Read(void *buffer, size_t size, size_t count) + { + if (!m_fp) return 0; + return fread(buffer, size, count, m_fp); + } +////////////////////////////////////////////////////////// + virtual size_t Write(const void *buffer, size_t size, size_t count) + { + if (!m_fp) return 0; + return fwrite(buffer, size, count, m_fp); + } +////////////////////////////////////////////////////////// + virtual bool Seek(long offset, int origin) + { + if (!m_fp) return false; + return (bool)(fseek(m_fp, offset, origin) == 0); + } +////////////////////////////////////////////////////////// + virtual long Tell() + { + if (!m_fp) return 0; + return ftell(m_fp); + } +////////////////////////////////////////////////////////// + virtual long Size() + { + if (!m_fp) return -1; + long pos,size; + pos = ftell(m_fp); + fseek(m_fp, 0, SEEK_END); + size = ftell(m_fp); + fseek(m_fp, pos,SEEK_SET); + return size; + } +////////////////////////////////////////////////////////// + virtual bool Flush() + { + if (!m_fp) return false; + return (bool)(fflush(m_fp) == 0); + } +////////////////////////////////////////////////////////// + virtual bool Eof() + { + if (!m_fp) return true; + return (bool)(feof(m_fp) != 0); + } +////////////////////////////////////////////////////////// + virtual long Error() + { + if (!m_fp) return -1; + return ferror(m_fp); + } +////////////////////////////////////////////////////////// + virtual bool PutC(unsigned char c) + { + if (!m_fp) return false; + return (bool)(fputc(c, m_fp) == c); + } +////////////////////////////////////////////////////////// + virtual long GetC() + { + if (!m_fp) return EOF; + return getc(m_fp); + } +////////////////////////////////////////////////////////// +protected: + FILE *m_fp; + bool m_bCloseFile; + }; + +#endif diff --git a/win32/include/cximage/xmemfile.h b/win32/include/cximage/xmemfile.h new file mode 100644 index 0000000..197cb8b --- /dev/null +++ b/win32/include/cximage/xmemfile.h @@ -0,0 +1,69 @@ +#if !defined(__xmemfile_h) +#define __xmemfile_h + +#include "xfile.h" + +////////////////////////////////////////////////////////// +class DLL_EXP CxMemFile : public CxFile + { +public: + CxMemFile(BYTE* pBuffer = NULL, DWORD size = 0) + { + m_pBuffer = pBuffer; + m_Position = 0; + m_Size = m_Edge = size; + m_bFreeOnClose = (bool)(pBuffer==0); + } +////////////////////////////////////////////////////////// + ~CxMemFile() + { + Close(); + } +////////////////////////////////////////////////////////// + virtual bool Close() + { + if ( (m_pBuffer) && (m_bFreeOnClose) ){ + free(m_pBuffer); + m_pBuffer = NULL; + m_Size = 0; + } + return true; + } +////////////////////////////////////////////////////////// + bool Open() + { + if (m_pBuffer) return false; // Can't re-open without closing first + + m_Position = m_Size = m_Edge = 0; + m_pBuffer=(BYTE*)malloc(0); + m_bFreeOnClose = true; + + return (m_pBuffer!=0); + } +////////////////////////////////////////////////////////// +BYTE* GetBuffer(bool bDetachBuffer = true) { m_bFreeOnClose = !bDetachBuffer; return m_pBuffer;} +////////////////////////////////////////////////////////// + virtual size_t Read(void *buffer, size_t size, size_t count); + virtual size_t Write(const void *buffer, size_t size, size_t count); + virtual bool Seek(long offset, int origin); + virtual long Tell(); + virtual long Size(); + virtual bool Flush(); + virtual bool Eof(); + virtual long Error(); + virtual bool PutC(unsigned char c); + virtual long GetC(); + +protected: + void Alloc(DWORD nBytes); + void Free(); + +protected: + BYTE* m_pBuffer; + DWORD m_Size; + bool m_bFreeOnClose; + long m_Position; //current position + long m_Edge; //buffer size + }; + +#endif diff --git a/win32/include/png/png.h b/win32/include/png/png.h new file mode 100644 index 0000000..f9d4cbd --- /dev/null +++ b/win32/include/png/png.h @@ -0,0 +1,3156 @@ + +/* png.h - header file for PNG reference library + * + * libpng version 1.2.0 - September 1, 2001 + * Copyright (c) 1998-2001 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.0 - September 1, 2001: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-4 3 10200 3.1.2.0beta3-4 + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as RFC 2083 + * and as a W3C Recommendation + */ + +/* + * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * + * If you modify libpng you may insert additional notices immediately following + * this sentence. + * + * libpng versions 1.0.7, July 1, 2000, through 1.2.0, September 1, 2001, are + * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are + * distributed according to the same disclaimer and license as libpng-1.0.6 + * with the following individuals added to the list of Contributing Authors + * + * Simon-Pierre Cadieux + * Eric S. Raymond + * Gilles Vollant + * + * and with the following additions to the disclaimer: + * + * There is no warranty against interference with your enjoyment of the + * library or against infringement. There is no warranty that our + * efforts or the library will fulfill any of your particular purposes + * or needs. This library is provided with all faults, and the entire + * risk of satisfactory quality, performance, accuracy, and effort is with + * the user. + * + * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are + * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson + * Distributed according to the same disclaimer and license as libpng-0.96, + * with the following individuals added to the list of Contributing Authors: + * + * Tom Lane + * Glenn Randers-Pehrson + * Willem van Schaik + * + * libpng versions 0.89, June 1996, through 0.96, May 1997, are + * Copyright (c) 1996, 1997 Andreas Dilger + * Distributed according to the same disclaimer and license as libpng-0.88, + * with the following individuals added to the list of Contributing Authors: + * + * John Bowler + * Kevin Bracey + * Sam Bushell + * Magnus Holmgren + * Greg Roelofs + * Tom Tanner + * + * libpng versions 0.5, May 1995, through 0.88, January 1996, are + * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + * + * For the purposes of this copyright and license, "Contributing Authors" + * is defined as the following set of individuals: + * + * Andreas Dilger + * Dave Martindale + * Guy Eric Schalnat + * Paul Schmidt + * Tim Wegner + * + * The PNG Reference Library is supplied "AS IS". The Contributing Authors + * and Group 42, Inc. disclaim all warranties, expressed or implied, + * including, without limitation, the warranties of merchantability and of + * fitness for any purpose. The Contributing Authors and Group 42, Inc. + * assume no liability for direct, indirect, incidental, special, exemplary, + * or consequential damages, which may result from the use of the PNG + * Reference Library, even if advised of the possibility of such damage. + * + * Permission is hereby granted to use, copy, modify, and distribute this + * source code, or portions hereof, for any purpose, without fee, subject + * to the following restrictions: + * + * 1. The origin of this source code must not be misrepresented. + * + * 2. Altered versions must be plainly marked as such and + * must not be misrepresented as being the original source. + * + * 3. This Copyright notice may not be removed or altered from + * any source or altered source distribution. + * + * The Contributing Authors and Group 42, Inc. specifically permit, without + * fee, and encourage the use of this source code as a component to + * supporting the PNG file format in commercial products. If you use this + * source code in a product, acknowledgment is not required but would be + * appreciated. + */ + +/* + * A "png_get_copyright" function is available, for convenient use in "about" + * boxes and the like: + * + * printf("%s",png_get_copyright(NULL)); + * + * Also, the PNG logo (in PNG format, of course) is supplied in the + * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + */ + +/* + * Libpng is OSI Certified Open Source Software. OSI Certified is a + * certification mark of the Open Source Initiative. + */ + +/* + * The contributing authors would like to thank all those who helped + * with testing, bug fixes, and patience. This wouldn't have been + * possible without all of you. + * + * Thanks to Frank J. T. Wojcik for helping with the documentation. + */ + +/* + * Y2K compliance in libpng: + * ========================= + * + * September 1, 2001 + * + * Since the PNG Development group is an ad-hoc body, we can't make + * an official declaration. + * + * This is your unofficial assurance that libpng from version 0.71 and + * upward through 1.2.0 are Y2K compliant. It is my belief that earlier + * versions were also Y2K compliant. + * + * Libpng only has three year fields. One is a 2-byte unsigned integer + * that will hold years up to 65535. The other two hold the date in text + * format, and will hold years up to 9999. + * + * The integer is + * "png_uint_16 year" in png_time_struct. + * + * The strings are + * "png_charp time_buffer" in png_struct and + * "near_time_buffer", which is a local character string in png.c. + * + * There are seven time-related functions: + * png.c: png_convert_to_rfc_1123() in png.c + * (formerly png_convert_to_rfc_1152() in error) + * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c + * png_convert_from_time_t() in pngwrite.c + * png_get_tIME() in pngget.c + * png_handle_tIME() in pngrutil.c, called in pngread.c + * png_set_tIME() in pngset.c + * png_write_tIME() in pngwutil.c, called in pngwrite.c + * + * All handle dates properly in a Y2K environment. The + * png_convert_from_time_t() function calls gmtime() to convert from system + * clock time, which returns (year - 1900), which we properly convert to + * the full 4-digit year. There is a possibility that applications using + * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() + * function, or that they are incorrectly passing only a 2-digit year + * instead of "year - 1900" into the png_convert_from_struct_tm() function, + * but this is not under our control. The libpng documentation has always + * stated that it works with 4-digit years, and the APIs have been + * documented as such. + * + * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned + * integer to hold the year, and can hold years as large as 65535. + * + * zlib, upon which libpng depends, is also Y2K compliant. It contains + * no date-related code. + * + * Glenn Randers-Pehrson + * libpng maintainer + * PNG Development Group + */ + +#ifndef PNG_H +#define PNG_H + +/* This is not the place to learn how to use libpng. The file libpng.txt + * describes how to use libpng, and the file example.c summarizes it + * with some code on which to build. This file is useful for looking + * at the actual function definitions and structure components. + */ + +/* Version information for png.h - this should match the version in png.c */ +#define PNG_LIBPNG_VER_STRING "1.2.0" + +#define PNG_LIBPNG_VER_SONUM 3 +#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% + +/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ +#define PNG_LIBPNG_VER_MAJOR 1 +#define PNG_LIBPNG_VER_MINOR 2 +#define PNG_LIBPNG_VER_RELEASE 0 +/* This should match the numeric part of the final component of + * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ + +#define PNG_LIBPNG_VER_BUILD 0 + +#define PNG_LIBPNG_BUILD_ALPHA 1 +#define PNG_LIBPNG_BUILD_BETA 2 +#define PNG_LIBPNG_BUILD_RC 3 +#define PNG_LIBPNG_BUILD_STABLE 4 +#define PNG_LIBPNG_BUILD_TYPEMASK 7 +#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */ +#define PNG_LIBPNG_BUILD_TYPE 4 + +/* Careful here. At one time, Guy wanted to use 082, but that would be octal. + * We must not include leading zeros. + * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only + * version 1.0.0 was mis-numbered 100 instead of 10000). From + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ +#define PNG_LIBPNG_VER 10200 /* 1.2.0 */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* include the compression library's header */ +#include "zlib.h" + +/* include all user configurable info, including optional assembler routines */ +#include "pngconf.h" + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* This file is arranged in several sections. The first section contains + * structure and type definitions. The second section contains the external + * library functions, while the third has the internal library functions, + * which applications aren't expected to use directly. + */ + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* Version information for C files, stored in png.c. This had better match + * the version above. + */ +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const char) png_libpng_ver[18]; + /* need room for 99.99.99beta99z*/ +#else +#define png_libpng_ver png_get_header_ver(NULL) +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* This was removed in version 1.0.5c */ +/* Structures to facilitate easy interlacing. See png.c for more details */ +PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; +#endif +/* This isn't currently used. If you need it, see png.c for more details. +PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; +*/ +#endif + +#endif /* PNG_NO_EXTERN */ + +/* Three color definitions. The order of the red, green, and blue, (and the + * exact size) is not important, although the size of the fields need to + * be png_byte or png_uint_16 (as defined below). + */ +typedef struct png_color_struct +{ + png_byte red; + png_byte green; + png_byte blue; +} png_color; +typedef png_color FAR * png_colorp; +typedef png_color FAR * FAR * png_colorpp; + +typedef struct png_color_16_struct +{ + png_byte index; /* used for palette files */ + png_uint_16 red; /* for use in red green blue files */ + png_uint_16 green; + png_uint_16 blue; + png_uint_16 gray; /* for use in grayscale files */ +} png_color_16; +typedef png_color_16 FAR * png_color_16p; +typedef png_color_16 FAR * FAR * png_color_16pp; + +typedef struct png_color_8_struct +{ + png_byte red; /* for use in red green blue files */ + png_byte green; + png_byte blue; + png_byte gray; /* for use in grayscale files */ + png_byte alpha; /* for alpha channel files */ +} png_color_8; +typedef png_color_8 FAR * png_color_8p; +typedef png_color_8 FAR * FAR * png_color_8pp; + +/* + * The following two structures are used for the in-core representation + * of sPLT chunks. + */ +typedef struct png_sPLT_entry_struct +{ + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + png_uint_16 alpha; + png_uint_16 frequency; +} png_sPLT_entry; +typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; + +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + +typedef struct png_sPLT_struct +{ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ +} png_sPLT_t; +typedef png_sPLT_t FAR * png_sPLT_tp; +typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; + +#ifdef PNG_TEXT_SUPPORTED +/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, + * and whether that contents is compressed or not. The "key" field + * points to a regular zero-terminated C string. The "text", "lang", and + * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. + * However, the * structure returned by png_get_text() will always contain + * regular zero-terminated C strings (possibly empty), never NULL pointers, + * so they can be safely used in printf() and other string-handling functions. + */ +typedef struct png_text_struct +{ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ + png_charp key; /* keyword, 1-79 character description of "text" */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ + png_size_t text_length; /* length of the text string */ +#ifdef PNG_iTXt_SUPPORTED + png_size_t itxt_length; /* length of the itxt string */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ + png_charp lang_key; /* keyword translated UTF-8 string, 0 or more + chars or a NULL pointer */ +#endif +} png_text; +typedef png_text FAR * png_textp; +typedef png_text FAR * FAR * png_textpp; +#endif + +/* Supported compression types for text in PNG files (tEXt, and zTXt). + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ +#define PNG_TEXT_COMPRESSION_NONE_WR -3 +#define PNG_TEXT_COMPRESSION_zTXt_WR -2 +#define PNG_TEXT_COMPRESSION_NONE -1 +#define PNG_TEXT_COMPRESSION_zTXt 0 +#define PNG_ITXT_COMPRESSION_NONE 1 +#define PNG_ITXT_COMPRESSION_zTXt 2 +#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ + +/* png_time is a way to hold the time in an machine independent way. + * Two conversions are provided, both from time_t and struct tm. There + * is no portable way to convert to either of these structures, as far + * as I know. If you know of a portable way, send it to me. As a side + * note - PNG has always been Year 2000 compliant! + */ +typedef struct png_time_struct +{ + png_uint_16 year; /* full year, as in, 1995 */ + png_byte month; /* month of year, 1 - 12 */ + png_byte day; /* day of month, 1 - 31 */ + png_byte hour; /* hour of day, 0 - 23 */ + png_byte minute; /* minute of hour, 0 - 59 */ + png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ +} png_time; +typedef png_time FAR * png_timep; +typedef png_time FAR * FAR * png_timepp; + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* png_unknown_chunk is a structure to hold queued chunks for which there is + * no specific support. The idea is that we can use this to queue + * up private chunks for output even though the library doesn't actually + * know about their semantics. + */ +typedef struct png_unknown_chunk_t +{ + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* libpng-using applications should NOT directly modify this byte. */ + png_byte location; /* mode of operation at read time */ +} +png_unknown_chunk; +typedef png_unknown_chunk FAR * png_unknown_chunkp; +typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; +#endif + +/* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, then call png_write_info(). + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. + * + * In any case, the order of the parameters in png_info_struct should NOT + * be changed for as long as possible to keep compatibility with applications + * that use the old direct-access method with png_info_struct. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +typedef struct png_info_struct +{ + /* the following are necessary for every PNG file */ + png_uint_32 width; /* width of image in pixels (from IHDR) */ + png_uint_32 height; /* height of image in pixels (from IHDR) */ + png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ + png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ + png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ + png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ + png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ + png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following is informational only on read, and not used on writes. */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + /* The gAMA chunk describes the gamma characteristics of the system + * on which the image was created, normally in the range [1.0, 2.5]. + * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. + */ + float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_sRGB_SUPPORTED) + /* GR-P, 0.96a */ + /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ + png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ +#endif + +#if defined(PNG_TEXT_SUPPORTED) + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read/to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read/to write */ +#endif /* PNG_TEXT_SUPPORTED */ + +#if defined(PNG_tIME_SUPPORTED) + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#if defined(PNG_sBIT_SUPPORTED) + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans; /* transparent values for paletted image */ + png_color_16 trans_values; /* transparent color for non-palette image */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The bKGD chunk gives the suggested image background color if the + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#if defined(PNG_oFFs_SUPPORTED) + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#if defined(PNG_pHYs_SUPPORTED) + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#if defined(PNG_hIST_SUPPORTED) + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_cHRM_SUPPORTED + /* The cHRM chunk describes the CIE color characteristics of the monitor + * on which the PNG was created. This data allows the viewer to do gamut + * mapping of the input image to ensure that the viewer sees the same + * colors in the image as the creator. Values are in the range + * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float x_white; + float y_white; + float x_red; + float y_red; + float x_green; + float y_green; + float x_blue; + float y_blue; +#endif +#endif + +#if defined(PNG_pCAL_SUPPORTED) + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + png_size_t unknown_chunks_num; +#endif + +#if defined(PNG_iCCP_SUPPORTED) + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_charp iccp_profile; /* International Color Consortium profile data */ + /* Note to maintainer: should be png_bytep */ + png_uint_32 iccp_proflen; /* ICC profile data length */ + png_byte iccp_compression; /* Always zero */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) + /* data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + png_uint_32 splt_palettes_num; +#endif + +#if defined(PNG_sCAL_SUPPORTED) + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. This external representation is converted to double + * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + double scal_pixel_width; /* width of one pixel */ + double scal_pixel_height; /* height of one pixel */ +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif +#endif + +#if defined(PNG_INFO_IMAGE_SUPPORTED) + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) + png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) + png_fixed_point int_x_white; + png_fixed_point int_y_white; + png_fixed_point int_x_red; + png_fixed_point int_y_red; + png_fixed_point int_x_green; + png_fixed_point int_y_green; + png_fixed_point int_x_blue; + png_fixed_point int_y_blue; +#endif + +} png_info; + +typedef png_info FAR * png_infop; +typedef png_info FAR * FAR * png_infopp; + +/* Maximum positive integer used in PNG is (2^31)-1 */ +#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL) + +/* These describe the color_type field in png_info. */ +/* color type masks */ +#define PNG_COLOR_MASK_PALETTE 1 +#define PNG_COLOR_MASK_COLOR 2 +#define PNG_COLOR_MASK_ALPHA 4 + +/* color types. Note that not all combinations are legal */ +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) +#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) +#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) +#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) +/* aliases */ +#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA +#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA + +/* This is for compression type. PNG 1.0-1.2 only define the single type. */ +#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ +#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE + +/* This is for filter type. PNG 1.0-1.2 only define the single type. */ +#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ +#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ +#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE + +/* These are for the interlacing type. These values should NOT be changed. */ +#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ +#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ +#define PNG_INTERLACE_LAST 2 /* Not a valid value */ + +/* These are for the oFFs chunk. These values should NOT be changed. */ +#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ +#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ +#define PNG_OFFSET_LAST 2 /* Not a valid value */ + +/* These are for the pCAL chunk. These values should NOT be changed. */ +#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ +#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ +#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ +#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ +#define PNG_EQUATION_LAST 4 /* Not a valid value */ + +/* These are for the sCAL chunk. These values should NOT be changed. */ +#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ +#define PNG_SCALE_METER 1 /* meters per pixel */ +#define PNG_SCALE_RADIAN 2 /* radians per pixel */ +#define PNG_SCALE_LAST 3 /* Not a valid value */ + +/* These are for the pHYs chunk. These values should NOT be changed. */ +#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ +#define PNG_RESOLUTION_METER 1 /* pixels/meter */ +#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ + +/* These are for the sRGB chunk. These values should NOT be changed. */ +#define PNG_sRGB_INTENT_PERCEPTUAL 0 +#define PNG_sRGB_INTENT_RELATIVE 1 +#define PNG_sRGB_INTENT_SATURATION 2 +#define PNG_sRGB_INTENT_ABSOLUTE 3 +#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ + +/* This is for text chunks */ +#define PNG_KEYWORD_MAX_LENGTH 79 + +/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ +#define PNG_MAX_PALETTE_LENGTH 256 + +/* These determine if an ancillary chunk's data has been successfully read + * from the PNG header, or if the application has filled in the corresponding + * data in the info_struct to be written into the output file. The values + * of the PNG_INFO_ defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions*/ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +# if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +# endif /* PNG_READ_GAMMA && PNG_bKGD_SUPPORTED */ +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ + png_uint_32 mng_features_permitted; +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; + png_uint_32 asm_flags; +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +}; + + +/* This prevents a compiler error in png_get_copyright() in png.c if png.c + and png.h are both at version 1.2.0 + */ +typedef png_structp version_1_2_0; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read a one or more rows of image data.*/ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); + +/* read a row of data.*/ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); + +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy_info PNGARG((png_infop info_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error)); + +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp message)); + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behavour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#define png_debug(l,m) _RPT0(_CRT_WARN,m) +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ +#if (PNG_DEBUG > 1) +#define png_debug(l,m) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ +} +#define png_debug1(l,m,p1) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ +} +#define png_debug2(l,m,p1,p2) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ +} +#endif /* (PNG_DEBUG > 1) */ +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 + + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +#define PNG_HEADER_VERSION_STRING \ + " libpng version 1.2.0 - September 1, 2001 (header)\n" + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +#if defined(PNG_INTERNAL) + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L + +/* For use in png_set_keep_unknown, png_handle_as_unknown */ +#define HANDLE_CHUNK_AS_DEFAULT 0 +#define HANDLE_CHUNK_NEVER 1 +#define HANDLE_CHUNK_IF_SAFE 2 +#define HANDLE_CHUNK_ALWAYS 3 + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#define png_sig png_sig_bytes(NULL) +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +# endif +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +#else +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); +# endif +PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); +PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ + +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + * The only currently known PNG chunks that use signed numbers are + * the ancillary extension chunks, oFFs and pCAL. + */ +PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); + +#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); +#endif + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXTERN int png_handle_as_unknown PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/win32/include/png/pngasmrd.h b/win32/include/png/pngasmrd.h new file mode 100644 index 0000000..420f5fe --- /dev/null +++ b/win32/include/png/pngasmrd.h @@ -0,0 +1,11 @@ +/* pngasmrd.h - assembler version of utilities to read a PNG file + * + * libpng 1.2.0 - September 1, 2001 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 2001 Glenn Randers-Pehrson + * + */ + +/* This file is obsolete in libpng-1.0.9 and later; its contents now appear + * at the end of pngconf.h. + */ diff --git a/win32/include/png/pngconf.h b/win32/include/png/pngconf.h new file mode 100644 index 0000000..18d6f65 --- /dev/null +++ b/win32/include/png/pngconf.h @@ -0,0 +1,1322 @@ +/* pngconf.h - machine configurable file for libpng + * + * libpng 1.2.0 - September 1, 2001 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2001 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#ifndef PNG_NO_MNG_FEATURES +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- building the dll + * (no define) -- building an application, linking to the dll + * PNG_STATIC -- building the static lib, or building an application + * that links to the static lib. + * ALL_STATIC -- building various static libs, or building an application + * that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + */ + +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + __png.h__ already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# define _BSD_SOURCE +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not + * stdlib.h like it should (I think). Or perhaps this is a C++ + * "feature"? + */ +#ifdef __TURBOC__ +# include +# include "alloc.h" +#endif + +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt is supported. It is turned off by default, to support old apps + * that malloc the png_text structure instead of calling png_set_text() + * and letting libpng malloc it. It will be turned on by default in + * libpng-1.3.0. + */ + +#ifndef PNG_iTXt_SUPPORTED +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_NO_READ_iTXt +# endif +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_NO_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_NO_ERROR_NUMBERS +#define PNG_ERROR_NUMBERS_SUPPORTED +#endif + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif +#endif + +/* If you are sure that you don't need thread safety and you are compiling + with PNG_USE_PNGCCRD for an MMX application, you can define this for + faster execution. See pnggccrd.c. +#define PNG_THREAD_UNSAFE_OK +*/ + +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +# endif +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# define PNG_READ_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# define PNG_WRITE_iTXt_SUPPORTED +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +typedef size_t png_size_t; + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + + +#ifndef PNGAPI + +#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ + ) && !defined(__CYGWIN__)) + +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in + VC++*/ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if defined(__CYGWIN__) && !defined(PNG_DLL) +# if !defined(PNG_IMPEXP) +# define PNG_IMPEXP +# endif +# define PNGAPI __cdecl +# else +# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# define PNG_IMPEXP +# else +# if 0 /* ... other platforms, with other meanings */ +# else +# define PNGAPI +# define PNG_IMPEXP +# endif +# endif +# endif +#endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_strcpy _fstrcpy +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536 +#endif + +#ifdef PNG_READ_SUPPORTED +/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ +#if defined(PNG_INTERNAL) + +/* These are the default thresholds before the MMX code kicks in; if either + * rowbytes or bitdepth is below the threshold, plain C code is used. These + * can be overridden at runtime via the png_set_mmx_thresholds() call in + * libpng 1.2.0 and later. The values below were chosen by Intel. + */ + +#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT +# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ +#endif +#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT +# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ +#endif + +/* Set this in the makefile for VC++ on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGVCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif + +/* Set this in the makefile for gcc/as on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGGCCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif +/* - see pnggccrd.c for info about what is currently enabled */ + +#endif /* PNG_INTERNAL */ +#endif /* PNG_READ_SUPPORTED */ + +#endif /* PNGCONF_H */ + diff --git a/win32/include/zlib/zconf.h b/win32/include/zlib/zconf.h new file mode 100644 index 0000000..0b62e63 --- /dev/null +++ b/win32/include/zlib/zconf.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) zconf.h,v 1.1 2002/10/20 13:03:13 forgotten Exp */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/win32/include/zlib/zlib.h b/win32/include/zlib/zlib.h new file mode 100644 index 0000000..54de28c --- /dev/null +++ b/win32/include/zlib/zlib.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + 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. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/win32/include/zlib/zutil.h b/win32/include/zlib/zutil.h new file mode 100644 index 0000000..ccba696 --- /dev/null +++ b/win32/include/zlib/zutil.h @@ -0,0 +1,220 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id: zutil.h,v 1.2 2004/01/17 23:07:32 kxu Exp $ */ + +#ifndef _Z_UTIL_H +#define _Z_UTIL_H + +#include + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#ifdef MSDOS +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +#endif + +#ifdef WIN32 /* Window 95 & Windows NT */ +# define OS_CODE 0x0b +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0F +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# define fdopen(fd,type) _fdopen(fd,type) +#endif + + + /* Common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#ifdef HAVE_STRERROR + extern char *strerror OF((int)); +# define zstrerror(errnum) strerror(errnum) +#else +# define zstrerror(errnum) "" +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, + uInt len)); +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* _Z_UTIL_H */ diff --git a/win32/lib/win32/CxImage.lib b/win32/lib/win32/CxImage.lib new file mode 100644 index 0000000..13a935d Binary files /dev/null and b/win32/lib/win32/CxImage.lib differ diff --git a/win32/lib/win32/jpeg.lib b/win32/lib/win32/jpeg.lib new file mode 100644 index 0000000..b8810d6 Binary files /dev/null and b/win32/lib/win32/jpeg.lib differ diff --git a/win32/lib/win32/libpng.lib b/win32/lib/win32/libpng.lib new file mode 100644 index 0000000..17daaf9 Binary files /dev/null and b/win32/lib/win32/libpng.lib differ diff --git a/win32/lib/win32/libpngMD.lib b/win32/lib/win32/libpngMD.lib new file mode 100644 index 0000000..7d97890 Binary files /dev/null and b/win32/lib/win32/libpngMD.lib differ diff --git a/win32/lib/win32/zlib.lib b/win32/lib/win32/zlib.lib new file mode 100644 index 0000000..e479948 Binary files /dev/null and b/win32/lib/win32/zlib.lib differ diff --git a/win32/lib/win32/zlibMD.lib b/win32/lib/win32/zlibMD.lib new file mode 100644 index 0000000..528398c Binary files /dev/null and b/win32/lib/win32/zlibMD.lib differ diff --git a/win32/nasm.exe b/win32/nasm.exe new file mode 100644 index 0000000..9810b41 Binary files /dev/null and b/win32/nasm.exe differ