mirror of https://github.com/PCSX2/pcsx2.git
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@428 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
aa94c30dc3
commit
94cc1fd329
|
@ -0,0 +1,58 @@
|
|||
CDVDisoEFP v0.6 Changes:
|
||||
--------------------
|
||||
|
||||
v0.6:
|
||||
* Completely re-wrote screens (efp)
|
||||
* Used device access sources from CDVDlinuz to get data from DVDs. (efp)
|
||||
* Added ability to read devices from Windows XP (efp)
|
||||
Note: only ISO and CDDA seem to be readable from CDs at this time.
|
||||
If your trying to get another format, use Linux.
|
||||
DVD5 is readable. Don't have a DVD9 game to test. (I think - efp)
|
||||
* Separated image file access by OS. (Linux, Windows) (efp)
|
||||
* Separated Multi-file/Compression/Image-Typing to their own source files. (efp)
|
||||
* Added a few entries to the Image Typing database, based on Linux CD-ROM sources (efp)
|
||||
* Added Table Rebuild (for those who lost .table files.) (efp)
|
||||
* Put in a separate source program to compare two ISOs for data accuracy. (efp)
|
||||
* Renamed executables and config files (so not to conflict with CDVDiso) (efp)
|
||||
* Internalized the .INI File code (to allow use in other OS-es besides Windows) (efp)
|
||||
* Added temporarily a .toc file saving track info (for PS1 and Music CDs) (efp)
|
||||
* Added a new compression format. (BZip2 Size) (efp)
|
||||
* Added .glade files at linuzappz's request (efp)
|
||||
* Upgraded to 0.6.0 beta PS2Edef.h definitions (efp)
|
||||
|
||||
* Data buffer start position re-set for CDs. (shadow caught the problem while testing)
|
||||
* Supported images grouped in "Browse" button (shadow's suggestion)
|
||||
* Initial Image reminder added to Windows CDVDOpen() (shadow's suggestion)
|
||||
* used 64 bit fstat (fstat64) for correct sizes on >2GB files in Linux (efp)
|
||||
* Adjusted CD types to allow for PS2 CDs (shadow pointed out an example iso)
|
||||
* Added changing CDs/DVDs while emulation stopped (shadow's suggestion)
|
||||
Built in an "open tray" delay when switching media. (efp)
|
||||
* Added ".img" to Image Filter (although .cue/.sub files aren't tapped.) (efp)
|
||||
* Added ".nrg" to Image Filter (shadow's suggestion)
|
||||
* In Windows, when newly selected from the PCSX2 configure screen, CDVDinit()
|
||||
(as well as InitConf()) are not called. Fixed (EFP)
|
||||
|
||||
v0.5:
|
||||
* Added block dumping code
|
||||
* Added BZ2/Z2 format ;)
|
||||
* Added optimaze asm code of zlib with vsnet2003 only. Compression / Uncompression should be faster now (shadow)
|
||||
* Added Vsnet2005 beta1 project files + amd64 asm optimaze code for zlib (shadow)
|
||||
|
||||
v0.4:
|
||||
* Rewrote mostly ;)
|
||||
* .bz is still unsupported
|
||||
|
||||
v0.3:
|
||||
* Better Iso detection, thx florin :)
|
||||
* Updated to PS2Edefs v0.4.5
|
||||
|
||||
v0.2:
|
||||
* Added support for isos using 2048 blocksize
|
||||
* Nero images are supported
|
||||
* Better extension filtering
|
||||
|
||||
v0.1:
|
||||
* First Release
|
||||
* Tested with Pcsx2
|
||||
|
||||
Email: <linuzappz@hotmail.com>
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
curdir=`pwd`
|
||||
|
||||
echo -------------------
|
||||
echo Building CDVDisoEFP
|
||||
echo -------------------
|
||||
|
||||
cd ${curdir}/src/Linux
|
||||
make $@
|
||||
|
||||
if [ -s cfgCDVDisoEFP ] && [ -s libCDVDisoEFP.so ]
|
||||
then
|
||||
# copy the files
|
||||
cp cfgCDVDisoEFP libCDVDisoEFP.so ${PCSX2PLUGINS}
|
||||
fi
|
|
@ -0,0 +1,342 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 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.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
CDVDiso v0.6
|
||||
------------
|
||||
|
||||
This is an extension to use with play station2 emulators
|
||||
as PCSX2 (only one right now).
|
||||
The plugin is free open source code.
|
||||
|
||||
Linux requirements:
|
||||
------------------
|
||||
You need the GTK library, compiled with GTK v2.6.1 (at least).
|
||||
|
||||
Usage:
|
||||
-----
|
||||
For those using Windows, place the file "CDVDisoEFP.dll" in the Plugin
|
||||
directory of the Emulator to use it.
|
||||
|
||||
For Linux users, place the file "libCDVDisoEFP.so" in the plugin
|
||||
directory of the Emulator. Also, place the file "cfgCDVDisoEFP" in the "cfg"
|
||||
directory of the Emulator to use it.
|
||||
|
||||
Configuration:
|
||||
-------------
|
||||
You must select the iso you want to use in the Configuration dialog. You
|
||||
will come back to this dialog should the Emulator want another disc.
|
||||
|
||||
Creating an iso (linux, Windows XP only):
|
||||
---------------
|
||||
To create an iso you can use the button 'Make Image'. The file
|
||||
will be the one in the Iso Edit, and the Source Device is the CDRom or
|
||||
DVD drive that will have the disc you want to make an image of.
|
||||
The compression method is specified by the Compression Method Combo.
|
||||
|
||||
Note: This will fail if the file already exists (if it's compressed
|
||||
a .z or .bz2 suffix will be added).
|
||||
|
||||
Compressed isos:
|
||||
---------------
|
||||
You can create them using the Convert button. This will create a .Z or .bz
|
||||
file (the compressed image) and a .z.table or .bz2.table file (this is a
|
||||
table, for speed reasons.) Both will be created in the same dir as the
|
||||
selected image. The original image will not be deleted and/or changed. Also,
|
||||
you can decompress a compressed image by selecting "None" in the
|
||||
Compression Method Combo.
|
||||
|
||||
Note: you only can decompress the images with this program; not with
|
||||
compress or bzip2.
|
||||
|
||||
Compression Method:
|
||||
------------------
|
||||
.z speed - fast compression, small blocks, table in memory.
|
||||
.bz2 speed - average compression, 32k - 40k blocks, table in memory.
|
||||
.bz2 size - best compression, 60k - 62k blocks, table on file.
|
||||
|
||||
|
||||
Email: <linuzappz@hotmail.com>
|
|
@ -0,0 +1,367 @@
|
|||
/* CD.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <stddef.h> // NULL
|
||||
#include <string.h> // strerror()
|
||||
#include <fcntl.h> // open()
|
||||
#include <sys/ioctl.h> // ioctl()
|
||||
#include <sys/stat.h> // open()
|
||||
#include <sys/types.h> // lseek(), open()
|
||||
#include <unistd.h> // close(), lseek(), (sleep())
|
||||
|
||||
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
|
||||
|
||||
#include "../convert.h"
|
||||
#include "logfile.h"
|
||||
#include "device.h"
|
||||
#include "CD.h"
|
||||
|
||||
|
||||
// Constants
|
||||
u8 *playstationcdname = "PLAYSTATION\0";
|
||||
u8 *ps1name = "CD-XA001\0";
|
||||
|
||||
// CD-ROM temp storage structures (see linux/cdrom.h for details)
|
||||
struct cdrom_tochdr cdheader;
|
||||
struct cdrom_tocentry cdtrack;
|
||||
struct cdrom_subchnl subchannel;
|
||||
u8 cdtempbuffer[2352];
|
||||
|
||||
int cdmode; // mode of last CDVDreadTrack call (important for CDs)
|
||||
|
||||
|
||||
// Internal Functions
|
||||
|
||||
void InitCDSectorInfo() {
|
||||
cdmode = -1;
|
||||
} // END InitSectorInfo();
|
||||
|
||||
|
||||
// Function Calls from CDVD.c
|
||||
|
||||
void InitCDInfo() {
|
||||
InitCDSectorInfo();
|
||||
} // END InitDiscType()
|
||||
|
||||
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
s32 s32result;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDreadTrack(%i)", lsn);
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
s32result = 0;
|
||||
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
// The CD way of figuring out where to read.
|
||||
LBAtoMSF(lsn, buffer);
|
||||
|
||||
switch(mode) {
|
||||
case CDVD_MODE_2048:
|
||||
case CDVD_MODE_2328:
|
||||
case CDVD_MODE_2340:
|
||||
case CDVD_MODE_2352:
|
||||
errno = 4; // Interrupted system call... (simulated the first time)
|
||||
while(errno == 4) {
|
||||
errno = 0;
|
||||
s32result = ioctl(devicehandle, CDROMREADRAW, buffer);
|
||||
} // ENDWHILE- Continually being interrupted by the system...
|
||||
break;
|
||||
case CDVD_MODE_2368: // Unimplemented... as yet.
|
||||
default:
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Unknown Mode %i", mode);
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1); // Illegal Read Mode? Abort
|
||||
break;
|
||||
} // ENDSWITCH- Which read mode should we choose?
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error reading CD: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
InitCDSectorInfo();
|
||||
return(-1);
|
||||
} // ENDIF- Trouble getting a track count?
|
||||
|
||||
cdmode = mode; // Save mode for buffer positioning later.
|
||||
return(0); // Call accomplished
|
||||
} // END CDreadTrack()
|
||||
|
||||
s32 CDgetBufferOffset() {
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDgetBufferOffset()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
switch(cdmode) {
|
||||
case CDVD_MODE_2048:
|
||||
return(0+24);
|
||||
case CDVD_MODE_2328:
|
||||
return(0+24);
|
||||
case CDVD_MODE_2340:
|
||||
return(0+12);
|
||||
case CDVD_MODE_2352:
|
||||
return(0+0);
|
||||
case CDVD_MODE_2368: // Unimplemented... as yet.
|
||||
default:
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Unknown Mode %i", cdmode);
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(0); // Not to worry. for now.
|
||||
} // ENDSWITCH- where should we put the buffer pointer?
|
||||
} // END CDgetBuffer()
|
||||
|
||||
// I, personally, don't see the big deal with SubQ
|
||||
// However, sooner or later I'll incorporate it into the Cache Buffer system
|
||||
// (backward compatibility, and all that)
|
||||
s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq) {
|
||||
int tempmode;
|
||||
s32 s32result;
|
||||
|
||||
s32result = 0;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDreadSubQ()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
tempmode = cdmode;
|
||||
if(tempmode == -1) tempmode = CDVD_MODE_2352;
|
||||
CDreadTrack(lsn, tempmode, cdtempbuffer);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error prepping CD SubQ: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(s32result);
|
||||
} // ENDIF- Trouble?
|
||||
|
||||
subchannel.cdsc_format = CDROM_MSF;
|
||||
s32result = ioctl(devicehandle, CDROMSUBCHNL, &subchannel);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error reading CD SubQ: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(s32result);
|
||||
} // ENDIF- Trouble?
|
||||
|
||||
if(subq != NULL) {
|
||||
subq->mode = subchannel.cdsc_adr;
|
||||
subq->ctrl = subchannel.cdsc_ctrl;
|
||||
subq->trackNum = subchannel.cdsc_trk;
|
||||
subq->trackIndex = subchannel.cdsc_ind;
|
||||
subq->trackM = subchannel.cdsc_reladdr.msf.minute;
|
||||
subq->trackS = subchannel.cdsc_reladdr.msf.second;
|
||||
subq->trackF = subchannel.cdsc_reladdr.msf.frame;
|
||||
subq->discM = subchannel.cdsc_absaddr.msf.minute;
|
||||
subq->discS = subchannel.cdsc_absaddr.msf.second;
|
||||
subq->discF = subchannel.cdsc_absaddr.msf.frame;
|
||||
} // ENDIF- Did the caller want all this data?
|
||||
|
||||
return(0);
|
||||
} // END CDVDreadSubQ()
|
||||
|
||||
s32 CDgetTN(cdvdTN *cdvdtn) {
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDgetTN()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
if(cdvdtn != NULL) {
|
||||
cdvdtn->strack = cdheader.cdth_trk0;
|
||||
cdvdtn->etrack = cdheader.cdth_trk1;
|
||||
} // ENDIF- programmer actually WANTS this info?
|
||||
|
||||
return(0); // Call accomplished
|
||||
} // END CDVDgetTN()
|
||||
|
||||
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
|
||||
u8 j;
|
||||
u16 k;
|
||||
char temptime[3];
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDgetTD()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
j = newtrack;
|
||||
if(j == CDROM_LEADOUT) j = 0;
|
||||
|
||||
if(j == 0) {
|
||||
k = 27;
|
||||
} else {
|
||||
k = j * 10 + 37;
|
||||
} // ENDIF- Where to start hunting for this number?
|
||||
|
||||
if(cdvdtd != NULL) {
|
||||
cdvdtd->type = tocbuffer[j*10 + 30];
|
||||
|
||||
temptime[0] = BCDTOHEX(tocbuffer[k]);
|
||||
temptime[1] = BCDTOHEX(tocbuffer[k + 1]);
|
||||
temptime[2] = BCDTOHEX(tocbuffer[k + 2]);
|
||||
cdvdtd->lsn = MSFtoLBA(temptime);
|
||||
} // ENDIF- Does the caller REALLY want this data?
|
||||
|
||||
return(0); // Call accomplished
|
||||
} // END CDVDgetTD()
|
||||
|
||||
s32 CALLBACK CDgetDiskType(s32 ioctldisktype) {
|
||||
s32 offset;
|
||||
s32 s32result;
|
||||
int i;
|
||||
u8 j;
|
||||
int tempdisctype;
|
||||
|
||||
offset = 0;
|
||||
errno = 0;
|
||||
i = 0;
|
||||
j = 0;
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDgetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
s32result = CDreadTrack(16, CDVD_MODE_2352, cdtempbuffer);
|
||||
if((s32result != 0) || (errno != 0)) {
|
||||
return(-1);
|
||||
} // ENDIF- Cannot read the CD's ISO9660 volume sector? Abort
|
||||
disctype = CDVD_TYPE_DETCTCD;
|
||||
|
||||
switch(ioctldisktype) {
|
||||
case CDS_AUDIO:
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Detected CDDA Audio disc.");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tempdisctype = CDVD_TYPE_CDDA;
|
||||
tocbuffer[0] = 0x01;
|
||||
break;
|
||||
|
||||
case CDS_DATA_1:
|
||||
case CDS_MIXED:
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Detected CD disc.");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tocbuffer[0] = 0x41;
|
||||
|
||||
CDreadTrack(16, CDVD_MODE_2048, cdtempbuffer);
|
||||
offset = CDgetBufferOffset();
|
||||
i = 0;
|
||||
while((*(playstationcdname + i) != 0) &&
|
||||
(*(playstationcdname + i) == cdtempbuffer[offset + 8 + i])) i++;
|
||||
if(*(playstationcdname + i) == 0) {
|
||||
i = 0;
|
||||
while((*(ps1name + i) != 0) &&
|
||||
(*(ps1name + i) == cdtempbuffer[offset + 1024 + i])) i++;
|
||||
if(*(ps1name + i) == 0) {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Detected Playstation CD disc.");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tempdisctype = CDVD_TYPE_PSCD;
|
||||
} else {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Detected Playstation 2 CD disc.");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tempdisctype = CDVD_TYPE_PS2CD;
|
||||
} // ENDIF- Did we find the CD ident? (For Playstation 1 CDs)
|
||||
} else {
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
} // ENDIF- Did we find the Playstation name?
|
||||
break;
|
||||
|
||||
default:
|
||||
return(-1);
|
||||
} // ENDSWITCH- What has ioctl disc type come up with?
|
||||
|
||||
// Collect TN data
|
||||
cdheader.cdth_trk0 = 0;
|
||||
cdheader.cdth_trk1 = 0;
|
||||
|
||||
s32result = ioctl(devicehandle, CDROMREADTOCHDR, &cdheader);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error reading TN: (%i) %i:%s",
|
||||
s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
cdheader.cdth_trk0 = 1;
|
||||
cdheader.cdth_trk1 = 1;
|
||||
} // ENDIF- Failed to read in track count? Assume 1 track.
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Track Number Range: %i-%i",
|
||||
cdheader.cdth_trk0, cdheader.cdth_trk1);
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
tocbuffer[2] = 0xA0;
|
||||
tocbuffer[7] = HEXTOBCD(cdheader.cdth_trk0);
|
||||
tocbuffer[12] = 0xA1;
|
||||
tocbuffer[17] = HEXTOBCD(cdheader.cdth_trk1);
|
||||
|
||||
// Collect disc TD data
|
||||
cdtrack.cdte_track = CDROM_LEADOUT;
|
||||
cdtrack.cdte_format = CDROM_LBA;
|
||||
s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error reading TD for disc: (%i) %i:%s",
|
||||
s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Trouble getting a track count?
|
||||
|
||||
LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[27]);
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Total Time: %i:%i",
|
||||
tocbuffer[27], tocbuffer[28]);
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
tocbuffer[27] = HEXTOBCD(tocbuffer[27]);
|
||||
tocbuffer[28] = HEXTOBCD(tocbuffer[28]);
|
||||
tocbuffer[29] = HEXTOBCD(tocbuffer[29]);
|
||||
|
||||
// Collect track TD data
|
||||
for(j = cdheader.cdth_trk0; j <= cdheader.cdth_trk1; j++) {
|
||||
cdtrack.cdte_track = j; // j-1?
|
||||
cdtrack.cdte_format = CDROM_LBA;
|
||||
s32result = ioctl(devicehandle, CDROMREADTOCENTRY, &cdtrack);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error reading TD for track %i: (%i) %i:%s",
|
||||
j, s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
// No more here...
|
||||
|
||||
} else {
|
||||
LBAtoMSF(cdtrack.cdte_addr.lba, &tocbuffer[j*10 + 37]);
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Track %i: Data Mode %i Disc Start Time:%i:%i.%i\n",
|
||||
j,
|
||||
cdtrack.cdte_datamode,
|
||||
tocbuffer[j*10+37],
|
||||
tocbuffer[j*10+38],
|
||||
tocbuffer[j*10+39]);
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
tocbuffer[j*10 + 30] = cdtrack.cdte_datamode;
|
||||
tocbuffer[j*10 + 32] = HEXTOBCD(j);
|
||||
tocbuffer[j*10 + 37] = HEXTOBCD(tocbuffer[j*10 + 37]);
|
||||
tocbuffer[j*10 + 38] = HEXTOBCD(tocbuffer[j*10 + 38]);
|
||||
tocbuffer[j*10 + 39] = HEXTOBCD(tocbuffer[j*10 + 39]);
|
||||
} // ENDIF- Trouble getting a track count?
|
||||
} // NEXT j- Reading each track's info in turn
|
||||
|
||||
errno = 0;
|
||||
disctype = tempdisctype; // Trigger the fact we have the info (finally)
|
||||
return(disctype);
|
||||
} // END CDVDgetDiskType()
|
|
@ -0,0 +1,46 @@
|
|||
/* CD.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef __CD_H__
|
||||
#define __CD_H__
|
||||
|
||||
|
||||
#ifndef __LINUX__
|
||||
#ifdef __linux__
|
||||
#define __LINUX__
|
||||
#endif /* __linux__ */
|
||||
#endif /* No __LINUX__ */
|
||||
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
|
||||
// Exported Functions
|
||||
|
||||
extern void InitCDInfo();
|
||||
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 CDgetBufferOffset();
|
||||
extern s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq);
|
||||
extern s32 CDgetTN(cdvdTN *cdvdtn);
|
||||
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
|
||||
extern s32 CDgetDiskType(s32 ioctldisktype);
|
||||
|
||||
|
||||
#endif /* __CD_H__ */
|
|
@ -0,0 +1,450 @@
|
|||
/* CDVDiso.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
#ifndef __LINUX__
|
||||
#ifdef __linux__
|
||||
#define __LINUX__
|
||||
#endif /* __linux__ */
|
||||
#endif /* No __LINUX__ */
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "actualfile.h"
|
||||
#include "isofile.h"
|
||||
#include "logfile.h"
|
||||
#include "convert.h"
|
||||
#include "version.h"
|
||||
#include "CDVDiso.h"
|
||||
|
||||
|
||||
struct IsoFile *isofile;
|
||||
char isobuffer[2448];
|
||||
char isocdcheck[2448];
|
||||
int isomode;
|
||||
int deviceopencount; // 0 = Closed, 1+ = Open
|
||||
|
||||
|
||||
char* CALLBACK PS2EgetLibName() {
|
||||
return(libname);
|
||||
} // END PS2EgetLibName()
|
||||
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
return(PS2E_LT_CDVD);
|
||||
} // END PS2getLibType()
|
||||
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
return((version << 16) | (revision << 8) | build);
|
||||
}
|
||||
|
||||
|
||||
s32 CALLBACK CDVDinit() {
|
||||
int i;
|
||||
|
||||
InitLog();
|
||||
if(OpenLog() != 0) return(-1); // Couldn't open Log File? Abort.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDinit()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
InitConf();
|
||||
|
||||
isofile = NULL;
|
||||
isomode = -1;
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = 0;
|
||||
deviceopencount = 0;
|
||||
|
||||
return(0);
|
||||
} // END CDVDinit()
|
||||
|
||||
|
||||
void CALLBACK CDVDshutdown() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDshutdown()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
isofile = IsoFileClose(isofile);
|
||||
CloseLog();
|
||||
} // END CDVDshutdown()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDopen(const char* pTitleFilename) {
|
||||
int retval;
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDopen()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
LoadConf();
|
||||
|
||||
if( pTitleFilename != NULL ) strcpy(conf.isoname, pTitleFilename);
|
||||
|
||||
if((conf.isoname[0] == 0) ||
|
||||
((conf.startconfigure != 0) && (deviceopencount == 0)) ||
|
||||
((conf.restartconfigure != 0) && (deviceopencount > 0))) {
|
||||
ExecCfg("configure");
|
||||
LoadConf();
|
||||
} // ENDIF- Haven't initialized the configure program yet? Do so now.
|
||||
|
||||
isofile = IsoFileOpenForRead(conf.isoname);
|
||||
if(isofile == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Failed to open ISO file!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
// return(-1); // Taken out for "NULL" device simulation
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = 0;
|
||||
return(0);
|
||||
} // ENDIF- Trouble opening file? Abort.
|
||||
|
||||
retval = IsoFileSeek(isofile, 16);
|
||||
if(retval != 0) return(-1);
|
||||
retval = IsoFileRead(isofile, isobuffer);
|
||||
if(retval != 0) return(-1);
|
||||
|
||||
if(deviceopencount > 0) {
|
||||
i = 0;
|
||||
while((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
|
||||
if(i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
|
||||
} // ENDIF- Is this a restart? Check for disc change.
|
||||
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
|
||||
|
||||
return(0);
|
||||
} // END CDVDopen()
|
||||
|
||||
|
||||
void CALLBACK CDVDclose() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDclose()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
isofile = IsoFileClose(isofile);
|
||||
deviceopencount = 50;
|
||||
} // END CDVDclose()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
|
||||
char temptime[3];
|
||||
int i;
|
||||
int pos;
|
||||
u32 tracklsn;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDreadSubQ()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) return(-1);
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
return(-1); // DVDs don't have SubQ data
|
||||
} // ENDIF- Trying to get a SubQ from a DVD?
|
||||
|
||||
// fake it
|
||||
i = BCDTOHEX(isofile->toc[7]);
|
||||
pos = i * 10;
|
||||
pos += 30;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
tracklsn = MSFtoLBA(temptime);
|
||||
while((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn)) {
|
||||
i++;
|
||||
pos = i * 10;
|
||||
pos += 30;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
tracklsn = MSFtoLBA(temptime);
|
||||
} // ENDIF- Loop through tracks searching for lsn track
|
||||
i--;
|
||||
|
||||
subq->ctrl = 4;
|
||||
subq->mode = 1;
|
||||
subq->trackNum = HEXTOBCD(i);
|
||||
subq->trackIndex = HEXTOBCD(i);
|
||||
|
||||
LBAtoMSF(lsn - tracklsn, temptime);
|
||||
subq->trackM = HEXTOBCD(temptime[0]);
|
||||
subq->trackS = HEXTOBCD(temptime[1]);
|
||||
subq->trackF = HEXTOBCD(temptime[2]);
|
||||
|
||||
subq->pad = 0;
|
||||
|
||||
// lba_to_msf(lsn + (2*75), &min, &sec, &frm);
|
||||
LBAtoMSF(lsn, temptime);
|
||||
subq->discM = HEXTOBCD(temptime[0]);
|
||||
subq->discS = HEXTOBCD(temptime[1]);
|
||||
subq->discF = HEXTOBCD(temptime[2]);
|
||||
|
||||
return(0);
|
||||
} // END CDVDreadSubQ()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) {
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTN()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
Buffer->strack = 1;
|
||||
Buffer->etrack = 1;
|
||||
} else {
|
||||
Buffer->strack = BCDTOHEX(isofile->toc[7]);
|
||||
Buffer->etrack = BCDTOHEX(isofile->toc[17]);
|
||||
} // ENDIF- Retrieve track info from a DVD? (or a CD?)
|
||||
|
||||
return(0);
|
||||
} // END CDVDgetTN()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
|
||||
u8 actualtrack;
|
||||
int pos;
|
||||
char temptime[3];
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTD()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
actualtrack = track;
|
||||
if(actualtrack == 0xaa) actualtrack = 0;
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
if (actualtrack <= 1) {
|
||||
Buffer->type = 0;
|
||||
Buffer->lsn = isofile->filesectorsize;
|
||||
} else {
|
||||
Buffer->type = CDVD_MODE1_TRACK;
|
||||
Buffer->lsn = 0;
|
||||
} // ENDIF- Whole disc? (or single track?)
|
||||
} else {
|
||||
if (actualtrack == 0) {
|
||||
Buffer->type = 0;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[27]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[28]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[29]);
|
||||
Buffer->lsn = MSFtoLBA(temptime);
|
||||
} else {
|
||||
pos = actualtrack * 10;
|
||||
pos += 30;
|
||||
Buffer->type = isofile->toc[pos];
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
Buffer->lsn = MSFtoLBA(temptime);
|
||||
} // ENDIF- Whole disc? (or single track?)
|
||||
} // ENDIF- Retrieve track info from a DVD? (or a CD?)
|
||||
|
||||
return(0);
|
||||
} // END CDVDgetTD()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTOC(void* toc) {
|
||||
int i;
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTOC()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
for(i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i];
|
||||
return(0);
|
||||
} // END CDVDgetTOC()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) {
|
||||
int retval;
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
return(-1);
|
||||
} // ENDIF- Simulate a temporarily open device?
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn);
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
retval = IsoFileSeek(isofile, (off64_t) lsn);
|
||||
if(retval != 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Trouble finding the sector!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(-1);
|
||||
} // ENDIF- Trouble finding the sector?
|
||||
|
||||
retval = IsoFileRead(isofile, isobuffer);
|
||||
if(retval != 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Trouble reading the sector!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(-1);
|
||||
} // ENDIF- Trouble finding the sector?
|
||||
|
||||
isomode = mode;
|
||||
return(0);
|
||||
} // END CDVDreadTrack()
|
||||
|
||||
|
||||
u8* CALLBACK CDVDgetBuffer() {
|
||||
int offset;
|
||||
|
||||
if(isofile == NULL) return(NULL);
|
||||
if(deviceopencount > 0) return(NULL);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetBuffer()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
offset = 0;
|
||||
switch(isomode) {
|
||||
case CDVD_MODE_2352:
|
||||
offset = 0;
|
||||
break;
|
||||
case CDVD_MODE_2340:
|
||||
offset = 12;
|
||||
break;
|
||||
case CDVD_MODE_2328:
|
||||
case CDVD_MODE_2048:
|
||||
offset = 24;
|
||||
break;
|
||||
} // ENDSWITCH isomode- offset to where data it wants is.
|
||||
|
||||
if(offset > isofile->blockoffset) offset = isofile->blockoffset;
|
||||
|
||||
return(isobuffer + offset);
|
||||
} // END CDVDgetBuffer()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetDiskType() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(CDVD_TYPE_NODISC);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
return(CDVD_TYPE_DETCT);
|
||||
} // ENDIF- Simulate a temporarily open device?
|
||||
|
||||
return(isofile->cdvdtype);
|
||||
} // END CDVDgetDiskType()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTrayStatus() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTrayStatus()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(CDVD_TRAY_OPEN);
|
||||
if(deviceopencount > 30) {
|
||||
deviceopencount--;
|
||||
return(CDVD_TRAY_OPEN);
|
||||
} // ENDIF- Simulate a temporarily open device?
|
||||
|
||||
return(CDVD_TRAY_CLOSE);
|
||||
} // END CDVDgetTrayStatus()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayOpen() {
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDctrlTrayOpen()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
// Close()
|
||||
isofile = IsoFileClose(isofile);
|
||||
deviceopencount = 50;
|
||||
|
||||
// and re-Open()
|
||||
if((conf.isoname[0] == 0) ||
|
||||
((conf.restartconfigure != 0) && (deviceopencount > 0))) {
|
||||
ExecCfg("configure");
|
||||
LoadConf();
|
||||
} // ENDIF- Haven't initialized the configure program yet? Do so now.
|
||||
|
||||
isofile = IsoFileOpenForRead(conf.isoname);
|
||||
if(isofile == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Failed to open ISO file!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
} // ENDIF- Trouble opening file? Abort.
|
||||
|
||||
if(deviceopencount > 0) {
|
||||
i = 0;
|
||||
while((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
|
||||
if(i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
|
||||
} // ENDIF- Is this a restart? Check for disc change.
|
||||
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
|
||||
|
||||
return(0);
|
||||
} // END CDVDctrlTrayOpen()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayClose() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDctrlTrayClose()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(0);
|
||||
} // END CDVDctrlTrayClose()
|
||||
|
||||
|
||||
void CALLBACK CDVDconfigure() {
|
||||
ExecCfg("configure");
|
||||
} // END CDVDconfigure()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDtest() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDtest()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
InitConf(); // Odd... hasn't CDVDinit been called yet?
|
||||
LoadConf();
|
||||
|
||||
if(conf.isoname[0] == 0) return(0); // No name chosen yet. Catch on Open()
|
||||
if(IsIsoFile(conf.isoname) == 0) return(0); // Valid name. Go.
|
||||
return(-1); // Invalid name - reconfigure first.
|
||||
// Note really need this? Why not just return(0)...
|
||||
} // END CDVDtest()
|
||||
|
||||
|
||||
void CALLBACK CDVDabout() {
|
||||
ExecCfg("about");
|
||||
} // END CDVDabout()
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/* CDVDiso.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CDVDISO_H
|
||||
#define CDVDISO_H
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_INTERFACE
|
||||
|
||||
|
||||
#endif /* CDVDISO_H */
|
|
@ -0,0 +1,582 @@
|
|||
/* DVD.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strerror(), memset(), memcpy()
|
||||
#include <fcntl.h> // open()
|
||||
#include <sys/ioctl.h> // ioctl()
|
||||
#include <sys/stat.h> // open()
|
||||
#include <sys/types.h> // lseek(), open()
|
||||
#include <unistd.h> // close(), lseek(), (sleep())
|
||||
|
||||
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
|
||||
|
||||
#include "logfile.h"
|
||||
#include "device.h"
|
||||
#include "DVD.h"
|
||||
|
||||
|
||||
// Constants
|
||||
u8 *playstationname = "PLAYSTATION\0";
|
||||
|
||||
// DVD storage structures (see linux/cdrom.h for details)
|
||||
dvd_struct dvdphysical;
|
||||
dvd_struct dvdcopyright[DVD_LAYERS];
|
||||
dvd_struct dvdbca;
|
||||
dvd_struct dvdmanufact[DVD_LAYERS];
|
||||
|
||||
u32 dvdlastlsn;
|
||||
u8 dvdtempbuffer[2064];
|
||||
|
||||
|
||||
// Internal Functions
|
||||
|
||||
void InitDVDSectorInfo() {
|
||||
dvdlastlsn = 0xffffffff;
|
||||
} // END InitSectorInfo();
|
||||
|
||||
void HexDump(u8 *strptr, u8 count) {
|
||||
int i;
|
||||
u8 ch[2];
|
||||
char hexline[81];
|
||||
int hexlinepos;
|
||||
|
||||
ch[1] = 0;
|
||||
|
||||
if(count == 0) count = 16;
|
||||
if((count < 1) || (count > 16)) return;
|
||||
|
||||
hexlinepos = 0;
|
||||
hexlinepos += sprintf(&hexline[hexlinepos], "CDVD driver: ");
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
hexlinepos += sprintf(&hexline[hexlinepos], "%.2x ", (*(strptr + i)) * 1);
|
||||
} // NEXT i- printing each new Hex number
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
if((*(strptr + i) < 32) || (*(strptr + i) > 127)) {
|
||||
hexlinepos += sprintf(&hexline[hexlinepos], ".");
|
||||
} else {
|
||||
ch[0] = *(strptr + i);
|
||||
hexlinepos += sprintf(&hexline[hexlinepos], "%s", ch);
|
||||
} // ENDIF- Is this an unprintable character?
|
||||
} // NEXT i- printing each new character
|
||||
PrintLog(hexline);
|
||||
} // ENDIF HexDump()
|
||||
|
||||
|
||||
//// DVD Structure Functions
|
||||
|
||||
s32 DVDreadPhysical() {
|
||||
s32 s32result;
|
||||
u8 i;
|
||||
|
||||
errno = 0;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDreadPhysical()\n");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
memset(&dvdphysical, 0, sizeof(dvd_struct));
|
||||
dvdphysical.type = DVD_STRUCT_PHYSICAL;
|
||||
|
||||
i = DVD_LAYERS;
|
||||
while(i > 0) {
|
||||
i--;
|
||||
dvdphysical.physical.layer_num = i;
|
||||
errno = 0;
|
||||
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdphysical);
|
||||
} // ENDWHILE- reading in all physical layers...
|
||||
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
dvdphysical.type = 0xFF;
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error getting Physical structure: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Problem with reading Layer 0 of the physical data? Abort
|
||||
|
||||
i = 3;
|
||||
while((i > 0) && (dvdphysical.physical.layer[i].end_sector == 0)) i--;
|
||||
dvdphysical.physical.layer_num = i;
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Physical Characteristics");
|
||||
PrintLog("CDVD driver: Number of Layers: %i",
|
||||
(s32) dvdphysical.physical.layer_num + 1);
|
||||
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
|
||||
PrintLog("CDVD driver: Layer Number %i", i);
|
||||
switch(dvdphysical.physical.layer[i].book_type) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Book Type: DVD-ROM");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Book Type: DVD-RAM");
|
||||
break;
|
||||
case 2:
|
||||
PrintLog("CDVD driver: Book Type: DVD-R");
|
||||
break;
|
||||
case 3:
|
||||
PrintLog("CDVD driver: Book Type: DVD-RW");
|
||||
break;
|
||||
case 9:
|
||||
PrintLog("CDVD driver: Book Type: DVD+RW");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Book Type: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].book_type);
|
||||
break;
|
||||
} // ENDSWITCH- Displaying the Book Type
|
||||
PrintLog("CDVD driver: Book Version %i",
|
||||
dvdphysical.physical.layer[i].book_version);
|
||||
switch(dvdphysical.physical.layer[i].min_rate) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: DVD-ROM");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: DVD-RAM");
|
||||
break;
|
||||
case 2:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: DVD-R");
|
||||
break;
|
||||
case 3:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: DVD-RW");
|
||||
break;
|
||||
case 9:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: DVD+RW");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Use Minimum Rate for: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].min_rate);
|
||||
break;
|
||||
} // ENDSWITCH- Displaying the Minimum (Spin?) Rate
|
||||
switch(dvdphysical.physical.layer[i].disc_size) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Physical Disk Size: 120mm");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Physical Disk Size: 80mm");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Physical Disk Size: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].disc_size);
|
||||
break;
|
||||
} // ENDSWITCH- What's the Disk Size?
|
||||
switch(dvdphysical.physical.layer[i].layer_type) {
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Layer Type: Read-Only");
|
||||
break;
|
||||
case 2:
|
||||
PrintLog("CDVD driver: Layer Type: Recordable");
|
||||
break;
|
||||
case 4:
|
||||
PrintLog("CDVD driver: Layer Type: Rewritable");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Layer Type: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].layer_type);
|
||||
break;
|
||||
} // ENDSWITCH- Displaying the Layer Type
|
||||
switch(dvdphysical.physical.layer[i].track_path) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Track Path: PTP");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Track Path: OTP");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Track Path: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].track_path);
|
||||
break;
|
||||
} // ENDSWITCH- What's Track Path Layout?
|
||||
// PrintLog("CDVD driver: Disc Size %i Layer Type %i Track Path %i Nlayers %i",
|
||||
// dvdphysical.physical.layer[i].nlayers);
|
||||
switch(dvdphysical.physical.layer[i].track_density) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Track Density: .74 m/track");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Track Density: .8 m/track");
|
||||
break;
|
||||
case 2:
|
||||
PrintLog("CDVD driver: Track Density: .615 m/track");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Track Density: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].track_density);
|
||||
break;
|
||||
} // ENDSWITCH- Displaying the Track Density
|
||||
switch(dvdphysical.physical.layer[i].linear_density) {
|
||||
case 0:
|
||||
PrintLog("CDVD driver: Linear Density: .267 m/bit");
|
||||
break;
|
||||
case 1:
|
||||
PrintLog("CDVD driver: Linear Density: .293 m/bit");
|
||||
break;
|
||||
case 2:
|
||||
PrintLog("CDVD driver: Linear Density: .409 to .435 m/bit");
|
||||
break;
|
||||
case 4:
|
||||
PrintLog("CDVD driver: Linear Density: .280 to .291 m/bit");
|
||||
break;
|
||||
case 8:
|
||||
PrintLog("CDVD driver: Linear Density: .353 m/bit");
|
||||
break;
|
||||
default:
|
||||
PrintLog("CDVD driver: Linear Density: Unknown (%i)",
|
||||
dvdphysical.physical.layer[i].linear_density);
|
||||
break;
|
||||
} // ENDSWITCH- Displaying the Linear Density
|
||||
if(dvdphysical.physical.layer[i].start_sector == 0x30000) {
|
||||
PrintLog("CDVD driver: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)",
|
||||
dvdphysical.physical.layer[i].start_sector);
|
||||
} else if(dvdphysical.physical.layer[i].start_sector == 0x31000) {
|
||||
PrintLog("CDVD driver: Starting Sector: %lu (DVD-RAM, DVD+RW)",
|
||||
dvdphysical.physical.layer[i].start_sector);
|
||||
} else {
|
||||
PrintLog("CDVD driver: Starting Sector: %lu",
|
||||
dvdphysical.physical.layer[i].start_sector);
|
||||
} // ENDLONGIF- What does the starting sector tell us?
|
||||
PrintLog("CDVD driver: End of Layer 0: %lu",
|
||||
dvdphysical.physical.layer[i].end_sector_l0);
|
||||
PrintLog("CDVD driver: Ending Sector: %lu",
|
||||
dvdphysical.physical.layer[i].end_sector);
|
||||
if(dvdphysical.physical.layer[i].bca != 0)
|
||||
PrintLog("CDVD driver: BCA data present");
|
||||
} // NEXT i- Work our way through each layer...
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
return(0); // Success. Physical data stored for perusal.
|
||||
} // END DVDreadPhysical()
|
||||
|
||||
s32 DVDreadCopyright() {
|
||||
s32 s32result;
|
||||
u8 i;
|
||||
int successflag;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDreadCopyright()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
successflag = 0;
|
||||
|
||||
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
|
||||
memset(&dvdcopyright[i], 0, sizeof(dvd_struct));
|
||||
dvdcopyright[i].type = DVD_STRUCT_COPYRIGHT;
|
||||
dvdcopyright[i].copyright.layer_num = i;
|
||||
errno = 0;
|
||||
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdcopyright[i]);
|
||||
if(s32result == 0) {
|
||||
successflag = 1;
|
||||
} else {
|
||||
dvdcopyright[i].type = 0xFF;
|
||||
} // ENDIF-
|
||||
} // NEXT i- Getting copyright data for every known layer
|
||||
|
||||
if(successflag == 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error getting Copyright info: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Problem with read of physical data?
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Copyright Information\n");
|
||||
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
|
||||
if(dvdcopyright[i].type != 0xFF) {
|
||||
PrintLog("CDVD driver: Layer Number %i CPST %i RMI %i",
|
||||
dvdcopyright[i].copyright.layer_num,
|
||||
dvdcopyright[i].copyright.cpst,
|
||||
dvdcopyright[i].copyright.rmi);
|
||||
} // ENDIF- Were we successful reading this one?
|
||||
} // NEXT i- Printing out all copyright info found...
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
errno = 0;
|
||||
return(0); // Success. Copyright data stored for perusal.
|
||||
} // END DVDreadCopyright()
|
||||
|
||||
s32 DVDreadBCA() {
|
||||
s32 s32result;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
errno = 0;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDreadBCA()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
memset(&dvdbca, 0, sizeof(dvd_struct));
|
||||
dvdbca.type = DVD_STRUCT_BCA;
|
||||
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdbca);
|
||||
if((s32result == -1) || (errno != 0)) {
|
||||
dvdbca.type = 0xFF;
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error getting BCA: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Problem with read of physical data?
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: BCA Length %i Value:",
|
||||
dvdbca.bca.len);
|
||||
for(i = 0; i < 188-15; i += 16) {
|
||||
HexDump(dvdbca.bca.value+i, 16);
|
||||
} // NEXT i- dumping whole key data
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
return(0); // Success. BCA data stored for perusal.
|
||||
} // END DVDreadBCA()
|
||||
|
||||
s32 DVDreadManufact() {
|
||||
s32 s32result;
|
||||
u8 i;
|
||||
int successflag;
|
||||
int j;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDreadManufact()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
j = 0;
|
||||
successflag = 0;
|
||||
|
||||
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
|
||||
memset(&dvdmanufact[i], 0, sizeof(dvd_struct));
|
||||
dvdmanufact[i].type = DVD_STRUCT_MANUFACT;
|
||||
dvdmanufact[i].manufact.layer_num = i;
|
||||
errno = 0;
|
||||
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdmanufact[i]);
|
||||
if((s32result != 0) || (errno != 0)) {
|
||||
dvdmanufact[i].type = 0xFF;
|
||||
} else {
|
||||
successflag = 1;
|
||||
} // ENDIF- Did we fail to read in some manufacturer data?
|
||||
} // NEXT i- Collecting manufacturer data from all layers
|
||||
|
||||
if(successflag == 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error getting Manufact: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Problem with read of physical data?
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD driver: Manufact Data");
|
||||
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
|
||||
if(dvdmanufact[i].type != 0xFF) {
|
||||
PrintLog("CDVD driver: Layer %i Length %i Value:",
|
||||
dvdmanufact[i].manufact.layer_num,
|
||||
dvdmanufact[i].manufact.len);
|
||||
for(j = 0; j < 128-15; j += 16) {
|
||||
HexDump(dvdmanufact[i].manufact.value+j, 16);
|
||||
} // NEXT j- dumping whole key data
|
||||
} // ENDIF- Do we have data at this layer?
|
||||
} // NEXT i- Running through all the layers
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
errno = 0;
|
||||
return(0); // Success. Manufacturer's data stored for perusal.
|
||||
} // END DVDreadManufact()
|
||||
|
||||
|
||||
// External Functions
|
||||
|
||||
// Function Calls from CDVD.c
|
||||
|
||||
void InitDVDInfo() {
|
||||
int j;
|
||||
|
||||
dvdphysical.type = 0xFF; // Using for empty=0xff, full!=0xff test
|
||||
dvdbca.type = 0xFF;
|
||||
for(j = 0; j < DVD_LAYERS; j++) {
|
||||
dvdcopyright[j].type = 0xFF;
|
||||
dvdmanufact[j].type = 0xFF;
|
||||
} // NEXT j- Zeroing each layer of data
|
||||
InitDVDSectorInfo();
|
||||
} // END InitDiscType()
|
||||
|
||||
s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
s32 s32result;
|
||||
off64_t offsettarget;
|
||||
off64_t offsetresult;
|
||||
|
||||
errno = 0;
|
||||
s32result = 0;
|
||||
offsetresult = 0;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDreadTrack(%i)", lsn);
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
if(lsn != dvdlastlsn + 1) {
|
||||
offsettarget = lsn;
|
||||
offsettarget *= 2048;
|
||||
errno = 4;
|
||||
while(errno == 4) {
|
||||
errno = 0;
|
||||
offsetresult = lseek64(devicehandle, offsettarget, SEEK_SET);
|
||||
} // ENDWHILE- waiting for the system interruptions to cease.
|
||||
if((offsetresult < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: Error on seek: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
InitDVDSectorInfo();
|
||||
return(-1);
|
||||
} // ENDIF- trouble with seek? Reset pointer and abort
|
||||
} // ENDIF- Do we have to seek a new position to read?
|
||||
|
||||
errno = 4;
|
||||
while(errno == 4) {
|
||||
errno = 0;
|
||||
s32result = read(devicehandle, buffer, 2048);
|
||||
} // ENDWHILE- waiting for the system interruptions to cease.
|
||||
if((s32result != 2048) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD driver: DVD Short Block, Size: %i", s32result);
|
||||
PrintLog("CDVD driver: Error: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
InitDVDSectorInfo();
|
||||
return(-1);
|
||||
} // ENDIF- Trouble reading the data? Reset pointer and abort
|
||||
|
||||
dvdlastlsn = lsn;
|
||||
return(0); // Call accomplished
|
||||
} // END DVDreadTrack()
|
||||
|
||||
s32 DVDgetTN(cdvdTN *cdvdtn) {
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDVDgetTN()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
// Going to treat this as one large track for now.
|
||||
if(cdvdtn != NULL) {
|
||||
cdvdtn->strack = 1;
|
||||
cdvdtn->etrack = 1;
|
||||
} // ENDIF- programmer actually WANTS this info?
|
||||
|
||||
return(0); // Call accomplished
|
||||
} // END DVDgetTN()
|
||||
|
||||
s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: CDVDgetTD()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
if((newtrack >= 2) && (newtrack != CDROM_LEADOUT)) return(-1);
|
||||
|
||||
if(cdvdtd != NULL) {
|
||||
cdvdtd->lsn = dvdphysical.physical.layer[0].end_sector
|
||||
- dvdphysical.physical.layer[0].start_sector
|
||||
+ 1;
|
||||
cdvdtd->type = CDVD_MODE_2048;
|
||||
} // ENDIF- Does the caller REALLY want this data?
|
||||
|
||||
return(0); // Call accomplished
|
||||
} // END DVDgetTD()
|
||||
|
||||
s32 DVDgetDiskType(s32 ioctldisktype) {
|
||||
s32 s32result;
|
||||
int i;
|
||||
s32 tempdisctype;
|
||||
|
||||
errno = 0;
|
||||
s32result = 0;
|
||||
i = 0;
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION
|
||||
PrintLog("CDVD driver: DVDgetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION */
|
||||
|
||||
if((ioctldisktype != CDS_DATA_1) && (ioctldisktype != CDS_MIXED)) {
|
||||
return(-1);
|
||||
} // ENDIF- Not a data disc we know of? Abort then
|
||||
|
||||
s32result = DVDreadPhysical();
|
||||
if((s32result != 0) || (errno != 0)) {
|
||||
return(-1);
|
||||
} // ENDIF- Error reading the DVD physical structure? Not a DVD after all.
|
||||
|
||||
if(dvdphysical.physical.layer[0].end_sector >= (2048*1024)) {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: DVD Found (Dual-Sided)");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
disctype = CDVD_TYPE_DETCTDVDD;
|
||||
} else {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: DVD Found (Single-Sided)");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
disctype = CDVD_TYPE_DETCTDVDS;
|
||||
} // ENDIF- Definitely a DVD. Size Test?
|
||||
|
||||
// Read in the rest of the structures...
|
||||
DVDreadCopyright();
|
||||
DVDreadBCA();
|
||||
DVDreadManufact();
|
||||
|
||||
// Test for "Playstation" header
|
||||
s32result = DVDreadTrack(16, CDVD_MODE_2048, dvdtempbuffer);
|
||||
if(s32result != 0) {
|
||||
return(-1);
|
||||
} else {
|
||||
i = 0;
|
||||
while((*(playstationname + i) != 0) &&
|
||||
(*(playstationname + i) == dvdtempbuffer[8 + i])) {
|
||||
i++;
|
||||
} // ENDWHILE- Checking each letter of PLAYSTATION name for a match
|
||||
if(*(playstationname + i) == 0) {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Detected Playstation 2 DVD");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tempdisctype = CDVD_TYPE_PS2DVD;
|
||||
} else {
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD driver: Guessing it's a Video DVD");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
tempdisctype = CDVD_TYPE_DVDV;
|
||||
} // ENDIF- Did we find the Playstation name?
|
||||
} // ENDIF- Error reading disc volume information? Invalidate Disc
|
||||
|
||||
if(dvdphysical.physical.layer[0].end_sector >= (2048*1024)) {
|
||||
tocbuffer[0] = 0x24; // Dual-Sided DVD
|
||||
tocbuffer[4] = 0x41;
|
||||
tocbuffer[5] = 0x95;
|
||||
} else {
|
||||
tocbuffer[0] = 0x04; // Single-Sided DVD
|
||||
tocbuffer[4] = 0x86;
|
||||
tocbuffer[5] = 0x72;
|
||||
} // ENDIF- Are there too many sectors for a single-sided disc?
|
||||
|
||||
tocbuffer[1] = 0x02;
|
||||
tocbuffer[2] = 0xF2;
|
||||
tocbuffer[3] = 0x00;
|
||||
|
||||
tocbuffer[16] = 0x00;
|
||||
tocbuffer[17] = 0x03;
|
||||
tocbuffer[18] = 0x00;
|
||||
tocbuffer[19] = 0x00;
|
||||
|
||||
disctype = tempdisctype; // Triggers the fact the other info is available
|
||||
return(disctype);
|
||||
} // END DVDgetDiskType()
|
|
@ -0,0 +1,45 @@
|
|||
/* DVD.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef __DVD_H__
|
||||
#define __DVD_H__
|
||||
|
||||
|
||||
#ifndef __LINUX__
|
||||
#ifdef __linux__
|
||||
#define __LINUX__
|
||||
#endif /* __linux__ */
|
||||
#endif /* No __LINUX__ */
|
||||
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
// Exported Functions
|
||||
|
||||
extern void HexDump(u8 *strptr, u8 count);
|
||||
extern void InitDVDInfo();
|
||||
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 DVDgetTN(cdvdTN *cdvdtn);
|
||||
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
|
||||
extern s32 DVDgetDiskType(s32 ioctldisktype);
|
||||
|
||||
|
||||
#endif /* __DVD_H__ */
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
PLUGIN = libCDVDisoEFP.so
|
||||
PLUGINOBJS = CDVDiso.o
|
||||
PLUGINHEADERS = CDVDiso.h
|
||||
PLUGINFLAGS = -fPIC -Wall -O2 -fomit-frame-pointer -D_LARGEFILE64_SOURCE \
|
||||
-I.. -I. -I./Linux
|
||||
PLUGINLIBS = -lz -lbz2
|
||||
|
||||
CFG = cfgCDVDisoEFP
|
||||
CFGOBJS = interface.o aboutbox.o mainbox.o selectionbox.o \
|
||||
devicebox.o conversionbox.o progressbox.o messagebox.o \
|
||||
tablerebuild.o device.o CD.o DVD.o
|
||||
CFGHEADERS = interface.h aboutbox.h mainbox.h selectionbox.h \
|
||||
devicebox.h conversionbox.h progressbox.h messagebox.h \
|
||||
tablerebuild.h device.h CD.h DVD.h
|
||||
CFGFLAGS = -fPIC -Wall -O2 -fomit-frame-pointer -D_LARGEFILE64_SOURCE \
|
||||
-I.. -I. -I./Linux
|
||||
CFGLIBS = -lz -lbz2
|
||||
|
||||
COMP = compCDVDisoEFP
|
||||
COMPOBJS = comparisonbox.o progressbox.o messagebox.o \
|
||||
comparisondummy.o
|
||||
COMPHEADERS = progressbox.h messagebox.h
|
||||
|
||||
SHAREDOBJS = ../version.o actualfile.o ../isofile.o conf.o logfile.o \
|
||||
../imagetype.o ../multifile.o ../isocompress.o ../convert.o \
|
||||
../gzipv1.o ../blockv2.o ../gzipv2.o ../ecma119.o \
|
||||
../bzip2v3.o ../bzip2v2.o \
|
||||
../toc.o ../ini.o
|
||||
SHAREDHEADERS = ../version.h actualfile.h ../isofile.h conf.h logfile.h \
|
||||
../imagetype.h ../multifile.h ../isocompress.h ../convert.h \
|
||||
../gzipv1.h ../blockv2.h ../gzipv2.h ../bzip2v2.h ../ecma119.h \
|
||||
../toc.h ../ini.h ../bzip2v3.h
|
||||
|
||||
|
||||
CC = gcc
|
||||
|
||||
GTKFLAGS = $(shell pkg-config --cflags gtk+-2.0)
|
||||
|
||||
//GTKFLAGS += -DG_DISABLE_DEPRECATED \
|
||||
// -DGDK_DISABLE_DEPRECATED \
|
||||
// -DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
// -DGTK_DISABLE_DEPRECATED
|
||||
|
||||
GTKLIBS = $(shell pkg-config --libs gtk+-2.0)
|
||||
# Do we need to remove "-rdynamic" as well? Or is that just the main program?
|
||||
|
||||
|
||||
all: plugin cfg
|
||||
install: all
|
||||
|
||||
release: plugin cfg
|
||||
cp $(PLUGIN) ../..
|
||||
cp $(CFG) ../..
|
||||
|
||||
plugin: $(PLUGINOBJS) $(SHAREDOBJS)
|
||||
rm -f $(PLUGIN)
|
||||
$(CC) -shared -Wl,-soname,$(PLUGIN) $(PLUGINFLAGS) $(PLUGINLIBS) \
|
||||
$(PLUGINOBJS) $(SHAREDOBJS) -o $(PLUGIN)
|
||||
strip --strip-unneeded --strip-debug $(PLUGIN)
|
||||
|
||||
cfg: $(CFGOBJS) $(SHAREDOBJS)
|
||||
rm -f $(CFG)
|
||||
$(CC) $(CFGFLAGS) $(GTKFLAGS) $(CFGLIBS) $(GTKLIBS) \
|
||||
$(CFGOBJS) $(SHAREDOBJS) -o $(CFG)
|
||||
strip $(CFG)
|
||||
|
||||
compare: $(COMPOBJS) $(SHAREDOBJS)
|
||||
rm -f $(COMP)
|
||||
$(CC) $(CFGFLAGS) $(GTKFLAGS) $(CFGLIBS) $(GTKLIBS) \
|
||||
$(COMPOBJS) $(SHAREDOBJS) -o $(COMP)
|
||||
strip $(COMP)
|
||||
|
||||
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
|
||||
$(CC) $(PLUGINFLAGS) -c $< -o $@
|
||||
|
||||
$(CFGOBJS) ../comparisonbox.o ../comparisondummy.o: %.o: %.c
|
||||
$(CC) $(CFGFLAGS) $(GTKFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY : clean allclean
|
||||
clean:
|
||||
-rm -f $(PLUGINOBJS) $(PLUGIN) $(CFGOBJS) $(CFG) \
|
||||
$(COMP) $(COMPOBJS) $(SHAREDOBJS)
|
||||
-rm -f *~ temp.txt ../*~ ../temp.txt ../../*~
|
||||
|
||||
allclean:
|
||||
-rm -f $(PLUGINOBJS) $(PLUGIN) $(CFGOBJS) $(CFG) \
|
||||
$(COMP) $(COMPOBJS) $(SHAREDOBJS)
|
||||
-rm -f *~ temp.txt ../*~ ../temp.txt ../../*~
|
||||
-rm -f ../../$(PLUGIN) ../../$(CFG)
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/* aboutbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "version.h"
|
||||
#include "aboutbox.h"
|
||||
|
||||
|
||||
struct AboutBoxData aboutbox;
|
||||
|
||||
|
||||
gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
if(aboutbox.window != NULL) {
|
||||
gtk_widget_destroy(aboutbox.window);
|
||||
aboutbox.window = NULL;
|
||||
} // ENDIF- Do we have an About Box still?
|
||||
|
||||
gtk_main_quit();
|
||||
return(TRUE);
|
||||
} // END AboutBoxCancelEvent()
|
||||
|
||||
|
||||
void AboutBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *container;
|
||||
GtkWidget *vbox1;
|
||||
char templine[256];
|
||||
|
||||
aboutbox.window = NULL;
|
||||
aboutbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(aboutbox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(aboutbox.window), "About CDVDisoEFP");
|
||||
gtk_window_set_position(GTK_WINDOW(aboutbox.window), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_modal(GTK_WINDOW(aboutbox.window), TRUE);
|
||||
gtk_window_set_resizable(GTK_WINDOW(aboutbox.window), FALSE);
|
||||
|
||||
g_signal_connect(G_OBJECT(aboutbox.window), "delete_event",
|
||||
G_CALLBACK(AboutBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(aboutbox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
sprintf(templine, "%s v%i.%i", libname, revision, build);
|
||||
item = gtk_label_new(templine);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
item = gtk_label_new("Current Author: efp");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
item = gtk_label_new("Original code by: linuzappz & shadow");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
container = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), container, TRUE, TRUE, 0);
|
||||
gtk_widget_show(container);
|
||||
|
||||
item = gtk_button_new_with_label("Ok");
|
||||
gtk_container_add(GTK_CONTAINER(container), item);
|
||||
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
|
||||
gtk_widget_show(item);
|
||||
|
||||
g_signal_connect(G_OBJECT(item), "clicked",
|
||||
G_CALLBACK(AboutBoxCancelEvent), NULL);
|
||||
item = NULL;
|
||||
container = NULL;
|
||||
vbox1 = NULL;
|
||||
|
||||
gtk_widget_show(aboutbox.window);
|
||||
gtk_main();
|
||||
} // END AboutDisplay()
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">About CDVDiso</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">CDVDiso ISO Driver v0.6</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Author: linuzappz <linuzappz@hotmail.com></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Modified by: shadow, efp</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Ok</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,39 @@
|
|||
/* aboutbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ABOUTBOX_H
|
||||
#define ABOUTBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct AboutBoxData {
|
||||
GtkWidget *window; // GtkWindow - About Box
|
||||
};
|
||||
|
||||
extern struct AboutBoxData aboutbox;
|
||||
|
||||
|
||||
extern void AboutBoxDisplay();
|
||||
|
||||
|
||||
#endif /* ABOUTBOX_H */
|
|
@ -0,0 +1,222 @@
|
|||
/* actualfile.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <fcntl.h> // open()
|
||||
#include <stdio.h> // rename()
|
||||
#include <string.h> // strerror()
|
||||
#include <sys/stat.h> // stat64(), open(), fstat()
|
||||
#include <sys/types.h> // stat64(), open(), fstat(), lseek64()
|
||||
#include <unistd.h> // stat64(), fstat(), lseek64(), read(), close(), write()
|
||||
// unlink()
|
||||
|
||||
#include "logfile.h"
|
||||
#include "actualfile.h"
|
||||
|
||||
|
||||
int IsActualFile(const char *filename) {
|
||||
int retval;
|
||||
struct stat64 filestat;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: IsActualFile(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = stat64(filename, &filestat);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error retrieving stats on %s", filename);
|
||||
PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1); // Name doesn't exist.
|
||||
} // ENDIF- Trouble getting stat on a file?
|
||||
|
||||
if(S_ISREG(filestat.st_mode) == 0) return(-2); // Not a regular file.
|
||||
return(0); // Yep, that's a file.
|
||||
} // END IsActualFile()
|
||||
|
||||
|
||||
void ActualFileDelete(const char *filename) {
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileDelete(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
unlink(filename);
|
||||
} // END ActualFileDelete()
|
||||
|
||||
|
||||
void ActualFileRename(const char *origname, const char *newname) {
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileRename(%s->%s)", origname, newname);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
rename(origname, newname);
|
||||
return;
|
||||
} // END ActualFileRename()
|
||||
|
||||
|
||||
ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
|
||||
int newhandle;
|
||||
|
||||
if(filename == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
newhandle = open(filename, O_RDONLY | O_LARGEFILE);
|
||||
if((newhandle < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error opening file %s\n", filename);
|
||||
PrintLog("CDVDiso file: (%i) %i:%s\n", newhandle, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
return(newhandle);
|
||||
} // END ActualFileOpenForRead()
|
||||
|
||||
|
||||
off64_t ActualFileSize(ACTUALHANDLE handle) {
|
||||
int retval;
|
||||
struct stat64 filestat;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileSize()\n");
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = fstat64(handle, &filestat);
|
||||
if((retval < 0) || (errno != 0)) return(-1); // Name doesn't exist.
|
||||
return(filestat.st_size);
|
||||
} // END ActualFileSize()
|
||||
|
||||
|
||||
int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
|
||||
off64_t moved;
|
||||
|
||||
if(handle < 0) return(-1);
|
||||
if(position < 0) return(-1); // Maybe... position = 0?
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileSeek(%lli)", position);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
moved = lseek64(handle, position, SEEK_SET);
|
||||
if(errno != 0) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error on seek (%lli)", position);
|
||||
PrintLog("CDVDiso file: %i:%s\n", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
return(0);
|
||||
} // END ActualFileSeek()
|
||||
|
||||
|
||||
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
|
||||
int retval;
|
||||
|
||||
if(handle == ACTUALHANDLENULL) return(-1);
|
||||
if(bytes < 1) return(-1);
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = read(handle, buffer, bytes);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error reading from file!");
|
||||
PrintLog("CDVDiso file: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
// return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
return(retval); // Send back how many bytes read
|
||||
} // END ActualFileRead()
|
||||
|
||||
|
||||
void ActualFileClose(ACTUALHANDLE handle) {
|
||||
if(handle < 0) return;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileClose()");
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
close(handle);
|
||||
return;
|
||||
} // END ActualFileClose()
|
||||
|
||||
|
||||
ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
|
||||
int newhandle;
|
||||
|
||||
if(filename == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
newhandle = open(filename, O_WRONLY | O_CREAT | O_LARGEFILE, 0644);
|
||||
if((newhandle < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error opening file %s", filename);
|
||||
PrintLog("CDVDiso file: (%i) %i:%s", newhandle, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
return(newhandle);
|
||||
} // END ActualFileOpenForWrite()
|
||||
|
||||
|
||||
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
|
||||
int retval;
|
||||
|
||||
if(handle < 0) return(-1);
|
||||
if(bytes < 1) return(-1);
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = write(handle, buffer, bytes);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("CDVDiso file: Error writing to file!");
|
||||
PrintLog("CDVDiso file: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
// return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
return(retval); // Send back how many bytes written
|
||||
} // END ActualFileWrite()
|
|
@ -0,0 +1,50 @@
|
|||
/* actualfile.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ACTUALFILE_H
|
||||
#define ACTUALFILE_H
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
#define ACTUALHANDLE int
|
||||
#define ACTUALHANDLENULL -1
|
||||
|
||||
// #define VERBOSE_FUNCTION_ACTUALFILE
|
||||
// #define VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
|
||||
extern int IsActualFile(const char *filename);
|
||||
extern void ActualFileDelete(const char *filename);
|
||||
extern void ActualFileRename(const char *origname, const char *newname);
|
||||
|
||||
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
|
||||
extern off64_t ActualFileSize(ACTUALHANDLE handle);
|
||||
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
|
||||
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
|
||||
extern void ActualFileClose(ACTUALHANDLE handle);
|
||||
|
||||
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
|
||||
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
|
||||
|
||||
|
||||
#endif /* ACTUALFILE_H */
|
|
@ -0,0 +1,415 @@
|
|||
/* comparisonbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkentry.h> // gtk_entry_new()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtkhbox.h> // gtk_hbox_new()
|
||||
#include <gtk/gtkhseparator.h> // gtk_hseparator_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "logfile.h"
|
||||
#include "conf.h"
|
||||
#include "isofile.h"
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
#include "multifile.h" // multinames[]
|
||||
#include "tablerebuild.h" // IsoTableRebuild()
|
||||
#include "progressbox.h"
|
||||
#include "messagebox.h"
|
||||
|
||||
|
||||
struct MainBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *file1; // GtkEntry
|
||||
GtkWidget *desc1; // GtkLabel
|
||||
GtkWidget *file2; // GtkEntry
|
||||
GtkWidget *desc2; // GtkLabel
|
||||
GtkWidget *okbutton; // GtkButton
|
||||
// Leaving the Cancel button unblocked... for emergency shutdown
|
||||
|
||||
int stop; // Variable signal to stop long processes
|
||||
};
|
||||
|
||||
|
||||
struct MainBoxData mainbox;
|
||||
|
||||
|
||||
void MainBoxDestroy() {
|
||||
if(mainbox.window != NULL) {
|
||||
gtk_widget_destroy(mainbox.window);
|
||||
mainbox.window = NULL;
|
||||
mainbox.file1 = NULL;
|
||||
mainbox.desc1 = NULL;
|
||||
mainbox.file2 = NULL;
|
||||
mainbox.desc2 = NULL;
|
||||
mainbox.okbutton = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END MainBoxDestroy()
|
||||
|
||||
|
||||
void MainBoxUnfocus() {
|
||||
gtk_widget_set_sensitive(mainbox.file1, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.file2, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.okbutton, FALSE);
|
||||
gtk_window_iconify(GTK_WINDOW(mainbox.window));
|
||||
} // END MainBoxUnfocus()
|
||||
|
||||
|
||||
gint MainBoxFile1Event(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file1)));
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Not a valid image file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Image file?
|
||||
|
||||
if(returnval == -4) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc1), "File Type: Missing Table File (will rebuild)");
|
||||
return(TRUE);
|
||||
} // ENDIF- Missing Compression seek table?
|
||||
|
||||
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file1)));
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc1), templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return(TRUE);
|
||||
} // END MainBoxFileEvent()
|
||||
|
||||
|
||||
gint MainBoxFile2Event(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file2)));
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Not a valid image file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Image file?
|
||||
|
||||
if(returnval == -4) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc2), "File Type: Missing Table File (will rebuild)");
|
||||
return(TRUE);
|
||||
} // ENDIF- Missing Compression seek table?
|
||||
|
||||
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file2)));
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc2), templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return(TRUE);
|
||||
} // END MainBoxFileEvent()
|
||||
|
||||
|
||||
void MainBoxRefocus() {
|
||||
GdkEvent event;
|
||||
|
||||
MainBoxFile1Event(NULL, event, NULL);
|
||||
MainBoxFile2Event(NULL, event, NULL);
|
||||
|
||||
gtk_widget_set_sensitive(mainbox.file1, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.file2, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
|
||||
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file1);
|
||||
gtk_window_deiconify(GTK_WINDOW(mainbox.window));
|
||||
} // END MainBoxRefocus()
|
||||
|
||||
|
||||
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
mainbox.stop = 1; // Halt all long processess...
|
||||
|
||||
MessageBoxDestroy();
|
||||
ProgressBoxDestroy();
|
||||
MainBoxDestroy();
|
||||
|
||||
gtk_main_quit();
|
||||
return(TRUE);
|
||||
} // END MainBoxCancelEvent()
|
||||
|
||||
|
||||
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
const char *tempisoname1;
|
||||
const char *tempisoname2;
|
||||
struct IsoFile *tempiso1;
|
||||
struct IsoFile *tempiso2;
|
||||
int stop;
|
||||
off64_t endsector;
|
||||
off64_t sector;
|
||||
int retval;
|
||||
char tempblock1[2448];
|
||||
char tempblock2[2448];
|
||||
int i;
|
||||
|
||||
MainBoxUnfocus();
|
||||
|
||||
tempisoname1 = gtk_entry_get_text(GTK_ENTRY(mainbox.file1));
|
||||
tempisoname2 = gtk_entry_get_text(GTK_ENTRY(mainbox.file2));
|
||||
tempiso1 = NULL;
|
||||
tempiso2 = NULL;
|
||||
|
||||
tempiso1 = IsoFileOpenForRead(tempisoname1);
|
||||
if(tempiso1 == NULL) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("First file is not a Valid Image File.", 0);
|
||||
tempisoname1 = NULL;
|
||||
tempisoname2 = NULL;
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an ISO file? Message and Stop here.
|
||||
|
||||
tempiso2 = IsoFileOpenForRead(tempisoname2);
|
||||
if(tempiso2 == NULL) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Second file is not a Valid Image File.", 0);
|
||||
tempiso1 = IsoFileClose(tempiso1);
|
||||
tempisoname1 = NULL;
|
||||
tempisoname2 = NULL;
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an ISO file? Message and Stop here.
|
||||
|
||||
if(tempiso1->blocksize != tempiso2->blocksize) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Block sizes in Image files do not match.", 0);
|
||||
tempiso1 = IsoFileClose(tempiso1);
|
||||
tempiso2 = IsoFileClose(tempiso2);
|
||||
tempisoname1 = NULL;
|
||||
tempisoname2 = NULL;
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an ISO file? Message and Stop here.
|
||||
|
||||
if(tempiso1->multi == 1) {
|
||||
i = 0;
|
||||
while((i < 10) &&
|
||||
(IsoFileSeek(tempiso1, tempiso1->multisectorend[i] + 1) == 0)) i++;
|
||||
endsector = tempiso1->multisectorend[tempiso1->multiend];
|
||||
} else {
|
||||
endsector = tempiso1->filesectorsize;
|
||||
} // ENDIF- Get ending sector from multifile? (Or single file?)
|
||||
IsoFileSeek(tempiso1, 0);
|
||||
|
||||
if(tempiso2->multi == 1) {
|
||||
i = 0;
|
||||
while((i < 10) &&
|
||||
(IsoFileSeek(tempiso2, tempiso2->multisectorend[i] + 1) == 0)) i++;
|
||||
sector = tempiso2->multisectorend[tempiso2->multiend];
|
||||
} else {
|
||||
sector = tempiso2->filesectorsize;
|
||||
} // ENDIF- Get ending sector from multifile? (Or single file?)
|
||||
IsoFileSeek(tempiso2, 0);
|
||||
if(sector != endsector) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Number of blocks in Image files do not match.", 0);
|
||||
tempiso1 = IsoFileClose(tempiso1);
|
||||
tempiso2 = IsoFileClose(tempiso2);
|
||||
tempisoname1 = NULL;
|
||||
tempisoname2 = NULL;
|
||||
return(TRUE);
|
||||
} // ENDIF- Number of blocks don't match? Say so.
|
||||
|
||||
sprintf(tempblock1, "%s == %s ?", tempisoname1, tempisoname2);
|
||||
ProgressBoxStart(tempblock1, endsector);
|
||||
|
||||
stop = 0;
|
||||
mainbox.stop = 0;
|
||||
progressbox.stop = 0;
|
||||
while((stop == 0) && (tempiso1->sectorpos < endsector)) {
|
||||
retval = IsoFileRead(tempiso1, tempblock1);
|
||||
if(retval < 0) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Trouble reading first file.", 0);
|
||||
stop = 1;
|
||||
} else {
|
||||
retval = IsoFileRead(tempiso2, tempblock2);
|
||||
if(retval < 0) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Trouble reading second file.", 0);
|
||||
stop = 1;
|
||||
} else {
|
||||
i = 0;
|
||||
while((i < tempiso1->blocksize) && (tempblock1[i] == tempblock2[i])) i++;
|
||||
if(i < tempiso1->blocksize) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Trouble reading second file.", 0);
|
||||
stop = 1;
|
||||
} // ENDIF- Sectors don't match? Say so.
|
||||
} // ENDIF- Trouble reading second file?
|
||||
} // ENDIF- Trouble reading first file?
|
||||
|
||||
ProgressBoxTick(tempiso1->sectorpos);
|
||||
while(gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
if(mainbox.stop != 0) stop = 2;
|
||||
if(progressbox.stop != 0) stop = 2;
|
||||
} // ENDWHILE- Comparing two files... sector by sector
|
||||
|
||||
if(stop == 0) {
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Images Match.", 0);
|
||||
} // ENDIF- Everything checked out? Say so.
|
||||
tempiso1 = IsoFileClose(tempiso1);
|
||||
tempiso2 = IsoFileClose(tempiso2);
|
||||
tempisoname1 = NULL;
|
||||
tempisoname2 = NULL;
|
||||
return(TRUE);
|
||||
} // END MainBoxOKEvent()
|
||||
|
||||
|
||||
void MainBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
|
||||
mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Comparsion");
|
||||
gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER);
|
||||
// gtk_window_set_resizable(GTK_WINDOW(mainbox.window), FALSE);
|
||||
|
||||
g_signal_connect(G_OBJECT(mainbox.window), "delete_event",
|
||||
G_CALLBACK(MainBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("First Iso File:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
mainbox.file1 = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.file1);
|
||||
g_signal_connect(G_OBJECT(mainbox.file1), "changed",
|
||||
G_CALLBACK(MainBoxFile1Event), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
mainbox.desc1 = gtk_label_new("File Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc1, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.desc1);
|
||||
|
||||
item = gtk_hseparator_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Second Iso File:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
mainbox.file2 = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file2, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.file2);
|
||||
g_signal_connect(G_OBJECT(mainbox.file2), "changed",
|
||||
G_CALLBACK(MainBoxFile2Event), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
mainbox.desc2 = gtk_label_new("File Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc2, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.desc2);
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
mainbox.okbutton = gtk_button_new_with_label("Compare");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.okbutton);
|
||||
g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked",
|
||||
G_CALLBACK(MainBoxOKEvent), NULL);
|
||||
|
||||
item = gtk_button_new_with_label("Exit");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
g_signal_connect(G_OBJECT(item), "clicked",
|
||||
G_CALLBACK(MainBoxCancelEvent), NULL);
|
||||
item = NULL;
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
|
||||
// We held off setting the name until now... so description would show.
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file1), conf.isoname);
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file2), conf.isoname);
|
||||
} // END MainBoxDisplay()
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
gtk_init(NULL, NULL);
|
||||
|
||||
OpenLog();
|
||||
InitConf();
|
||||
LoadConf();
|
||||
MainBoxDisplay();
|
||||
ProgressBoxDisplay();
|
||||
MessageBoxDisplay();
|
||||
|
||||
gtk_widget_show_all(mainbox.window);
|
||||
gtk_main();
|
||||
CloseLog();
|
||||
return(0);
|
||||
} // END main()
|
|
@ -0,0 +1,227 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso Comparison</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">First Iso File:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotfile1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">File Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHSeparator" id="hseparator1">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Second Iso File:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotfile2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">File Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotokbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Compare</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Exit</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,24 @@
|
|||
/* comparisondummy.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
void ConversionBoxRefocus() { return; }
|
||||
|
||||
void DeviceBoxRefocus() { return; }
|
|
@ -0,0 +1,204 @@
|
|||
/* conf.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <stdlib.h> // getenv()
|
||||
#include <string.h> // strerror()
|
||||
#include <sys/stat.h> // mkdir(), stat()
|
||||
#include <sys/types.h> // mkdir(), stat()
|
||||
#include <unistd.h> // stat()
|
||||
|
||||
// #define CDVDdefs
|
||||
// #include "../PS2Edefs.h"
|
||||
#include "logfile.h"
|
||||
#include "../ini.h"
|
||||
#include "conf.h"
|
||||
|
||||
|
||||
const char *cfgname[] = { \
|
||||
"./cfg/cfgCDVDisoEFP", \
|
||||
"../cfg/cfgCDVDisoEFP", \
|
||||
"./cfgCDVDisoEFP", \
|
||||
"../cfgCDVDisoEFP", \
|
||||
"./plugins/cfgCDVDisoEFP", \
|
||||
"../plugins/cfgCDVDisoEFP", \
|
||||
NULL };
|
||||
|
||||
const char *confnames[] = { "IsoFile", "CdDev", NULL };
|
||||
const u8 defaultdevice[] = DEFAULT_DEVICE;
|
||||
const char defaulthome[] = "../inis";
|
||||
const char defaultdirectory[] = ".PS2E";
|
||||
const char defaultfile[] = "CDVDisoEFP.ini";
|
||||
|
||||
char confdirname[256];
|
||||
char conffilename[256];
|
||||
|
||||
CDVDconf conf;
|
||||
|
||||
|
||||
void ExecCfg(char *arg) {
|
||||
int nameptr;
|
||||
struct stat filestat;
|
||||
char templine[256];
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVDiso interface: ExecCfg(%s)", arg);
|
||||
#endif /* VERBOSE FUNCTION_CONF */
|
||||
errno = 0;
|
||||
nameptr = 0;
|
||||
while((cfgname[nameptr] != NULL) &&
|
||||
(stat(cfgname[nameptr], &filestat) == -1)) nameptr++;
|
||||
errno = 0;
|
||||
|
||||
if(cfgname[nameptr] == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVDiso interface: Couldn't find configuration program!");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
return;
|
||||
} // ENDIF- Did not find the executable?
|
||||
|
||||
sprintf(templine, "%s %s", cfgname[nameptr], arg);
|
||||
system(templine);
|
||||
} // END ExecCfg()
|
||||
|
||||
|
||||
void InitConf() {
|
||||
int i;
|
||||
int pos;
|
||||
char *envptr;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: InitConf()");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
conf.isoname[0] = 0; // Empty the iso name
|
||||
|
||||
i = 0;
|
||||
while((i < 255) && defaultdevice[i] != 0) {
|
||||
conf.devicename[i] = defaultdevice[i];
|
||||
i++;
|
||||
} // ENDWHILE- copying the default CD/DVD name in
|
||||
conf.devicename[i] = 0; // 0-terminate the device name
|
||||
|
||||
// Locating directory and file positions
|
||||
pos = 0;
|
||||
envptr = getenv("HOME");
|
||||
if(envptr == NULL) {
|
||||
// = <Default Home>
|
||||
i = 0;
|
||||
while((pos < 253) && (defaulthome[i] != 0)) {
|
||||
confdirname[pos] = defaulthome[i];
|
||||
conffilename[pos] = defaulthome[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // NEXT- putting a default place to store configuration data
|
||||
|
||||
} else {
|
||||
// = <Env Home>/<Default Directory>
|
||||
i = 0;
|
||||
while((pos < 253) && (*(envptr + i) != 0)) {
|
||||
confdirname[pos] = *(envptr + i);
|
||||
conffilename[pos] = *(envptr + i);
|
||||
pos++;
|
||||
i++;
|
||||
} // ENDWHILE- copying home directory info in
|
||||
|
||||
if(confdirname[pos-1] != '/') {
|
||||
confdirname[pos] = '/';
|
||||
conffilename[pos] = '/';
|
||||
pos++;
|
||||
} // ENDIF- No directory separator here? Add one.
|
||||
|
||||
i = 0;
|
||||
while((pos < 253) && (defaultdirectory[i] != 0)) {
|
||||
confdirname[pos] = defaultdirectory[i];
|
||||
conffilename[pos] = defaultdirectory[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // NEXT- putting a default place to store configuration data
|
||||
} // ENDIF- No Home directory?
|
||||
|
||||
confdirname[pos] = 0; // Directory reference finished
|
||||
|
||||
// += /<Config File Name>
|
||||
if(conffilename[pos-1] != '/') {
|
||||
conffilename[pos] = '/';
|
||||
pos++;
|
||||
} // ENDIF- No directory separator here? Add one.
|
||||
|
||||
i = 0;
|
||||
while((pos < 253) && (defaultfile[i] != 0)) {
|
||||
conffilename[pos] = defaultfile[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // NEXT- putting a default place to store configuration data
|
||||
|
||||
conffilename[pos] = 0; // File reference finished
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: Directory: %s\n", confdirname);
|
||||
PrintLog("CDVD config: File: %s\n", conffilename);
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
} // END InitConf()
|
||||
|
||||
|
||||
void LoadConf() {
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: LoadConf()\n");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname);
|
||||
if(retval < 0) {
|
||||
sprintf(conf.isoname, "[Put an Image Name here]");
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
|
||||
if(retval < 0) {
|
||||
sprintf(conf.devicename, "/dev/dvd");
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure);
|
||||
if(retval < 0) {
|
||||
conf.startconfigure = 0; // False
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure);
|
||||
if(retval < 0) {
|
||||
conf.restartconfigure = 1; // True
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
} // END LoadConf()
|
||||
|
||||
|
||||
void SaveConf() {
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: SaveConf()\n");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
mkdir(confdirname, 0755);
|
||||
|
||||
INISaveString(conffilename, "Settings", "IsoFile", conf.isoname);
|
||||
INISaveString(conffilename, "Settings", "Device", conf.devicename);
|
||||
INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure);
|
||||
INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure);
|
||||
} // END SaveConf()
|
|
@ -0,0 +1,54 @@
|
|||
/* conf.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef CONF_H
|
||||
#define CONF_H
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
|
||||
#define VERBOSE_FUNCTION_CONF
|
||||
|
||||
|
||||
// Configuration Data
|
||||
|
||||
typedef struct {
|
||||
u8 isoname[256];
|
||||
u8 devicename[256];
|
||||
unsigned int startconfigure;
|
||||
unsigned int restartconfigure;
|
||||
} CDVDconf;
|
||||
extern CDVDconf conf;
|
||||
|
||||
#define DEFAULT_DEVICE "K:\\"
|
||||
|
||||
|
||||
// Configuration Functions
|
||||
|
||||
extern void InitConf();
|
||||
extern void LoadConf();
|
||||
extern void SaveConf();
|
||||
|
||||
extern void ExecCfg(char *arg);
|
||||
|
||||
|
||||
#endif /* CONF_H */
|
|
@ -0,0 +1,388 @@
|
|||
/* conversionbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcpy()
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcombobox.h> // gtk_combo_box_new()
|
||||
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkentry.h> // gtk_entry_new()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtkhbox.h> // gtk_hbox_new()
|
||||
#include <gtk/gtkhseparator.h> // gtk_hseparator_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_main_iteration()
|
||||
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "isofile.h"
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
#include "imagetype.h" // imagedata[]
|
||||
#include "multifile.h" // multinames[]
|
||||
#include "toc.h"
|
||||
#include "progressbox.h"
|
||||
#include "messagebox.h"
|
||||
#include "selectionbox.h"
|
||||
#include "mainbox.h"
|
||||
#include "conversionbox.h"
|
||||
|
||||
|
||||
struct ConversionBoxData conversionbox;
|
||||
|
||||
|
||||
void ConversionBoxDestroy() {
|
||||
if(conversionbox.window != NULL) {
|
||||
gtk_widget_destroy(conversionbox.window);
|
||||
conversionbox.window = NULL;
|
||||
conversionbox.file = NULL;
|
||||
conversionbox.selectbutton = NULL;
|
||||
conversionbox.filedesc = NULL;
|
||||
conversionbox.compress = NULL;
|
||||
conversionbox.multi = NULL;
|
||||
conversionbox.okbutton = NULL;
|
||||
conversionbox.cancelbutton = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END ConversionBoxDestroy()
|
||||
|
||||
|
||||
void ConversionBoxUnfocus() {
|
||||
gtk_widget_set_sensitive(conversionbox.file, FALSE);
|
||||
gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE);
|
||||
gtk_widget_set_sensitive(conversionbox.compress, FALSE);
|
||||
gtk_widget_set_sensitive(conversionbox.multi, FALSE);
|
||||
gtk_widget_set_sensitive(conversionbox.okbutton, FALSE);
|
||||
gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE);
|
||||
// gtk_window_iconify(GTK_WINDOW(conversionbox.window));
|
||||
gtk_widget_hide(conversionbox.window);
|
||||
} // END ConversionBoxUnfocus()
|
||||
|
||||
|
||||
gint ConversionBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), "File Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
|
||||
"File Type: Not a file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
|
||||
"File Type: Not a valid image file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -4) {
|
||||
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc),
|
||||
"File Type: Missing Table File (will rebuild)");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
gtk_label_set_text(GTK_LABEL(conversionbox.filedesc), templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return(TRUE);
|
||||
} // END ConversionBoxFileEvent()
|
||||
|
||||
|
||||
void ConversionBoxRefocus() {
|
||||
GdkEvent event;
|
||||
|
||||
ConversionBoxFileEvent(NULL, event, NULL);
|
||||
|
||||
gtk_widget_set_sensitive(conversionbox.file, TRUE);
|
||||
gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE);
|
||||
gtk_widget_set_sensitive(conversionbox.compress, TRUE);
|
||||
gtk_widget_set_sensitive(conversionbox.multi, TRUE);
|
||||
gtk_widget_set_sensitive(conversionbox.okbutton, TRUE);
|
||||
gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE);
|
||||
gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
|
||||
gtk_widget_show_all(conversionbox.window);
|
||||
gtk_window_deiconify(GTK_WINDOW(conversionbox.window));
|
||||
} // END ConversionBoxRefocus()
|
||||
|
||||
|
||||
gint ConversionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
gtk_widget_hide(conversionbox.window);
|
||||
MainBoxRefocus();
|
||||
return(TRUE);
|
||||
} // END ConversionBoxCancelEvent()
|
||||
|
||||
|
||||
gint ConversionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
char templine[256];
|
||||
char tempblock[2352];
|
||||
const char *filename;
|
||||
int compressmethod;
|
||||
int multi;
|
||||
struct IsoFile *fromfile;
|
||||
struct IsoFile *tofile;
|
||||
int i;
|
||||
off64_t endsector;
|
||||
int stop;
|
||||
int retval;
|
||||
|
||||
ConversionBoxUnfocus();
|
||||
|
||||
filename = gtk_entry_get_text(GTK_ENTRY(conversionbox.file));
|
||||
if(IsIsoFile(filename) < 0) {
|
||||
filename = NULL;
|
||||
MessageBoxShow("Not a valid file", 3);
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(conversionbox.compress));
|
||||
if(compressmethod > 0) compressmethod += 2;
|
||||
multi = 0;
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(conversionbox.multi)) == TRUE)
|
||||
multi = 1;
|
||||
|
||||
fromfile = NULL;
|
||||
fromfile = IsoFileOpenForRead(filename);
|
||||
if(fromfile == NULL) {
|
||||
filename = NULL;
|
||||
MessageBoxShow("Cannot opening the source file", 3);
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
if((compressmethod == fromfile->compress) &&
|
||||
(multi == fromfile->multi)) {
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
filename = NULL;
|
||||
MessageBoxShow("Compress/Multifile methods match - no need to convert", 3);
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
tofile = IsoFileOpenForWrite(filename,
|
||||
GetImageTypeConvertTo(fromfile->imagetype),
|
||||
multi,
|
||||
compressmethod);
|
||||
if(tofile == NULL) {
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
filename = NULL;
|
||||
MessageBoxShow("Cannot create the new file", 3);
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
if(fromfile->multi == 1) {
|
||||
i = 0;
|
||||
while((i < 10) &&
|
||||
(IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++;
|
||||
endsector = fromfile->multisectorend[fromfile->multiend];
|
||||
} else {
|
||||
endsector = fromfile->filesectorsize;
|
||||
} // ENDIF- Get ending sector from multifile? (Or single file?)
|
||||
IsoFileSeek(fromfile, 0);
|
||||
|
||||
// Open Progress Bar
|
||||
sprintf(templine, "%s: %s%s -> %s%s",
|
||||
filename,
|
||||
multinames[fromfile->multi],
|
||||
compressdesc[fromfile->compress],
|
||||
multinames[tofile->multi],
|
||||
compressdesc[tofile->compress]);
|
||||
ProgressBoxStart(templine, endsector);
|
||||
|
||||
tofile->cdvdtype = fromfile->cdvdtype;
|
||||
for(i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i];
|
||||
|
||||
stop = 0;
|
||||
mainbox.stop = 0;
|
||||
progressbox.stop = 0;
|
||||
while((stop == 0) && (tofile->sectorpos < endsector)) {
|
||||
retval = IsoFileRead(fromfile, tempblock);
|
||||
if(retval < 0) {
|
||||
MessageBoxShow("Trouble reading source file", 3);
|
||||
stop = 1;
|
||||
} else {
|
||||
retval = IsoFileWrite(tofile, tempblock);
|
||||
if(retval < 0) {
|
||||
MessageBoxShow("Trouble writing new file", 3);
|
||||
stop = 1;
|
||||
} // ENDIF- Trouble writing out the next block?
|
||||
} // ENDIF- Trouble reading in the next block?
|
||||
|
||||
ProgressBoxTick(tofile->sectorpos);
|
||||
while(gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
if(mainbox.stop != 0) stop = 2;
|
||||
if(progressbox.stop != 0) stop = 2;
|
||||
} // ENDWHILE- Not stopped for some reason...
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
if(stop == 0) {
|
||||
if(tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
|
||||
strcpy(templine, tofile->name);
|
||||
|
||||
// fromfile = IsoFileCloseAndDelete(fromfile);
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
|
||||
IsoSaveTOC(tofile);
|
||||
tofile = IsoFileClose(tofile);
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
|
||||
|
||||
} else {
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
tofile = IsoFileCloseAndDelete(tofile);
|
||||
} // ENDIF- Did we succeed in the transfer?
|
||||
|
||||
if(stop != 1) ConversionBoxRefocus();
|
||||
if(stop == 0) ConversionBoxCancelEvent(widget, event, data);
|
||||
return(TRUE);
|
||||
} // END ConversionBoxOKEvent()
|
||||
|
||||
|
||||
gint ConversionBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
ConversionBoxUnfocus();
|
||||
|
||||
// Transfer file name to file selection
|
||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
|
||||
gtk_entry_get_text(GTK_ENTRY(conversionbox.file)));
|
||||
selectionbox.wherefrom = 3; // From the Conversion Window
|
||||
SelectionBoxRefocus();
|
||||
return(TRUE);
|
||||
} // END ConversionBoxBrowseEvent()
|
||||
|
||||
|
||||
void ConversionBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
int nameptr;
|
||||
|
||||
conversionbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(conversionbox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(conversionbox.window), "CDVDisoEFP File Conversion");
|
||||
gtk_window_set_position(GTK_WINDOW(conversionbox.window), GTK_WIN_POS_CENTER);
|
||||
|
||||
g_signal_connect(G_OBJECT(conversionbox.window), "delete_event",
|
||||
G_CALLBACK(ConversionBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(conversionbox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Iso File:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
conversionbox.file = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.file, TRUE, TRUE, 0);
|
||||
gtk_widget_show(conversionbox.file);
|
||||
g_signal_connect(G_OBJECT(conversionbox.file), "changed",
|
||||
G_CALLBACK(ConversionBoxFileEvent), NULL);
|
||||
|
||||
conversionbox.selectbutton = gtk_button_new_with_label("Browse");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.selectbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show(conversionbox.selectbutton);
|
||||
g_signal_connect(G_OBJECT(conversionbox.selectbutton), "clicked",
|
||||
G_CALLBACK(ConversionBoxBrowseEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
conversionbox.filedesc = gtk_label_new("File Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), conversionbox.filedesc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(conversionbox.filedesc);
|
||||
// ConversionBoxFileEvent(NULL, 0, NULL); // Work out compromise later...
|
||||
|
||||
item = gtk_hseparator_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Change Compression To:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
conversionbox.compress = gtk_combo_box_new_text();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.compress, FALSE, FALSE, 0);
|
||||
nameptr = 0;
|
||||
while(compressnames[nameptr] != NULL) {
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(conversionbox.compress),
|
||||
compressnames[nameptr]);
|
||||
nameptr++;
|
||||
} // ENDWHILE- loading compression types into combo box
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(conversionbox.compress), 0); // Temp Line
|
||||
gtk_widget_show(conversionbox.compress);
|
||||
hbox1 = NULL;
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Multiple Files (all under 2 GB):");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
conversionbox.multi = gtk_check_button_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.multi, FALSE, FALSE, 0);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(conversionbox.multi), FALSE);
|
||||
gtk_widget_show(conversionbox.multi);
|
||||
hbox1 = NULL;
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
conversionbox.okbutton = gtk_button_new_with_label("Change File");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.okbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(conversionbox.okbutton);
|
||||
g_signal_connect(G_OBJECT(conversionbox.okbutton), "clicked",
|
||||
G_CALLBACK(ConversionBoxOKEvent), NULL);
|
||||
|
||||
conversionbox.cancelbutton = gtk_button_new_with_label("Cancel");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), conversionbox.cancelbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(conversionbox.cancelbutton);
|
||||
g_signal_connect(G_OBJECT(conversionbox.cancelbutton), "clicked",
|
||||
G_CALLBACK(ConversionBoxCancelEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
} // END ConversionBoxDisplay()
|
|
@ -0,0 +1,272 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso File Conversion</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Iso File:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotfile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotselectbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Browse</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">File Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHSeparator" id="hseparator1">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Change Compression To:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBoxEntry" id="dotcompress">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">None
|
||||
GZip (for speed)
|
||||
BZip2 (for speed)
|
||||
BZip2 (for size)
|
||||
</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Multiple Files (all under 2 GB): </property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="dotmulti">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotokbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Change File</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotcancelbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,47 @@
|
|||
/* conversionbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CONVERSIONBOX_H
|
||||
#define CONVERSIONBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct ConversionBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *file; // GtkEntry
|
||||
GtkWidget *selectbutton; // GtkButton
|
||||
GtkWidget *filedesc; // GtkLabel
|
||||
GtkWidget *compress; // GtkComboBox
|
||||
GtkWidget *multi; // GtkCheckButton
|
||||
GtkWidget *okbutton; // GtkButton
|
||||
GtkWidget *cancelbutton; // GtkButton
|
||||
};
|
||||
|
||||
extern struct ConversionBoxData conversionbox;
|
||||
|
||||
extern void ConversionBoxDestroy();
|
||||
extern void ConversionBoxRefocus();
|
||||
extern void ConversionBoxDisplay();
|
||||
|
||||
|
||||
#endif /* CONVERSIONBOX_H */
|
|
@ -0,0 +1,418 @@
|
|||
/* device.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <fcntl.h> // open()
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdlib.h> // getenv()
|
||||
#include <string.h> // strerror()
|
||||
#include <sys/ioctl.h> // ioctl()
|
||||
#include <sys/stat.h> // open()
|
||||
#include <sys/types.h> // open()
|
||||
#include <time.h> // time_t, time(), struct timeval
|
||||
#include <unistd.h> // close(), select()
|
||||
|
||||
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
|
||||
|
||||
#include "logfile.h"
|
||||
#include "conf.h"
|
||||
#include "CD.h"
|
||||
#include "DVD.h"
|
||||
#include "device.h"
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
int devicehandle; // File Handle for the device/drive
|
||||
s32 devicecapability; // Capability Flags
|
||||
time_t lasttime; // Time marker (in case something gets called too often)
|
||||
s32 traystatus; // Is the CD/DVD tray open?
|
||||
|
||||
s32 disctype; // Type of disc in drive (Video DVD, PSX CD, etc.)
|
||||
u8 tocbuffer[2048];
|
||||
|
||||
|
||||
void DeviceInit() {
|
||||
devicehandle = -1;
|
||||
devicecapability = 0;
|
||||
lasttime = time(NULL);
|
||||
|
||||
InitDisc();
|
||||
} // END DeviceInit()
|
||||
|
||||
|
||||
// Called by DeviceOpen(), DeviceGetDiskType()
|
||||
void InitDisc() {
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: InitDisc()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) ||
|
||||
(disctype == CDVD_TYPE_DVDV)) {
|
||||
InitDVDInfo();
|
||||
} // ENDIF- Clean out DVD Disc Info?
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2CD) ||
|
||||
(disctype == CDVD_TYPE_PS2CDDA) ||
|
||||
(disctype == CDVD_TYPE_PSCD) ||
|
||||
(disctype == CDVD_TYPE_PSCDDA) ||
|
||||
(disctype == CDVD_TYPE_CDDA)) {
|
||||
InitCDInfo();
|
||||
} // ENDIF- Clean out DVD Disc Info?
|
||||
|
||||
disctype = CDVD_TYPE_NODISC;
|
||||
for(i = 0; i > sizeof(tocbuffer); i++) tocbuffer[i] = 0x00;
|
||||
} // END InitDisc()
|
||||
|
||||
|
||||
s32 DiscInserted() {
|
||||
if(devicehandle == -1) return(-1);
|
||||
if(traystatus == CDVD_TRAY_OPEN) return(-1);
|
||||
if(disctype == CDVD_TYPE_ILLEGAL) return(-1);
|
||||
// if(disctype == CDVD_TYPE_UNKNOWN) return(-1); // Hmm. Let this one through?
|
||||
if(disctype == CDVD_TYPE_DETCTDVDD) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCTDVDS) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCTCD) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCT) return(-1);
|
||||
if(disctype == CDVD_TYPE_NODISC) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DiscInserted()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
return(0);
|
||||
} // END DiscInserted()
|
||||
|
||||
|
||||
// Called by DeviceTrayStatus() and CDVDopen()
|
||||
s32 DeviceOpen() {
|
||||
// s32 s32result;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if(devicehandle != -1) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVD device: Device already open!");
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(0);
|
||||
} // ENDIF- Is the CD/DVD already in use? That's fine.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceOpen()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
// InitConf();
|
||||
// LoadConf(); // Should be done once before making this call
|
||||
|
||||
devicehandle = open(conf.devicename, O_RDONLY | O_NONBLOCK);
|
||||
if(devicehandle == -1) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD device: Error opening device: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(-1);
|
||||
} // ENDIF- Failed to open device? Abort
|
||||
|
||||
// Note: Hmm. Need a minimum capability in case this fails?
|
||||
devicecapability = ioctl(devicehandle, CDROM_GET_CAPABILITY);
|
||||
if(errno != 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD device: Error getting device capabilities: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
close(devicehandle);
|
||||
devicehandle = -1;
|
||||
devicecapability = 0;
|
||||
return(-1);
|
||||
} // ENDIF- Can't read drive capabilities? Close and Abort.
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
PrintLog("CDVD device: Device Type(s)");
|
||||
if(devicecapability < CDC_CD_R) PrintLog("CDVD device: CD");
|
||||
if(devicecapability & CDC_CD_R) PrintLog("CDVD device: CD-R");
|
||||
if(devicecapability & CDC_CD_RW) PrintLog("CDVD device: CD-RW");
|
||||
if(devicecapability & CDC_DVD) PrintLog("CDVD device: DVD");
|
||||
if(devicecapability & CDC_DVD_R) PrintLog("CDVD device: DVD-R");
|
||||
if(devicecapability & CDC_DVD_RAM) PrintLog("CDVD device: DVD-RAM");
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
PrintLog("CDVD device: Device Capabilities:");
|
||||
if(devicecapability & CDC_CLOSE_TRAY) PrintLog("CDVD device: Can close a tray");
|
||||
if(devicecapability & CDC_OPEN_TRAY) PrintLog("CDVD device: Can open a tray");
|
||||
// if(devicecapability & CDC_LOCK) PrintLog("CDVD device: Can lock the drive door");
|
||||
if(devicecapability & CDC_SELECT_SPEED) PrintLog("CDVD device: Can change spin speed");
|
||||
// if(devicecapability & CDC_SELECT_DISC) PrintLog("CDVD device: Can change disks (multi-disk tray)");
|
||||
// if(devicecapability & CDC_MULTI_SESSION) PrintLog("CDVD device: Can read multi-session disks");
|
||||
// if(devicecapability & CDC_MCN) PrintLog("CDVD device: Can read Medium Catalog Numbers (maybe)");
|
||||
if(devicecapability & CDC_MEDIA_CHANGED) PrintLog("CDVD device: Can tell if the disc was changed");
|
||||
if(devicecapability & CDC_PLAY_AUDIO) PrintLog("CDVD device: Can play audio disks");
|
||||
// if(devicecapability & CDC_RESET) PrintLog("CDVD device: Can reset the device");
|
||||
//if(devicecapability & CDC_IOCTLS) PrintLog("CDVD device: Odd IOCTLs. Not sure of compatability");
|
||||
if(devicecapability & CDC_DRIVE_STATUS) PrintLog("CDVD device: Can monitor the drive tray");
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
////// Should be called after an open (instead of inside of one)
|
||||
// InitDisc();
|
||||
// traystatus = CDVD_TRAY_OPEN; // Start with Tray Open
|
||||
// DeviceTrayStatus(); // Now find out for sure.
|
||||
|
||||
return(0); // Device opened and ready for use.
|
||||
} // END DeviceOpen()
|
||||
|
||||
|
||||
// Called by DeviceTrayStatus(), CDVDclose(), and CDVDshutdown()
|
||||
void DeviceClose() {
|
||||
// s32 s32result;
|
||||
int zerospeed;
|
||||
|
||||
zerospeed = 0;
|
||||
|
||||
if(devicehandle == -1) {
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: Device already closed");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
return;
|
||||
} // ENDIF- Device already closed? Ok.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceClose()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
InitDisc();
|
||||
close(devicehandle);
|
||||
devicehandle = -1;
|
||||
devicecapability = 0;
|
||||
return;
|
||||
} // END CDVDclose()
|
||||
|
||||
|
||||
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
s32 s32result;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceReadTrack(%i)", lsn);
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
// Get that data
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
s32result = DVDreadTrack(lsn, mode, buffer);
|
||||
} else {
|
||||
s32result = CDreadTrack(lsn, mode, buffer);
|
||||
} //ENDIF- Read a DVD sector or a CD sector?
|
||||
|
||||
return(s32result);
|
||||
} // END DeviceReadTrack()
|
||||
|
||||
|
||||
s32 DeviceBufferOffset() {
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceBufferOffset()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
return(0);
|
||||
} else {
|
||||
return(CDgetBufferOffset());
|
||||
} // ENDIF- Is this a DVD?
|
||||
} // END DeviceBufferOffset()
|
||||
|
||||
|
||||
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd) {
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
return(DVDgetTD(track, cdvdtd));
|
||||
} else {
|
||||
return(CDgetTD(track, cdvdtd));
|
||||
} // ENDIF- Is this a DVD?
|
||||
} // END DeviceGetTD()
|
||||
|
||||
|
||||
// Called by DeviceTrayStatus()
|
||||
s32 DeviceGetDiskType() {
|
||||
s32 s32result;
|
||||
s32 ioctldisktype;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if(devicehandle == -1) {
|
||||
return(-1);
|
||||
} // ENDIF- Someone forget to open the device?
|
||||
|
||||
if(traystatus == CDVD_TRAY_OPEN) {
|
||||
return(disctype);
|
||||
} // ENDIF- Is the device tray open? No disc to check yet.
|
||||
|
||||
if(disctype != CDVD_TYPE_NODISC) {
|
||||
return(disctype);
|
||||
} // ENDIF- Already checked? Drive still closed? Disc hasn't changed.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceGetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
disctype = CDVD_TYPE_DETCT;
|
||||
|
||||
ioctldisktype = ioctl(devicehandle, CDROM_DISC_STATUS);
|
||||
if(errno != 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD device: Trouble reading Disc Type!");
|
||||
PrintLog("CDVD device: Error: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
disctype = CDVD_TYPE_UNKNOWN;
|
||||
return(disctype);
|
||||
} // ENDIF- Trouble probing for a disc?
|
||||
|
||||
s32result = DVDgetDiskType(ioctldisktype);
|
||||
if(s32result != -1) {
|
||||
return(disctype);
|
||||
} // ENDIF- Did we find a disc type?
|
||||
|
||||
s32result = CDgetDiskType(ioctldisktype);
|
||||
if(s32result != -1) {
|
||||
return(disctype);
|
||||
} // ENDIF- Did we find a disc type?
|
||||
|
||||
disctype = CDVD_TYPE_UNKNOWN; // Not a CD? Not a DVD? Is is peanut butter?
|
||||
return(disctype);
|
||||
} // END CDVDgetDiskType()
|
||||
|
||||
|
||||
// Called by PollLoop() and CDVDgetTrayStatus()
|
||||
s32 DeviceTrayStatus() {
|
||||
s32 s32result;
|
||||
|
||||
errno = 0;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceTrayStatus()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if(devicehandle == -1) {
|
||||
return(-1);
|
||||
} // ENDIF- Someone forget to open the device?
|
||||
|
||||
if((devicecapability & CDC_DRIVE_STATUS) != 0) {
|
||||
s32result = ioctl(devicehandle, CDROM_DRIVE_STATUS);
|
||||
if(s32result < 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD device: Trouble reading Drive Status!");
|
||||
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
s32result = CDS_TRAY_OPEN;
|
||||
} // ENDIF- Failure to get status? Assume it's open.
|
||||
errno = 0;
|
||||
|
||||
} else {
|
||||
s32result = ioctl(devicehandle, CDROM_DISC_STATUS);
|
||||
if(errno != 0) {
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
PrintLog("CDVD device: Trouble detecting Disc Status presense!");
|
||||
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
s32result = CDS_TRAY_OPEN;
|
||||
errno = 0;
|
||||
} // ENDIF- Trouble?
|
||||
if(s32result == CDS_NO_DISC) {
|
||||
s32result = CDS_TRAY_OPEN;
|
||||
} // ENDIF- Is there no disc in the device? Guess the tray is open
|
||||
} // ENDIF- Can we poll the tray directly? (Or look at disc status instead?)
|
||||
|
||||
if(s32result == CDS_TRAY_OPEN) {
|
||||
traystatus = CDVD_TRAY_OPEN;
|
||||
if(disctype != CDVD_TYPE_NODISC) {
|
||||
DeviceClose(); // Kind of severe way of flushing all buffers.
|
||||
DeviceOpen();
|
||||
InitDisc();
|
||||
} // ENDIF- Tray just opened... clear disc info
|
||||
} else {
|
||||
traystatus = CDVD_TRAY_CLOSE;
|
||||
if(disctype == CDVD_TYPE_NODISC) {
|
||||
DeviceGetDiskType();
|
||||
} // ENDIF- Tray just closed? Get disc information
|
||||
} // ENDIF- Do we detect an open tray?
|
||||
return(traystatus);
|
||||
} // END CDVD_getTrayStatus()
|
||||
|
||||
|
||||
s32 DeviceTrayOpen() {
|
||||
s32 s32result;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if(devicehandle == -1) {
|
||||
return(-1);
|
||||
} // ENDIF- Someone forget to open the device?
|
||||
|
||||
if((devicecapability & CDC_OPEN_TRAY) == 0) {
|
||||
return(-1);
|
||||
} // ENDIF- Don't have open capability? Error out.
|
||||
|
||||
// Tray already open? Exit.
|
||||
if(traystatus == CDVD_TRAY_OPEN) return(0);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceTrayOpen()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
s32result = ioctl(devicehandle, CDROMEJECT);
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
if((s32result != 0) || (errno != 0)) {
|
||||
PrintLog("CDVD device: Could not open the tray!");
|
||||
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
} // ENDIF- Trouble?
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(s32result);
|
||||
} // END DeviceTrayOpen()
|
||||
|
||||
|
||||
s32 DeviceTrayClose() {
|
||||
s32 s32result;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if(devicehandle == -1) {
|
||||
return(-1);
|
||||
} // ENDIF- Someone forget to open the device?
|
||||
|
||||
if((devicecapability & CDC_CLOSE_TRAY) == 0) {
|
||||
return(-1);
|
||||
} // ENDIF- Don't have close capability? Error out.
|
||||
|
||||
// Tray already closed? Exit.
|
||||
if(traystatus == CDVD_TRAY_CLOSE) return(0);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVD device: DeviceTrayClose()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
s32result = ioctl(devicehandle, CDROMCLOSETRAY);
|
||||
#ifdef VERBOSE_WARNINGS
|
||||
if((s32result != 0) || (errno != 0)) {
|
||||
PrintLog("CDVD device: Could not close the tray!");
|
||||
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
|
||||
} // ENDIF- Trouble?
|
||||
#endif /* VERBOSE_WARNINGS */
|
||||
return(s32result);
|
||||
} // END DeviceTrayClose()
|
|
@ -0,0 +1,69 @@
|
|||
/* device.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef __DEVICE_H__
|
||||
#define __DEVICE_H__
|
||||
|
||||
|
||||
#include <time.h> // time_t
|
||||
|
||||
#ifndef __LINUX__
|
||||
#ifdef __linux__
|
||||
#define __LINUX__
|
||||
#endif /* __linux__ */
|
||||
#endif /* No __LINUX__ */
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_DEVICE
|
||||
// #define VERBOSE_WARNINGS
|
||||
#define VERBOSE_DISC_TYPE
|
||||
#define VERBOSE_DISC_INFO
|
||||
|
||||
|
||||
// Device Data
|
||||
|
||||
extern int devicehandle;
|
||||
extern s32 devicecapability; // Need to export?
|
||||
|
||||
extern time_t lasttime;
|
||||
extern s32 traystatus;
|
||||
extern s32 disctype;
|
||||
extern u8 tocbuffer[];
|
||||
|
||||
|
||||
// Device Functions
|
||||
|
||||
extern void DeviceInit();
|
||||
extern void InitDisc();
|
||||
extern s32 DiscInserted();
|
||||
extern s32 DeviceOpen();
|
||||
extern void DeviceClose();
|
||||
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 DeviceBufferOffset();
|
||||
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
|
||||
extern s32 DeviceGetDiskType();
|
||||
extern s32 DeviceTrayStatus();
|
||||
extern s32 DeviceTrayOpen();
|
||||
extern s32 DeviceTrayClose();
|
||||
|
||||
|
||||
#endif /* __DEVICE_H__ */
|
|
@ -0,0 +1,443 @@
|
|||
/* devicebox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcpy()
|
||||
#include <sys/stat.h> // stat()
|
||||
#include <sys/types.h> // stat()
|
||||
#include <unistd.h> // stat()
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcombobox.h> // gtk_combo_box_new()
|
||||
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkentry.h> // gtk_entry_new()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtkhbox.h> // gtk_hbox_new()
|
||||
#include <gtk/gtkhseparator.h> // gtk_hseparator_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_main_iteration()
|
||||
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_get_active()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#ifndef __LINUX__
|
||||
#ifdef __linux__
|
||||
#define __LINUX__
|
||||
#endif /* __linux__ */
|
||||
#endif /* No __LINUX__ */
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "device.h"
|
||||
#include "isofile.h"
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
// #include "imagetype.h" // imagedata[].name
|
||||
#include "multifile.h" // multinames[]
|
||||
#include "toc.h"
|
||||
#include "progressbox.h"
|
||||
#include "messagebox.h"
|
||||
#include "selectionbox.h"
|
||||
#include "mainbox.h"
|
||||
#include "devicebox.h"
|
||||
|
||||
|
||||
struct DeviceBoxData devicebox;
|
||||
|
||||
|
||||
void DeviceBoxDestroy() {
|
||||
if(devicebox.window != NULL) {
|
||||
gtk_widget_destroy(devicebox.window);
|
||||
devicebox.window = NULL;
|
||||
devicebox.device = NULL;
|
||||
devicebox.devicedesc = NULL;
|
||||
devicebox.file = NULL;
|
||||
devicebox.selectbutton = NULL;
|
||||
devicebox.filedesc = NULL;
|
||||
devicebox.compress = NULL;
|
||||
devicebox.multi = NULL;
|
||||
devicebox.okbutton = NULL;
|
||||
devicebox.cancelbutton = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END DeviceBoxDestroy()
|
||||
|
||||
|
||||
void DeviceBoxUnfocus() {
|
||||
gtk_widget_set_sensitive(devicebox.device, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.file, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.selectbutton, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.compress, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.multi, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.okbutton, FALSE);
|
||||
gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE);
|
||||
gtk_widget_hide(devicebox.window);
|
||||
// gtk_window_iconify(GTK_WINDOW(devicebox.window));
|
||||
} // END DeviceBoxUnfocus()
|
||||
|
||||
|
||||
gint DeviceBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
struct stat filestat;
|
||||
int returnval;
|
||||
|
||||
returnval = stat(gtk_entry_get_text(GTK_ENTRY(devicebox.device)), &filestat);
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(S_ISDIR(filestat.st_mode) != 0) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Not a device");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.devicedesc), "Device Type: Device Likely");
|
||||
return(TRUE);
|
||||
} // END DeviceBoxDeviceEvent()
|
||||
|
||||
|
||||
gint DeviceBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Not a valid image file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an image file?
|
||||
|
||||
if(returnval == -4) {
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), "File Type: Missing Table File (will rebuild)");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
gtk_label_set_text(GTK_LABEL(devicebox.filedesc), templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return(TRUE);
|
||||
} // END DeviceBoxFileEvent()
|
||||
|
||||
|
||||
void DeviceBoxRefocus() {
|
||||
GdkEvent event;
|
||||
|
||||
DeviceBoxDeviceEvent(NULL, event, NULL);
|
||||
DeviceBoxFileEvent(NULL, event, NULL);
|
||||
|
||||
gtk_widget_set_sensitive(devicebox.device, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.file, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.selectbutton, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.compress, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.multi, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.okbutton, TRUE);
|
||||
gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE);
|
||||
gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
|
||||
gtk_widget_show_all(devicebox.window);
|
||||
gtk_window_deiconify(GTK_WINDOW(devicebox.window));
|
||||
} // END DeviceBoxRefocus()
|
||||
|
||||
|
||||
gint DeviceBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
gtk_widget_hide(devicebox.window);
|
||||
MainBoxRefocus();
|
||||
return(TRUE);
|
||||
} // END DeviceBoxCancelEvent()
|
||||
|
||||
|
||||
gint DeviceBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
char templine[256];
|
||||
u8 tempbuffer[2352];
|
||||
struct IsoFile *tofile;
|
||||
const char *tempdevice;
|
||||
s32 retval;
|
||||
cdvdTD cdvdtd;
|
||||
int stop;
|
||||
int compressmethod;
|
||||
int multi;
|
||||
int imagetype;
|
||||
int i;
|
||||
|
||||
DeviceBoxUnfocus();
|
||||
|
||||
tempdevice = gtk_entry_get_text(GTK_ENTRY(devicebox.device));
|
||||
strcpy(conf.devicename, tempdevice); // Temporarily put in new device name
|
||||
tempdevice = NULL;
|
||||
retval = DeviceOpen();
|
||||
if(retval != 0) {
|
||||
DeviceClose();
|
||||
MessageBoxShow("Could not open the device", 2);
|
||||
return(TRUE);
|
||||
} // ENDIF- Trouble opening device? Abort here.
|
||||
|
||||
DeviceTrayStatus();
|
||||
retval = DiscInserted();
|
||||
if(retval != 0) {
|
||||
DeviceClose();
|
||||
MessageBoxShow("No disc in the device\r\nPlease put a disc in and try again.", 2);
|
||||
return(TRUE);
|
||||
} // ENDIF- Trouble opening device? Abort here.
|
||||
|
||||
retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
|
||||
if(retval < 0) {
|
||||
DeviceClose();
|
||||
MessageBoxShow("Could not retrieve disc sector size", 2);
|
||||
return(TRUE);
|
||||
} // ENDIF- Trouble getting disc sector count?
|
||||
|
||||
compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(devicebox.compress));
|
||||
if(compressmethod > 0) compressmethod += 2;
|
||||
multi = 0;
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(devicebox.multi)) == TRUE)
|
||||
multi = 1;
|
||||
|
||||
imagetype = 0;
|
||||
if((disctype != CDVD_TYPE_PS2DVD) &&
|
||||
(disctype != CDVD_TYPE_DVDV)) imagetype = 8;
|
||||
|
||||
tofile = IsoFileOpenForWrite(gtk_entry_get_text(GTK_ENTRY(devicebox.file)),
|
||||
imagetype,
|
||||
multi,
|
||||
compressmethod);
|
||||
if(tofile == NULL) {
|
||||
DeviceClose();
|
||||
MessageBoxShow("Could not create the new ISO file", 2);
|
||||
return(TRUE);
|
||||
} // ENDIF- Trouble opening the ISO file?
|
||||
|
||||
// Open Progress Bar
|
||||
sprintf(templine, "%s -> %s",
|
||||
gtk_entry_get_text(GTK_ENTRY(devicebox.device)), tofile->name);
|
||||
ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
|
||||
|
||||
tofile->cdvdtype = disctype;
|
||||
for(i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i];
|
||||
|
||||
stop = 0;
|
||||
mainbox.stop = 0;
|
||||
progressbox.stop = 0;
|
||||
while((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) {
|
||||
if(imagetype == 0) {
|
||||
retval = DeviceReadTrack((u32) tofile->sectorpos,
|
||||
CDVD_MODE_2048,
|
||||
tempbuffer);
|
||||
} else {
|
||||
retval = DeviceReadTrack((u32) tofile->sectorpos,
|
||||
CDVD_MODE_2352,
|
||||
tempbuffer);
|
||||
} // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
|
||||
if(retval < 0) {
|
||||
for(i = 0; i < 2352; i++) {
|
||||
tempbuffer[i] = 0;
|
||||
} // NEXT i- Zeroing the buffer
|
||||
} // ENDIF- Trouble reading next block?
|
||||
retval = IsoFileWrite(tofile, tempbuffer);
|
||||
if(retval < 0) {
|
||||
MessageBoxShow("Trouble writing new file", 3);
|
||||
stop = 1;
|
||||
} // ENDIF- Trouble writing out the next block?
|
||||
|
||||
ProgressBoxTick(tofile->sectorpos);
|
||||
while(gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
if(mainbox.stop != 0) stop = 2;
|
||||
if(progressbox.stop != 0) stop = 2;
|
||||
} // ENDWHILE- No reason found to stop...
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
if(stop == 0) {
|
||||
if(tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
|
||||
strcpy(templine, tofile->name);
|
||||
} // ENDIF- Did we succeed with the transfer?
|
||||
|
||||
DeviceClose();
|
||||
if(stop == 0) {
|
||||
IsoSaveTOC(tofile);
|
||||
tofile = IsoFileClose(tofile);
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
|
||||
} else {
|
||||
tofile = IsoFileCloseAndDelete(tofile);
|
||||
} // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
|
||||
|
||||
if(stop != 1) DeviceBoxRefocus();
|
||||
if(stop == 0) DeviceBoxCancelEvent(widget, event, data);
|
||||
return(TRUE);
|
||||
} // END DeviceBoxOKEvent()
|
||||
|
||||
|
||||
gint DeviceBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
DeviceBoxUnfocus();
|
||||
|
||||
// Transfer file name to file selection
|
||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
|
||||
gtk_entry_get_text(GTK_ENTRY(devicebox.file)));
|
||||
selectionbox.wherefrom = 2; // From the Device Window
|
||||
SelectionBoxRefocus();
|
||||
return(TRUE);
|
||||
} // END DeviceBoxBrowseEvent()
|
||||
|
||||
|
||||
void DeviceBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
int nameptr;
|
||||
|
||||
devicebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(devicebox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(devicebox.window), "CDVDisoEFP ISO Creation");
|
||||
gtk_window_set_position(GTK_WINDOW(devicebox.window), GTK_WIN_POS_CENTER);
|
||||
|
||||
g_signal_connect(G_OBJECT(devicebox.window), "delete_event",
|
||||
G_CALLBACK(DeviceBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(devicebox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Source CD/DVD Device:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
devicebox.device = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.device, TRUE, TRUE, 0);
|
||||
gtk_widget_show(devicebox.device);
|
||||
g_signal_connect(G_OBJECT(devicebox.device), "changed",
|
||||
G_CALLBACK(DeviceBoxDeviceEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
devicebox.devicedesc = gtk_label_new("Device Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), devicebox.devicedesc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(devicebox.devicedesc);
|
||||
|
||||
item = gtk_hseparator_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Iso File:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
devicebox.file = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.file, TRUE, TRUE, 0);
|
||||
gtk_widget_show(devicebox.file);
|
||||
g_signal_connect(G_OBJECT(devicebox.file), "changed",
|
||||
G_CALLBACK(DeviceBoxFileEvent), NULL);
|
||||
|
||||
devicebox.selectbutton = gtk_button_new_with_label("Browse");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.selectbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show(devicebox.selectbutton);
|
||||
g_signal_connect(G_OBJECT(devicebox.selectbutton), "clicked",
|
||||
G_CALLBACK(DeviceBoxBrowseEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
devicebox.filedesc = gtk_label_new("File Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), devicebox.filedesc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(devicebox.filedesc);
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("New File Compression:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
devicebox.compress = gtk_combo_box_new_text();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.compress, FALSE, FALSE, 0);
|
||||
nameptr = 0;
|
||||
while(compressnames[nameptr] != NULL) {
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(devicebox.compress),
|
||||
compressnames[nameptr]);
|
||||
nameptr++;
|
||||
} // ENDWHILE- loading compression types into combo box
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(devicebox.compress), 0); // Temp Line
|
||||
gtk_widget_show(devicebox.compress);
|
||||
hbox1 = NULL;
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Multiple Files (all under 2 GB):");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
devicebox.multi = gtk_check_button_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.multi, FALSE, FALSE, 0);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(devicebox.multi), FALSE);
|
||||
gtk_widget_show(devicebox.multi);
|
||||
hbox1 = NULL;
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
devicebox.okbutton = gtk_button_new_with_label("Make File");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.okbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(devicebox.okbutton);
|
||||
g_signal_connect(G_OBJECT(devicebox.okbutton), "clicked",
|
||||
G_CALLBACK(DeviceBoxOKEvent), NULL);
|
||||
|
||||
devicebox.cancelbutton = gtk_button_new_with_label("Cancel");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), devicebox.cancelbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(devicebox.cancelbutton);
|
||||
g_signal_connect(G_OBJECT(devicebox.cancelbutton), "clicked",
|
||||
G_CALLBACK(DeviceBoxCancelEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
|
||||
// Device text not set until now to get the correct description.
|
||||
gtk_entry_set_text(GTK_ENTRY(devicebox.device), conf.devicename);
|
||||
|
||||
DeviceInit(); // Initialize device access
|
||||
} // END DeviceBoxDisplay()
|
|
@ -0,0 +1,345 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso ISO Creation</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Source CD/DVD Device:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotdevice">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes">/dev/dvd</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdevicedesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Device Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHSeparator" id="hseparator1">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Iso File:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotfile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotselectbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Browse</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotfiledesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">File Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">New File Compression:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBoxEntry" id="dotcompress">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">None
|
||||
GZip (for speed)
|
||||
BZip2 (for speed)
|
||||
BZip2 (for size)
|
||||
</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Multiple Files (all under 2GB):</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="dotmulti">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotokbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Make File</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotcancelbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,50 @@
|
|||
/* devicebox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DEVICEBOX_H
|
||||
#define DEVICEBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct DeviceBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *device; // GtkEntry
|
||||
GtkWidget *devicedesc; // GtkLabel
|
||||
GtkWidget *file; // GtkEntry
|
||||
GtkWidget *selectbutton; // GtkButton
|
||||
GtkWidget *filedesc; // GtkLabel
|
||||
GtkWidget *compress; // GtkComboBox
|
||||
GtkWidget *multi; // GtkCheckButton
|
||||
GtkWidget *okbutton; // GtkButton
|
||||
GtkWidget *cancelbutton; // GtkButton
|
||||
};
|
||||
|
||||
extern struct DeviceBoxData devicebox;
|
||||
|
||||
extern void DeviceBoxDestroy();
|
||||
// extern void DeviceBoxUnfocus();
|
||||
extern void DeviceBoxRefocus();
|
||||
extern void DeviceBoxDisplay();
|
||||
|
||||
|
||||
#endif /* DEVICEBOX_H */
|
|
@ -0,0 +1,67 @@
|
|||
/* interface.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcmp()
|
||||
|
||||
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
|
||||
#include <gtk/gtkwidget.h> // gtk_widget_show_all()
|
||||
|
||||
#include "logfile.h"
|
||||
#include "conf.h"
|
||||
#include "aboutbox.h"
|
||||
#include "mainbox.h"
|
||||
#include "devicebox.h"
|
||||
#include "selectionbox.h"
|
||||
#include "progressbox.h"
|
||||
#include "messagebox.h"
|
||||
#include "conversionbox.h"
|
||||
#include "interface.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if(argc != 2) return(1);
|
||||
|
||||
gtk_init(NULL, NULL);
|
||||
|
||||
if(!strcmp(argv[1], "about")) {
|
||||
AboutBoxDisplay();
|
||||
return(0);
|
||||
} else if (!strcmp(argv[1], "configure")) {
|
||||
OpenLog();
|
||||
InitConf();
|
||||
LoadConf();
|
||||
MainBoxDisplay();
|
||||
DeviceBoxDisplay();
|
||||
ConversionBoxDisplay();
|
||||
ProgressBoxDisplay();
|
||||
MessageBoxDisplay();
|
||||
SelectionBoxDisplay();
|
||||
|
||||
gtk_widget_show_all(mainbox.window);
|
||||
gtk_main();
|
||||
CloseLog();
|
||||
return(0);
|
||||
} // ENDLONGIF- Which display would you like to see?
|
||||
|
||||
return(1); // No Displays chosen? Abort!
|
||||
} // END main()
|
|
@ -0,0 +1,29 @@
|
|||
/* interface.h
|
||||
* Copyright (C) 2002-2004 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
|
||||
// Place holder... for now
|
||||
|
||||
|
||||
#endif /* INTERFACE_H */
|
|
@ -0,0 +1,90 @@
|
|||
/* logfile.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <fcntl.h> // open
|
||||
#include <stdio.h> // vsprintf()
|
||||
#include <stdarg.h> // va_start(), va_end(), vsprintf()
|
||||
#include <sys/stat.h> // mkdir(), open()
|
||||
#include <sys/types.h> // mkdir(), open()
|
||||
#include <unistd.h> // close(), write(), unlink()
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
|
||||
int logfile;
|
||||
char logfiletemp[2048];
|
||||
|
||||
|
||||
void InitLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
mkdir("./logs", 0755);
|
||||
|
||||
unlink("./logs/CDVDlog.txt");
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END InitLog();
|
||||
|
||||
|
||||
int OpenLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
logfile = -1;
|
||||
logfile = open("./logs/CDVDlog.txt", O_WRONLY | O_CREAT | O_APPEND, 0755);
|
||||
if(logfile == -1) return(-1);
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
|
||||
return(0);
|
||||
} // END OpenLog();
|
||||
|
||||
|
||||
void CloseLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
if(logfile != -1) {
|
||||
close(logfile);
|
||||
logfile = -1;
|
||||
} // ENDIF- Is the log file actually open? Close it.
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END CloseLog()
|
||||
|
||||
|
||||
void PrintLog(const char *fmt, ...) {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
va_list list;
|
||||
int len;
|
||||
|
||||
if(logfile == -1) return; // Log file not open.
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(logfiletemp, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
len = 0;
|
||||
while((len < 2048) && (logfiletemp[len] != 0)) len++;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\n')) len--;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\r')) len--;
|
||||
logfiletemp[len] = 0; // Slice off the last "\r\n"...
|
||||
|
||||
write(logfile, logfiletemp, len);
|
||||
write(logfile, "\r\n", 2); // ... and write out your own.
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END PrintLog()
|
|
@ -0,0 +1,35 @@
|
|||
/* logfile.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOGFILE_H
|
||||
#define LOGFILE_H
|
||||
|
||||
|
||||
#define VERBOSE_LOGFILE
|
||||
|
||||
|
||||
extern void InitLog();
|
||||
extern int OpenLog();
|
||||
extern void CloseLog();
|
||||
extern void PrintLog(const char *format, ...);
|
||||
|
||||
|
||||
#endif /* LOGFILE_H */
|
|
@ -0,0 +1,324 @@
|
|||
/* mainbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcheckbutton.h> // gtk_check_button_new_with_label()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkentry.h> // gtk_entry_new()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtkhbox.h> // gtk_hbox_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
|
||||
#include <gtk/gtktogglebutton.h> // gtk_toggle_button_set_active(), (_get_)
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "conf.h"
|
||||
#include "isofile.h"
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
// #include "imagetype.h" // imagedata[].name
|
||||
#include "multifile.h" // multinames[]
|
||||
#include "tablerebuild.h" // IsoTableRebuild()
|
||||
#include "devicebox.h"
|
||||
#include "conversionbox.h"
|
||||
#include "progressbox.h"
|
||||
#include "messagebox.h"
|
||||
#include "selectionbox.h"
|
||||
#include "mainbox.h"
|
||||
|
||||
|
||||
struct MainBoxData mainbox;
|
||||
|
||||
|
||||
void MainBoxDestroy() {
|
||||
if(mainbox.window != NULL) {
|
||||
gtk_widget_destroy(mainbox.window);
|
||||
mainbox.window = NULL;
|
||||
mainbox.file = NULL;
|
||||
mainbox.selectbutton = NULL;
|
||||
mainbox.desc = NULL;
|
||||
mainbox.startcheck = NULL;
|
||||
mainbox.restartcheck = NULL;
|
||||
mainbox.okbutton = NULL;
|
||||
mainbox.devbutton = NULL;
|
||||
mainbox.convbutton = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END MainBoxDestroy()
|
||||
|
||||
|
||||
void MainBoxUnfocus() {
|
||||
gtk_widget_set_sensitive(mainbox.file, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.selectbutton, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.startcheck, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.restartcheck, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.okbutton, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.devbutton, FALSE);
|
||||
gtk_widget_set_sensitive(mainbox.convbutton, FALSE);
|
||||
gtk_window_iconify(GTK_WINDOW(mainbox.window));
|
||||
} // END MainBoxUnfocus()
|
||||
|
||||
|
||||
gint MainBoxFileEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
returnval = IsIsoFile(gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
|
||||
if(returnval == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: ---");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Not a valid image file");
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an Image file?
|
||||
|
||||
if(returnval == -4) {
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc), "File Type: Missing Table File (will rebuild)");
|
||||
return(TRUE);
|
||||
} // ENDIF- Missing Compression seek table?
|
||||
|
||||
tempfile = IsoFileOpenForRead(gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
gtk_label_set_text(GTK_LABEL(mainbox.desc), templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return(TRUE);
|
||||
} // END MainBoxFileEvent()
|
||||
|
||||
|
||||
void MainBoxRefocus() {
|
||||
GdkEvent event;
|
||||
|
||||
MainBoxFileEvent(NULL, event, NULL);
|
||||
|
||||
gtk_widget_set_sensitive(mainbox.file, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.selectbutton, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.startcheck, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.restartcheck, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.devbutton, TRUE);
|
||||
gtk_widget_set_sensitive(mainbox.convbutton, TRUE);
|
||||
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file);
|
||||
gtk_window_deiconify(GTK_WINDOW(mainbox.window));
|
||||
} // END MainBoxRefocus()
|
||||
|
||||
|
||||
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
mainbox.stop = 1; // Halt all long processess...
|
||||
|
||||
MessageBoxDestroy();
|
||||
SelectionBoxDestroy();
|
||||
ProgressBoxDestroy();
|
||||
ConversionBoxDestroy();
|
||||
DeviceBoxDestroy();
|
||||
MainBoxDestroy();
|
||||
|
||||
gtk_main_quit();
|
||||
return(TRUE);
|
||||
} // END MainBoxCancelEvent()
|
||||
|
||||
|
||||
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
const char *tempisoname;
|
||||
|
||||
MainBoxUnfocus();
|
||||
|
||||
tempisoname = gtk_entry_get_text(GTK_ENTRY(mainbox.file));
|
||||
if(*(tempisoname) != 0) {
|
||||
if(IsIsoFile(tempisoname) == -4) {
|
||||
IsoTableRebuild(tempisoname);
|
||||
MainBoxRefocus();
|
||||
return(TRUE);
|
||||
} // ENDIF- Do we need to rebuild an image file's index before using it?
|
||||
|
||||
if(IsIsoFile(tempisoname) < 0) {
|
||||
tempisoname = NULL;
|
||||
MainBoxRefocus();
|
||||
MessageBoxShow("Not a Valid Image File.", 1);
|
||||
return(TRUE);
|
||||
} // ENDIF- Not an ISO file? Message and Stop here.
|
||||
} // ENDIF- Is there an ISO file to check out?
|
||||
|
||||
strcpy(conf.isoname, tempisoname);
|
||||
tempisoname = NULL;
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.startcheck)) == FALSE) {
|
||||
conf.startconfigure = 0; // FALSE
|
||||
} else {
|
||||
conf.startconfigure = 1; // TRUE
|
||||
} // ENDIF- Was this check button turned off?
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck)) == FALSE) {
|
||||
conf.restartconfigure = 0; // FALSE
|
||||
} else {
|
||||
conf.restartconfigure = 1; // TRUE
|
||||
} // ENDIF- Was this check button turned off?
|
||||
|
||||
SaveConf();
|
||||
|
||||
MainBoxCancelEvent(widget, event, data);
|
||||
return(TRUE);
|
||||
} // END MainBoxOKEvent()
|
||||
|
||||
|
||||
gint MainBoxBrowseEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
MainBoxUnfocus();
|
||||
|
||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(selectionbox.window),
|
||||
gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
|
||||
selectionbox.wherefrom = 1; // From the Main Window
|
||||
SelectionBoxRefocus();
|
||||
return(TRUE);
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
MainBoxUnfocus();
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(devicebox.file),
|
||||
gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
|
||||
gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
|
||||
gtk_widget_show_all(devicebox.window);
|
||||
return(TRUE);
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
gint MainBoxConversionEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
MainBoxUnfocus();
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(conversionbox.file),
|
||||
gtk_entry_get_text(GTK_ENTRY(mainbox.file)));
|
||||
gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
|
||||
gtk_widget_show_all(conversionbox.window);
|
||||
return(TRUE);
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
void MainBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
|
||||
mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDisoEFP Configuration");
|
||||
gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER);
|
||||
|
||||
g_signal_connect(G_OBJECT(mainbox.window), "delete_event",
|
||||
G_CALLBACK(MainBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_label_new("Iso File:");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
|
||||
gtk_widget_show(item);
|
||||
item = NULL;
|
||||
|
||||
mainbox.file = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.file, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.file);
|
||||
g_signal_connect(G_OBJECT(mainbox.file), "changed",
|
||||
G_CALLBACK(MainBoxFileEvent), NULL);
|
||||
|
||||
mainbox.selectbutton = gtk_button_new_with_label("Browse");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.selectbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.selectbutton);
|
||||
g_signal_connect(G_OBJECT(mainbox.selectbutton), "clicked",
|
||||
G_CALLBACK(MainBoxBrowseEvent), NULL);
|
||||
hbox1 = NULL;
|
||||
|
||||
mainbox.desc = gtk_label_new("File Type: ---");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.desc);
|
||||
|
||||
// hbox1 = gtk_hbox_new(FALSE, 10);
|
||||
// gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
// gtk_widget_show(hbox1);
|
||||
|
||||
mainbox.startcheck = gtk_check_button_new_with_label("Show Configure screen when starting emulation");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.startcheck, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.startcheck);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), FALSE);
|
||||
if(conf.startconfigure != 0) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.startcheck), TRUE);
|
||||
} // ENDIF- Is this box supposed to be checked?
|
||||
|
||||
mainbox.restartcheck = gtk_check_button_new_with_label("Show Configure screen when restarting emulation");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.restartcheck, FALSE, FALSE, 0);
|
||||
gtk_widget_show(mainbox.restartcheck);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), FALSE);
|
||||
if(conf.restartconfigure != 0) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck), TRUE);
|
||||
} // ENDIF- Is this box supposed to be checked?
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
mainbox.okbutton = gtk_button_new_with_label("Ok");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.okbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.okbutton);
|
||||
g_signal_connect(G_OBJECT(mainbox.okbutton), "clicked",
|
||||
G_CALLBACK(MainBoxOKEvent), NULL);
|
||||
|
||||
mainbox.devbutton = gtk_button_new_with_label("Get from Disc");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.devbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.devbutton);
|
||||
g_signal_connect(G_OBJECT(mainbox.devbutton), "clicked",
|
||||
G_CALLBACK(MainBoxDeviceEvent), NULL);
|
||||
|
||||
mainbox.convbutton = gtk_button_new_with_label("Convert");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.convbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_show(mainbox.convbutton);
|
||||
g_signal_connect(G_OBJECT(mainbox.convbutton), "clicked",
|
||||
G_CALLBACK(MainBoxConversionEvent), NULL);
|
||||
|
||||
item = gtk_button_new_with_label("Cancel");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
g_signal_connect(G_OBJECT(item), "clicked",
|
||||
G_CALLBACK(MainBoxCancelEvent), NULL);
|
||||
item = NULL;
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
|
||||
// We held off setting the name until now... so description would show.
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file), conf.isoname);
|
||||
} // END MainBoxDisplay()
|
|
@ -0,0 +1,219 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso Configuration</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Iso File:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotfile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotselectbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Browse</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">File Type: ---</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkstart">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Show Configure screen when starting emulation</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkrestart">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Show Configure screen when restarting emulation</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotokbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Ok</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotdevbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Get from Disc</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="dotconvbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Convert</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,50 @@
|
|||
/* mainbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MAINBOX_H
|
||||
#define MAINBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct MainBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *file; // GtkEntry
|
||||
GtkWidget *selectbutton; // GtkButton
|
||||
GtkWidget *desc; // GtkLabel
|
||||
GtkWidget *startcheck; // GtkCheckBox
|
||||
GtkWidget *restartcheck; // GtkCheckBox
|
||||
GtkWidget *devbutton; // GtkButton
|
||||
GtkWidget *convbutton; // GtkButton
|
||||
GtkWidget *okbutton; // GtkButton
|
||||
// Leaving the Cancel button unblocked... for emergency shutdown
|
||||
|
||||
int stop; // Variable signal to stop long processes
|
||||
};
|
||||
|
||||
extern struct MainBoxData mainbox;
|
||||
|
||||
extern void MainBoxRefocus();
|
||||
extern void MainBoxDisplay();
|
||||
|
||||
|
||||
#endif /* MAINBOX_H */
|
|
@ -0,0 +1,113 @@
|
|||
/* messagebox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "mainbox.h"
|
||||
#include "devicebox.h"
|
||||
#include "conversionbox.h"
|
||||
#include "messagebox.h"
|
||||
|
||||
|
||||
struct MessageBoxData messagebox;
|
||||
|
||||
|
||||
void MessageBoxDestroy() {
|
||||
if(messagebox.window != NULL) {
|
||||
gtk_widget_destroy(messagebox.window);
|
||||
messagebox.window = NULL;
|
||||
messagebox.desc = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END MessageBoxDestroy()
|
||||
|
||||
|
||||
void MessageBoxShow(char *message, int wherefrom) {
|
||||
gtk_label_set_text(GTK_LABEL(messagebox.desc), message);
|
||||
messagebox.wherefrom = wherefrom;
|
||||
|
||||
gtk_widget_show_all(messagebox.window);
|
||||
gtk_window_deiconify(GTK_WINDOW(messagebox.window));
|
||||
} // END MessageBox()
|
||||
|
||||
|
||||
gint MessageBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
gtk_widget_hide(messagebox.window);
|
||||
|
||||
switch(messagebox.wherefrom) {
|
||||
case 1:
|
||||
MainBoxRefocus();
|
||||
break;
|
||||
case 2:
|
||||
DeviceBoxRefocus();
|
||||
break;
|
||||
case 3:
|
||||
ConversionBoxRefocus();
|
||||
break;
|
||||
} // ENDSWITCH- Whose window do I get to re-focus when this is done?
|
||||
|
||||
return(TRUE);
|
||||
} // END MessageBoxCancelEvent()
|
||||
|
||||
|
||||
void MessageBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
|
||||
messagebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(messagebox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(messagebox.window), "CDVDisoEFP");
|
||||
gtk_window_set_position(GTK_WINDOW(messagebox.window), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_resizable(GTK_WINDOW(messagebox.window), FALSE);
|
||||
|
||||
g_signal_connect(G_OBJECT(messagebox.window), "delete_event",
|
||||
G_CALLBACK(MessageBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(messagebox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
messagebox.desc = gtk_label_new("Hi There!\r\nHow are you doing?");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), messagebox.desc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(messagebox.desc);
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_button_new_with_label("Cancel");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
|
||||
gtk_widget_show(item);
|
||||
g_signal_connect(G_OBJECT(item), "clicked",
|
||||
G_CALLBACK(MessageBoxCancelEvent), NULL);
|
||||
item = NULL;
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
} // END MessageBoxDisplay()
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Hello there
|
||||
How are you doing?</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">button1</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,43 @@
|
|||
/* messagebox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MESSAGEBOX_H
|
||||
#define MESSAGEBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct MessageBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *desc; // GtkLabel
|
||||
|
||||
int wherefrom; // Whom do I refocus when the message is read?
|
||||
};
|
||||
|
||||
extern struct MessageBoxData messagebox;
|
||||
|
||||
extern void MessageBoxDestroy();
|
||||
extern void MessageBoxShow(char *message, int wherefrom);
|
||||
extern void MessageBoxDisplay();
|
||||
|
||||
|
||||
#endif /* MESSAGEBOX_H */
|
|
@ -0,0 +1,144 @@
|
|||
/* progressbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
|
||||
#include <gtk/gtkcontainer.h> // gtk_container_add()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_set_filename()
|
||||
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
|
||||
#include <gtk/gtkhbox.h> // gtk_hbox_new()
|
||||
#include <gtk/gtklabel.h> // gtk_label_new()
|
||||
#include <gtk/gtkmain.h> // gtk_main_iteration(), gtk_events_pending()
|
||||
#include <gtk/gtkprogressbar.h> // gtk_progress_bar_new()
|
||||
#include <gtk/gtkvbox.h> // gtk_vbox_new()
|
||||
#include <gtk/gtkwindow.h> // gtk_window_new()
|
||||
|
||||
#include "progressbox.h"
|
||||
|
||||
|
||||
struct ProgressBoxData progressbox;
|
||||
char progressboxline[256];
|
||||
|
||||
|
||||
void ProgressBoxDestroy() {
|
||||
if(progressbox.window != NULL) {
|
||||
gtk_widget_destroy(progressbox.window);
|
||||
progressbox.window = NULL;
|
||||
progressbox.desc = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END ProgressBoxDestroy()
|
||||
|
||||
|
||||
void ProgressBoxStart(char *description, off64_t maximum) {
|
||||
gtk_label_set_text(GTK_LABEL(progressbox.desc), description);
|
||||
|
||||
progressbox.max = maximum;
|
||||
progressbox.gmax = maximum;
|
||||
progressbox.lastpct = 100;
|
||||
progressbox.stop = 0;
|
||||
|
||||
ProgressBoxTick(0);
|
||||
gtk_widget_show_all(progressbox.window);
|
||||
gtk_window_deiconify(GTK_WINDOW(progressbox.window));
|
||||
} // END ProgressBoxStart()
|
||||
|
||||
|
||||
void ProgressBoxTick(off64_t current) {
|
||||
gdouble gcur;
|
||||
off64_t thispct;
|
||||
|
||||
gcur = current;
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbox.bar),
|
||||
gcur / progressbox.gmax);
|
||||
|
||||
sprintf(progressboxline, "%llu of %llu", current, progressbox.max);
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progressbox.bar), progressboxline);
|
||||
|
||||
if(progressbox.max >= 100) {
|
||||
thispct = current / ( progressbox.max / 100 );
|
||||
if(thispct != progressbox.lastpct) {
|
||||
sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct);
|
||||
gtk_window_set_title(GTK_WINDOW(progressbox.window), progressboxline);
|
||||
progressbox.lastpct = thispct;
|
||||
} // ENDIF- Change in percentage? (Avoiding title flicker)
|
||||
} // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error)
|
||||
|
||||
while(gtk_events_pending()) gtk_main_iteration(); // Give time for window to redraw.
|
||||
} // END ProgressBoxTick()
|
||||
|
||||
|
||||
void ProgressBoxStop() {
|
||||
gtk_widget_hide(progressbox.window);
|
||||
gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress");
|
||||
} // END ProgressBoxStop()
|
||||
|
||||
|
||||
gint ProgressBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
progressbox.stop = 1;
|
||||
|
||||
return(TRUE);
|
||||
} // END ProgressBoxCancelEvent()
|
||||
|
||||
|
||||
void ProgressBoxDisplay() {
|
||||
GtkWidget *item;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *vbox1;
|
||||
|
||||
progressbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(progressbox.window), 5);
|
||||
gtk_window_set_title(GTK_WINDOW(progressbox.window), "CDVDisoEFP Progress");
|
||||
gtk_window_set_position(GTK_WINDOW(progressbox.window), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_resizable(GTK_WINDOW(progressbox.window), FALSE);
|
||||
|
||||
g_signal_connect(G_OBJECT(progressbox.window), "delete_event",
|
||||
G_CALLBACK(ProgressBoxCancelEvent), NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new(FALSE, 5);
|
||||
gtk_container_add(GTK_CONTAINER(progressbox.window), vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
gtk_widget_show(vbox1);
|
||||
|
||||
progressbox.desc = gtk_label_new("Twiddling Thumbs");
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), progressbox.desc, FALSE, FALSE, 0);
|
||||
gtk_widget_show(progressbox.desc);
|
||||
|
||||
progressbox.bar = gtk_progress_bar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), progressbox.bar, FALSE, FALSE, 0);
|
||||
gtk_widget_show(progressbox.bar);
|
||||
|
||||
hbox1 = gtk_hbutton_box_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
|
||||
gtk_widget_show(hbox1);
|
||||
|
||||
item = gtk_button_new_with_label("Cancel");
|
||||
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
|
||||
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
|
||||
gtk_widget_show(item);
|
||||
g_signal_connect(G_OBJECT(item), "clicked",
|
||||
G_CALLBACK(ProgressBoxCancelEvent), NULL);
|
||||
item = NULL;
|
||||
hbox1 = NULL;
|
||||
vbox1 = NULL;
|
||||
} // END ProgressBoxDisplay()
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="dotwindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">CDVDiso Progress</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="dotdesc">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">/dev/dvd -> /usr/src/iso/GameImage.iso</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="dotbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes">Progress Bar: 12758 of 131509</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,55 @@
|
|||
/* progressbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PROGRESSBOX_H
|
||||
#define PROGRESSBOX_H
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
#include <gtk/gtkwidget.h> // GtkWidget
|
||||
|
||||
|
||||
extern const char *compressnames[];
|
||||
|
||||
struct ProgressBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
GtkWidget *desc; // GtkLabel - What are we showing progress on?
|
||||
GtkWidget *bar; // GtkProgressBar
|
||||
|
||||
off64_t max;
|
||||
gdouble gmax;
|
||||
off64_t lastpct;
|
||||
|
||||
int stop; // Someone pressed the Stop button
|
||||
};
|
||||
|
||||
extern struct ProgressBoxData progressbox;
|
||||
|
||||
|
||||
extern void ProgressBoxStart(char *description, off64_t maximum);
|
||||
extern void ProgressBoxTick(off64_t current);
|
||||
extern void ProgressBoxStop();
|
||||
extern void ProgressBoxDestroy();
|
||||
extern void ProgressBoxDisplay();
|
||||
|
||||
|
||||
#endif /* MAINBOX_H */
|
|
@ -0,0 +1,102 @@
|
|||
/* selectionbox.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
#include <glib-object.h> // g_signal_connect()
|
||||
#include <gtk/gtkentry.h> // gtk_entry_set_text()
|
||||
#include <gtk/gtkfilesel.h> // gtk_file_selection_new()
|
||||
|
||||
#include "devicebox.h"
|
||||
#include "conversionbox.h"
|
||||
#include "selectionbox.h"
|
||||
#include "mainbox.h"
|
||||
|
||||
|
||||
struct SelectionBoxData selectionbox;
|
||||
|
||||
|
||||
void SelectionBoxDestroy() {
|
||||
if(selectionbox.window != NULL) {
|
||||
gtk_widget_destroy(selectionbox.window);
|
||||
selectionbox.window = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END SelectionBoxDestroy()
|
||||
|
||||
|
||||
void SelectionBoxRefresh() {
|
||||
} // END SelectionBoxRefresh()
|
||||
|
||||
|
||||
void SelectionBoxUnfocus() {
|
||||
gtk_widget_hide(selectionbox.window);
|
||||
} // END SelectionBoxUnfocus()
|
||||
|
||||
|
||||
void SelectionBoxRefocus() {
|
||||
gtk_widget_show(selectionbox.window);
|
||||
} // END SelectionBoxRefocus()
|
||||
|
||||
|
||||
gint SelectionBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
SelectionBoxUnfocus();
|
||||
switch(selectionbox.wherefrom) {
|
||||
case 1:
|
||||
gtk_entry_set_text(GTK_ENTRY(mainbox.file),
|
||||
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
|
||||
MainBoxRefocus();
|
||||
break;
|
||||
case 2:
|
||||
gtk_entry_set_text(GTK_ENTRY(devicebox.file),
|
||||
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
|
||||
DeviceBoxRefocus();
|
||||
break;
|
||||
case 3:
|
||||
gtk_entry_set_text(GTK_ENTRY(conversionbox.file),
|
||||
gtk_file_selection_get_filename(GTK_FILE_SELECTION(selectionbox.window)));
|
||||
ConversionBoxRefocus();
|
||||
break;
|
||||
} // ENDSWITCH wherefrom- What Box called us?
|
||||
return(TRUE);
|
||||
} // END SelectionBoxCancelEvent()
|
||||
|
||||
|
||||
gint SelectionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
|
||||
// Validate listed file(?)
|
||||
|
||||
// Transfer file name to calling window?
|
||||
|
||||
SelectionBoxCancelEvent(widget, event, data);
|
||||
return(TRUE);
|
||||
} // END SelectionBoxOKEvent()
|
||||
|
||||
|
||||
void SelectionBoxDisplay() {
|
||||
selectionbox.window = gtk_file_selection_new("Select an ISO file");
|
||||
g_signal_connect(G_OBJECT(selectionbox.window), "delete_event",
|
||||
G_CALLBACK(SelectionBoxCancelEvent), NULL);
|
||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->ok_button),
|
||||
"clicked", G_CALLBACK(SelectionBoxOKEvent), NULL);
|
||||
g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(selectionbox.window)->cancel_button),
|
||||
"clicked", G_CALLBACK(SelectionBoxCancelEvent), NULL);
|
||||
|
||||
selectionbox.wherefrom = 0; // Called by no one... yet.
|
||||
} // END SelectionBoxDisplay()
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkFileSelection" id="dotwindow">
|
||||
<property name="border_width">10</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Select an ISO File</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="show_fileops">True</property>
|
||||
|
||||
<child internal-child="cancel_button">
|
||||
<widget class="GtkButton" id="cancel_button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child internal-child="ok_button">
|
||||
<widget class="GtkButton" id="ok_button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
|
@ -0,0 +1,46 @@
|
|||
/* selectionbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SELECTIONBOX_H
|
||||
#define SELECTIONBOX_H
|
||||
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
|
||||
struct SelectionBoxData {
|
||||
GtkWidget *window; // GtkWindow
|
||||
|
||||
int wherefrom; // Which box called you?
|
||||
// 1 = MainBox
|
||||
// 2 = DeviceBox
|
||||
// 3 = ConversionBox
|
||||
};
|
||||
|
||||
extern struct SelectionBoxData selectionbox;
|
||||
|
||||
|
||||
extern void SelectionBoxDestroy();
|
||||
extern void SelectionBoxRefocus();
|
||||
extern void SelectionBoxDisplay();
|
||||
|
||||
|
||||
#endif /* SELECTIONBOX_H */
|
|
@ -0,0 +1,190 @@
|
|||
/* tablerebuild.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <stdlib.h> // malloc()
|
||||
|
||||
// #include <gtk/gtkmain.h> // gtk_main_iteration()
|
||||
|
||||
#include "mainbox.h"
|
||||
#include "progressbox.h"
|
||||
#include "isofile.h"
|
||||
#include "multifile.h"
|
||||
#include "isocompress.h" // CompressClose()
|
||||
#include "gzipv1.h"
|
||||
#include "gzipv2.h"
|
||||
#include "bzip2v2.h"
|
||||
#include "bzip2v3.h"
|
||||
#include "actualfile.h" // ACTUALHANDLENULL
|
||||
|
||||
|
||||
void IsoTableRebuild(const char *filename) {
|
||||
struct IsoFile *datafile;
|
||||
struct IsoFile *tablefile;
|
||||
int retval;
|
||||
char tempblock[65536];
|
||||
int stop;
|
||||
|
||||
struct TableData table;
|
||||
|
||||
datafile = IsoFileOpenForRead(filename);
|
||||
|
||||
// Note: This is the start of the "Multifile" process. It's commented
|
||||
// out so at least we can rebuild 1 part of a multifile at a time.
|
||||
// IsoNameStripExt(datafile);
|
||||
// IsoNameStripMulti(datafile);
|
||||
|
||||
// Prep tablefile to hold ONLY a table (no data)
|
||||
tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
|
||||
if(tablefile == NULL) {
|
||||
datafile = IsoFileClose(datafile);
|
||||
return;
|
||||
} // ENDIF- Failed to allocate? Abort.
|
||||
|
||||
tablefile->sectorpos = 0;
|
||||
tablefile->openforread = 0;
|
||||
tablefile->filebytepos = 0;
|
||||
tablefile->filebytesize = 0;
|
||||
tablefile->filesectorpos = 0;
|
||||
tablefile->filesectorsize = 0;
|
||||
tablefile->handle = ACTUALHANDLENULL;
|
||||
|
||||
tablefile->namepos = 0;
|
||||
while((tablefile->namepos < 255) &&
|
||||
(*(filename + tablefile->namepos) != 0)) {
|
||||
tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos);
|
||||
tablefile->namepos++;
|
||||
} // ENDWHILE- Copying file name into tablefile
|
||||
tablefile->name[tablefile->namepos] = 0; // And 0-terminate.
|
||||
|
||||
tablefile->imageheader = datafile->imageheader;
|
||||
tablefile->blocksize = datafile->blocksize;
|
||||
tablefile->blockoffset = datafile->blockoffset;
|
||||
tablefile->cdvdtype = 0; // Not important right now.
|
||||
|
||||
tablefile->compress = datafile->compress;
|
||||
tablefile->compresspos = datafile->compresspos;
|
||||
tablefile->numsectors = datafile->numsectors;
|
||||
tablefile->tabledata = NULL;
|
||||
|
||||
switch(tablefile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3OpenTableForWrite(tablefile);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Which table are we writing out?
|
||||
if(retval < 0) {
|
||||
datafile = IsoFileClose(datafile);
|
||||
return;
|
||||
} // ENDIF- Failed to open table file? Abort
|
||||
|
||||
sprintf(tempblock, "Rebuilding table for %s", datafile->name);
|
||||
ProgressBoxStart(tempblock, datafile->filebytesize);
|
||||
|
||||
stop = 0;
|
||||
mainbox.stop = 0;
|
||||
progressbox.stop = 0;
|
||||
while((stop == 0) && (datafile->filebytepos < datafile->filebytesize)) {
|
||||
switch(datafile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3Read(datafile, 0, tempblock);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Scanning for the next complete compressed block
|
||||
|
||||
if(retval <= 0) {
|
||||
#ifdef FUNCTION_WARNING_TABLEREBUILD
|
||||
PrintLog("CDVDiso rebuild: failed to decompress - data corrupt");
|
||||
#endif /* FUNCTION_WARNING_TABLEREBUILD */
|
||||
stop = 1;
|
||||
} else {
|
||||
table.offset = datafile->filebytepos - retval;
|
||||
table.size = retval;
|
||||
switch(tablefile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1WriteTable(tablefile, table);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2WriteTable(tablefile, table);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2WriteTable(tablefile, table);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3WriteTable(tablefile, table);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Writing out the relavent table facts
|
||||
if(retval < 0) stop = 1;
|
||||
} // ENDIF- Do we have a valid record to write an entry for?
|
||||
|
||||
ProgressBoxTick(datafile->filebytepos);
|
||||
// while(gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
if(mainbox.stop != 0) stop = 2;
|
||||
if(progressbox.stop != 0) stop = 2;
|
||||
} // ENDWHILE- Read in the data file and writing a table, 1 block at a time
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
CompressClose(tablefile); // Guarentee the table is flushed and closed.
|
||||
if(stop != 0) {
|
||||
ActualFileDelete(tablefile->tablename);
|
||||
} // ENDIF- Aborted or trouble? Delete the table file
|
||||
tablefile = IsoFileClose(tablefile);
|
||||
datafile = IsoFileClose(datafile);
|
||||
|
||||
return;
|
||||
} // END IsoTableRebuild()
|
|
@ -0,0 +1,32 @@
|
|||
/* tablerebuild.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TABLEREBUILD_H
|
||||
#define TABLEREBUILD_H
|
||||
|
||||
|
||||
// #define FUNCTION_WARNING_TABLEREBUILD
|
||||
|
||||
|
||||
extern void IsoTableRebuild(const char *filename);
|
||||
|
||||
|
||||
#endif /* TABLEREBUILD_H */
|
|
@ -0,0 +1,812 @@
|
|||
#ifndef __PS2EDEFS_H__
|
||||
#define __PS2EDEFS_H__
|
||||
|
||||
/*
|
||||
* PS2E Definitions v0.6.2 (beta)
|
||||
*
|
||||
* Author: linuzappz@hotmail.com
|
||||
* shadowpcsx2@yahoo.gr
|
||||
* florinsasu@hotmail.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Notes:
|
||||
* Since this is still beta things may change.
|
||||
|
||||
* OSflags:
|
||||
__LINUX__ (linux OS)
|
||||
_WIN32 (win32 OS)
|
||||
|
||||
* common return values (for ie. GSinit):
|
||||
0 - success
|
||||
-1 - error
|
||||
|
||||
* reserved keys:
|
||||
F1 to F10 are reserved for the emulator
|
||||
|
||||
* plugins should NOT change the current
|
||||
working directory.
|
||||
(on win32, add flag OFN_NOCHANGEDIR for
|
||||
GetOpenFileName)
|
||||
|
||||
*/
|
||||
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
#ifdef __LINUX__
|
||||
#define CALLBACK
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* common defines */
|
||||
#ifndef C_ASSERT
|
||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
||||
#endif
|
||||
|
||||
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
||||
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
||||
defined(USBdefs) || defined(FWdefs)
|
||||
#define COMMONdefs
|
||||
#endif
|
||||
|
||||
// PS2EgetLibType returns (may be OR'd)
|
||||
#define PS2E_LT_GS 0x01
|
||||
#define PS2E_LT_PAD 0x02 // -=[ OBSOLETE ]=-
|
||||
#define PS2E_LT_SPU2 0x04
|
||||
#define PS2E_LT_CDVD 0x08
|
||||
#define PS2E_LT_DEV9 0x10
|
||||
#define PS2E_LT_USB 0x20
|
||||
#define PS2E_LT_FW 0x40
|
||||
#define PS2E_LT_SIO 0x80
|
||||
|
||||
// PS2EgetLibVersion2 (high 16 bits)
|
||||
#define PS2E_GS_VERSION 0x0006
|
||||
#define PS2E_PAD_VERSION 0x0002 // -=[ OBSOLETE ]=-
|
||||
#define PS2E_SPU2_VERSION 0x0005
|
||||
#define PS2E_CDVD_VERSION 0x0005
|
||||
#define PS2E_DEV9_VERSION 0x0003
|
||||
#define PS2E_USB_VERSION 0x0003
|
||||
#define PS2E_FW_VERSION 0x0002
|
||||
#define PS2E_SIO_VERSION 0x0001
|
||||
#ifdef COMMONdefs
|
||||
|
||||
u32 CALLBACK PS2EgetLibType(void);
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type);
|
||||
char* CALLBACK PS2EgetLibName(void);
|
||||
|
||||
#endif
|
||||
|
||||
// key values:
|
||||
/* key values must be OS dependant:
|
||||
win32: the VK_XXX will be used (WinUser)
|
||||
linux: the XK_XXX will be used (XFree86)
|
||||
*/
|
||||
|
||||
// event values:
|
||||
#define KEYPRESS 1
|
||||
#define KEYRELEASE 2
|
||||
|
||||
typedef struct {
|
||||
u32 key;
|
||||
u32 event;
|
||||
} keyEvent;
|
||||
|
||||
// for 64bit compilers
|
||||
typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
|
||||
|
||||
// plugin types
|
||||
#define SIO_TYPE_PAD 0x00000001
|
||||
#define SIO_TYPE_MTAP 0x00000004
|
||||
#define SIO_TYPE_RM 0x00000040
|
||||
#define SIO_TYPE_MC 0x00000100
|
||||
|
||||
typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
|
||||
|
||||
typedef struct {
|
||||
u8 ctrl:4; // control and mode bits
|
||||
u8 mode:4; // control and mode bits
|
||||
u8 trackNum; // current track number (1 to 99)
|
||||
u8 trackIndex; // current index within track (0 to 99)
|
||||
u8 trackM; // current minute location on the disc (BCD encoded)
|
||||
u8 trackS; // current sector location on the disc (BCD encoded)
|
||||
u8 trackF; // current frame location on the disc (BCD encoded)
|
||||
u8 pad; // unused
|
||||
u8 discM; // current minute offset from first track (BCD encoded)
|
||||
u8 discS; // current sector offset from first track (BCD encoded)
|
||||
u8 discF; // current frame offset from first track (BCD encoded)
|
||||
} cdvdSubQ;
|
||||
|
||||
typedef struct { // NOT bcd coded
|
||||
u32 lsn;
|
||||
u8 type;
|
||||
} cdvdTD;
|
||||
|
||||
typedef struct {
|
||||
u8 strack; //number of the first track (usually 1)
|
||||
u8 etrack; //number of the last track
|
||||
} cdvdTN;
|
||||
|
||||
// CDVDreadTrack mode values:
|
||||
#define CDVD_MODE_2352 0 // full 2352 bytes
|
||||
#define CDVD_MODE_2340 1 // skip sync (12) bytes
|
||||
#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
|
||||
|
||||
// CDVDgetDiskType returns:
|
||||
#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
|
||||
#define CDVD_TYPE_DVDV 0xfe // DVD Video
|
||||
#define CDVD_TYPE_CDDA 0xfd // Audio CD
|
||||
#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
|
||||
#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
|
||||
#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
|
||||
#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
|
||||
#define CDVD_TYPE_PSCD 0x10 // PS CD
|
||||
#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
|
||||
#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
|
||||
#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
|
||||
#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
|
||||
#define CDVD_TYPE_DETCT 0x01 // Detecting
|
||||
#define CDVD_TYPE_NODISC 0x00 // No Disc
|
||||
|
||||
// CDVDgetTrayStatus returns:
|
||||
#define CDVD_TRAY_CLOSE 0x00
|
||||
#define CDVD_TRAY_OPEN 0x01
|
||||
|
||||
// cdvdTD.type (track types for cds)
|
||||
#define CDVD_AUDIO_TRACK 0x01
|
||||
#define CDVD_MODE1_TRACK 0x41
|
||||
#define CDVD_MODE2_TRACK 0x61
|
||||
|
||||
#define CDVD_AUDIO_MASK 0x00
|
||||
#define CDVD_DATA_MASK 0x40
|
||||
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
|
||||
|
||||
typedef void (*DEV9callback)(int cycles);
|
||||
typedef int (*DEV9handler)(void);
|
||||
|
||||
typedef void (*USBcallback)(int cycles);
|
||||
typedef int (*USBhandler)(void);
|
||||
|
||||
// freeze modes:
|
||||
#define FREEZE_LOAD 0
|
||||
#define FREEZE_SAVE 1
|
||||
#define FREEZE_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
char name[8];
|
||||
void *common;
|
||||
} GSdriverInfo;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef struct { // unsupported values must be set to zero
|
||||
HWND hWnd;
|
||||
HMENU hMenu;
|
||||
HWND hStatusWnd;
|
||||
} winInfo;
|
||||
#endif
|
||||
|
||||
/* GS plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef GSdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK GSinit();
|
||||
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
|
||||
void CALLBACK GSclose();
|
||||
void CALLBACK GSshutdown();
|
||||
void CALLBACK GSvsync(int field);
|
||||
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
|
||||
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
|
||||
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
|
||||
void CALLBACK GSgifSoftReset(u32 mask);
|
||||
void CALLBACK GSreadFIFO(off64_t *mem);
|
||||
void CALLBACK GSreadFIFO2(off64_t *mem, int qwc);
|
||||
|
||||
// extended funcs
|
||||
|
||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||
void CALLBACK GSkeyEvent(keyEvent *ev);
|
||||
void CALLBACK GSchangeSaveState(int, const char* filename);
|
||||
void CALLBACK GSmakeSnapshot(char *path);
|
||||
void CALLBACK GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
|
||||
void CALLBACK GSirqCallback(void (*callback)());
|
||||
void CALLBACK GSprintf(int timeout, char *fmt, ...);
|
||||
void CALLBACK GSsetBaseMem(void*);
|
||||
void CALLBACK GSsetGameCRC(int);
|
||||
|
||||
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
|
||||
void CALLBACK GSsetFrameSkip(int frameskip);
|
||||
|
||||
void CALLBACK GSreset();
|
||||
void CALLBACK GSwriteCSR(u32 value);
|
||||
void CALLBACK GSgetDriverInfo(GSdriverInfo *info);
|
||||
#ifdef _WIN32
|
||||
s32 CALLBACK GSsetWindowInfo(winInfo *info);
|
||||
#endif
|
||||
s32 CALLBACK GSfreeze(int mode, freezeData *data);
|
||||
void CALLBACK GSconfigure();
|
||||
void CALLBACK GSabout();
|
||||
s32 CALLBACK GStest();
|
||||
|
||||
#endif
|
||||
|
||||
/* PAD plugin API -=[ OBSOLETE ]=- */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef PADdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK PADinit(u32 flags);
|
||||
s32 CALLBACK PADopen(void *pDsp);
|
||||
void CALLBACK PADclose();
|
||||
void CALLBACK PADshutdown();
|
||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||
keyEvent* CALLBACK PADkeyEvent();
|
||||
u8 CALLBACK PADstartPoll(int pad);
|
||||
u8 CALLBACK PADpoll(u8 value);
|
||||
// returns: 1 if supported pad1
|
||||
// 2 if supported pad2
|
||||
// 3 if both are supported
|
||||
u32 CALLBACK PADquery();
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
|
||||
void CALLBACK PADconfigure();
|
||||
void CALLBACK PADabout();
|
||||
s32 CALLBACK PADtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* SIO plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef SIOdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f);
|
||||
s32 CALLBACK SIOopen(void *pDsp);
|
||||
void CALLBACK SIOclose();
|
||||
void CALLBACK SIOshutdown();
|
||||
u8 CALLBACK SIOstartPoll(u8 value);
|
||||
u8 CALLBACK SIOpoll(u8 value);
|
||||
// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
|
||||
u32 CALLBACK SIOquery();
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK SIOconfigure();
|
||||
void CALLBACK SIOabout();
|
||||
s32 CALLBACK SIOtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* SPU2 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef SPU2defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK SPU2init();
|
||||
s32 CALLBACK SPU2open(void *pDsp);
|
||||
void CALLBACK SPU2close();
|
||||
void CALLBACK SPU2shutdown();
|
||||
void CALLBACK SPU2write(u32 mem, u16 value);
|
||||
u16 CALLBACK SPU2read(u32 mem);
|
||||
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2writeDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA4();
|
||||
void CALLBACK SPU2readDMA7Mem(u16* pMem, int size);
|
||||
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA7();
|
||||
u32 CALLBACK SPU2ReadMemAddr(int core);
|
||||
void CALLBACK SPU2WriteMemAddr(int core,u32 value);
|
||||
void CALLBACK SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK SPU2async(u32 cycles);
|
||||
s32 CALLBACK SPU2freeze(int mode, freezeData *data);
|
||||
void CALLBACK SPU2configure();
|
||||
void CALLBACK SPU2about();
|
||||
s32 CALLBACK SPU2test();
|
||||
|
||||
#endif
|
||||
|
||||
/* CDVD plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef CDVDdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK CDVDinit();
|
||||
s32 CALLBACK CDVDopen(const char* pTitleFilename);
|
||||
void CALLBACK CDVDclose();
|
||||
void CALLBACK CDVDshutdown();
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
|
||||
|
||||
// return can be NULL (for async modes)
|
||||
u8* CALLBACK CDVDgetBuffer();
|
||||
|
||||
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
|
||||
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
||||
s32 CALLBACK CDVDgetTOC(void* toc); //gets ps2 style toc from disc
|
||||
s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
|
||||
s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
||||
s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
|
||||
s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK CDVDconfigure();
|
||||
void CALLBACK CDVDabout();
|
||||
s32 CALLBACK CDVDtest();
|
||||
void CALLBACK CDVDnewDiskCB(void (*callback)());
|
||||
|
||||
#endif
|
||||
|
||||
/* DEV9 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef DEV9defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
s32 CALLBACK DEV9init();
|
||||
s32 CALLBACK DEV9open(void *pDsp);
|
||||
void CALLBACK DEV9close();
|
||||
void CALLBACK DEV9shutdown();
|
||||
u8 CALLBACK DEV9read8(u32 addr);
|
||||
u16 CALLBACK DEV9read16(u32 addr);
|
||||
u32 CALLBACK DEV9read32(u32 addr);
|
||||
void CALLBACK DEV9write8(u32 addr, u8 value);
|
||||
void CALLBACK DEV9write16(u32 addr, u16 value);
|
||||
void CALLBACK DEV9write32(u32 addr, u32 value);
|
||||
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK DEV9writeDMA8Mem(u32 *pMem, int size);
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK DEV9irqCallback(DEV9callback callback);
|
||||
DEV9handler CALLBACK DEV9irqHandler(void);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK DEV9freeze(int mode, freezeData *data);
|
||||
void CALLBACK DEV9configure();
|
||||
void CALLBACK DEV9about();
|
||||
s32 CALLBACK DEV9test();
|
||||
|
||||
#endif
|
||||
|
||||
/* USB plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef USBdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK USBinit();
|
||||
s32 CALLBACK USBopen(void *pDsp);
|
||||
void CALLBACK USBclose();
|
||||
void CALLBACK USBshutdown();
|
||||
u8 CALLBACK USBread8(u32 addr);
|
||||
u16 CALLBACK USBread16(u32 addr);
|
||||
u32 CALLBACK USBread32(u32 addr);
|
||||
void CALLBACK USBwrite8(u32 addr, u8 value);
|
||||
void CALLBACK USBwrite16(u32 addr, u16 value);
|
||||
void CALLBACK USBwrite32(u32 addr, u32 value);
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK USBirqCallback(USBcallback callback);
|
||||
USBhandler CALLBACK USBirqHandler(void);
|
||||
void CALLBACK USBsetRAM(void *mem);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK USBfreeze(int mode, freezeData *data);
|
||||
void CALLBACK USBconfigure();
|
||||
void CALLBACK USBabout();
|
||||
s32 CALLBACK USBtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* FW plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef FWdefs
|
||||
// basic funcs
|
||||
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
s32 CALLBACK FWinit();
|
||||
s32 CALLBACK FWopen(void *pDsp);
|
||||
void CALLBACK FWclose();
|
||||
void CALLBACK FWshutdown();
|
||||
u32 CALLBACK FWread32(u32 addr);
|
||||
void CALLBACK FWwrite32(u32 addr, u32 value);
|
||||
void CALLBACK FWirqCallback(void (*callback)());
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK FWfreeze(int mode, freezeData *data);
|
||||
void CALLBACK FWconfigure();
|
||||
void CALLBACK FWabout();
|
||||
s32 CALLBACK FWtest();
|
||||
#endif
|
||||
|
||||
// might be useful for emulators
|
||||
#ifdef PLUGINtypedefs
|
||||
|
||||
typedef u32 (CALLBACK* _PS2EgetLibType)(void);
|
||||
typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
|
||||
typedef char*(CALLBACK* _PS2EgetLibName)(void);
|
||||
|
||||
// GS
|
||||
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _GSinit)();
|
||||
typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title, int multithread);
|
||||
typedef void (CALLBACK* _GSclose)();
|
||||
typedef void (CALLBACK* _GSshutdown)();
|
||||
typedef void (CALLBACK* _GSvsync)(int field);
|
||||
typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr);
|
||||
typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSgifSoftReset)(u32 mask);
|
||||
typedef void (CALLBACK* _GSreadFIFO)(off64_t *pMem);
|
||||
typedef void (CALLBACK* _GSreadFIFO2)(off64_t *pMem, int qwc);
|
||||
|
||||
typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev);
|
||||
typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename);
|
||||
typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
|
||||
typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...);
|
||||
typedef void (CALLBACK* _GSsetBaseMem)(void*);
|
||||
typedef void (CALLBACK* _GSsetGameCRC)(int);
|
||||
typedef void (CALLBACK* _GSsetFrameSkip)(int frameskip);
|
||||
typedef void (CALLBACK* _GSreset)();
|
||||
typedef void (CALLBACK* _GSwriteCSR)(u32 value);
|
||||
typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info);
|
||||
#ifdef _WIN32
|
||||
typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info);
|
||||
#endif
|
||||
typedef void (CALLBACK* _GSmakeSnapshot)(char *path);
|
||||
typedef void (CALLBACK* _GSmakeSnapshot2)(char *path, int*, int);
|
||||
typedef s32 (CALLBACK* _GSfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _GSconfigure)();
|
||||
typedef s32 (CALLBACK* _GStest)();
|
||||
typedef void (CALLBACK* _GSabout)();
|
||||
|
||||
// PAD
|
||||
typedef s32 (CALLBACK* _PADinit)(u32 flags);
|
||||
typedef s32 (CALLBACK* _PADopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _PADclose)();
|
||||
typedef void (CALLBACK* _PADshutdown)();
|
||||
typedef keyEvent* (CALLBACK* _PADkeyEvent)();
|
||||
typedef u8 (CALLBACK* _PADstartPoll)(int pad);
|
||||
typedef u8 (CALLBACK* _PADpoll)(u8 value);
|
||||
typedef u32 (CALLBACK* _PADquery)();
|
||||
|
||||
typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
|
||||
typedef void (CALLBACK* _PADconfigure)();
|
||||
typedef s32 (CALLBACK* _PADtest)();
|
||||
typedef void (CALLBACK* _PADabout)();
|
||||
|
||||
// SIO
|
||||
typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
|
||||
typedef s32 (CALLBACK* _SIOopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _SIOclose)();
|
||||
typedef void (CALLBACK* _SIOshutdown)();
|
||||
typedef u8 (CALLBACK* _SIOstartPoll)(u8 value);
|
||||
typedef u8 (CALLBACK* _SIOpoll)(u8 value);
|
||||
typedef u32 (CALLBACK* _SIOquery)();
|
||||
|
||||
typedef void (CALLBACK* _SIOconfigure)();
|
||||
typedef s32 (CALLBACK* _SIOtest)();
|
||||
typedef void (CALLBACK* _SIOabout)();
|
||||
|
||||
// SPU2
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _SPU2init)();
|
||||
typedef s32 (CALLBACK* _SPU2open)(void *pDsp);
|
||||
typedef void (CALLBACK* _SPU2close)();
|
||||
typedef void (CALLBACK* _SPU2shutdown)();
|
||||
typedef void (CALLBACK* _SPU2write)(u32 mem, u16 value);
|
||||
typedef u16 (CALLBACK* _SPU2read)(u32 mem);
|
||||
typedef void (CALLBACK* _SPU2readDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA4)();
|
||||
typedef void (CALLBACK* _SPU2readDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA7)();
|
||||
typedef void (CALLBACK* _SPU2irqCallback)(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
|
||||
typedef u32 (CALLBACK* _SPU2ReadMemAddr)(int core);
|
||||
typedef void (CALLBACK* _SPU2WriteMemAddr)(int core,u32 value);
|
||||
typedef void (CALLBACK* _SPU2async)(u32 cycles);
|
||||
typedef s32 (CALLBACK* _SPU2freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _SPU2configure)();
|
||||
typedef s32 (CALLBACK* _SPU2test)();
|
||||
typedef void (CALLBACK* _SPU2about)();
|
||||
|
||||
// CDVD
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _CDVDinit)();
|
||||
typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename);
|
||||
typedef void (CALLBACK* _CDVDclose)();
|
||||
typedef void (CALLBACK* _CDVDshutdown)();
|
||||
typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
|
||||
typedef u8* (CALLBACK* _CDVDgetBuffer)();
|
||||
typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq);
|
||||
typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTOC)(void* toc);
|
||||
typedef s32 (CALLBACK* _CDVDgetDiskType)();
|
||||
typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
|
||||
|
||||
typedef void (CALLBACK* _CDVDconfigure)();
|
||||
typedef s32 (CALLBACK* _CDVDtest)();
|
||||
typedef void (CALLBACK* _CDVDabout)();
|
||||
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
|
||||
|
||||
// DEV9
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _DEV9init)();
|
||||
typedef s32 (CALLBACK* _DEV9open)(void *pDsp);
|
||||
typedef void (CALLBACK* _DEV9close)();
|
||||
typedef void (CALLBACK* _DEV9shutdown)();
|
||||
typedef u8 (CALLBACK* _DEV9read8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _DEV9read16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _DEV9read32)(u32 mem);
|
||||
typedef void (CALLBACK* _DEV9write8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _DEV9write16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _DEV9write32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
|
||||
typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
|
||||
|
||||
typedef s32 (CALLBACK* _DEV9freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _DEV9configure)();
|
||||
typedef s32 (CALLBACK* _DEV9test)();
|
||||
typedef void (CALLBACK* _DEV9about)();
|
||||
|
||||
// USB
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _USBinit)();
|
||||
typedef s32 (CALLBACK* _USBopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _USBclose)();
|
||||
typedef void (CALLBACK* _USBshutdown)();
|
||||
typedef u8 (CALLBACK* _USBread8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _USBread16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _USBread32)(u32 mem);
|
||||
typedef void (CALLBACK* _USBwrite8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _USBwrite16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
|
||||
typedef USBhandler (CALLBACK* _USBirqHandler)(void);
|
||||
typedef void (CALLBACK* _USBsetRAM)(void *mem);
|
||||
|
||||
typedef s32 (CALLBACK* _USBfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _USBconfigure)();
|
||||
typedef s32 (CALLBACK* _USBtest)();
|
||||
typedef void (CALLBACK* _USBabout)();
|
||||
|
||||
//FW
|
||||
typedef s32 (CALLBACK* _FWinit)();
|
||||
typedef s32 (CALLBACK* _FWopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _FWclose)();
|
||||
typedef void (CALLBACK* _FWshutdown)();
|
||||
typedef u32 (CALLBACK* _FWread32)(u32 mem);
|
||||
typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _FWirqCallback)(void (*callback)());
|
||||
|
||||
typedef s32 (CALLBACK* _FWfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _FWconfigure)();
|
||||
typedef s32 (CALLBACK* _FWtest)();
|
||||
typedef void (CALLBACK* _FWabout)();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLUGINfuncs
|
||||
|
||||
// GS
|
||||
_GSinit GSinit;
|
||||
_GSopen GSopen;
|
||||
_GSclose GSclose;
|
||||
_GSshutdown GSshutdown;
|
||||
_GSvsync GSvsync;
|
||||
_GSgifTransfer1 GSgifTransfer1;
|
||||
_GSgifTransfer2 GSgifTransfer2;
|
||||
_GSgifTransfer3 GSgifTransfer3;
|
||||
_GSgifSoftReset GSgifSoftReset;
|
||||
_GSreadFIFO GSreadFIFO;
|
||||
_GSreadFIFO2 GSreadFIFO2;
|
||||
|
||||
_GSkeyEvent GSkeyEvent;
|
||||
_GSchangeSaveState GSchangeSaveState;
|
||||
_GSmakeSnapshot GSmakeSnapshot;
|
||||
_GSmakeSnapshot2 GSmakeSnapshot2;
|
||||
_GSirqCallback GSirqCallback;
|
||||
_GSprintf GSprintf;
|
||||
_GSsetBaseMem GSsetBaseMem;
|
||||
_GSsetGameCRC GSsetGameCRC;
|
||||
_GSsetFrameSkip GSsetFrameSkip;
|
||||
_GSreset GSreset;
|
||||
_GSwriteCSR GSwriteCSR;
|
||||
_GSgetDriverInfo GSgetDriverInfo;
|
||||
#ifdef _WIN32
|
||||
_GSsetWindowInfo GSsetWindowInfo;
|
||||
#endif
|
||||
_GSfreeze GSfreeze;
|
||||
_GSconfigure GSconfigure;
|
||||
_GStest GStest;
|
||||
_GSabout GSabout;
|
||||
|
||||
// PAD1
|
||||
_PADinit PAD1init;
|
||||
_PADopen PAD1open;
|
||||
_PADclose PAD1close;
|
||||
_PADshutdown PAD1shutdown;
|
||||
_PADkeyEvent PAD1keyEvent;
|
||||
_PADstartPoll PAD1startPoll;
|
||||
_PADpoll PAD1poll;
|
||||
_PADquery PAD1query;
|
||||
|
||||
_PADgsDriverInfo PAD1gsDriverInfo;
|
||||
_PADconfigure PAD1configure;
|
||||
_PADtest PAD1test;
|
||||
_PADabout PAD1about;
|
||||
|
||||
// PAD2
|
||||
_PADinit PAD2init;
|
||||
_PADopen PAD2open;
|
||||
_PADclose PAD2close;
|
||||
_PADshutdown PAD2shutdown;
|
||||
_PADkeyEvent PAD2keyEvent;
|
||||
_PADstartPoll PAD2startPoll;
|
||||
_PADpoll PAD2poll;
|
||||
_PADquery PAD2query;
|
||||
|
||||
_PADgsDriverInfo PAD2gsDriverInfo;
|
||||
_PADconfigure PAD2configure;
|
||||
_PADtest PAD2test;
|
||||
_PADabout PAD2about;
|
||||
|
||||
// SIO[2]
|
||||
_SIOinit SIOinit[2][9];
|
||||
_SIOopen SIOopen[2][9];
|
||||
_SIOclose SIOclose[2][9];
|
||||
_SIOshutdown SIOshutdown[2][9];
|
||||
_SIOstartPoll SIOstartPoll[2][9];
|
||||
_SIOpoll SIOpoll[2][9];
|
||||
_SIOquery SIOquery[2][9];
|
||||
|
||||
_SIOconfigure SIOconfigure[2][9];
|
||||
_SIOtest SIOtest[2][9];
|
||||
_SIOabout SIOabout[2][9];
|
||||
|
||||
// SPU2
|
||||
_SPU2init SPU2init;
|
||||
_SPU2open SPU2open;
|
||||
_SPU2close SPU2close;
|
||||
_SPU2shutdown SPU2shutdown;
|
||||
_SPU2write SPU2write;
|
||||
_SPU2read SPU2read;
|
||||
_SPU2readDMA4Mem SPU2readDMA4Mem;
|
||||
_SPU2writeDMA4Mem SPU2writeDMA4Mem;
|
||||
_SPU2interruptDMA4 SPU2interruptDMA4;
|
||||
_SPU2readDMA7Mem SPU2readDMA7Mem;
|
||||
_SPU2writeDMA7Mem SPU2writeDMA7Mem;
|
||||
_SPU2interruptDMA7 SPU2interruptDMA7;
|
||||
_SPU2ReadMemAddr SPU2ReadMemAddr;
|
||||
_SPU2WriteMemAddr SPU2WriteMemAddr;
|
||||
_SPU2irqCallback SPU2irqCallback;
|
||||
|
||||
_SPU2async SPU2async;
|
||||
_SPU2freeze SPU2freeze;
|
||||
_SPU2configure SPU2configure;
|
||||
_SPU2test SPU2test;
|
||||
_SPU2about SPU2about;
|
||||
|
||||
// CDVD
|
||||
_CDVDinit CDVDinit;
|
||||
_CDVDopen CDVDopen;
|
||||
_CDVDclose CDVDclose;
|
||||
_CDVDshutdown CDVDshutdown;
|
||||
_CDVDreadTrack CDVDreadTrack;
|
||||
_CDVDgetBuffer CDVDgetBuffer;
|
||||
_CDVDreadSubQ CDVDreadSubQ;
|
||||
_CDVDgetTN CDVDgetTN;
|
||||
_CDVDgetTD CDVDgetTD;
|
||||
_CDVDgetTOC CDVDgetTOC;
|
||||
_CDVDgetDiskType CDVDgetDiskType;
|
||||
_CDVDgetTrayStatus CDVDgetTrayStatus;
|
||||
_CDVDctrlTrayOpen CDVDctrlTrayOpen;
|
||||
_CDVDctrlTrayClose CDVDctrlTrayClose;
|
||||
|
||||
_CDVDconfigure CDVDconfigure;
|
||||
_CDVDtest CDVDtest;
|
||||
_CDVDabout CDVDabout;
|
||||
_CDVDnewDiskCB CDVDnewDiskCB;
|
||||
|
||||
// DEV9
|
||||
_DEV9init DEV9init;
|
||||
_DEV9open DEV9open;
|
||||
_DEV9close DEV9close;
|
||||
_DEV9shutdown DEV9shutdown;
|
||||
_DEV9read8 DEV9read8;
|
||||
_DEV9read16 DEV9read16;
|
||||
_DEV9read32 DEV9read32;
|
||||
_DEV9write8 DEV9write8;
|
||||
_DEV9write16 DEV9write16;
|
||||
_DEV9write32 DEV9write32;
|
||||
_DEV9readDMA8Mem DEV9readDMA8Mem;
|
||||
_DEV9writeDMA8Mem DEV9writeDMA8Mem;
|
||||
_DEV9irqCallback DEV9irqCallback;
|
||||
_DEV9irqHandler DEV9irqHandler;
|
||||
|
||||
_DEV9configure DEV9configure;
|
||||
_DEV9freeze DEV9freeze;
|
||||
_DEV9test DEV9test;
|
||||
_DEV9about DEV9about;
|
||||
|
||||
// USB
|
||||
_USBinit USBinit;
|
||||
_USBopen USBopen;
|
||||
_USBclose USBclose;
|
||||
_USBshutdown USBshutdown;
|
||||
_USBread8 USBread8;
|
||||
_USBread16 USBread16;
|
||||
_USBread32 USBread32;
|
||||
_USBwrite8 USBwrite8;
|
||||
_USBwrite16 USBwrite16;
|
||||
_USBwrite32 USBwrite32;
|
||||
_USBirqCallback USBirqCallback;
|
||||
_USBirqHandler USBirqHandler;
|
||||
_USBsetRAM USBsetRAM;
|
||||
|
||||
_USBconfigure USBconfigure;
|
||||
_USBfreeze USBfreeze;
|
||||
_USBtest USBtest;
|
||||
_USBabout USBabout;
|
||||
|
||||
// FW
|
||||
_FWinit FWinit;
|
||||
_FWopen FWopen;
|
||||
_FWclose FWclose;
|
||||
_FWshutdown FWshutdown;
|
||||
_FWread32 FWread32;
|
||||
_FWwrite32 FWwrite32;
|
||||
_FWirqCallback FWirqCallback;
|
||||
|
||||
_FWconfigure FWconfigure;
|
||||
_FWfreeze FWfreeze;
|
||||
_FWtest FWtest;
|
||||
_FWabout FWabout;
|
||||
#endif
|
||||
|
||||
#endif /* __PS2EDEFS_H__ */
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef __PS2ETYPES_H__
|
||||
#define __PS2ETYPES_H__
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#if defined (__linux__) // some distributions are lower case
|
||||
#define __LINUX__
|
||||
#endif
|
||||
|
||||
// Basic types
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
typedef __int8 s8;
|
||||
typedef __int16 s16;
|
||||
typedef __int32 s32;
|
||||
typedef __int64 s64;
|
||||
|
||||
typedef unsigned __int8 u8;
|
||||
typedef unsigned __int16 u16;
|
||||
typedef unsigned __int32 u32;
|
||||
typedef unsigned __int64 u64;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
typedef u64 uptr;
|
||||
#else
|
||||
typedef u32 uptr;
|
||||
#endif
|
||||
|
||||
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||
|
||||
#else
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
typedef u64 uptr;
|
||||
#else
|
||||
typedef u32 uptr;
|
||||
#endif
|
||||
|
||||
#ifdef __LINUX__
|
||||
typedef union _LARGE_INTEGER
|
||||
{
|
||||
long long QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||
#else
|
||||
#define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
|
||||
#endif
|
||||
|
||||
#ifndef __forceinline
|
||||
#define __forceinline inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
s8 *data;
|
||||
} freezeData;
|
||||
|
||||
#endif /* __PS2ETYPES_H__ */
|
|
@ -0,0 +1,774 @@
|
|||
/* CD.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ddk/ntddcdrm.h> // IOCTL_CDROM...
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#include "../convert.h" // MSFtoLBA(), HEXTOBCD()
|
||||
|
||||
#include "actualfile.h"
|
||||
|
||||
#include "device.h" // tocbuffer[], FinishCommand()
|
||||
|
||||
#include "CD.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int actualcdmode; // -1=ReadFile, 0=YellowMode2, 1=XAForm2, 2=CDDA
|
||||
|
||||
DWORD cdblocksize; // 2048 to 2352
|
||||
|
||||
int cdoffset; // 0, 8, 16, or 24
|
||||
|
||||
int cdmode;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void InitCDInfo() {
|
||||
|
||||
actualcdmode = -1;
|
||||
|
||||
cdblocksize = 2048;
|
||||
|
||||
cdmode = -1;
|
||||
|
||||
} // END InitCDInfo()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDreadTrackPass(u32 lsn, int mode, u8 *buffer) {
|
||||
|
||||
RAW_READ_INFO rawinfo;
|
||||
|
||||
BOOL boolresult;
|
||||
|
||||
DWORD byteswritten;
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
LARGE_INTEGER targetpos;
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
if((actualcdmode < -1) || (actualcdmode > 2)) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVD CD: CDreadTrack(%llu, %i)", lsn, actualcdmode);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
if(actualcdmode >= 0) {
|
||||
|
||||
rawinfo.DiskOffset.QuadPart = lsn * 2048; // Yes, 2048.
|
||||
|
||||
rawinfo.SectorCount = 1;
|
||||
|
||||
rawinfo.TrackMode = actualcdmode;
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
|
||||
IOCTL_CDROM_RAW_READ,
|
||||
|
||||
&rawinfo,
|
||||
|
||||
sizeof(RAW_READ_INFO),
|
||||
|
||||
buffer,
|
||||
|
||||
2352,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: Couldn't read a sector raw!");
|
||||
|
||||
PrintError("CDVDiso CD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't read a raw sector? Maybe not a CD.
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
targetpos.QuadPart = lsn * 2048;
|
||||
|
||||
waitevent.Offset = targetpos.LowPart;
|
||||
|
||||
waitevent.OffsetHigh = targetpos.HighPart;
|
||||
|
||||
|
||||
|
||||
boolresult = ReadFile(devicehandle,
|
||||
|
||||
buffer + 24,
|
||||
|
||||
2048,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: Couldn't read a cooked sector!");
|
||||
|
||||
PrintError("CDVDiso CD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble with seek? Report it.
|
||||
|
||||
|
||||
|
||||
for(i = 0; i < 24; i++) *(buffer + i) = 0;
|
||||
|
||||
for(i = 24 + 2048; i < 2352; i++) *(buffer + i) = 0;
|
||||
|
||||
} // ENDIF- Could we read a raw sector? Read another one!
|
||||
|
||||
|
||||
|
||||
if(boolresult == FALSE) {
|
||||
|
||||
boolresult = GetOverlappedResult(devicehandle,
|
||||
|
||||
&waitevent,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
FALSE);
|
||||
|
||||
} // ENDIF- Did the initial call not complete? Get byteswritten for
|
||||
|
||||
// the completed call.
|
||||
|
||||
|
||||
|
||||
if(byteswritten < 2048) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
errcode = GetLastError();
|
||||
|
||||
PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes",
|
||||
|
||||
byteswritten, cdblocksize);
|
||||
|
||||
PrintError("CDVDiso CD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't read a raw sector? Maybe not a CD.
|
||||
|
||||
|
||||
|
||||
cdmode = mode;
|
||||
|
||||
cdblocksize = byteswritten;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END CDreadTrackPass()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDreadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
int lastmode;
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
retval = CDreadTrackPass(lsn, mode, buffer);
|
||||
|
||||
if(retval >= 0) return(retval);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: Same mode doesn't work. Scanning...");
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
|
||||
|
||||
lastmode = actualcdmode;
|
||||
|
||||
actualcdmode = 2;
|
||||
|
||||
while(actualcdmode >= -1) {
|
||||
|
||||
retval = CDreadTrackPass(lsn, mode, buffer);
|
||||
|
||||
if(retval >= 0) return(retval);
|
||||
|
||||
actualcdmode--;
|
||||
|
||||
} // ENDWHILE- Searching each mode for a way to read the sector
|
||||
|
||||
actualcdmode = lastmode; // None worked? Go back to first mode.
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: No modes work. Failing sector!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
|
||||
|
||||
for(i = 0; i < 2352; i++) *(buffer + i) = 0;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END CDreadTrack()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDgetBufferOffset() {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVD CD: CDgetBufferOffset()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
// Send a whole CDDA record in?
|
||||
|
||||
if((actualcdmode == CDDA) && (cdmode == CDVD_MODE_2352)) return(0);
|
||||
|
||||
|
||||
|
||||
// Otherwise, send the start of the data block in...
|
||||
|
||||
return(cdoffset);
|
||||
|
||||
} // END CDgetBufferOffset()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDreadSubQ() {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END CDreadSubQ()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDgetTN(cdvdTN *cdvdtn) {
|
||||
|
||||
cdvdtn->strack = BCDTOHEX(tocbuffer[7]);
|
||||
|
||||
cdvdtn->etrack = BCDTOHEX(tocbuffer[17]);
|
||||
|
||||
return(0);
|
||||
|
||||
} // END CDgetTN()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
|
||||
|
||||
u8 actualtrack;
|
||||
|
||||
int pos;
|
||||
|
||||
char temptime[3];
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: CDgetTD()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
actualtrack = newtrack;
|
||||
|
||||
if(actualtrack == 0xaa) actualtrack = 0;
|
||||
|
||||
|
||||
|
||||
if(actualtrack == 0) {
|
||||
|
||||
cdvdtd->type = 0;
|
||||
|
||||
temptime[0] = BCDTOHEX(tocbuffer[27]);
|
||||
|
||||
temptime[1] = BCDTOHEX(tocbuffer[28]);
|
||||
|
||||
temptime[2] = BCDTOHEX(tocbuffer[29]);
|
||||
|
||||
cdvdtd->lsn = MSFtoLBA(temptime);
|
||||
|
||||
} else {
|
||||
|
||||
pos = actualtrack * 10;
|
||||
|
||||
pos += 30;
|
||||
|
||||
cdvdtd->type = tocbuffer[pos];
|
||||
|
||||
temptime[0] = BCDTOHEX(tocbuffer[pos + 7]);
|
||||
|
||||
temptime[1] = BCDTOHEX(tocbuffer[pos + 8]);
|
||||
|
||||
temptime[2] = BCDTOHEX(tocbuffer[pos + 9]);
|
||||
|
||||
cdvdtd->lsn = MSFtoLBA(temptime);
|
||||
|
||||
} // ENDIF- Whole disc? (or single track?)
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END CDgetTD()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 CDgetDiskType() {
|
||||
|
||||
CDROM_TOC cdinfo;
|
||||
|
||||
BOOL boolresult;
|
||||
|
||||
int retval;
|
||||
|
||||
DWORD byteswritten;
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
u8 iso9660name[] = "CD001\0";
|
||||
|
||||
u8 playstationname[] = "PLAYSTATION\0";
|
||||
|
||||
u8 ps1name[] = "CD-XA001\0";
|
||||
|
||||
u8 tempbuffer[2448];
|
||||
|
||||
int tempdisctype;
|
||||
|
||||
int i;
|
||||
|
||||
int pos;
|
||||
|
||||
unsigned long volumesize;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso CD: CDgetDiskType()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
|
||||
|
||||
|
||||
actualcdmode = 2;
|
||||
|
||||
retval = CDreadTrack(16, CDVD_MODE_2048, tempbuffer);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
disctype = tempdisctype;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't read the directory sector? Abort.
|
||||
|
||||
|
||||
|
||||
disctype = CDVD_TYPE_DETCTCD;
|
||||
|
||||
tempdisctype = CDVD_TYPE_CDDA;
|
||||
|
||||
|
||||
|
||||
cdoffset = 0;
|
||||
|
||||
i = 0;
|
||||
|
||||
while((cdoffset <= 24) && (iso9660name[i] != 0)) {
|
||||
|
||||
i = 0;
|
||||
|
||||
while((iso9660name[i] != 0) &&
|
||||
|
||||
(iso9660name[i] == tempbuffer[cdoffset + 1 + i])) i++;
|
||||
|
||||
if(iso9660name[i] != 0) cdoffset += 8;
|
||||
|
||||
} // ENDWHILE- Trying to find a working offset for a ISO9660 record.
|
||||
|
||||
|
||||
|
||||
if(iso9660name[i] != 0) {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("Detected a CDDA (Music CD).");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_CDDA;
|
||||
|
||||
tocbuffer[0] = 0x01;
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
tocbuffer[0] = 0x41;
|
||||
|
||||
i = 0;
|
||||
|
||||
while((playstationname[i] != 0) &&
|
||||
|
||||
(playstationname[i] == tempbuffer[cdoffset + 8 + i])) i++;
|
||||
|
||||
if(playstationname[i] != 0) {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("Detected a non-Playstation CD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
i = 0;
|
||||
|
||||
while((ps1name[i] != 0) &&
|
||||
|
||||
(ps1name[i] == tempbuffer[cdoffset + 1024 + i])) i++;
|
||||
|
||||
if(ps1name[i] != 0) {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("Detected a Playstation 2 CD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_PS2CD;
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("Detected a Playstation CD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_PSCD;
|
||||
|
||||
} // ENDIF- Is this not a PlayStation Disc?
|
||||
|
||||
} // ENDIF- Is this not a PlayStation Disc?
|
||||
|
||||
} // ENDIF- Is this not an ISO9660 CD? (a CDDA, in other words?)
|
||||
|
||||
|
||||
|
||||
// Build the Fake TOC
|
||||
|
||||
tocbuffer[2] = 0xA0;
|
||||
|
||||
tocbuffer[7] = HEXTOBCD(1); // Starting Track
|
||||
|
||||
tocbuffer[12] = 0xA1;
|
||||
|
||||
tocbuffer[17] = HEXTOBCD(1); // Ending Track
|
||||
|
||||
|
||||
|
||||
volumesize = tempbuffer[84]; // Volume size (big endian)
|
||||
|
||||
volumesize *= 256;
|
||||
|
||||
volumesize += tempbuffer[85];
|
||||
|
||||
volumesize *= 256;
|
||||
|
||||
volumesize += tempbuffer[86];
|
||||
|
||||
volumesize *= 256;
|
||||
|
||||
volumesize += tempbuffer[87];
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
if(tempdisctype != CDVD_TYPE_CDDA) {
|
||||
|
||||
PrintLog("CDVDiso CD: ISO9660 size %llu", volumesize);
|
||||
|
||||
} // ENDIF- Data CD? Print size in blocks.
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
|
||||
|
||||
LBAtoMSF(volumesize, &tocbuffer[27]);
|
||||
|
||||
tocbuffer[27] = HEXTOBCD(tocbuffer[27]);
|
||||
|
||||
tocbuffer[28] = HEXTOBCD(tocbuffer[28]);
|
||||
|
||||
tocbuffer[29] = HEXTOBCD(tocbuffer[29]);
|
||||
|
||||
|
||||
|
||||
tocbuffer[40] = 0x02; // Data Mode
|
||||
|
||||
tocbuffer[42] = 0x01; // Track #
|
||||
|
||||
LBAtoMSF(0, &tocbuffer[47]);
|
||||
|
||||
tocbuffer[47] = HEXTOBCD(tocbuffer[47]);
|
||||
|
||||
tocbuffer[48] = HEXTOBCD(tocbuffer[48]);
|
||||
|
||||
tocbuffer[49] = HEXTOBCD(tocbuffer[49]);
|
||||
|
||||
|
||||
|
||||
// Can we get the REAL TOC?
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
|
||||
IOCTL_CDROM_READ_TOC,
|
||||
|
||||
NULL,
|
||||
|
||||
0,
|
||||
|
||||
&cdinfo,
|
||||
|
||||
sizeof(CDROM_TOC),
|
||||
|
||||
&byteswritten,
|
||||
|
||||
NULL);
|
||||
|
||||
|
||||
|
||||
if(boolresult == FALSE) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
errcode = GetLastError();
|
||||
|
||||
PrintLog("CDVDiso CD: Can't get TOC!");
|
||||
|
||||
PrintError("CDVDiso CD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
disctype = tempdisctype;
|
||||
|
||||
return(disctype);
|
||||
|
||||
} // ENDIF- Can't read the TOC? Accept the fake TOC then.
|
||||
|
||||
|
||||
|
||||
// Fill in the pieces of the REAL TOC.
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
PrintLog("CDVDiso CD: TOC First Track: %u Last Track: %u",
|
||||
|
||||
cdinfo.FirstTrack, cdinfo.LastTrack);
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
tocbuffer[7] = HEXTOBCD(cdinfo.FirstTrack);
|
||||
|
||||
tocbuffer[17] = HEXTOBCD(cdinfo.LastTrack);
|
||||
|
||||
|
||||
|
||||
// for(i = cdinfo.FirstTrack; i <= cdinfo.LastTrack; i++) {
|
||||
|
||||
for(i = 0; i <= cdinfo.LastTrack - cdinfo.FirstTrack; i++) {
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
PrintLog("CDVDiso CD: TOC Track %u Disc Size: %u:%u.%u Data Mode %u",
|
||||
|
||||
cdinfo.TrackData[i].TrackNumber,
|
||||
|
||||
cdinfo.TrackData[i].Address[1] * 1,
|
||||
|
||||
cdinfo.TrackData[i].Address[2] * 1,
|
||||
|
||||
cdinfo.TrackData[i].Address[3] * 1,
|
||||
|
||||
cdinfo.TrackData[i].Control * 1);
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
pos = i * 10 + 40;
|
||||
|
||||
tocbuffer[pos] = cdinfo.TrackData[i].Control;
|
||||
|
||||
tocbuffer[pos + 2] = HEXTOBCD(i + 1);
|
||||
|
||||
tocbuffer[pos + 7] = HEXTOBCD(cdinfo.TrackData[i].Address[1]);
|
||||
|
||||
tocbuffer[pos + 8] = HEXTOBCD(cdinfo.TrackData[i].Address[2]);
|
||||
|
||||
tocbuffer[pos + 9] = HEXTOBCD(cdinfo.TrackData[i].Address[3]);
|
||||
|
||||
} // NEXT i- Transferring Track data to the PS2 TOC
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
PrintLog("CDVDiso CD: TOC Disc Size: %u:%u.%u",
|
||||
|
||||
cdinfo.TrackData[i].Address[1] * 1,
|
||||
|
||||
cdinfo.TrackData[i].Address[2] * 1,
|
||||
|
||||
cdinfo.TrackData[i].Address[3] * 1);
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
tocbuffer[27] = HEXTOBCD(cdinfo.TrackData[i].Address[1]);
|
||||
|
||||
tocbuffer[28] = HEXTOBCD(cdinfo.TrackData[i].Address[2]);
|
||||
|
||||
tocbuffer[29] = HEXTOBCD(cdinfo.TrackData[i].Address[3]);
|
||||
|
||||
|
||||
|
||||
disctype = tempdisctype;
|
||||
|
||||
return(disctype);
|
||||
|
||||
} // END CDgetDiskType()
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/* CD.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CD_H
|
||||
#define CD_H
|
||||
|
||||
|
||||
#include <windows.h> // DWORD
|
||||
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
extern DWORD cdblocksize;
|
||||
|
||||
|
||||
extern void InitCDInfo();
|
||||
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 CDgetBufferOffset();
|
||||
extern s32 CDreadSubQ();
|
||||
extern s32 CDgetTN(cdvdTN *cdvdtn);
|
||||
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
|
||||
extern s32 CDgetDiskType();
|
||||
|
||||
|
||||
#endif /* CD_H */
|
|
@ -0,0 +1,570 @@
|
|||
/* CDVDiso.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h> // BOOL, CALLBACK, APIENTRY
|
||||
#include <windef.h> // NULL
|
||||
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "actualfile.h"
|
||||
#include "../isofile.h"
|
||||
#include "logfile.h"
|
||||
#include "../convert.h"
|
||||
#include "../version.h"
|
||||
#include "screens.h"
|
||||
#include "mainbox.h" // Initialize mainboxwindow
|
||||
#include "progressbox.h" // Initialize progressboxwindow
|
||||
#include "conversionbox.h" // Initialize conversionboxwindow
|
||||
#include "devicebox.h" // Initialize deviceboxwindow
|
||||
#include "CDVDiso.h"
|
||||
|
||||
|
||||
struct IsoFile *isofile;
|
||||
char isobuffer[2448];
|
||||
char isocdcheck[2048];
|
||||
int isomode;
|
||||
int deviceopencount;
|
||||
|
||||
HINSTANCE progmodule;
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain(HANDLE hModule,
|
||||
DWORD param,
|
||||
LPVOID reserved) {
|
||||
|
||||
|
||||
switch(param) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
progmodule = hModule;
|
||||
// mainboxwindow = NULL;
|
||||
// progressboxwindow = NULL;
|
||||
// conversionboxwindow = NULL;
|
||||
// deviceboxwindow = NULL;
|
||||
return(TRUE);
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
// CDVDshutdown();
|
||||
return(TRUE);
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
return(TRUE);
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
return(TRUE);
|
||||
break;
|
||||
} // ENDSWITCH param- What does the OS want with us?
|
||||
|
||||
return(FALSE); // Wasn't on list? Wasn't handled.
|
||||
} // END DllMain()
|
||||
|
||||
|
||||
char* CALLBACK PS2EgetLibName() {
|
||||
return(libname);
|
||||
} // END PS2EgetLibName()
|
||||
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
return(PS2E_LT_CDVD);
|
||||
} // END PS2getLibType()
|
||||
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
return((version << 16) | (revision << 8) | build);
|
||||
} // END PS2EgetLibVersion2()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDinit() {
|
||||
int i;
|
||||
|
||||
InitLog();
|
||||
if(OpenLog() != 0) return(-1); // Couldn't open Log File? Abort.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDinit()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
InitConf();
|
||||
|
||||
isofile = NULL;
|
||||
isomode = -1;
|
||||
deviceopencount = 0;
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = 0;
|
||||
|
||||
mainboxwindow = NULL;
|
||||
progressboxwindow = NULL;
|
||||
conversionboxwindow = NULL;
|
||||
deviceboxwindow = NULL;
|
||||
|
||||
return(0);
|
||||
} // END CDVDinit()
|
||||
|
||||
|
||||
void CALLBACK CDVDshutdown() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDshutdown()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
isofile = IsoFileClose(isofile);
|
||||
|
||||
// Close Windows as well? (Just in case)
|
||||
|
||||
CloseLog();
|
||||
} // END CDVDshutdown()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDopen(const char* pTitleFilename) {
|
||||
HWND lastwindow;
|
||||
int i;
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDopen()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
lastwindow = GetActiveWindow();
|
||||
LoadConf();
|
||||
|
||||
if( pTitleFilename != NULL ) strcpy(conf.isoname, pTitleFilename);
|
||||
|
||||
if((conf.isoname[0] == 0) || (conf.isoname[0] == '[') ||
|
||||
((conf.startconfigure == 1) && (deviceopencount == 0)) ||
|
||||
((conf.restartconfigure == 1) && (deviceopencount > 0))) {
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0200),
|
||||
lastwindow,
|
||||
(DLGPROC)MainBoxCallback);
|
||||
SetActiveWindow(lastwindow);
|
||||
LoadConf();
|
||||
// Blank out the name in config file afterwards? Seems excessive.
|
||||
} // ENDIF- Haven't initialized the configure program yet? Do so now.
|
||||
lastwindow = NULL;
|
||||
|
||||
isofile = IsoFileOpenForRead(conf.isoname);
|
||||
if(isofile == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Failed to open ISO file!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
// return(-1); // Removed to simulate disc not in drive.
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = 0;
|
||||
return(0);
|
||||
} // ENDIF- Trouble opening file? Abort.
|
||||
|
||||
retval = IsoFileSeek(isofile, 16);
|
||||
if(retval != 0) return(-1);
|
||||
retval = IsoFileRead(isofile, isobuffer);
|
||||
if(retval != 0) return(-1);
|
||||
|
||||
if(deviceopencount > 0) {
|
||||
i = 0;
|
||||
while((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
|
||||
if(i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
|
||||
} // ENDIF- Is this a restart? Check for disc change.
|
||||
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
|
||||
|
||||
return(0);
|
||||
} // END CDVDopen()
|
||||
|
||||
|
||||
void CALLBACK CDVDclose() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDclose()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
isofile = IsoFileClose(isofile);
|
||||
deviceopencount = 50;
|
||||
} // END CDVDclose()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
|
||||
char temptime[3];
|
||||
int i;
|
||||
int pos;
|
||||
u32 tracklsn;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDreadSubQ()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(-1);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
return(-1); // DVDs don't have SubQ data
|
||||
} // ENDIF- Trying to get a SubQ from a DVD?
|
||||
|
||||
// fake it
|
||||
i = BCDTOHEX(isofile->toc[7]);
|
||||
pos = i * 10;
|
||||
pos += 30;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
tracklsn = MSFtoLBA(temptime);
|
||||
while((i < BCDTOHEX(isofile->toc[17])) && (tracklsn < lsn)) {
|
||||
i++;
|
||||
pos = i * 10;
|
||||
pos += 30;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
tracklsn = MSFtoLBA(temptime);
|
||||
} // ENDIF- Loop through tracks searching for lsn track
|
||||
i--;
|
||||
|
||||
subq->ctrl = 4;
|
||||
subq->mode = 1;
|
||||
subq->trackNum = HEXTOBCD(i);
|
||||
subq->trackIndex = HEXTOBCD(i);
|
||||
|
||||
LBAtoMSF(lsn - tracklsn, temptime);
|
||||
subq->trackM = HEXTOBCD(temptime[0]);
|
||||
subq->trackS = HEXTOBCD(temptime[1]);
|
||||
subq->trackF = HEXTOBCD(temptime[2]);
|
||||
|
||||
subq->pad = 0;
|
||||
|
||||
// lba_to_msf(lsn + (2*75), &min, &sec, &frm);
|
||||
LBAtoMSF(lsn, temptime);
|
||||
subq->discM = HEXTOBCD(temptime[0]);
|
||||
subq->discS = HEXTOBCD(temptime[1]);
|
||||
subq->discF = HEXTOBCD(temptime[2]);
|
||||
|
||||
return(0);
|
||||
} // END CDVDreadSubQ()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTN()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(-1);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
Buffer->strack = 1;
|
||||
Buffer->etrack = 1;
|
||||
} else {
|
||||
Buffer->strack = BCDTOHEX(isofile->toc[7]);
|
||||
Buffer->etrack = BCDTOHEX(isofile->toc[17]);
|
||||
} // ENDIF- Retrieve track info from a DVD? (or a CD?)
|
||||
|
||||
return(0);
|
||||
} // END CDVDgetTN()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *Buffer) {
|
||||
u8 actualtrack;
|
||||
int pos;
|
||||
char temptime[3];
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTD()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(-1);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
actualtrack = track;
|
||||
if(actualtrack == 0xaa) actualtrack = 0;
|
||||
|
||||
if((isofile->cdvdtype == CDVD_TYPE_PS2DVD) ||
|
||||
(isofile->cdvdtype == CDVD_TYPE_DVDV)) {
|
||||
if (actualtrack <= 1) {
|
||||
Buffer->type = 0;
|
||||
Buffer->lsn = isofile->filesectorsize;
|
||||
} else {
|
||||
Buffer->type = CDVD_MODE1_TRACK;
|
||||
Buffer->lsn = 0;
|
||||
} // ENDIF- Whole disc? (or single track?)
|
||||
} else {
|
||||
if (actualtrack == 0) {
|
||||
Buffer->type = 0;
|
||||
temptime[0] = BCDTOHEX(isofile->toc[27]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[28]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[29]);
|
||||
Buffer->lsn = MSFtoLBA(temptime);
|
||||
} else {
|
||||
pos = actualtrack * 10;
|
||||
pos += 30;
|
||||
Buffer->type = isofile->toc[pos];
|
||||
temptime[0] = BCDTOHEX(isofile->toc[pos + 7]);
|
||||
temptime[1] = BCDTOHEX(isofile->toc[pos + 8]);
|
||||
temptime[2] = BCDTOHEX(isofile->toc[pos + 9]);
|
||||
Buffer->lsn = MSFtoLBA(temptime);
|
||||
} // ENDIF- Whole disc? (or single track?)
|
||||
} // ENDIF- Retrieve track info from a DVD? (or a CD?)
|
||||
|
||||
return(0);
|
||||
} // END CDVDgetTD()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTOC(void* toc) {
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetTOC()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(-1);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
for(i = 0; i < 2048; i++) *(((char *) toc) + i) = isofile->toc[i];
|
||||
return(0);
|
||||
} // END CDVDgetTOC()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) {
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDreadTrack(%u)", lsn);
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(-1);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
retval = IsoFileSeek(isofile, (off64_t) lsn);
|
||||
if(retval != 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Trouble finding the sector!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(-1);
|
||||
} // ENDIF- Trouble finding the sector?
|
||||
|
||||
retval = IsoFileRead(isofile, isobuffer);
|
||||
if(retval != 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Trouble reading the sector!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(-1);
|
||||
} // ENDIF- Trouble finding the sector?
|
||||
|
||||
isomode = mode;
|
||||
return(0);
|
||||
} // END CDVDreadTrack()
|
||||
|
||||
|
||||
u8* CALLBACK CDVDgetBuffer() {
|
||||
int offset;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDgetBuffer()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(NULL);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(NULL);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
offset = 0;
|
||||
switch(isomode) {
|
||||
case CDVD_MODE_2352:
|
||||
offset = 0;
|
||||
break;
|
||||
case CDVD_MODE_2340:
|
||||
offset = 12;
|
||||
break;
|
||||
case CDVD_MODE_2328:
|
||||
case CDVD_MODE_2048:
|
||||
offset = 24;
|
||||
break;
|
||||
} // ENDSWITCH isomode- offset to where data it wants is.
|
||||
|
||||
if(offset > isofile->blockoffset) offset = isofile->blockoffset;
|
||||
|
||||
return(isobuffer + offset);
|
||||
} // END CDVDgetBuffer()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetDiskType() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
// PrintLog("CDVDiso interface: CDVDgetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(CDVD_TYPE_NODISC);
|
||||
if(deviceopencount > 0) {
|
||||
deviceopencount--;
|
||||
if(deviceopencount > 0) return(CDVD_TYPE_DETCT);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
return(isofile->cdvdtype);
|
||||
} // END CDVDgetDiskType()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDgetTrayStatus() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
// PrintLog("CDVDiso interface: CDVDgetTrayStatus()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
|
||||
if(isofile == NULL) return(CDVD_TRAY_OPEN);
|
||||
if(deviceopencount > 30) {
|
||||
deviceopencount--;
|
||||
return(CDVD_TRAY_OPEN);
|
||||
} // ENDIF- Still simulating device tray open?
|
||||
|
||||
return(CDVD_TRAY_CLOSE);
|
||||
} // END CDVDgetTrayStatus()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayOpen() {
|
||||
HWND lastwindow;
|
||||
int i;
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDctrlTrayOpen()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
// CDVDclose();
|
||||
isofile = IsoFileClose(isofile);
|
||||
deviceopencount = 50;
|
||||
|
||||
// CDVDopen();
|
||||
lastwindow = GetActiveWindow();
|
||||
LoadConf();
|
||||
if((conf.isoname[0] == 0) || (conf.isoname[0] == '[') ||
|
||||
((conf.restartconfigure == 1) && (deviceopencount > 0))) {
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0200),
|
||||
lastwindow,
|
||||
(DLGPROC)MainBoxCallback);
|
||||
SetActiveWindow(lastwindow);
|
||||
LoadConf();
|
||||
// Blank out the name in config file afterwards? Seems excessive.
|
||||
} // ENDIF- Haven't initialized the configure program yet? Do so now.
|
||||
lastwindow = NULL;
|
||||
deviceopencount = 0; // Temp line!
|
||||
// NOTE: What happened to repetitive polling when disc not in drive?
|
||||
|
||||
isofile = IsoFileOpenForRead(conf.isoname);
|
||||
if(isofile == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: Failed to open ISO file!");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
// return(-1); // Removed to simulate disc not in drive.
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = 0;
|
||||
return(0);
|
||||
} // ENDIF- Trouble opening file? Abort.
|
||||
|
||||
retval = IsoFileSeek(isofile, 16);
|
||||
if(retval != 0) return(-1);
|
||||
retval = IsoFileRead(isofile, isobuffer);
|
||||
if(retval != 0) return(-1);
|
||||
|
||||
if(deviceopencount > 0) {
|
||||
i = 0;
|
||||
while((i < 2048) && (isocdcheck[i] == isobuffer[i])) i++;
|
||||
if(i == 2048) deviceopencount = 0; // Same CD/DVD? No delay.
|
||||
} // ENDIF- Is this a restart? Check for disc change.
|
||||
|
||||
for(i = 0; i < 2048; i++) isocdcheck[i] = isobuffer[i];
|
||||
|
||||
return(0);
|
||||
} // END CDVDctrlTrayOpen()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDctrlTrayClose() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDctrlTrayClose()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
return(0);
|
||||
} // END CDVDctrlTrayClose()
|
||||
|
||||
|
||||
s32 CALLBACK CDVDtest() {
|
||||
#ifdef VERBOSE_FUNCTION_INTERFACE
|
||||
PrintLog("CDVDiso interface: CDVDtest()");
|
||||
#endif /* VERBOSE_FUNCTION_INTERFACE */
|
||||
// InitConf(); // Shouldn't need this. Doesn't CDVDInit() get called first?
|
||||
LoadConf();
|
||||
|
||||
if(conf.isoname[0] == 0) return(0); // No name chosen yet. Catch on Open()
|
||||
if(IsIsoFile(conf.isoname) == 0) return(0); // Valid name. Go.
|
||||
return(-1); // Invalid name - reconfigure first.
|
||||
// Note really need this? Why not just return(0)...
|
||||
} // END CDVDtest()
|
||||
|
||||
|
||||
void CALLBACK CDVDconfigure() {
|
||||
HWND lastwindow;
|
||||
|
||||
lastwindow = GetActiveWindow();
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0200),
|
||||
lastwindow,
|
||||
(DLGPROC)MainBoxCallback);
|
||||
SetActiveWindow(lastwindow);
|
||||
lastwindow = NULL;
|
||||
return;
|
||||
} // END CDVDconfigure()
|
||||
|
||||
|
||||
BOOL CALLBACK AboutCallback(HWND window, UINT msg, WPARAM param, LPARAM param2) {
|
||||
switch(msg) {
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(param)) {
|
||||
case IDC_0104: // "Ok" Button
|
||||
EndDialog(window, FALSE);
|
||||
return(TRUE);
|
||||
break;
|
||||
} // ENDSWITCH param- Which Windows Message Command?
|
||||
|
||||
case WM_CLOSE:
|
||||
EndDialog(window, FALSE);
|
||||
return(TRUE);
|
||||
break;
|
||||
} // ENDSWITCH msg- what message has been sent to this window?
|
||||
|
||||
return(FALSE); // Not a recognisable message. Pass it back to the OS.
|
||||
} // END AboutCallback()
|
||||
|
||||
void CALLBACK CDVDabout() {
|
||||
HWND lastwindow;
|
||||
|
||||
lastwindow = GetActiveWindow();
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0100),
|
||||
lastwindow,
|
||||
(DLGPROC)AboutCallback);
|
||||
SetActiveWindow(lastwindow);
|
||||
return;
|
||||
} // END CDVDabout()
|
|
@ -0,0 +1,36 @@
|
|||
/* CDVDiso.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CDVDISO_H
|
||||
#define CDVDISO_H
|
||||
|
||||
|
||||
#include <windows.h> // HINSTANCE
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_INTERFACE
|
||||
|
||||
|
||||
extern HINSTANCE progmodule;
|
||||
extern char isobuffer[];
|
||||
|
||||
|
||||
#endif /* CDVDISO_H */
|
|
@ -0,0 +1,796 @@
|
|||
/* DVD.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ddk/ntddcdvd.h> // IOCTL_DVD...
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#include "device.h" // FinishCommand()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct {
|
||||
|
||||
DVD_DESCRIPTOR_HEADER h;
|
||||
|
||||
DVD_LAYER_DESCRIPTOR d;
|
||||
|
||||
} layer;
|
||||
|
||||
// DVD_LAYER_DESCRIPTOR layer;
|
||||
|
||||
// DVD_COPYRIGHT_DESCRIPTOR copyright;
|
||||
|
||||
// DVD_DISK_KEY_DESCRIPTOR disckey;
|
||||
|
||||
// DVD_BCA_DESCRIPTOR bca;
|
||||
|
||||
// DVD_MANUFACTURER_DESCRIPTOR manufact;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void InitDVDInfo() {
|
||||
|
||||
layer.d.EndDataSector = 0;
|
||||
|
||||
} // END InitDVDInfo()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 DVDGetStructures() {
|
||||
|
||||
DVD_SESSION_ID sessionid;
|
||||
|
||||
DVD_READ_STRUCTURE request;
|
||||
|
||||
DWORD byteswritten;
|
||||
|
||||
BOOL boolresult;
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
s32 retval;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: DVDgetStructures()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
|
||||
IOCTL_DVD_START_SESSION,
|
||||
|
||||
NULL,
|
||||
|
||||
0,
|
||||
|
||||
&sessionid,
|
||||
|
||||
sizeof(DVD_SESSION_ID),
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: Couldn't start session!");
|
||||
|
||||
PrintError("CDVDiso DVD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't start a user session on the DVD drive? Fail.
|
||||
|
||||
|
||||
|
||||
request.BlockByteOffset.QuadPart = 0;
|
||||
|
||||
request.Format = DvdPhysicalDescriptor;
|
||||
|
||||
request.SessionId = sessionid;
|
||||
|
||||
request.LayerNumber = 0;
|
||||
|
||||
retval = 0;
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
|
||||
IOCTL_DVD_READ_STRUCTURE,
|
||||
|
||||
&request,
|
||||
|
||||
sizeof(DVD_READ_STRUCTURE),
|
||||
|
||||
&layer,
|
||||
|
||||
sizeof(layer),
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: Couldn't get layer data!");
|
||||
|
||||
PrintError("CDVDiso DVD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
retval = -1;
|
||||
|
||||
} // ENDIF- Couldn't get layer data? (Including DVD size) Abort.
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
switch(layer.d.BookType) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: DVD-ROM");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: DVD-RAM");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: DVD-R");
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: DVD-RW");
|
||||
|
||||
break;
|
||||
|
||||
case 9:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: DVD+RW");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Type: Unknown (%i)", layer.d.BookType);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- Displaying the Book Type
|
||||
|
||||
PrintLog("CDVDiso DVD: Book Version %i", layer.d.BookVersion);
|
||||
|
||||
switch(layer.d.MinimumRate) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-ROM");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RAM");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-R");
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD-RW");
|
||||
|
||||
break;
|
||||
|
||||
case 9:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: DVD+RW");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Use Minimum Rate for: Unknown (%i)", layer.d.MinimumRate);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- Displaying the Minimum (Spin?) Rate
|
||||
|
||||
switch(layer.d.DiskSize) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Physical Disk Size: 120mm");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Physical Disk Size: 80mm");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Physical Disk Size: Unknown (%i)", layer.d.DiskSize);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- What's the Disk Size?
|
||||
|
||||
switch(layer.d.LayerType) {
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Layer Type: Read-Only");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
PrintLog("CDVDiso DVD: Layer Type: Recordable");
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
PrintLog("CDVDiso DVD: Layer Type: Rewritable");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Layer Type: Unknown (%i)", layer.d.LayerType);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- Displaying the Layer Type
|
||||
|
||||
switch(layer.d.TrackPath) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Path: PTP");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Path: OTP");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Path: Unknown (%i)", layer.d.TrackPath);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- What's Track Path Layout?
|
||||
|
||||
PrintLog("CDVDiso DVD: Number of Layers: %i", layer.d.NumberOfLayers + 1);
|
||||
|
||||
switch(layer.d.TrackDensity) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Density: .74 m/track");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Density: .8 m/track");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Density: .615 m/track");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Track Density: Unknown (%i)", layer.d.TrackDensity);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- Displaying the Layer Type
|
||||
|
||||
switch(layer.d.LinearDensity) {
|
||||
|
||||
case 0:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: .267 m/bit");
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: .293 m/bit");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: .409 to .435 m/bit");
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: .280 to .291 m/bit");
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: .353 m/bit");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
PrintLog("CDVDiso DVD: Linear Density: Unknown (%i)", layer.d.LinearDensity);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH- Displaying the Book Type
|
||||
|
||||
if(layer.d.StartingDataSector == 0x30000) {
|
||||
|
||||
PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)",
|
||||
|
||||
layer.d.StartingDataSector);
|
||||
|
||||
} else if(layer.d.StartingDataSector == 0x31000) {
|
||||
|
||||
PrintLog("CDVDiso DVD: Starting Sector: %lu (DVD-RAM, DVD+RW)",
|
||||
|
||||
layer.d.StartingDataSector);
|
||||
|
||||
} else {
|
||||
|
||||
PrintLog("CDVDiso DVD: Starting Sector: %lu", layer.d.StartingDataSector);
|
||||
|
||||
} // ENDLONGIF- What does the starting sector tell us?
|
||||
|
||||
PrintLog("CDVDiso DVD: End of Layer 0: %lu", layer.d.EndLayerZeroSector);
|
||||
|
||||
PrintLog("CDVDiso DVD: Ending Sector: %lu", layer.d.EndDataSector);
|
||||
|
||||
if(layer.d.BCAFlag != 0) PrintLog("CDVDiso DVD: BCA data present");
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
|
||||
IOCTL_DVD_END_SESSION,
|
||||
|
||||
&sessionid,
|
||||
|
||||
sizeof(DVD_SESSION_ID),
|
||||
|
||||
NULL,
|
||||
|
||||
0,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: Couldn't end the session!");
|
||||
|
||||
PrintError("CDVDiso DVD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
} // ENDIF- Couldn't end the user session? Report it.
|
||||
|
||||
|
||||
|
||||
return(retval);
|
||||
|
||||
} // END DVDGetStructures()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
|
||||
LARGE_INTEGER targetpos;
|
||||
|
||||
DWORD byteswritten;
|
||||
|
||||
BOOL boolresult;
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: DVDreadTrack(%lu)", lsn);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
targetpos.QuadPart = lsn * 2048;
|
||||
|
||||
waitevent.Offset = targetpos.LowPart;
|
||||
|
||||
waitevent.OffsetHigh = targetpos.HighPart;
|
||||
|
||||
|
||||
|
||||
boolresult = ReadFile(devicehandle,
|
||||
|
||||
buffer,
|
||||
|
||||
2048,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
&waitevent);
|
||||
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
|
||||
|
||||
if(errcode != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: Couldn't read sector!");
|
||||
|
||||
PrintError("CDVDiso DVD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble with the command? Report it.
|
||||
|
||||
|
||||
|
||||
if(boolresult == FALSE) {
|
||||
|
||||
boolresult = GetOverlappedResult(devicehandle,
|
||||
|
||||
&waitevent,
|
||||
|
||||
&byteswritten,
|
||||
|
||||
FALSE);
|
||||
|
||||
} // ENDIF- Did the initial call not complete? Get byteswritten for
|
||||
|
||||
// the completed call.
|
||||
|
||||
|
||||
|
||||
if(byteswritten < 2048) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
|
||||
errcode = GetLastError();
|
||||
|
||||
PrintLog("CDVDiso CD: Short block! only got %u out of %u bytes",
|
||||
|
||||
byteswritten, 2048);
|
||||
|
||||
PrintError("CDVDiso CD", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Didn't get enough bytes? Report and Abort!
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END DVDreadTrack()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 DVDgetTN(cdvdTN *cdvdtn) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: DVDgetTN()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
if(cdvdtn != NULL) {
|
||||
|
||||
cdvdtn->strack = 1;
|
||||
|
||||
cdvdtn->etrack = 1;
|
||||
|
||||
} // ENDIF- Does the user really want this data?
|
||||
|
||||
return(0);
|
||||
|
||||
} // END DVDgetTN()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: DVDgetTD()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
if((newtrack >= 2) && (newtrack != 0xAA)) return(-1); // Wrong track
|
||||
|
||||
|
||||
|
||||
if(cdvdtd != NULL) {
|
||||
|
||||
cdvdtd->type = 0;
|
||||
|
||||
cdvdtd->lsn = layer.d.EndDataSector - layer.d.StartingDataSector + 1;
|
||||
|
||||
} // ENDIF- Does the user really want this data?
|
||||
|
||||
return(0);
|
||||
|
||||
} // END DVDgetTD()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
s32 DVDgetDiskType() {
|
||||
|
||||
char playstationname[] = "PLAYSTATION\0";
|
||||
|
||||
int retval;
|
||||
|
||||
s32 tempdisctype;
|
||||
|
||||
char tempbuffer[2048];
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
|
||||
PrintLog("CDVDiso DVD: DVDgetDiskType()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
|
||||
|
||||
retval = DVDGetStructures();
|
||||
|
||||
if(retval < 0) return(-1); // Can't get DVD structures? Not a DVD then.
|
||||
|
||||
if(layer.d.EndDataSector == 0) return(-1); // Missing info? Abort.
|
||||
|
||||
|
||||
|
||||
retval = DVDreadTrack(16, CDVD_MODE_2048, tempbuffer);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't read the ISO9660 volume track? Fail.
|
||||
|
||||
|
||||
|
||||
tempdisctype = CDVD_TYPE_UNKNOWN;
|
||||
|
||||
if(layer.d.NumberOfLayers == 0) {
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
PrintLog("CDVDiso DVD: Found Single-Sided DVD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
disctype = CDVD_TYPE_DETCTDVDS;
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef VERBOSE_DISC_INFO
|
||||
|
||||
PrintLog("CDVDiso DVD: Found Dual-Sided DVD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_INFO */
|
||||
|
||||
disctype = CDVD_TYPE_DETCTDVDD;
|
||||
|
||||
} // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1)
|
||||
|
||||
|
||||
|
||||
i = 0;
|
||||
|
||||
while((playstationname[i] != 0) &&
|
||||
|
||||
(playstationname[i] == tempbuffer[8 + i])) i++;
|
||||
|
||||
if(playstationname[i] == 0) {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("CDVDiso DVD: Found Playstation 2 DVD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_PS2DVD;
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef VERBOSE_DISC_TYPE
|
||||
|
||||
PrintLog("CDVDiso DVD: Guessing it's a Video DVD.");
|
||||
|
||||
#endif /* VERBOSE_DISC_TYPE */
|
||||
|
||||
tempdisctype = CDVD_TYPE_DVDV;
|
||||
|
||||
} // ENDIF- Is this a playstation disc?
|
||||
|
||||
|
||||
|
||||
for(i = 0; i < 2048; i++) tocbuffer[i] = 0;
|
||||
|
||||
|
||||
|
||||
if(layer.d.NumberOfLayers == 0) {
|
||||
|
||||
tocbuffer[0] = 0x04;
|
||||
|
||||
tocbuffer[4] = 0x86;
|
||||
|
||||
tocbuffer[5] = 0x72;
|
||||
|
||||
} else {
|
||||
|
||||
tocbuffer[0] = 0x24;
|
||||
|
||||
tocbuffer[4] = 0x41;
|
||||
|
||||
tocbuffer[5] = 0x95;
|
||||
|
||||
} // ENDIF- Are we looking at a single layer DVD? (NumberOfLayers + 1)
|
||||
|
||||
|
||||
|
||||
tocbuffer[1] = 0x02;
|
||||
|
||||
tocbuffer[2] = 0xF2;
|
||||
|
||||
tocbuffer[3] = 0x00;
|
||||
|
||||
|
||||
|
||||
tocbuffer[16] = 0x00;
|
||||
|
||||
tocbuffer[17] = 0x03;
|
||||
|
||||
tocbuffer[18] = 0x00;
|
||||
|
||||
tocbuffer[19] = 0x00;
|
||||
|
||||
|
||||
|
||||
disctype = tempdisctype;
|
||||
|
||||
return(disctype);
|
||||
|
||||
} // END DVDgetDiskType()
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/* DVD.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DVD_H
|
||||
#define DVD_H
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
extern void InitDVDInfo();
|
||||
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 DVDgetTN(cdvdTN *cdvdtn);
|
||||
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
|
||||
extern s32 DVDgetDiskType();
|
||||
|
||||
|
||||
#endif /* DVD_H */
|
|
@ -0,0 +1,59 @@
|
|||
all: plugin
|
||||
|
||||
PLUGIN = CDVDisoEFP.dll
|
||||
CC = mingw32-gcc.exe
|
||||
|
||||
PLUGINOBJS = CDVDiso.o mainbox.o tablerebuild.o progressbox.o conversionbox.o \
|
||||
devicebox.o device.o DVD.o CD.o
|
||||
PLUGINHEADERS = CDVDiso.h mainbox.h tablerebuild.h progressbox.h conversionbox.h \
|
||||
devicebox.h device.h DVD.h CD.h
|
||||
PLUGINFLAGS = -Wall -O2 -D_WIN32 -D_LARGEFILE64_SOURCE -I.. -I. -I./Win32 -mwindows
|
||||
PLUGINLIBS = -L./ -lcomctl32 -lwsock32 -lwinmm -lgdi32 -lcomdlg32 -lkernel32 \
|
||||
-luser32 --subsystem,windows
|
||||
# Note: Don't think we need all the above libs... will pare down later.
|
||||
|
||||
SHAREDOBJS = ..\\version.o conf.o ..\\isofile.o actualfile.o logfile.o \
|
||||
..\\imagetype.o ..\\multifile.o ..\\isocompress.o ..\\convert.o \
|
||||
..\\gzipv1.o ..\\blockv2.o ..\\gzipv2.o ..\\bzip2v2.o ..\\ecma119.o \
|
||||
..\\toc.o ..\\ini.o ..\\bzip2v3.o \
|
||||
..\\zlib\\adler32.o ..\\zlib\\compress.o ..\\zlib\\crc32.o \
|
||||
..\\zlib\\gzio.o ..\\zlib\\uncompr.o ..\\zlib\\deflate.o \
|
||||
..\\zlib\\trees.o ..\\zlib\\zutil.o ..\\zlib\\inflate.o \
|
||||
..\\zlib\\infback.o ..\\zlib\\inftrees.o ..\\zlib\\inffast.o \
|
||||
..\\bzip2\\blocksort.o ..\\bzip2\\bzlib.o ..\\bzip2\\compress.o \
|
||||
..\\bzip2\\crctable.o ..\\bzip2\\decompress.o ..\\bzip2\\huffman.o \
|
||||
..\\bzip2\\randtable.o
|
||||
SHAREDHEADERS = ..\\version.h conf.h ..\\isofile.h actualfile.h logfile.h \
|
||||
..\\imagetype.h ..\\multifile.h ..\\isocompress.h ..\\convert.h \
|
||||
..\\gzipv1.h ..\\blockv2.o ..\\gzipv2.h ..\\bzip2v2.h ..\\ecma119.h \
|
||||
..\\toc.h ..\\ini.h ..\\bzip2v3.o
|
||||
|
||||
|
||||
|
||||
WINDRES = windres.exe
|
||||
|
||||
|
||||
|
||||
release: plugin
|
||||
copy $(PLUGIN) ..\\..
|
||||
|
||||
plugin: $(PLUGINOBJS) $(SHAREDOBJS) screens.res
|
||||
-del $(PLUGIN)
|
||||
dllwrap --def plugin.def -o $(PLUGIN) $(PLUGINOBJS) screens.res $(SHAREDOBJS) $(PLUGINLIBS)
|
||||
strip --strip-unneeded --strip-debug $(PLUGIN)
|
||||
|
||||
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
|
||||
$(CC) $(PLUGINFLAGS) -c $< -o $@
|
||||
|
||||
screens.res: screens.rc
|
||||
$(WINDRES) -i screens.rc -J rc -o screens.res -O coff
|
||||
|
||||
.PHONY : clean allclean
|
||||
clean:
|
||||
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
|
||||
|
||||
allclean:
|
||||
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
|
||||
-del temp.txt err.txt ..\\temp.txt ..\\err.txt
|
||||
-del ..\\..\\$(PLUGIN)
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
PLUGIN = CDVDisoEFP.dll
|
||||
PLUGINOBJS = CDVDiso.o mainbox.o tablerebuild.o progressbox.o conversionbox.o \
|
||||
devicebox.o device.o DVD.o CD.o
|
||||
PLUGINHEADERS = CDVDiso.h mainbox.h tablerebuild.h progressbox.h conversionbox.h \
|
||||
devicebox.h device.h DVD.h CD.h
|
||||
PLUGINFLAGS = -Wall -O2 -D_LARGEFILE64_SOURCE -I.. -I. -I./Win32 -mwindows
|
||||
PLUGINLIBS = -L./ -lcomctl32 -lwsock32 -lwinmm -lgdi32 -lcomdlg32 -lkernel32 \
|
||||
-luser32 --subsystem,windows
|
||||
# Note: Don't think we need all the above libs... will pare down later.
|
||||
|
||||
SHAREDOBJS = ..\\version.o conf.o ..\\isofile.o actualfile.o logfile.o \
|
||||
..\\imagetype.o ..\\multifile.o ..\\isocompress.o ..\\convert.o \
|
||||
..\\gzipv1.o ..\\blockv2.o ..\\gzipv2.o ..\\bzip2v2.o ..\\ecma119.o \
|
||||
..\\toc.o ..\\ini.o ..\\bzip2v3.o \
|
||||
..\\zlib\\adler32.o ..\\zlib\\compress.o ..\\zlib\\crc32.o \
|
||||
..\\zlib\\gzio.o ..\\zlib\\uncompr.o ..\\zlib\\deflate.o \
|
||||
..\\zlib\\trees.o ..\\zlib\\zutil.o ..\\zlib\\inflate.o \
|
||||
..\\zlib\\infback.o ..\\zlib\\inftrees.o ..\\zlib\\inffast.o \
|
||||
..\\bzip2\\blocksort.o ..\\bzip2\\bzlib.o ..\\bzip2\\compress.o \
|
||||
..\\bzip2\\crctable.o ..\\bzip2\\decompress.o ..\\bzip2\\huffman.o \
|
||||
..\\bzip2\\randtable.o
|
||||
SHAREDHEADERS = ..\\version.h conf.h ..\\isofile.h actualfile.h logfile.h \
|
||||
..\\imagetype.h ..\\multifile.h ..\\isocompress.h ..\\convert.h \
|
||||
..\\gzipv1.h ..\\blockv2.o ..\\gzipv2.h ..\\bzip2v2.h ..\\ecma119.h \
|
||||
..\\toc.h ..\\ini.h ..\\bzip2v3.o
|
||||
|
||||
|
||||
CC = mingw32-gcc.exe
|
||||
WINDRES = windres.exe
|
||||
|
||||
|
||||
all: plugin
|
||||
|
||||
release: plugin
|
||||
copy $(PLUGIN) ..\\..
|
||||
|
||||
plugin: $(PLUGINOBJS) $(SHAREDOBJS) screens.res
|
||||
-del $(PLUGIN)
|
||||
dllwrap --def plugin.def -o $(PLUGIN) $(PLUGINOBJS) screens.res $(SHAREDOBJS) $(PLUGINLIBS)
|
||||
strip --strip-unneeded --strip-debug $(PLUGIN)
|
||||
|
||||
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
|
||||
$(CC) $(PLUGINFLAGS) -c $< -o $@
|
||||
|
||||
screens.res: screens.rc
|
||||
$(WINDRES) -i screens.rc -J rc -o screens.res -O coff
|
||||
|
||||
.PHONY : clean allclean
|
||||
clean:
|
||||
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
|
||||
|
||||
allclean:
|
||||
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
|
||||
-del temp.txt err.txt ..\\temp.txt ..\\err.txt
|
||||
-del ..\\..\\$(PLUGIN)
|
||||
|
|
@ -0,0 +1,506 @@
|
|||
/* actualfile.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#include "actualfile.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int IsActualFile(const char *filename) {
|
||||
|
||||
DWORD retval;
|
||||
|
||||
|
||||
|
||||
if(filename == NULL) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: IsActualFile(%s)", filename);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
retval = GetFileAttributes(filename);
|
||||
|
||||
if(retval == INVALID_FILE_ATTRIBUTES) return(-1); // Name doesn't exist.
|
||||
|
||||
if((retval & FILE_ATTRIBUTE_DIRECTORY) != 0) return(-2);
|
||||
|
||||
|
||||
|
||||
return(0); // Yep, that's a file.
|
||||
|
||||
} // END IsActualFile()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ActualFileDelete(const char *filename) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileDelete(%s)", filename);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
DeleteFile(filename);
|
||||
|
||||
} // END ActualFileDelete()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ActualFileRename(const char *origname, const char *newname) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileDelete(%s->%s)", origname, newname);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
MoveFile(origname, newname);
|
||||
|
||||
return;
|
||||
|
||||
} // END ActualFileRename()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
|
||||
|
||||
HANDLE newhandle;
|
||||
|
||||
|
||||
|
||||
if(filename == NULL) return(NULL);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
newhandle = CreateFile(filename,
|
||||
|
||||
GENERIC_READ,
|
||||
|
||||
FILE_SHARE_READ,
|
||||
|
||||
NULL,
|
||||
|
||||
OPEN_EXISTING,
|
||||
|
||||
FILE_FLAG_RANDOM_ACCESS,
|
||||
|
||||
NULL);
|
||||
|
||||
if(newhandle == INVALID_HANDLE_VALUE) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: Error opening file %s", filename);
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
return(NULL);
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
||||
|
||||
return(newhandle);
|
||||
|
||||
} // END ActualFileOpenForRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
off64_t ActualFileSize(ACTUALHANDLE handle) {
|
||||
|
||||
int retval;
|
||||
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
|
||||
off64_t retsize;
|
||||
|
||||
|
||||
|
||||
if(handle == NULL) return(-1);
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileSize()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
retval = GetFileInformationByHandle(handle, &info);
|
||||
|
||||
if(retval == 0) return(-1); // Handle doesn't exist...
|
||||
|
||||
|
||||
|
||||
retsize = info.nFileSizeHigh;
|
||||
|
||||
retsize *= 0x10000;
|
||||
|
||||
retsize *= 0x10000;
|
||||
|
||||
retsize += info.nFileSizeLow;
|
||||
|
||||
return(retsize);
|
||||
|
||||
} // END ActualFileSize()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
|
||||
|
||||
// int retval;
|
||||
|
||||
LARGE_INTEGER realpos;
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
|
||||
|
||||
if(handle == NULL) return(-1);
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(position < 0) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileSeek(%llu)", position);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
realpos.QuadPart = position;
|
||||
|
||||
////// WinXP code for seek
|
||||
|
||||
// retval = SetFilePointerEx(handle,
|
||||
|
||||
// realpos,
|
||||
|
||||
// NULL,
|
||||
|
||||
// FILE_BEGIN);
|
||||
|
||||
// if(retval == 0) {
|
||||
|
||||
|
||||
|
||||
////// Win98 code for seek
|
||||
|
||||
realpos.LowPart = SetFilePointer(handle,
|
||||
|
||||
realpos.LowPart,
|
||||
|
||||
&realpos.HighPart,
|
||||
|
||||
FILE_BEGIN);
|
||||
|
||||
errcode = GetLastError();
|
||||
|
||||
if((realpos.LowPart == 0xFFFFFFFF) && (errcode != NO_ERROR)) {
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: Error on seek (%llu)", position);
|
||||
|
||||
PrintError("CDVDiso file", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END ActualFileSeek()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
DWORD bytesread;
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
DWORD errcode;
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
if(handle == NULL) return(-1);
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(bytes < 1) return(-1);
|
||||
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
retval = ReadFile(handle, buffer, bytes, &bytesread, NULL);
|
||||
|
||||
if(retval == 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
errcode = GetLastError();
|
||||
|
||||
PrintLog("CDVDiso file: Error reading from file");
|
||||
|
||||
PrintError("CDVDiso file", errcode);
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
if(bytesread < bytes) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: Short Block! Only read %i out of %i bytes", bytesread, bytes);
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
||||
|
||||
return(bytesread); // Send back how many bytes read
|
||||
|
||||
} // END ActualFileRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ActualFileClose(ACTUALHANDLE handle) {
|
||||
|
||||
if(handle == NULL) return;
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE) return;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileClose()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
CloseHandle(handle);
|
||||
|
||||
return;
|
||||
|
||||
} // END ActualFileClose()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
|
||||
|
||||
HANDLE newhandle;
|
||||
|
||||
|
||||
|
||||
if(filename == NULL) return(NULL);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
newhandle = CreateFile(filename,
|
||||
|
||||
GENERIC_WRITE,
|
||||
|
||||
0,
|
||||
|
||||
NULL,
|
||||
|
||||
CREATE_ALWAYS,
|
||||
|
||||
FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
|
||||
NULL);
|
||||
|
||||
if(newhandle == INVALID_HANDLE_VALUE) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: Error opening file %s", filename);
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
return(NULL);
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
||||
|
||||
return(newhandle);
|
||||
|
||||
} // END ActualFileOpenForWrite()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
DWORD byteswritten;
|
||||
|
||||
|
||||
|
||||
if(handle == NULL) return(-1);
|
||||
|
||||
if(handle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(bytes < 1) return(-1);
|
||||
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
|
||||
|
||||
retval = WriteFile(handle, buffer, bytes, &byteswritten, NULL);
|
||||
|
||||
if(retval == 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
PrintLog("CDVDiso file: Error writing to file!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
|
||||
// return(-1);
|
||||
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
||||
|
||||
return(byteswritten); // Send back how many bytes written
|
||||
|
||||
} // END ActualFileWrite()
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* actualfile.h
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef ACTUALFILE_H
|
||||
|
||||
#define ACTUALFILE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#define ACTUALHANDLE HANDLE
|
||||
|
||||
#define ACTUALHANDLENULL NULL
|
||||
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_ACTUALFILE
|
||||
|
||||
// #define VERBOSE_WARNING_ACTUALFILE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int IsActualFile(const char *filename);
|
||||
|
||||
extern void ActualFileDelete(const char *filename);
|
||||
|
||||
extern void ActualFileRename(const char *origname, const char *newname);
|
||||
|
||||
|
||||
|
||||
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
|
||||
|
||||
extern off64_t ActualFileSize(ACTUALHANDLE handle);
|
||||
|
||||
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
|
||||
|
||||
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
|
||||
|
||||
extern void ActualFileClose(ACTUALHANDLE handle);
|
||||
|
||||
|
||||
|
||||
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
|
||||
|
||||
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* ACTUALFILE_H */
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
/* conf.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#include <errno.h> // errno
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <stdlib.h> // getenv()
|
||||
#include <string.h> // strerror()
|
||||
#include <sys/stat.h> // mkdir(), stat()
|
||||
#include <sys/types.h> // mkdir(), stat(), fork()
|
||||
#include <unistd.h> // stat(), fork(), execlp()
|
||||
|
||||
#include <windows.h> // CreateProcess()
|
||||
|
||||
// #define CDVDdefs
|
||||
// #include "../PS2Edefs.h"
|
||||
#include "../PS2Etypes.h" // u8
|
||||
#include "logfile.h"
|
||||
#include "../ini.h"
|
||||
#include "conf.h"
|
||||
|
||||
|
||||
const char *confnames[] = { "IsoFile", "Device", "OpenOnStart", "OpenOnRestart", NULL };
|
||||
const u8 defaultdevice[] = DEFAULT_DEVICE;
|
||||
const char defaulthome[] = "inis";
|
||||
const char defaultdirectory[] = "HideMe.PS2E";
|
||||
const char defaultfile[] = "CDVDisoEFP.ini";
|
||||
|
||||
char confdirname[256];
|
||||
char conffilename[256];
|
||||
|
||||
CDVDconf conf;
|
||||
|
||||
|
||||
void InitConf() {
|
||||
DWORD retval;
|
||||
int i;
|
||||
int pos;
|
||||
char *envptr;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: InitConf()");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
conf.isoname[0] = 0; // Empty the iso name
|
||||
|
||||
i = 0;
|
||||
while((i < 255) && defaultdevice[i] != 0) {
|
||||
conf.devicename[i] = defaultdevice[i];
|
||||
i++;
|
||||
} // ENDWHILE- copying the default CD/DVD name in
|
||||
conf.devicename[i] = 0; // 0-terminate the device name
|
||||
|
||||
// Locating directory and file positions
|
||||
pos = 0;
|
||||
envptr = NULL;
|
||||
// envptr = getenv("HOME");
|
||||
if(envptr == NULL) {
|
||||
// = <Default Home>
|
||||
retval = GetCurrentDirectory(253, confdirname);
|
||||
if(retval > 0) {
|
||||
pos = retval;
|
||||
} else {
|
||||
pos = 2;
|
||||
confdirname[0] = '.';
|
||||
confdirname[1] = '\\';
|
||||
} // ENDIF- Did we retrieve a directory reference?
|
||||
|
||||
i = 0;
|
||||
while(i < pos) {
|
||||
conffilename[i] = confdirname[i];
|
||||
i++;
|
||||
} // ENDWHILE- Copying dir info (so far) into file info
|
||||
|
||||
if(confdirname[pos-1] != '\\') {
|
||||
confdirname[pos] = '\\';
|
||||
conffilename[pos] = '\\';
|
||||
pos++;
|
||||
} // ENDIF- No directory separator here? Add one.
|
||||
|
||||
i = 0;
|
||||
while((pos < 253) && (defaulthome[i] != 0)) {
|
||||
confdirname[pos] = defaulthome[i];
|
||||
conffilename[pos] = defaulthome[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // ENDWHILE- putting an offset where to store ini data
|
||||
|
||||
} else {
|
||||
// = <Env Home>/<Default Directory>
|
||||
i = 0;
|
||||
while((pos < 253) && (*(envptr + i) != 0)) {
|
||||
confdirname[pos] = *(envptr + i);
|
||||
conffilename[pos] = *(envptr + i);
|
||||
pos++;
|
||||
i++;
|
||||
} // ENDWHILE- copying home directory info in
|
||||
|
||||
if(confdirname[pos-1] != '\\') {
|
||||
confdirname[pos] = '\\';
|
||||
conffilename[pos] = '\\';
|
||||
pos++;
|
||||
} // ENDIF- No directory separator here? Add one.
|
||||
|
||||
i = 0;
|
||||
while((pos < 253) && (defaultdirectory[i] != 0)) {
|
||||
confdirname[pos] = defaultdirectory[i];
|
||||
conffilename[pos] = defaultdirectory[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // NEXT- putting a default place to store configuration data
|
||||
} // ENDIF- No Home directory?
|
||||
|
||||
confdirname[pos] = 0; // Directory reference finished
|
||||
|
||||
// += /<Config File Name>
|
||||
if(conffilename[pos-1] != '\\') {
|
||||
conffilename[pos] = '\\';
|
||||
pos++;
|
||||
} // ENDIF- No directory separator here? Add one.
|
||||
|
||||
i = 0;
|
||||
while((pos < 253) && (defaultfile[i] != 0)) {
|
||||
conffilename[pos] = defaultfile[i];
|
||||
pos++;
|
||||
i++;
|
||||
} // NEXT- putting a default place to store configuration data
|
||||
|
||||
conffilename[pos] = 0; // File reference finished
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: Directory: %s", confdirname);
|
||||
PrintLog("CDVD config: File: %s", conffilename);
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
} // END InitConf()
|
||||
|
||||
|
||||
void LoadConf() {
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: LoadConf()");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname);
|
||||
if(retval < 0) {
|
||||
sprintf(conf.isoname, "[Put an Image File here]");
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
|
||||
if(retval < 0) {
|
||||
sprintf(conf.devicename, "D:");
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure);
|
||||
if(retval < 0) {
|
||||
conf.startconfigure = 0; // FALSE
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
|
||||
retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure);
|
||||
if(retval < 0) {
|
||||
conf.restartconfigure = 1; // TRUE
|
||||
} // ENDIF- Couldn't find keyword? Fill in a default
|
||||
} // END LoadConf()
|
||||
|
||||
|
||||
void SaveConf() {
|
||||
#ifdef VERBOSE_FUNCTION_CONF
|
||||
PrintLog("CDVD config: SaveConf()");
|
||||
#endif /* VERBOSE_FUNCTION_CONF */
|
||||
|
||||
mkdir(confdirname);
|
||||
|
||||
INISaveString(conffilename, "Settings", "IsoFile", conf.isoname);
|
||||
INISaveString(conffilename, "Settings", "Device", conf.devicename);
|
||||
INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure);
|
||||
INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure);
|
||||
} // END SaveConf()
|
|
@ -0,0 +1,54 @@
|
|||
/* conf.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef CONF_H
|
||||
#define CONF_H
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
|
||||
#define VERBOSE_FUNCTION_CONF
|
||||
|
||||
|
||||
// Configuration Data
|
||||
|
||||
typedef struct {
|
||||
u8 isoname[256];
|
||||
u8 devicename[256];
|
||||
unsigned int startconfigure;
|
||||
unsigned int restartconfigure;
|
||||
} CDVDconf;
|
||||
extern CDVDconf conf;
|
||||
|
||||
#define DEFAULT_DEVICE "K:\\"
|
||||
|
||||
|
||||
// Configuration Functions
|
||||
|
||||
extern void InitConf();
|
||||
extern void LoadConf();
|
||||
extern void SaveConf();
|
||||
|
||||
extern void ExecCfg(char *arg);
|
||||
|
||||
|
||||
#endif /* CONF_H */
|
|
@ -0,0 +1,750 @@
|
|||
/* conversionbox.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <windowsx.h> // ComboBox_AddString(), CheckDlgButton()
|
||||
|
||||
#include <windef.h> // NULL
|
||||
|
||||
// #include <commctrl.h>
|
||||
|
||||
|
||||
|
||||
#include <stdio.h> // sprintf()
|
||||
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#include "isofile.h"
|
||||
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
|
||||
#include "imagetype.h" // imagedata[]
|
||||
|
||||
#include "multifile.h" // multinames[]
|
||||
|
||||
#include "toc.h"
|
||||
|
||||
#include "progressbox.h"
|
||||
|
||||
#include "mainbox.h"
|
||||
|
||||
#include "screens.h" // DLG_..., IDC_...
|
||||
|
||||
#include "conversionbox.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HWND conversionboxwindow;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxDestroy() {
|
||||
|
||||
if(conversionboxwindow != NULL) {
|
||||
|
||||
EndDialog(conversionboxwindow, FALSE);
|
||||
|
||||
conversionboxwindow = NULL;
|
||||
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
|
||||
} // END ConversionBoxDestroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxUnfocus() {
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.file, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.selectbutton, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.compress, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.multi, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.okbutton, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.cancelbutton, FALSE);
|
||||
|
||||
ShowWindow(conversionboxwindow, SW_HIDE);
|
||||
|
||||
} // END ConversionBoxUnfocus()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxFileEvent() {
|
||||
|
||||
int returnval;
|
||||
|
||||
char templine[256];
|
||||
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(conversionboxwindow, IDC_0402, templine, 256);
|
||||
|
||||
returnval = IsIsoFile(templine);
|
||||
|
||||
if(returnval == -1) {
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: ---");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
|
||||
|
||||
if(returnval == -2) {
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a file");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
if(returnval == -3) {
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Not a valid image file");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
if(returnval == -4) {
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0404, "File Type: Missing Table File (will rebuild)");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
tempfile = IsoFileOpenForRead(templine);
|
||||
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
|
||||
multinames[tempfile->multi],
|
||||
|
||||
tempfile->imagename,
|
||||
|
||||
compressdesc[tempfile->compress]);
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0404, templine);
|
||||
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
|
||||
return;
|
||||
|
||||
} // END ConversionBoxFileEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxRefocus() {
|
||||
|
||||
ConversionBoxFileEvent();
|
||||
|
||||
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.file, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.selectbutton, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.compress, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.multi, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.okbutton, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(conversionbox.cancelbutton, TRUE);
|
||||
|
||||
// gtk_window_set_focus(GTK_WINDOW(conversionbox.window), conversionbox.file);
|
||||
|
||||
ShowWindow(conversionboxwindow, SW_SHOW);
|
||||
|
||||
SetActiveWindow(conversionboxwindow);
|
||||
|
||||
} // END ConversionBoxRefocus()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxCancelEvent() {
|
||||
|
||||
// ShowWindow(conversionboxwindow, SW_HIDE);
|
||||
|
||||
ConversionBoxDestroy();
|
||||
|
||||
MainBoxRefocus();
|
||||
|
||||
return;
|
||||
|
||||
} // END ConversionBoxCancelEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxOKEvent() {
|
||||
|
||||
char templine[256];
|
||||
|
||||
char tempblock[2352];
|
||||
|
||||
char filename[256];
|
||||
|
||||
HWND tempitem;
|
||||
|
||||
int compressmethod;
|
||||
|
||||
int multi;
|
||||
|
||||
struct IsoFile *fromfile;
|
||||
|
||||
struct IsoFile *tofile;
|
||||
|
||||
int i;
|
||||
|
||||
off64_t endsector;
|
||||
|
||||
int stop;
|
||||
|
||||
int retval;
|
||||
|
||||
|
||||
|
||||
ConversionBoxUnfocus();
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(conversionboxwindow, IDC_0402, filename, 256);
|
||||
|
||||
if(IsIsoFile(filename) < 0) {
|
||||
|
||||
ConversionBoxRefocus();
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Not a Valid Image File.",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
|
||||
|
||||
tempitem = GetDlgItem(conversionboxwindow, IDC_0406);
|
||||
|
||||
compressmethod = ComboBox_GetCurSel(tempitem);
|
||||
|
||||
tempitem = NULL;
|
||||
|
||||
if(compressmethod > 0) compressmethod += 2;
|
||||
|
||||
|
||||
|
||||
multi = 0;
|
||||
|
||||
if(IsDlgButtonChecked(conversionboxwindow, IDC_0408)) multi = 1;
|
||||
|
||||
|
||||
|
||||
fromfile = NULL;
|
||||
|
||||
fromfile = IsoFileOpenForRead(filename);
|
||||
|
||||
if(fromfile == NULL) {
|
||||
|
||||
ConversionBoxRefocus();
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Cannot opening the source file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
|
||||
|
||||
if((compressmethod == fromfile->compress) &&
|
||||
|
||||
(multi == fromfile->multi)) {
|
||||
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
|
||||
ConversionBoxRefocus();
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Compress/Multifile methods match - no need to convert",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
|
||||
|
||||
tofile = IsoFileOpenForWrite(filename,
|
||||
|
||||
GetImageTypeConvertTo(fromfile->imagetype),
|
||||
|
||||
multi,
|
||||
|
||||
compressmethod);
|
||||
|
||||
if(tofile == NULL) {
|
||||
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
|
||||
ConversionBoxRefocus();
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Cannot create the new file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not an Iso File? Stop early.
|
||||
|
||||
|
||||
|
||||
if(fromfile->multi == 1) {
|
||||
|
||||
i = 0;
|
||||
|
||||
while((i < 10) &&
|
||||
|
||||
(IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0)) i++;
|
||||
|
||||
endsector = fromfile->multisectorend[fromfile->multiend];
|
||||
|
||||
} else {
|
||||
|
||||
endsector = fromfile->filesectorsize;
|
||||
|
||||
} // ENDIF- Get ending sector from multifile? (Or single file?)
|
||||
|
||||
IsoFileSeek(fromfile, 0);
|
||||
|
||||
|
||||
|
||||
// Open Progress Bar
|
||||
|
||||
sprintf(templine, "%s: %s%s -> %s%s",
|
||||
|
||||
filename,
|
||||
|
||||
multinames[fromfile->multi],
|
||||
|
||||
compressdesc[fromfile->compress],
|
||||
|
||||
multinames[tofile->multi],
|
||||
|
||||
compressdesc[tofile->compress]);
|
||||
|
||||
ProgressBoxStart(templine, endsector);
|
||||
|
||||
|
||||
|
||||
tofile->cdvdtype = fromfile->cdvdtype;
|
||||
|
||||
for(i = 0; i < 2048; i++) tofile->toc[i] = fromfile->toc[i];
|
||||
|
||||
|
||||
|
||||
stop = 0;
|
||||
|
||||
mainboxstop = 0;
|
||||
|
||||
progressboxstop = 0;
|
||||
|
||||
while((stop == 0) && (tofile->sectorpos < endsector)) {
|
||||
|
||||
retval = IsoFileRead(fromfile, tempblock);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Trouble reading source file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
stop = 1;
|
||||
|
||||
} else {
|
||||
|
||||
retval = IsoFileWrite(tofile, tempblock);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
MessageBox(conversionboxwindow,
|
||||
|
||||
"Trouble writing new file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
stop = 1;
|
||||
|
||||
} // ENDIF- Trouble writing out the next block?
|
||||
|
||||
} // ENDIF- Trouble reading in the next block?
|
||||
|
||||
|
||||
|
||||
ProgressBoxTick(tofile->sectorpos);
|
||||
|
||||
|
||||
|
||||
if(mainboxstop != 0) stop = 2;
|
||||
|
||||
if(progressboxstop != 0) stop = 2;
|
||||
|
||||
} // ENDWHILE- Not stopped for some reason...
|
||||
|
||||
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
|
||||
|
||||
if(stop == 0) {
|
||||
|
||||
if(tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
|
||||
|
||||
strcpy(templine, tofile->name);
|
||||
|
||||
|
||||
|
||||
// fromfile = IsoFileCloseAndDelete(fromfile);
|
||||
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
|
||||
|
||||
|
||||
IsoSaveTOC(tofile);
|
||||
|
||||
tofile = IsoFileClose(tofile);
|
||||
|
||||
SetDlgItemText(mainboxwindow, IDC_0202, templine);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
fromfile = IsoFileClose(fromfile);
|
||||
|
||||
tofile = IsoFileCloseAndDelete(tofile);
|
||||
|
||||
} // ENDIF- Did we succeed in the transfer?
|
||||
|
||||
|
||||
|
||||
ConversionBoxRefocus();
|
||||
|
||||
if(stop == 0) ConversionBoxCancelEvent();
|
||||
|
||||
return;
|
||||
|
||||
} // END ConversionBoxOKEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxBrowseEvent() {
|
||||
|
||||
OPENFILENAME filebox;
|
||||
|
||||
char newfilename[256];
|
||||
|
||||
BOOL returnbool;
|
||||
|
||||
|
||||
|
||||
filebox.lStructSize = sizeof(filebox);
|
||||
|
||||
filebox.hwndOwner = conversionboxwindow;
|
||||
|
||||
filebox.hInstance = NULL;
|
||||
|
||||
filebox.lpstrFilter = fileselection;
|
||||
|
||||
filebox.lpstrCustomFilter = NULL;
|
||||
|
||||
filebox.nFilterIndex = 0;
|
||||
|
||||
filebox.lpstrFile = newfilename;
|
||||
|
||||
filebox.nMaxFile = 256;
|
||||
|
||||
filebox.lpstrFileTitle = NULL;
|
||||
|
||||
filebox.nMaxFileTitle = 0;
|
||||
|
||||
filebox.lpstrInitialDir = NULL;
|
||||
|
||||
filebox.lpstrTitle = NULL;
|
||||
|
||||
filebox.Flags = OFN_FILEMUSTEXIST
|
||||
|
||||
| OFN_NOCHANGEDIR
|
||||
|
||||
| OFN_HIDEREADONLY;
|
||||
|
||||
filebox.nFileOffset = 0;
|
||||
|
||||
filebox.nFileExtension = 0;
|
||||
|
||||
filebox.lpstrDefExt = NULL;
|
||||
|
||||
filebox.lCustData = 0;
|
||||
|
||||
filebox.lpfnHook = NULL;
|
||||
|
||||
filebox.lpTemplateName = NULL;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(conversionboxwindow, IDC_0402, newfilename, 256);
|
||||
|
||||
returnbool = GetOpenFileName(&filebox);
|
||||
|
||||
if(returnbool != FALSE) {
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0402, newfilename);
|
||||
|
||||
} // ENDIF- User actually selected a name? Save it.
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END ConversionBoxBrowseEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ConversionBoxDisplay() {
|
||||
|
||||
char templine[256];
|
||||
|
||||
HWND itemptr;
|
||||
|
||||
int itemcount;
|
||||
|
||||
|
||||
|
||||
// Adjust window position?
|
||||
|
||||
|
||||
|
||||
// Pull the name from the Main Window... for a starting place.
|
||||
|
||||
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
|
||||
|
||||
SetDlgItemText(conversionboxwindow, IDC_0402, templine);
|
||||
|
||||
|
||||
|
||||
// ConversionBoxFileEvent(); // Needed?
|
||||
|
||||
|
||||
|
||||
itemptr = GetDlgItem(conversionboxwindow, IDC_0406); // Compression Combo
|
||||
|
||||
itemcount = 0;
|
||||
|
||||
while(compressnames[itemcount] != NULL) {
|
||||
|
||||
ComboBox_AddString(itemptr, compressnames[itemcount]);
|
||||
|
||||
itemcount++;
|
||||
|
||||
} // ENDWHILE- loading compression types into combo box
|
||||
|
||||
ComboBox_SetCurSel(itemptr, 0); // First Selection?
|
||||
|
||||
itemptr = NULL;
|
||||
|
||||
|
||||
|
||||
CheckDlgButton(conversionboxwindow, IDC_0408, FALSE); // Start unchecked
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END ConversionBoxDisplay()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL CALLBACK ConversionBoxCallback(HWND window,
|
||||
|
||||
UINT msg,
|
||||
|
||||
WPARAM param,
|
||||
|
||||
LPARAM param2) {
|
||||
|
||||
switch(msg) {
|
||||
|
||||
case WM_INITDIALOG:
|
||||
|
||||
conversionboxwindow = window;
|
||||
|
||||
ConversionBoxDisplay(); // Final touches to this window
|
||||
|
||||
return(FALSE); // Let Windows display this window
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_CLOSE: // The "X" in the upper right corner was hit.
|
||||
|
||||
ConversionBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_COMMAND:
|
||||
|
||||
switch(LOWORD(param)) {
|
||||
|
||||
case IDC_0402: // Filename Edit Box
|
||||
|
||||
ConversionBoxFileEvent(); // Describe the File's current type...
|
||||
|
||||
return(FALSE); // Let Windows edit the text.
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0403: // "Browse" Button
|
||||
|
||||
ConversionBoxBrowseEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0409: // "Change File" Button
|
||||
|
||||
ConversionBoxOKEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0410: // "Cancel" Button
|
||||
|
||||
ConversionBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH param- Which object got the message?
|
||||
|
||||
} // ENDSWITCH msg- what message has been sent to this window?
|
||||
|
||||
|
||||
|
||||
return(FALSE);
|
||||
|
||||
} // END ConversionBoxEventLoop()
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/* conversionbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CONVERSIONBOX_H
|
||||
#define CONVERSIONBOX_H
|
||||
|
||||
|
||||
#include <windows.h> // HWND
|
||||
|
||||
|
||||
extern HWND conversionboxwindow;
|
||||
|
||||
extern void ConversionBoxDestroy();
|
||||
extern void ConversionBoxRefocus();
|
||||
extern void ConversionBoxDisplay();
|
||||
extern BOOL CALLBACK ConversionBoxCallback(HWND window,
|
||||
UINT msg,
|
||||
WPARAM param,
|
||||
LPARAM param2);
|
||||
|
||||
|
||||
#endif /* CONVERSIONBOX_H */
|
|
@ -0,0 +1,586 @@
|
|||
/* device.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddcdrm.h> // IOCTL_CDROM..., IOCTL_STORAGE...
|
||||
#include <ddk/ntdddisk.h> // IOCTL_DISK...
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <time.h> // time_t
|
||||
|
||||
#define CDVDdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
#include "logfile.h"
|
||||
#include "conf.h"
|
||||
#include "CD.h"
|
||||
#include "DVD.h"
|
||||
#include "device.h"
|
||||
|
||||
|
||||
HANDLE devicehandle;
|
||||
OVERLAPPED waitevent;
|
||||
|
||||
time_t lasttime;
|
||||
s32 traystatus;
|
||||
int traystatusmethod;
|
||||
s32 disctype;
|
||||
char tocbuffer[2048];
|
||||
|
||||
|
||||
void DeviceInit() {
|
||||
devicehandle = NULL;
|
||||
waitevent.hEvent = NULL;
|
||||
waitevent.Internal = 0;
|
||||
waitevent.InternalHigh = 0;
|
||||
waitevent.Offset = 0;
|
||||
waitevent.OffsetHigh = 0;
|
||||
lasttime = 0;
|
||||
|
||||
InitDisc();
|
||||
} // END DeviceInit()
|
||||
|
||||
|
||||
void InitDisc() {
|
||||
int i;
|
||||
|
||||
InitCDInfo();
|
||||
InitDVDInfo();
|
||||
traystatus = CDVD_TRAY_OPEN;
|
||||
traystatusmethod = 0; // Poll all until one works
|
||||
disctype = CDVD_TYPE_NODISC;
|
||||
for(i = 0; i < 2048; i++) tocbuffer[i] = 0;
|
||||
} // END InitDisc()
|
||||
|
||||
|
||||
s32 DiscInserted() {
|
||||
if(traystatus != CDVD_TRAY_CLOSE) return(-1);
|
||||
|
||||
if(disctype == CDVD_TYPE_ILLEGAL) return(-1);
|
||||
// if(disctype == CDVD_TYPE_UNKNOWN) return(-1); // Hmm. Let this one through?
|
||||
if(disctype == CDVD_TYPE_DETCTDVDD) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCTDVDS) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCTCD) return(-1);
|
||||
if(disctype == CDVD_TYPE_DETCT) return(-1);
|
||||
if(disctype == CDVD_TYPE_NODISC) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DiscInserted()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
return(0);
|
||||
} // END DiscInserted()
|
||||
|
||||
|
||||
// Returns errcode (or 0 if successful)
|
||||
DWORD FinishCommand(BOOL boolresult) {
|
||||
DWORD errcode;
|
||||
DWORD waitcode;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: FinishCommand()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if(boolresult == TRUE) {
|
||||
ResetEvent(waitevent.hEvent);
|
||||
return(0);
|
||||
} // ENDIF- Device is ready? Say so.
|
||||
|
||||
errcode = GetLastError();
|
||||
if(errcode == ERROR_IO_PENDING) {
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: Waiting for completion.");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
waitcode = WaitForSingleObject(waitevent.hEvent, 10 * 1000); // 10 sec wait
|
||||
if((waitcode == WAIT_FAILED) || (waitcode == WAIT_ABANDONED)) {
|
||||
errcode = GetLastError();
|
||||
} else if(waitcode == WAIT_TIMEOUT) {
|
||||
errcode = 21;
|
||||
CancelIo(devicehandle); // Speculative Line
|
||||
} else {
|
||||
ResetEvent(waitevent.hEvent);
|
||||
return(0); // Success!
|
||||
} // ENDIF- Trouble waiting? (Or doesn't finish in 5 seconds?)
|
||||
} // ENDIF- Should we wait for the call to finish?
|
||||
|
||||
ResetEvent(waitevent.hEvent);
|
||||
return(errcode);
|
||||
} // END DeviceCommand()
|
||||
|
||||
|
||||
s32 DeviceOpen() {
|
||||
char tempname[256];
|
||||
UINT drivetype;
|
||||
DWORD errcode;
|
||||
|
||||
if(conf.devicename[0] == 0) return(-1);
|
||||
|
||||
if(devicehandle != NULL) return(0);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceOpen()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
// InitConf();
|
||||
// LoadConf(); // Should be done at least once before this call
|
||||
|
||||
// Root Directory reference
|
||||
if(conf.devicename[1] == 0) {
|
||||
sprintf(tempname, "%s:\\", conf.devicename);
|
||||
} else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {
|
||||
sprintf(tempname, "%s\\", conf.devicename);
|
||||
} else {
|
||||
sprintf(tempname, "%s", conf.devicename);
|
||||
} // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.
|
||||
|
||||
drivetype = GetDriveType(tempname);
|
||||
if(drivetype != DRIVE_CDROM) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Not a CD-ROM!");
|
||||
PrintLog("CDVDiso device: (Came back: %u)", drivetype);
|
||||
errcode = GetLastError();
|
||||
if(errcode > 0) PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(-1);
|
||||
} // ENDIF- Not a CD-ROM? Say so!
|
||||
// Hmm. Do we want to include DRIVE_REMOVABLE... just in case?
|
||||
|
||||
// Device Reference
|
||||
if(conf.devicename[1] == 0) {
|
||||
sprintf(tempname, "\\\\.\\%s:", conf.devicename);
|
||||
} else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {
|
||||
sprintf(tempname, "\\\\.\\%s", conf.devicename);
|
||||
} else {
|
||||
sprintf(tempname, "%s", conf.devicename);
|
||||
} // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.
|
||||
|
||||
devicehandle = CreateFile(tempname,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Couldn't open device read-only! Read-Write perhaps?");
|
||||
errcode = GetLastError();
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
devicehandle = CreateFile(tempname,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
} // ENDIF- Couldn't open for read? Try read/write (for those drives that insist)
|
||||
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Couldn't open device!");
|
||||
errcode = GetLastError();
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
devicehandle = NULL;
|
||||
return(-1);
|
||||
} // ENDIF- Couldn't open that way either? Abort.
|
||||
|
||||
waitevent.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if(waitevent.hEvent == INVALID_HANDLE_VALUE) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Couldn't open event handler!");
|
||||
errcode = GetLastError();
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
waitevent.hEvent = NULL;
|
||||
CloseHandle(devicehandle);
|
||||
devicehandle = NULL;
|
||||
} // ENDIF- Couldn't create an "Wait for I/O" handle? Abort.
|
||||
|
||||
// More here... DeviceIoControl? for Drive Capabilities
|
||||
// DEVICE_CAPABILITIES?
|
||||
|
||||
////// Should be done just after the first DeviceOpen();
|
||||
// InitDisc(); // ?
|
||||
// DeviceTrayStatus();
|
||||
|
||||
return(0);
|
||||
} // END DeviceOpen()
|
||||
|
||||
|
||||
void DeviceClose() {
|
||||
if(devicehandle == NULL) return;
|
||||
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) {
|
||||
devicehandle = NULL;
|
||||
return;
|
||||
} // ENDIF- Bad value? Just clear the value.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceClose()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
if(waitevent.hEvent != NULL) {
|
||||
if(waitevent.hEvent != INVALID_HANDLE_VALUE) {
|
||||
CancelIo(devicehandle);
|
||||
CloseHandle(waitevent.hEvent);
|
||||
} // ENDIF- Is this handle actually open?
|
||||
waitevent.hEvent = NULL;
|
||||
waitevent.Offset = 0;
|
||||
waitevent.OffsetHigh = 0;
|
||||
} // ENDIF- Reset the event handle?
|
||||
|
||||
CloseHandle(devicehandle);
|
||||
devicehandle = NULL;
|
||||
return;
|
||||
} // END DeviceClose()
|
||||
|
||||
|
||||
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer) {
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
return(DVDreadTrack(lsn, mode, buffer));
|
||||
} else {
|
||||
return(CDreadTrack(lsn, mode, buffer));
|
||||
} // ENDIF- Is this a DVD?
|
||||
} // END DeviceReadTrack()
|
||||
|
||||
|
||||
s32 DeviceBufferOffset() {
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
return(0);
|
||||
} else {
|
||||
return(CDgetBufferOffset());
|
||||
} // ENDIF- Is this a DVD?
|
||||
|
||||
return(-1);
|
||||
} // END DeviceBufferOffset()
|
||||
|
||||
|
||||
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd) {
|
||||
if(DiscInserted() == -1) return(-1);
|
||||
|
||||
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
|
||||
return(DVDgetTD(track, cdvdtd));
|
||||
} else {
|
||||
return(CDgetTD(track, cdvdtd));
|
||||
} // ENDIF- Is this a DVD?
|
||||
|
||||
return(-1);
|
||||
} // END DeviceGetTD()
|
||||
|
||||
|
||||
s32 DeviceGetDiskType() {
|
||||
s32 s32result;
|
||||
|
||||
if(devicehandle == NULL) return(-1);
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(traystatus == CDVD_TRAY_OPEN) return(disctype);
|
||||
|
||||
if(disctype != CDVD_TYPE_NODISC) return(disctype);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceGetDiskType()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
disctype = CDVD_TYPE_DETCT;
|
||||
|
||||
s32result = DVDgetDiskType();
|
||||
if(s32result != -1) return(disctype);
|
||||
|
||||
s32result = CDgetDiskType();
|
||||
if(s32result != -1) return(disctype);
|
||||
|
||||
disctype = CDVD_TYPE_UNKNOWN;
|
||||
return(disctype);
|
||||
} // END DeviceGetDiskType()
|
||||
|
||||
|
||||
BOOL DeviceTrayStatusStorage() {
|
||||
BOOL boolresult;
|
||||
DWORD byteswritten;
|
||||
DWORD errcode;
|
||||
|
||||
// Note: Unlike other calls, CHECK_VERIFY is not waited on. At this point,
|
||||
// this is the only way to detect if a disc is ready for action.
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
IOCTL_STORAGE_CHECK_VERIFY,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
&byteswritten,
|
||||
NULL);
|
||||
errcode = GetLastError();
|
||||
|
||||
if(errcode == 0) return(TRUE);
|
||||
if(errcode == 21) return(FALSE); // Device not ready? (Valid error)
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Trouble detecting drive status (STORAGE)!");
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(FALSE);
|
||||
} // END DeviceTrayStatusStorage()
|
||||
|
||||
|
||||
BOOL DeviceTrayStatusCDRom() {
|
||||
BOOL boolresult;
|
||||
DWORD byteswritten;
|
||||
DWORD errcode;
|
||||
|
||||
// Note: Unlike other calls, CHECK_VERIFY is not waited on. At this point,
|
||||
// this is the only way to detect if a disc is ready for action.
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
IOCTL_CDROM_CHECK_VERIFY,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
&byteswritten,
|
||||
NULL);
|
||||
errcode = GetLastError();
|
||||
|
||||
if(errcode == 0) return(TRUE);
|
||||
if(errcode == 21) return(FALSE); // Device not ready? (Valid error)
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Trouble detecting drive status (CDROM)!");
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(FALSE);
|
||||
} // END DeviceTrayStatusCDRom()
|
||||
|
||||
|
||||
BOOL DeviceTrayStatusDisk() {
|
||||
BOOL boolresult;
|
||||
DWORD byteswritten;
|
||||
DWORD errcode;
|
||||
|
||||
// Note: Unlike other calls, CHECK_VERIFY is not waited on. At this point,
|
||||
// this is the only way to detect if a disc is ready for action.
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
IOCTL_DISK_CHECK_VERIFY,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
&byteswritten,
|
||||
NULL);
|
||||
errcode = GetLastError();
|
||||
|
||||
if(errcode == 0) return(TRUE);
|
||||
if(errcode == 21) return(FALSE); // Device not ready? (Valid error)
|
||||
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Trouble detecting drive status (DISK)!");
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(FALSE);
|
||||
} // END DeviceTrayStatusDisk()
|
||||
|
||||
|
||||
s32 DeviceTrayStatus() {
|
||||
BOOL boolresult;
|
||||
|
||||
if(devicehandle == NULL) return(-1);
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceTrayStatus()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
switch(traystatusmethod) {
|
||||
case 1:
|
||||
boolresult = DeviceTrayStatusStorage();
|
||||
break;
|
||||
case 2:
|
||||
boolresult = DeviceTrayStatusCDRom();
|
||||
break;
|
||||
case 3:
|
||||
boolresult = DeviceTrayStatusDisk();
|
||||
break;
|
||||
default:
|
||||
boolresult = FALSE;
|
||||
break;
|
||||
} // ENDSWITCH traystatusmethod- One method already working? Try it again.
|
||||
|
||||
if(boolresult == FALSE) {
|
||||
traystatusmethod = 0;
|
||||
boolresult = DeviceTrayStatusStorage();
|
||||
if(boolresult == TRUE) {
|
||||
traystatusmethod = 1;
|
||||
} else {
|
||||
boolresult = DeviceTrayStatusCDRom();
|
||||
if(boolresult == TRUE) {
|
||||
traystatusmethod = 2;
|
||||
} else {
|
||||
boolresult = DeviceTrayStatusDisk();
|
||||
if(boolresult == TRUE) traystatusmethod = 3;
|
||||
} // ENDIF- Did we succeed with CDRom?
|
||||
} // ENDIF- Did we succeed with Storage?
|
||||
} // Single call to already working test just failed? Test them all.
|
||||
|
||||
if(boolresult == FALSE) {
|
||||
if(traystatus == CDVD_TRAY_CLOSE) {
|
||||
traystatus = CDVD_TRAY_OPEN;
|
||||
DeviceClose();
|
||||
DeviceOpen();
|
||||
InitDisc();
|
||||
} // ENDIF- Just opened? clear disc info
|
||||
return(traystatus);
|
||||
} // ENDIF- Still failed? Assume no disc in drive then.
|
||||
|
||||
if(traystatus == CDVD_TRAY_OPEN) {
|
||||
traystatus = CDVD_TRAY_CLOSE;
|
||||
DeviceGetDiskType();
|
||||
return(traystatus);
|
||||
} // ENDIF- Just closed? Get disc information
|
||||
|
||||
return(traystatus);
|
||||
} // END DeviceTrayStatus()
|
||||
|
||||
|
||||
s32 DeviceTrayOpen() {
|
||||
BOOL boolresult;
|
||||
DWORD byteswritten;
|
||||
DWORD errcode;
|
||||
|
||||
if(devicehandle == NULL) return(-1);
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(traystatus == CDVD_TRAY_OPEN) return(0);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceOpenTray()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
IOCTL_STORAGE_EJECT_MEDIA,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
&byteswritten,
|
||||
&waitevent);
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
if(errcode != 0) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Couldn't signal media to eject! (STORAGE)");
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
|
||||
// boolresult = DeviceIoControl(devicehandle,
|
||||
// IOCTL_DISK_EJECT_MEDIA,
|
||||
// NULL,
|
||||
// 0,
|
||||
// NULL,
|
||||
// 0,
|
||||
// &byteswritten,
|
||||
// NULL);
|
||||
// } // ENDIF- Storage Call failed? Try Disk call.
|
||||
|
||||
// if(boolresult == FALSE) {
|
||||
// #ifdef VERBOSE_WARNING_DEVICE
|
||||
// PrintLog("CDVDiso device: Couldn't signal media to eject! (DISK)");
|
||||
// PrintError("CDVDiso device", errcode);
|
||||
// #endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(-1);
|
||||
} // ENDIF- Disk Call failed as well? Give it up.
|
||||
|
||||
return(0);
|
||||
} // END DeviceTrayOpen()
|
||||
|
||||
|
||||
s32 DeviceTrayClose() {
|
||||
BOOL boolresult;
|
||||
DWORD byteswritten;
|
||||
DWORD errcode;
|
||||
|
||||
if(devicehandle == NULL) return(-1);
|
||||
if(devicehandle == INVALID_HANDLE_VALUE) return(-1);
|
||||
|
||||
if(traystatus == CDVD_TRAY_CLOSE) return(0);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_DEVICE
|
||||
PrintLog("CDVDiso device: DeviceCloseTray()");
|
||||
#endif /* VERBOSE_FUNCTION_DEVICE */
|
||||
|
||||
boolresult = DeviceIoControl(devicehandle,
|
||||
IOCTL_STORAGE_LOAD_MEDIA,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
&byteswritten,
|
||||
NULL);
|
||||
errcode = FinishCommand(boolresult);
|
||||
|
||||
if(errcode != 0) {
|
||||
#ifdef VERBOSE_WARNING_DEVICE
|
||||
PrintLog("CDVDiso device: Couldn't signal media to load! (STORAGE)");
|
||||
PrintError("CDVDiso device", errcode);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
// boolresult = DeviceIoControl(devicehandle,
|
||||
// IOCTL_CDROM_LOAD_MEDIA,
|
||||
// NULL,
|
||||
// 0,
|
||||
// NULL,
|
||||
// 0,
|
||||
// &byteswritten,
|
||||
// NULL);
|
||||
// } // ENDIF- Storage call failed. CDRom call?
|
||||
|
||||
// if(boolresult == FALSE) {
|
||||
// errcode = GetLastError();
|
||||
// #ifdef VERBOSE_WARNING_DEVICE
|
||||
// PrintLog("CDVDiso device: Couldn't signal media to load! (CDROM)");
|
||||
// PrintError("CDVDiso device", errcode);
|
||||
// #endif /* VERBOSE_WARNING_DEVICE */
|
||||
// boolresult = DeviceIoControl(devicehandle,
|
||||
// IOCTL_DISK_LOAD_MEDIA,
|
||||
// NULL,
|
||||
// 0,
|
||||
// NULL,
|
||||
// 0,
|
||||
// &byteswritten,
|
||||
// NULL);
|
||||
// } // ENDIF- CDRom call failed. Disk call?
|
||||
|
||||
// if(boolresult == FALSE) {
|
||||
// #ifdef VERBOSE_WARNING_DEVICE
|
||||
// PrintLog("CDVDiso device: Couldn't signal media to load! (DISK)");
|
||||
// PrintError("CDVDiso device", errcode);
|
||||
// #endif /* VERBOSE_WARNING_DEVICE */
|
||||
return(-1);
|
||||
} // ENDIF- Media not available?
|
||||
|
||||
return(0);
|
||||
} // END DeviceTrayClose()
|
|
@ -0,0 +1,64 @@
|
|||
/* device.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
#ifndef __DEVICE_H__
|
||||
#define __DEVICE_H__
|
||||
|
||||
|
||||
#include <windows.h> // BOOL, DWORD
|
||||
|
||||
#include <time.h> // time_t
|
||||
|
||||
#define CDVDdefs
|
||||
#include "../PS2Edefs.h"
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_DEVICE
|
||||
// #define VERBOSE_WARNING_DEVICE
|
||||
#define VERBOSE_DISC_TYPE
|
||||
#define VERBOSE_DISC_INFO
|
||||
|
||||
|
||||
extern HANDLE devicehandle;
|
||||
extern OVERLAPPED waitevent;
|
||||
|
||||
extern time_t lasttime;
|
||||
extern s32 traystatus;
|
||||
extern s32 disctype;
|
||||
extern char tocbuffer[];
|
||||
|
||||
|
||||
extern void DeviceInit();
|
||||
extern void InitDisc();
|
||||
extern s32 DiscInserted();
|
||||
extern DWORD FinishCommand(BOOL boolresult);
|
||||
|
||||
extern s32 DeviceOpen();
|
||||
extern void DeviceClose();
|
||||
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
|
||||
extern s32 DeviceBufferOffset();
|
||||
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
|
||||
extern s32 DeviceGetDiskType();
|
||||
extern s32 DeviceTrayStatus();
|
||||
extern s32 DeviceTrayOpen();
|
||||
extern s32 DeviceTrayClose();
|
||||
|
||||
|
||||
#endif /* __DEVICE_H__ */
|
|
@ -0,0 +1,818 @@
|
|||
/* devicebox.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <windowsx.h> // ComboBox_AddString()
|
||||
|
||||
#include <windef.h> // NULL
|
||||
|
||||
|
||||
|
||||
#include <stdio.h> // sprintf()
|
||||
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
#include <sys/stat.h> // stat()
|
||||
|
||||
#include <sys/types.h> // stat()
|
||||
|
||||
#include <unistd.h> // stat()
|
||||
|
||||
|
||||
|
||||
#define CDVDdefs
|
||||
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#include "isofile.h"
|
||||
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
|
||||
// #include "imagetype.h" // imagedata[].name
|
||||
|
||||
#include "multifile.h" // multinames[]
|
||||
|
||||
#include "toc.h"
|
||||
|
||||
#include "progressbox.h"
|
||||
|
||||
#include "mainbox.h"
|
||||
|
||||
#include "screens.h"
|
||||
|
||||
#include "devicebox.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HWND deviceboxwindow;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxDestroy() {
|
||||
|
||||
if(deviceboxwindow != NULL) {
|
||||
|
||||
EndDialog(deviceboxwindow, FALSE);
|
||||
|
||||
deviceboxwindow = NULL;
|
||||
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
|
||||
} // END DeviceBoxDestroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxUnfocus() {
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.device, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.file, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.selectbutton, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.compress, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.multi, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.okbutton, FALSE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.cancelbutton, FALSE);
|
||||
|
||||
ShowWindow(deviceboxwindow, SW_HIDE);
|
||||
|
||||
} // END DeviceBoxUnfocus()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxDeviceEvent() {
|
||||
|
||||
char tempdevice[256];
|
||||
|
||||
struct stat filestat;
|
||||
|
||||
int returnval;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(deviceboxwindow, IDC_0302, tempdevice, 256);
|
||||
|
||||
returnval = stat(tempdevice, &filestat);
|
||||
|
||||
if(returnval == -1) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: ---");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
|
||||
|
||||
if(S_ISDIR(filestat.st_mode) != 0) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Not a device");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0303, "Device Type: Device Likely");
|
||||
|
||||
return;
|
||||
|
||||
} // END DeviceBoxDeviceEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxFileEvent() {
|
||||
|
||||
int returnval;
|
||||
|
||||
char templine[256];
|
||||
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256);
|
||||
|
||||
returnval = IsIsoFile(templine);
|
||||
|
||||
if(returnval == -1) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: ---");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
|
||||
|
||||
if(returnval == -2) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a file");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
if(returnval == -3) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Not a valid image file");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not an image file?
|
||||
|
||||
|
||||
|
||||
if(returnval == -4) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0307, "File Type: Missing Table File (will rebuild)");
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
|
||||
|
||||
tempfile = IsoFileOpenForRead(templine);
|
||||
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
|
||||
multinames[tempfile->multi],
|
||||
|
||||
tempfile->imagename,
|
||||
|
||||
compressdesc[tempfile->compress]);
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0307, templine);
|
||||
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
|
||||
return;
|
||||
|
||||
} // END DeviceBoxFileEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxRefocus() {
|
||||
|
||||
DeviceBoxDeviceEvent();
|
||||
|
||||
DeviceBoxFileEvent();
|
||||
|
||||
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.device, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.file, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.selectbutton, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.compress, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.multi, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.okbutton, TRUE);
|
||||
|
||||
// gtk_widget_set_sensitive(devicebox.cancelbutton, TRUE);
|
||||
|
||||
// gtk_window_set_focus(GTK_WINDOW(devicebox.window), devicebox.file);
|
||||
|
||||
ShowWindow(deviceboxwindow, SW_SHOW);
|
||||
|
||||
SetActiveWindow(deviceboxwindow);
|
||||
|
||||
} // END DeviceBoxRefocus()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxCancelEvent() {
|
||||
|
||||
// ShowWindow(deviceboxwindow, SW_HIDE);
|
||||
|
||||
DeviceBoxDestroy();
|
||||
|
||||
MainBoxRefocus();
|
||||
|
||||
return;
|
||||
|
||||
} // END DeviceBoxCancelEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxOKEvent() {
|
||||
|
||||
char templine[256];
|
||||
|
||||
u8 tempbuffer[2352];
|
||||
|
||||
struct IsoFile *tofile;
|
||||
|
||||
s32 retval;
|
||||
|
||||
cdvdTD cdvdtd;
|
||||
|
||||
int stop;
|
||||
|
||||
HWND tempitem;
|
||||
|
||||
int compressmethod;
|
||||
|
||||
int multi;
|
||||
|
||||
int imagetype;
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
DeviceBoxUnfocus();
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename, 256);
|
||||
|
||||
retval = DeviceOpen();
|
||||
|
||||
if(retval != 0) {
|
||||
|
||||
DeviceClose();
|
||||
|
||||
DeviceBoxRefocus();
|
||||
|
||||
MessageBox(deviceboxwindow,
|
||||
|
||||
"Could not open the device",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Trouble opening device? Abort here.
|
||||
|
||||
|
||||
|
||||
DeviceTrayStatus();
|
||||
|
||||
retval = DiscInserted();
|
||||
|
||||
if(retval != 0) {
|
||||
|
||||
DeviceClose();
|
||||
|
||||
DeviceBoxRefocus();
|
||||
|
||||
MessageBox(deviceboxwindow,
|
||||
|
||||
"No disc in the device\r\nPlease put a disc in and try again.",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Trouble opening device? Abort here.
|
||||
|
||||
|
||||
|
||||
retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
DeviceClose();
|
||||
|
||||
DeviceBoxRefocus();
|
||||
|
||||
MessageBox(deviceboxwindow,
|
||||
|
||||
"Could not retrieve disc sector size",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Trouble getting disc sector count?
|
||||
|
||||
|
||||
|
||||
tempitem = GetDlgItem(deviceboxwindow, IDC_0309);
|
||||
|
||||
compressmethod = ComboBox_GetCurSel(tempitem);
|
||||
|
||||
tempitem = NULL;
|
||||
|
||||
if(compressmethod > 0) compressmethod += 2;
|
||||
|
||||
|
||||
|
||||
multi = 0;
|
||||
|
||||
if(IsDlgButtonChecked(deviceboxwindow, IDC_0311)) multi = 1;
|
||||
|
||||
|
||||
|
||||
imagetype = 0;
|
||||
|
||||
if((disctype != CDVD_TYPE_PS2DVD) &&
|
||||
|
||||
(disctype != CDVD_TYPE_DVDV)) imagetype = 8;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(deviceboxwindow, IDC_0305, templine, 256);
|
||||
|
||||
tofile = IsoFileOpenForWrite(templine,
|
||||
|
||||
imagetype,
|
||||
|
||||
multi,
|
||||
|
||||
compressmethod);
|
||||
|
||||
if(tofile == NULL) {
|
||||
|
||||
DeviceClose();
|
||||
|
||||
DeviceBoxRefocus();
|
||||
|
||||
MessageBox(deviceboxwindow,
|
||||
|
||||
"Could not create the new ISO file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
|
||||
} // ENDIF- Trouble opening the ISO file?
|
||||
|
||||
|
||||
|
||||
// Open Progress Bar
|
||||
|
||||
sprintf(templine, "%s -> %s", conf.devicename, tofile->name);
|
||||
|
||||
ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
|
||||
|
||||
|
||||
|
||||
tofile->cdvdtype = disctype;
|
||||
|
||||
for(i = 0; i < 2048; i++) tofile->toc[i] = tocbuffer[i];
|
||||
|
||||
|
||||
|
||||
stop = 0;
|
||||
|
||||
mainboxstop = 0;
|
||||
|
||||
progressboxstop = 0;
|
||||
|
||||
while((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) {
|
||||
|
||||
if(imagetype == 0) {
|
||||
|
||||
retval = DeviceReadTrack((u32) tofile->sectorpos,
|
||||
|
||||
CDVD_MODE_2048,
|
||||
|
||||
tempbuffer);
|
||||
|
||||
} else {
|
||||
|
||||
retval = DeviceReadTrack((u32) tofile->sectorpos,
|
||||
|
||||
CDVD_MODE_2352,
|
||||
|
||||
tempbuffer);
|
||||
|
||||
} // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
for(i = 0; i < 2352; i++) {
|
||||
|
||||
tempbuffer[i] = 0;
|
||||
|
||||
} // NEXT i- Zeroing the buffer
|
||||
|
||||
} // ENDIF- Trouble reading next block?
|
||||
|
||||
retval = IsoFileWrite(tofile, tempbuffer);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
MessageBox(deviceboxwindow,
|
||||
|
||||
"Trouble writing new file",
|
||||
|
||||
"CDVDisoEFP Message",
|
||||
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
|
||||
stop = 1;
|
||||
|
||||
} // ENDIF- Trouble writing out the next block?
|
||||
|
||||
|
||||
|
||||
ProgressBoxTick(tofile->sectorpos);
|
||||
|
||||
|
||||
|
||||
if(mainboxstop != 0) stop = 2;
|
||||
|
||||
if(progressboxstop != 0) stop = 2;
|
||||
|
||||
} // ENDWHILE- No reason found to stop...
|
||||
|
||||
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
|
||||
|
||||
if(stop == 0) {
|
||||
|
||||
if(tofile->multi == 1) tofile->name[tofile->multipos] = '0'; // First file
|
||||
|
||||
strcpy(templine, tofile->name);
|
||||
|
||||
} // ENDIF- Did we succeed with the transfer?
|
||||
|
||||
|
||||
|
||||
DeviceClose();
|
||||
|
||||
if(stop == 0) {
|
||||
|
||||
IsoSaveTOC(tofile);
|
||||
|
||||
tofile = IsoFileClose(tofile);
|
||||
|
||||
SetDlgItemText(mainboxwindow, IDC_0202, templine);
|
||||
|
||||
} else {
|
||||
|
||||
tofile = IsoFileCloseAndDelete(tofile);
|
||||
|
||||
} // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
|
||||
|
||||
|
||||
|
||||
DeviceBoxRefocus();
|
||||
|
||||
if(stop == 0) DeviceBoxCancelEvent();
|
||||
|
||||
return;
|
||||
|
||||
} // END DeviceBoxOKEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxBrowseEvent() {
|
||||
|
||||
OPENFILENAME filebox;
|
||||
|
||||
char newfilename[256];
|
||||
|
||||
BOOL returnbool;
|
||||
|
||||
|
||||
|
||||
filebox.lStructSize = sizeof(filebox);
|
||||
|
||||
filebox.hwndOwner = deviceboxwindow;
|
||||
|
||||
filebox.hInstance = NULL;
|
||||
|
||||
filebox.lpstrFilter = fileselection;
|
||||
|
||||
filebox.lpstrCustomFilter = NULL;
|
||||
|
||||
filebox.nFilterIndex = 0;
|
||||
|
||||
filebox.lpstrFile = newfilename;
|
||||
|
||||
filebox.nMaxFile = 256;
|
||||
|
||||
filebox.lpstrFileTitle = NULL;
|
||||
|
||||
filebox.nMaxFileTitle = 0;
|
||||
|
||||
filebox.lpstrInitialDir = NULL;
|
||||
|
||||
filebox.lpstrTitle = NULL;
|
||||
|
||||
filebox.Flags = OFN_PATHMUSTEXIST
|
||||
|
||||
| OFN_NOCHANGEDIR
|
||||
|
||||
| OFN_HIDEREADONLY;
|
||||
|
||||
filebox.nFileOffset = 0;
|
||||
|
||||
filebox.nFileExtension = 0;
|
||||
|
||||
filebox.lpstrDefExt = NULL;
|
||||
|
||||
filebox.lCustData = 0;
|
||||
|
||||
filebox.lpfnHook = NULL;
|
||||
|
||||
filebox.lpTemplateName = NULL;
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(deviceboxwindow, IDC_0305, newfilename, 256);
|
||||
|
||||
returnbool = GetOpenFileName(&filebox);
|
||||
|
||||
if(returnbool != FALSE) {
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0305, newfilename);
|
||||
|
||||
} // ENDIF- User actually selected a name? Save it.
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END DeviceBoxBrowseEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeviceBoxDisplay() {
|
||||
|
||||
char templine[256];
|
||||
|
||||
HWND itemptr;
|
||||
|
||||
int itemcount;
|
||||
|
||||
|
||||
|
||||
// Adjust Window Position?
|
||||
|
||||
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename);
|
||||
|
||||
|
||||
|
||||
// DeviceBoxDeviceEvent(); // Needed?
|
||||
|
||||
|
||||
|
||||
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
|
||||
|
||||
SetDlgItemText(deviceboxwindow, IDC_0305, templine);
|
||||
|
||||
|
||||
|
||||
// DeviceBoxFileEvent(); // Needed?
|
||||
|
||||
|
||||
|
||||
itemptr = GetDlgItem(deviceboxwindow, IDC_0309); // Compression Combo
|
||||
|
||||
itemcount = 0;
|
||||
|
||||
while(compressnames[itemcount] != NULL) {
|
||||
|
||||
ComboBox_AddString(itemptr, compressnames[itemcount]);
|
||||
|
||||
itemcount++;
|
||||
|
||||
} // ENDWHILE- loading compression types into combo box
|
||||
|
||||
ComboBox_SetCurSel(itemptr, 0); // First Selection?
|
||||
|
||||
itemptr = NULL;
|
||||
|
||||
|
||||
|
||||
CheckDlgButton(deviceboxwindow, IDC_0311, FALSE); // Start unchecked
|
||||
|
||||
|
||||
|
||||
DeviceInit(); // Initialize device access
|
||||
|
||||
} // END DeviceBoxDisplay()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL CALLBACK DeviceBoxCallback(HWND window,
|
||||
|
||||
UINT msg,
|
||||
|
||||
WPARAM param,
|
||||
|
||||
LPARAM param2) {
|
||||
|
||||
switch(msg) {
|
||||
|
||||
case WM_INITDIALOG:
|
||||
|
||||
deviceboxwindow = window;
|
||||
|
||||
DeviceBoxDisplay(); // Final touches to this window
|
||||
|
||||
return(FALSE); // Let Windows display this window
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_CLOSE: // The "X" in the upper right corner was hit.
|
||||
|
||||
DeviceBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_COMMAND:
|
||||
|
||||
switch(LOWORD(param)) {
|
||||
|
||||
case IDC_0302: // Device Edit Box
|
||||
|
||||
DeviceBoxDeviceEvent();
|
||||
|
||||
return(FALSE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0305: // Filename Edit Box
|
||||
|
||||
DeviceBoxFileEvent();
|
||||
|
||||
return(FALSE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0306: // "Browse" Button
|
||||
|
||||
DeviceBoxBrowseEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0312: // "Make File" Button
|
||||
|
||||
DeviceBoxOKEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case IDC_0313: // "Cancel" Button
|
||||
|
||||
DeviceBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH param- Which object got the message?
|
||||
|
||||
} // ENDSWITCH msg- What message has been sent to this window?
|
||||
|
||||
|
||||
|
||||
return(FALSE);
|
||||
|
||||
} // END DeviceBoxCallback()
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/* devicebox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DEVICEBOX_H
|
||||
#define DEVICEBOX_H
|
||||
|
||||
|
||||
#include <windows.h> // HWND
|
||||
|
||||
|
||||
extern HWND deviceboxwindow;
|
||||
|
||||
extern void DeviceBoxDestroy();
|
||||
// extern void DeviceBoxUnfocus();
|
||||
extern void DeviceBoxRefocus();
|
||||
extern void DeviceBoxDisplay();
|
||||
extern BOOL CALLBACK DeviceBoxCallback(HWND window,
|
||||
UINT msg,
|
||||
WPARAM param,
|
||||
LPARAM param2);
|
||||
|
||||
|
||||
#endif /* DEVICEBOX_H */
|
|
@ -0,0 +1,119 @@
|
|||
/* logfile.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// #include <fcntl.h> // open()
|
||||
// #include <io.h> // mkdir()
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // vsprintf()
|
||||
#include <stdarg.h> // va_start(), va_end(), vsprintf()
|
||||
// #include <sys/stat.h> // open()
|
||||
// #include <sys/types.h> // open()
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
|
||||
HANDLE logfile;
|
||||
char logfiletemp[2048];
|
||||
|
||||
|
||||
void InitLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
CreateDirectory("logs", NULL);
|
||||
|
||||
DeleteFile("logs\\CDVDlog.txt");
|
||||
logfile = NULL;
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END InitLog();
|
||||
|
||||
|
||||
int OpenLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
logfile = CreateFile("logs\\CDVDlog.txt",
|
||||
GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
if(logfile == INVALID_HANDLE_VALUE) {
|
||||
logfile = NULL;
|
||||
return(-1);
|
||||
} // ENDIF- Failed to open? Say so.
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
|
||||
return(0);
|
||||
} // END OpenLog();
|
||||
|
||||
|
||||
void CloseLog() {
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
if(logfile != NULL) {
|
||||
CloseHandle(logfile);
|
||||
logfile = NULL;
|
||||
} // ENDIF- Is the log file actually open? Close it.
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END CloseLog()
|
||||
|
||||
|
||||
void PrintLog(const char *fmt, ...) {
|
||||
DWORD byteswritten;
|
||||
|
||||
// Token comment line
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
va_list list;
|
||||
int len;
|
||||
|
||||
if(logfile == NULL) return; // Log file not open... yet.
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(logfiletemp, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
len = 0;
|
||||
while((len < 2048) && (logfiletemp[len] != 0)) len++;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\n')) len--;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\r')) len--;
|
||||
logfiletemp[len] = 0; // Slice off the last "\r\n"...
|
||||
|
||||
WriteFile(logfile, logfiletemp, len, &byteswritten, NULL);
|
||||
WriteFile(logfile, "\r\n", 2, &byteswritten, NULL);
|
||||
#endif /* VERBOSE LOGFILE */
|
||||
} // END PrintLog()
|
||||
|
||||
void PrintError(const char *header, DWORD errcode) {
|
||||
#ifdef VERBOSE_LOGFILE
|
||||
TCHAR errmsg[256];
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | 80,
|
||||
NULL,
|
||||
errcode,
|
||||
0,
|
||||
errmsg,
|
||||
256,
|
||||
NULL);
|
||||
PrintLog("%s: (%u) %s", header, errcode, errmsg);
|
||||
#endif /* VERBOSE_WARNING_DEVICE */
|
||||
} // END PrintError()
|
|
@ -0,0 +1,39 @@
|
|||
/* logfile.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOGFILE_H
|
||||
#define LOGFILE_H
|
||||
|
||||
|
||||
#include <windows.h> // Just for DWORD
|
||||
|
||||
|
||||
#define VERBOSE_LOGFILE
|
||||
|
||||
|
||||
extern void InitLog();
|
||||
extern int OpenLog();
|
||||
extern void CloseLog();
|
||||
extern void PrintLog(const char *format, ...);
|
||||
extern void PrintError(const char *header, DWORD errcode);
|
||||
|
||||
|
||||
#endif /* LOGFILE_H */
|
|
@ -0,0 +1,309 @@
|
|||
/* mainbox.c
|
||||
* Copyright (C) 2002-2005 CDVDiso 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
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h> // Button_
|
||||
#include <windef.h> // NULL
|
||||
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <string.h> // strcpy()
|
||||
|
||||
#include "conf.h"
|
||||
#include "isofile.h"
|
||||
#include "isocompress.h" // compressdesc[]
|
||||
// #include "imagetype.h" // imagedata[].name
|
||||
#include "multifile.h" // multinames[]
|
||||
#include "tablerebuild.h" // IsoTableRebuild()
|
||||
#include "devicebox.h"
|
||||
#include "conversionbox.h"
|
||||
#include "progressbox.h"
|
||||
#include "screens.h" // DLG_, IDC_
|
||||
#include "CDVDiso.h" // progmodule
|
||||
#include "mainbox.h"
|
||||
|
||||
|
||||
const char fileselection[] = "\Disc Image Files (*.bin,*.img,*.iso,*.nrg)\0*.bin;*.img;*.iso;*.nrg\0\All Files (*.*)\0*.*\0\\0\0";
|
||||
|
||||
|
||||
HWND mainboxwindow;
|
||||
int mainboxstop;
|
||||
|
||||
|
||||
void MainBoxDestroy() {
|
||||
if(progressboxwindow != NULL) {
|
||||
ProgressBoxDestroy();
|
||||
} // ENDIF- Do we have a Progress Window still?
|
||||
|
||||
if(mainboxwindow != NULL) {
|
||||
EndDialog(mainboxwindow, FALSE);
|
||||
mainboxwindow = NULL;
|
||||
} // ENDIF- Do we have a Main Window still?
|
||||
} // END MainBoxDestroy()
|
||||
|
||||
|
||||
void MainBoxUnfocus() {
|
||||
// EnableWindow(?)
|
||||
// gtk_widget_set_sensitive(mainbox.file, FALSE);
|
||||
// gtk_widget_set_sensitive(mainbox.selectbutton, FALSE);
|
||||
// gtk_widget_set_sensitive(mainbox.okbutton, FALSE);
|
||||
// gtk_widget_set_sensitive(mainbox.devbutton, FALSE);
|
||||
// gtk_widget_set_sensitive(mainbox.convbutton, FALSE);
|
||||
ShowWindow(mainboxwindow, SW_HIDE);
|
||||
} // END MainBoxUnfocus()
|
||||
|
||||
|
||||
void MainBoxFileEvent() {
|
||||
int returnval;
|
||||
char templine[256];
|
||||
struct IsoFile *tempfile;
|
||||
|
||||
GetDlgItemText(mainboxwindow, IDC_0202, templine, 256);
|
||||
returnval = IsIsoFile(templine);
|
||||
if(returnval == -1) {
|
||||
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: ---");
|
||||
return;
|
||||
} // ENDIF- Not a name of any sort?
|
||||
|
||||
if(returnval == -2) {
|
||||
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a file");
|
||||
return;
|
||||
} // ENDIF- Not a regular file?
|
||||
|
||||
if(returnval == -3) {
|
||||
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Not a valid image file");
|
||||
return;
|
||||
} // ENDIF- Not an Image file?
|
||||
|
||||
if(returnval == -4) {
|
||||
SetDlgItemText(mainboxwindow, IDC_0204, "File Type: Missing Table File (will rebuild)");
|
||||
return;
|
||||
} // ENDIF- Missing Compression seek table?
|
||||
|
||||
tempfile = IsoFileOpenForRead(templine);
|
||||
sprintf(templine, "File Type: %s%s%s",
|
||||
multinames[tempfile->multi],
|
||||
tempfile->imagename,
|
||||
compressdesc[tempfile->compress]);
|
||||
SetDlgItemText(mainboxwindow, IDC_0204, templine);
|
||||
tempfile = IsoFileClose(tempfile);
|
||||
return;
|
||||
} // END MainBoxFileEvent()
|
||||
|
||||
|
||||
void MainBoxRefocus() {
|
||||
MainBoxFileEvent();
|
||||
|
||||
// gtk_widget_set_sensitive(mainbox.file, TRUE);
|
||||
// gtk_widget_set_sensitive(mainbox.selectbutton, TRUE);
|
||||
// gtk_widget_set_sensitive(mainbox.okbutton, TRUE);
|
||||
// gtk_widget_set_sensitive(mainbox.devbutton, TRUE);
|
||||
// gtk_widget_set_sensitive(mainbox.convbutton, TRUE);
|
||||
// gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.file);
|
||||
// ShowWindow(mainboxwindow, SW_RESTORE); // and/or, SW_SHOW? SW_SHOWNORMAL?
|
||||
ShowWindow(mainboxwindow, SW_SHOW);
|
||||
SetActiveWindow(mainboxwindow);
|
||||
} // END MainBoxRefocus()
|
||||
|
||||
|
||||
void MainBoxCancelEvent() {
|
||||
mainboxstop = 1; // Halt all long processess...
|
||||
|
||||
MainBoxDestroy();
|
||||
return;
|
||||
} // END MainBoxCancelEvent()
|
||||
|
||||
|
||||
void MainBoxOKEvent() {
|
||||
char tempisoname[256];
|
||||
|
||||
MainBoxUnfocus();
|
||||
|
||||
GetDlgItemText(mainboxwindow, IDC_0202, tempisoname, 256);
|
||||
if(*(tempisoname) != 0) {
|
||||
if(IsIsoFile(tempisoname) == -4) {
|
||||
IsoTableRebuild(tempisoname);
|
||||
MainBoxRefocus();
|
||||
return;
|
||||
} // ENDIF- Do we need to rebuild an image file's index before using it?
|
||||
|
||||
if(IsIsoFile(tempisoname) < 0) {
|
||||
MainBoxRefocus();
|
||||
MessageBox(mainboxwindow,
|
||||
"Not a Valid Image File.",
|
||||
"CDVDisoEFP Message",
|
||||
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
|
||||
return;
|
||||
} // ENDIF- Not an ISO file? Message and Stop here.
|
||||
} // ENDIF- Do we have a name to check out?
|
||||
|
||||
strcpy(conf.isoname, tempisoname);
|
||||
if(Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0209)) == BST_UNCHECKED) {
|
||||
conf.startconfigure = 0; // FALSE
|
||||
} else {
|
||||
conf.startconfigure = 1; // TRUE
|
||||
} // ENDIF- Was this checkbox unchecked?
|
||||
if(Button_GetCheck(GetDlgItem(mainboxwindow, IDC_0210)) == BST_UNCHECKED) {
|
||||
conf.restartconfigure = 0; // FALSE
|
||||
} else {
|
||||
conf.restartconfigure = 1; // TRUE
|
||||
} // ENDIF- Was this checkbox unchecked?
|
||||
SaveConf();
|
||||
|
||||
MainBoxCancelEvent();
|
||||
return;
|
||||
} // END MainBoxOKEvent()
|
||||
|
||||
|
||||
void MainBoxBrowseEvent() {
|
||||
OPENFILENAME filebox;
|
||||
char newfilename[256];
|
||||
BOOL returnbool;
|
||||
|
||||
filebox.lStructSize = sizeof(filebox);
|
||||
filebox.hwndOwner = mainboxwindow;
|
||||
filebox.hInstance = NULL;
|
||||
filebox.lpstrFilter = fileselection;
|
||||
filebox.lpstrCustomFilter = NULL;
|
||||
filebox.nFilterIndex = 0;
|
||||
filebox.lpstrFile = newfilename;
|
||||
filebox.nMaxFile = 256;
|
||||
filebox.lpstrFileTitle = NULL;
|
||||
filebox.nMaxFileTitle = 0;
|
||||
filebox.lpstrInitialDir = NULL;
|
||||
filebox.lpstrTitle = NULL;
|
||||
filebox.Flags = OFN_FILEMUSTEXIST
|
||||
| OFN_NOCHANGEDIR
|
||||
| OFN_HIDEREADONLY;
|
||||
filebox.nFileOffset = 0;
|
||||
filebox.nFileExtension = 0;
|
||||
filebox.lpstrDefExt = NULL;
|
||||
filebox.lCustData = 0;
|
||||
filebox.lpfnHook = NULL;
|
||||
filebox.lpTemplateName = NULL;
|
||||
|
||||
GetDlgItemText(mainboxwindow, IDC_0202, newfilename, 256);
|
||||
returnbool = GetOpenFileName(&filebox);
|
||||
if(returnbool != FALSE) {
|
||||
SetDlgItemText(mainboxwindow, IDC_0202, newfilename);
|
||||
} // ENDIF- User actually selected a name? Save it.
|
||||
|
||||
return;
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
void MainBoxDeviceEvent() {
|
||||
MainBoxUnfocus();
|
||||
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0300),
|
||||
mainboxwindow,
|
||||
(DLGPROC)DeviceBoxCallback);
|
||||
return;
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
void MainBoxConversionEvent() {
|
||||
MainBoxUnfocus();
|
||||
|
||||
DialogBox(progmodule,
|
||||
MAKEINTRESOURCE(DLG_0400),
|
||||
mainboxwindow,
|
||||
(DLGPROC)ConversionBoxCallback);
|
||||
return;
|
||||
} // END MainBoxBrowseEvent()
|
||||
|
||||
|
||||
void MainBoxDisplay() {
|
||||
LoadConf();
|
||||
|
||||
// Adjust window position?
|
||||
|
||||
// We held off setting the name until now... so description would show.
|
||||
SetDlgItemText(mainboxwindow, IDC_0202, conf.isoname);
|
||||
if(conf.startconfigure == 0) {
|
||||
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_UNCHECKED);
|
||||
} else {
|
||||
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0209), BST_CHECKED);
|
||||
} // ENDIF- Do we need to uncheck this box?
|
||||
if(conf.restartconfigure == 0) {
|
||||
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_UNCHECKED);
|
||||
} else {
|
||||
Button_SetCheck(GetDlgItem(mainboxwindow, IDC_0210), BST_CHECKED);
|
||||
} // ENDIF- Do we need to uncheck this box?
|
||||
|
||||
// First Time - Show the window
|
||||
ShowWindow(mainboxwindow, SW_SHOWNORMAL);
|
||||
} // END MainBoxDisplay()
|
||||
|
||||
|
||||
BOOL CALLBACK MainBoxCallback(HWND window,
|
||||
UINT msg,
|
||||
WPARAM param,
|
||||
LPARAM param2) {
|
||||
switch(msg) {
|
||||
case WM_INITDIALOG:
|
||||
mainboxwindow = window;
|
||||
MainBoxDisplay(); // In this case, final touches to this window.
|
||||
ProgressBoxDisplay(); // Create the Progress Box at this time.
|
||||
return(FALSE); // And let Windows display this window.
|
||||
break;
|
||||
|
||||
case WM_CLOSE: // The "X" in the upper right corner was hit.
|
||||
MainBoxCancelEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
// Do we wish to capture 'ENTER/RETURN' and/or 'ESC' here?
|
||||
|
||||
switch(LOWORD(param)) {
|
||||
case IDC_0202: // Filename Edit Box
|
||||
MainBoxFileEvent(); // Describe the File's type...
|
||||
return(FALSE); // Let Windows handle the actual 'edit' processing...
|
||||
break;
|
||||
|
||||
case IDC_0203: // "Browse" Button
|
||||
MainBoxBrowseEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
|
||||
case IDC_0205: // "Ok" Button
|
||||
MainBoxOKEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
|
||||
case IDC_0206: // "Get from Disc" Button
|
||||
MainBoxDeviceEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
|
||||
case IDC_0207: // "Convert" Button
|
||||
MainBoxConversionEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
|
||||
case IDC_0208: // "Cancel" Button
|
||||
MainBoxCancelEvent();
|
||||
return(TRUE);
|
||||
break;
|
||||
} // ENDSWITCH param- Which object got the message?
|
||||
} // ENDSWITCH msg- what message has been sent to this window?
|
||||
|
||||
return(FALSE); // Not a recognized message? Tell Windows to handle it.
|
||||
} // END MainBoxEventLoop()
|
|
@ -0,0 +1,43 @@
|
|||
/* mainbox.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MAINBOX_H
|
||||
#define MAINBOX_H
|
||||
|
||||
|
||||
#include <windows.h> // HWND
|
||||
|
||||
|
||||
extern const char fileselection[];
|
||||
|
||||
extern HWND mainboxwindow;
|
||||
extern int mainboxstop;
|
||||
|
||||
|
||||
extern void MainBoxRefocus();
|
||||
extern void MainBoxDisplay();
|
||||
extern BOOL CALLBACK MainBoxCallback(HWND window,
|
||||
UINT msg,
|
||||
WPARAM param,
|
||||
LPARAM param2);
|
||||
|
||||
|
||||
#endif /* MAINBOX_H */
|
|
@ -0,0 +1 @@
|
|||
mingw32-make -f Makefile.MinGW32 %1
|
|
@ -0,0 +1 @@
|
|||
make -f Makefile.MinGW32 %1
|
|
@ -0,0 +1,21 @@
|
|||
EXPORTS
|
||||
PS2EgetLibType = PS2EgetLibType@0 @2
|
||||
PS2EgetLibName = PS2EgetLibName@0 @3
|
||||
PS2EgetLibVersion2 = PS2EgetLibVersion2@4 @4
|
||||
CDVDinit = CDVDinit@0 @5
|
||||
CDVDshutdown = CDVDshutdown@0 @6
|
||||
CDVDopen = CDVDopen@4 @7
|
||||
CDVDclose = CDVDclose@0 @8
|
||||
CDVDreadTrack = CDVDreadTrack@8 @9
|
||||
CDVDgetBuffer = CDVDgetBuffer@0 @10
|
||||
CDVDreadSubQ = CDVDreadSubQ@8 @11
|
||||
CDVDgetTN = CDVDgetTN@4 @12
|
||||
CDVDgetTD = CDVDgetTD@8 @13
|
||||
CDVDgetTOC = CDVDgetTOC@4 @14
|
||||
CDVDgetDiskType = CDVDgetDiskType@0 @15
|
||||
CDVDgetTrayStatus = CDVDgetTrayStatus@0 @16
|
||||
CDVDctrlTrayOpen = CDVDctrlTrayOpen@0 @17
|
||||
CDVDctrlTrayClose = CDVDctrlTrayClose@0 @18
|
||||
CDVDconfigure = CDVDconfigure@0 @19
|
||||
CDVDtest = CDVDtest@0 @20
|
||||
CDVDabout = CDVDabout@0 @21
|
|
@ -0,0 +1,340 @@
|
|||
/* progressbox.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <windowsx.h> // Enable_Button()
|
||||
|
||||
#include <windef.h> // NULL
|
||||
|
||||
#include <commctrl.h> // PBM_...
|
||||
|
||||
|
||||
|
||||
#include <stdio.h> // sprintf()
|
||||
|
||||
#include <string.h> // strcat()
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#include "CDVDiso.h" // progmodule
|
||||
|
||||
#include "screens.h"
|
||||
|
||||
#include "mainbox.h"
|
||||
|
||||
#include "progressbox.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HWND progressboxwindow;
|
||||
|
||||
HWND progressboxbar;
|
||||
|
||||
int progressboxstop;
|
||||
|
||||
|
||||
|
||||
off64_t progressboxmax;
|
||||
|
||||
off64_t progressboxlastpct;
|
||||
|
||||
char progressboxline[256];
|
||||
|
||||
char progressboxmaxchar[16];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxDestroy() {
|
||||
|
||||
if(progressboxwindow != NULL) {
|
||||
|
||||
DestroyWindow(progressboxwindow);
|
||||
|
||||
progressboxwindow = NULL;
|
||||
|
||||
progressboxbar = NULL;
|
||||
|
||||
} // ENDIF- Do we have a Progress Window still?
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxDestroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxStart(char *description, off64_t maximum) {
|
||||
|
||||
SetDlgItemText(progressboxwindow, IDC_0501, description);
|
||||
|
||||
|
||||
|
||||
progressboxmax = maximum;
|
||||
|
||||
sprintf(progressboxmaxchar, "%llu", maximum);
|
||||
|
||||
progressboxlastpct = 100;
|
||||
|
||||
progressboxstop = 0;
|
||||
|
||||
|
||||
|
||||
ProgressBoxTick(0);
|
||||
|
||||
ShowWindow(progressboxwindow, SW_SHOW);
|
||||
|
||||
SetForegroundWindow(progressboxwindow);
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxStart()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxTick(off64_t current) {
|
||||
|
||||
off64_t thispct;
|
||||
|
||||
MSG msg;
|
||||
|
||||
BOOL returnbool;
|
||||
|
||||
|
||||
|
||||
sprintf(progressboxline, "%llu of ", current);
|
||||
|
||||
strcat(progressboxline, progressboxmaxchar);
|
||||
|
||||
SetDlgItemText(progressboxwindow, IDC_0503, progressboxline);
|
||||
|
||||
|
||||
|
||||
if(progressboxmax >= 30000 ) {
|
||||
|
||||
SendMessage(progressboxbar, PBM_SETPOS, current / (progressboxmax / 30000), 0);
|
||||
|
||||
} else {
|
||||
|
||||
SendMessage(progressboxbar, PBM_SETPOS, (current * 30000) / progressboxmax, 0);
|
||||
|
||||
} // ENDIF- Our maximum # over 30000? (Avoiding divide-by-zero error)
|
||||
|
||||
|
||||
|
||||
if(progressboxmax >= 100) {
|
||||
|
||||
thispct = current / ( progressboxmax / 100 );
|
||||
|
||||
if(thispct != progressboxlastpct) {
|
||||
|
||||
sprintf(progressboxline, "%llu%% CDVDisoEFP Progress", thispct);
|
||||
|
||||
SetWindowText(progressboxwindow, progressboxline);
|
||||
|
||||
progressboxlastpct = thispct;
|
||||
|
||||
} // ENDIF- Change in percentage? (Avoiding title flicker)
|
||||
|
||||
} // ENDIF- Our maximum # over 100? (Avoiding divide-by-zero error)
|
||||
|
||||
|
||||
|
||||
returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE);
|
||||
|
||||
while(returnbool != FALSE) {
|
||||
|
||||
TranslateMessage(&msg);
|
||||
|
||||
DispatchMessage(&msg);
|
||||
|
||||
returnbool = PeekMessage(&msg, progressboxwindow, 0, 0, PM_REMOVE);
|
||||
|
||||
} // ENDWHILE- Updating the progress window display as needed
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxTick()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxStop() {
|
||||
|
||||
ShowWindow(progressboxwindow, SW_HIDE);
|
||||
|
||||
SetWindowText(progressboxwindow, "CDVDisoEFP Progress");
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxStop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxCancelEvent() {
|
||||
|
||||
progressboxstop = 1;
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxCancelEvent()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL CALLBACK ProgressBoxCallback(HWND window,
|
||||
|
||||
UINT msg,
|
||||
|
||||
WPARAM param,
|
||||
|
||||
LPARAM param2) {
|
||||
|
||||
switch(msg) {
|
||||
|
||||
case WM_INITDIALOG:
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_CLOSE: // The "X" in the upper right corner is hit.
|
||||
|
||||
ProgressBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case WM_COMMAND:
|
||||
|
||||
switch(LOWORD(param)) {
|
||||
|
||||
case IDC_0504:
|
||||
|
||||
ProgressBoxCancelEvent();
|
||||
|
||||
return(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
} // ENDSWITCH param- Which item got the message?
|
||||
|
||||
|
||||
|
||||
// Hmm. Custom control? (for WM_GETFONT and WM_SETFONT msgs?)
|
||||
|
||||
} // ENDSWITCH msg- what message has been sent to this window?
|
||||
|
||||
|
||||
|
||||
return(FALSE); // Not a recognized message? Tell Windows to handle it.
|
||||
|
||||
} // ENDIF ProgressBoxCallback()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ProgressBoxDisplay() {
|
||||
|
||||
// ? progressload
|
||||
|
||||
LPARAM range;
|
||||
|
||||
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
// progressload.
|
||||
|
||||
// progressload. = ICC_PROGRESS_CLASS
|
||||
|
||||
// InitCommonControlsEx(&progressload);
|
||||
|
||||
|
||||
|
||||
progressboxwindow = CreateDialog(progmodule,
|
||||
|
||||
MAKEINTRESOURCE(DLG_0500),
|
||||
|
||||
mainboxwindow,
|
||||
|
||||
(DLGPROC) ProgressBoxCallback);
|
||||
|
||||
|
||||
|
||||
progressboxbar = GetDlgItem(progressboxwindow, IDC_0502);
|
||||
|
||||
range = MAKELPARAM(0, 30000); // Widen the range for granularity
|
||||
|
||||
SendMessage(progressboxbar, PBM_SETRANGE, 0, range);
|
||||
|
||||
|
||||
|
||||
ShowWindow(progressboxwindow, SW_SHOWNORMAL);
|
||||
|
||||
ShowWindow(progressboxwindow, SW_HIDE);
|
||||
|
||||
return;
|
||||
|
||||
} // END ProgressBoxDisplay()
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/* progressbox.h
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef PROGRESSBOX_H
|
||||
|
||||
#define PROGRESSBOX_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern const char *compressnames[];
|
||||
|
||||
|
||||
|
||||
extern HWND progressboxwindow;
|
||||
|
||||
extern int progressboxstop;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern void ProgressBoxStart(char *description, off64_t maximum);
|
||||
|
||||
extern void ProgressBoxTick(off64_t current);
|
||||
|
||||
extern void ProgressBoxStop();
|
||||
|
||||
extern void ProgressBoxDestroy();
|
||||
|
||||
extern void ProgressBoxDisplay();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* MAINBOX_H */
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/* Weditres generated include file. Do NOT edit */
|
||||
#include <windows.h>
|
||||
#define DLG_0100 100
|
||||
#define IDC_0104 104
|
||||
#define DLG_0200 200
|
||||
#define IDC_0202 202
|
||||
#define IDC_0203 203
|
||||
#define IDC_0204 204
|
||||
#define IDC_0205 205
|
||||
#define IDC_0206 206
|
||||
#define IDC_0207 207
|
||||
#define IDC_0208 208
|
||||
#define IDC_0209 209
|
||||
#define IDC_0210 210
|
||||
#define DLG_0300 300
|
||||
#define IDC_0302 302
|
||||
#define IDC_0303 303
|
||||
#define IDC_0305 305
|
||||
#define IDC_0306 306
|
||||
#define IDC_0307 307
|
||||
#define IDC_0309 309
|
||||
#define IDC_0311 311
|
||||
#define IDC_0312 312
|
||||
#define IDC_0313 313
|
||||
#define DLG_0400 400
|
||||
#define IDC_0402 402
|
||||
#define IDC_0403 403
|
||||
#define IDC_0404 404
|
||||
#define IDC_0406 406
|
||||
#define IDC_0408 408
|
||||
#define IDC_0409 409
|
||||
#define IDC_0410 410
|
||||
#define DLG_0500 500
|
||||
#define IDC_0501 501
|
||||
#define IDC_0502 502
|
||||
#define IDC_0503 503
|
||||
#define IDC_0504 504
|
|
@ -0,0 +1,82 @@
|
|||
/* Wedit generated resource file */
|
||||
#ifdef __LCC__
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "screens.h"
|
||||
|
||||
|
||||
DLG_0100 DIALOG 2, 2, 140, 59
|
||||
STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About CDVDisoEFP"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CTEXT "EFP Iso CDVD Driver v0.6", 101, 11, 6, 118, 12
|
||||
CTEXT "Current Author: efp", 102, 12, 16, 118, 12
|
||||
CTEXT "Original code by: linuzappz && shadow", 103, 12, 26, 118, 12
|
||||
PUSHBUTTON "Ok", IDC_0104, 50, 37, 40, 14
|
||||
END
|
||||
|
||||
DLG_0200 DIALOG 4, 2, 241, 73
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CDVDisoEFP Configuration"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Iso File:", 201, 14, 8, 27, 12
|
||||
EDITTEXT IDC_0202, 43, 7, 149, 12, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Browse", IDC_0203, 197, 6, 34, 12
|
||||
CTEXT "File Type: ---", IDC_0204, 10, 21, 220, 12
|
||||
PUSHBUTTON "Ok", IDC_0205, 15, 53, 48, 14
|
||||
PUSHBUTTON "Get from Disc", IDC_0206, 69, 53, 48, 14
|
||||
PUSHBUTTON "Convert", IDC_0207, 123, 53, 48, 14
|
||||
PUSHBUTTON "Cancel", IDC_0208, 177, 53, 48, 14
|
||||
AUTOCHECKBOX "Show Configure screen when starting emulation", IDC_0209, 13, 32, 179, 10
|
||||
AUTOCHECKBOX "Show Configure screen when restarting emulation", IDC_0210, 13, 41, 180, 10
|
||||
END
|
||||
|
||||
DLG_0300 DIALOG 3, 1, 255, 124
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CDVDisoEFP ISO Creation"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Source CD/DVD Device:", 301, 10, 8, 80, 12
|
||||
EDITTEXT IDC_0302, 92, 7, 153, 12, ES_AUTOHSCROLL
|
||||
CTEXT "Device Type: ---", IDC_0303, 10, 22, 234, 12
|
||||
LTEXT "Iso File:", 304, 11, 39, 26, 12
|
||||
EDITTEXT IDC_0305, 37, 38, 172, 12, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Browse", IDC_0306, 214, 37, 31, 14
|
||||
CTEXT "File Type: ---", IDC_0307, 9, 52, 236, 12
|
||||
LTEXT "New File Compression:", 308, 10, 71, 72, 12
|
||||
COMBOBOX IDC_0309, 83, 69, 100, 48, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Multiple Files (all under 2 GB):", 310, 10, 83, 94, 12
|
||||
AUTOCHECKBOX "", IDC_0311, 107, 83, 40, 10
|
||||
PUSHBUTTON "Make File", IDC_0312, 9, 104, 40, 14
|
||||
PUSHBUTTON "Cancel", IDC_0313, 205, 104, 40, 14
|
||||
END
|
||||
|
||||
DLG_0400 DIALOG 4, 2, 234, 89
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CDVDisoEFP File Conversion"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Iso File:", 401, 11, 7, 25, 12
|
||||
EDITTEXT IDC_0402, 37, 7, 146, 12, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "Browse", IDC_0403, 189, 6, 35, 12
|
||||
CTEXT "File Type: ---", IDC_0404, 10, 21, 214, 12
|
||||
LTEXT "Change Compression To:", 405, 9, 38, 81, 12
|
||||
COMBOBOX IDC_0406, 91, 36, 100, 50, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Multiple Files (all under 2 GB):", 407, 10, 51, 94, 12
|
||||
AUTOCHECKBOX "", IDC_0408, 105, 51, 40, 10
|
||||
PUSHBUTTON "Change File", IDC_0409, 10, 69, 40, 14
|
||||
PUSHBUTTON "Cancel", IDC_0410, 184, 68, 40, 14
|
||||
END
|
||||
|
||||
DLG_0500 DIALOG 3, 0, 273, 66
|
||||
STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CDVDisoEFP Progress"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CTEXT "Twiddling my Thumbs", IDC_0501, 9, 7, 255, 12
|
||||
CONTROL "", IDC_0502, "msctls_progress32", 0x1 | WS_CLIPSIBLINGS, 8, 19, 257, 11
|
||||
CTEXT "10 of 10", 503, 10, 32, 254, 12
|
||||
PUSHBUTTON "Cancel", IDC_0504, 118, 45, 40, 14
|
||||
END
|
|
@ -0,0 +1,187 @@
|
|||
/* tablerebuild.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
#include <stdio.h> // sprintf()
|
||||
#include <stdlib.h> // malloc()
|
||||
|
||||
#include "mainbox.h"
|
||||
#include "progressbox.h"
|
||||
#include "isofile.h"
|
||||
#include "multifile.h"
|
||||
#include "isocompress.h" // CompressClose()
|
||||
#include "gzipv1.h"
|
||||
#include "gzipv2.h"
|
||||
#include "bzip2v2.h"
|
||||
#include "bzip2v3.h"
|
||||
#include "actualfile.h" // ACTUALHANDLENULL
|
||||
|
||||
|
||||
void IsoTableRebuild(const char *filename) {
|
||||
struct IsoFile *datafile;
|
||||
struct IsoFile *tablefile;
|
||||
int retval;
|
||||
char tempblock[65536];
|
||||
int stop;
|
||||
|
||||
struct TableData table;
|
||||
|
||||
datafile = IsoFileOpenForRead(filename);
|
||||
|
||||
// Note: This is the start of the "Multifile" process. It's commented
|
||||
// out so at least we can rebuild 1 part of a multifile at a time.
|
||||
// IsoNameStripExt(datafile);
|
||||
// IsoNameStripMulti(datafile);
|
||||
|
||||
// Prep tablefile to hold ONLY a table (no data)
|
||||
tablefile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
|
||||
if(tablefile == NULL) {
|
||||
datafile = IsoFileClose(datafile);
|
||||
return;
|
||||
} // ENDIF- Failed to allocate? Abort.
|
||||
|
||||
tablefile->sectorpos = 0;
|
||||
tablefile->openforread = 0;
|
||||
tablefile->filebytepos = 0;
|
||||
tablefile->filebytesize = 0;
|
||||
tablefile->filesectorpos = 0;
|
||||
tablefile->filesectorsize = 0;
|
||||
tablefile->handle = ACTUALHANDLENULL;
|
||||
|
||||
tablefile->namepos = 0;
|
||||
while((tablefile->namepos < 255) &&
|
||||
(*(filename + tablefile->namepos) != 0)) {
|
||||
tablefile->name[tablefile->namepos] = *(filename + tablefile->namepos);
|
||||
tablefile->namepos++;
|
||||
} // ENDWHILE- Copying file name into tablefile
|
||||
tablefile->name[tablefile->namepos] = 0; // And 0-terminate.
|
||||
|
||||
tablefile->imageheader = datafile->imageheader;
|
||||
tablefile->blocksize = datafile->blocksize;
|
||||
tablefile->blockoffset = datafile->blockoffset;
|
||||
tablefile->cdvdtype = 0; // Not important right now.
|
||||
|
||||
tablefile->compress = datafile->compress;
|
||||
tablefile->compresspos = datafile->compresspos;
|
||||
tablefile->numsectors = datafile->numsectors;
|
||||
tablefile->tabledata = NULL;
|
||||
|
||||
switch(tablefile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2OpenTableForWrite(tablefile);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3OpenTableForWrite(tablefile);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Which table are we writing out?
|
||||
if(retval < 0) {
|
||||
datafile = IsoFileClose(datafile);
|
||||
return;
|
||||
} // ENDIF- Failed to open table file? Abort
|
||||
|
||||
sprintf(tempblock, "Rebuilding table for %s", datafile->name);
|
||||
ProgressBoxStart(tempblock, datafile->filebytesize);
|
||||
|
||||
stop = 0;
|
||||
mainboxstop = 0;
|
||||
progressboxstop = 0;
|
||||
while((stop == 0) && (datafile->filebytepos < datafile->filebytesize)) {
|
||||
switch(datafile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2Read(datafile, 0, tempblock);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3Read(datafile, 0, tempblock);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Scanning for the next complete compressed block
|
||||
|
||||
if(retval <= 0) {
|
||||
#ifdef FUNCTION_WARNING_TABLEREBUILD
|
||||
PrintLog("CDVDiso rebuild: failed to decompress - data corrupt");
|
||||
#endif /* FUNCTION_WARNING_TABLEREBUILD */
|
||||
stop = 1;
|
||||
} else {
|
||||
table.offset = datafile->filebytepos - retval;
|
||||
table.size = retval;
|
||||
switch(tablefile->compress) {
|
||||
case 1:
|
||||
retval = GZipV1WriteTable(tablefile, table);
|
||||
break;
|
||||
case 2:
|
||||
retval = -1;
|
||||
break;
|
||||
case 3:
|
||||
retval = GZipV2WriteTable(tablefile, table);
|
||||
break;
|
||||
case 4:
|
||||
retval = BZip2V2WriteTable(tablefile, table);
|
||||
break;
|
||||
case 5:
|
||||
retval = BZip2V3WriteTable(tablefile, table);
|
||||
break;
|
||||
default:
|
||||
retval = -1;
|
||||
break;
|
||||
} // ENDSWITCH compress- Writing out the relavent table facts
|
||||
if(retval < 0) stop = 1;
|
||||
} // ENDIF- Do we have a valid record to write an entry for?
|
||||
|
||||
ProgressBoxTick(datafile->filebytepos);
|
||||
|
||||
if(mainboxstop != 0) stop = 2;
|
||||
if(progressboxstop != 0) stop = 2;
|
||||
} // ENDWHILE- Read in the data file and writing a table, 1 block at a time
|
||||
|
||||
ProgressBoxStop();
|
||||
|
||||
CompressClose(tablefile); // Guarentee the table is flushed and closed.
|
||||
if(stop != 0) {
|
||||
ActualFileDelete(tablefile->tablename);
|
||||
} // ENDIF- Aborted or trouble? Delete the table file
|
||||
tablefile = IsoFileClose(tablefile);
|
||||
datafile = IsoFileClose(datafile);
|
||||
|
||||
return;
|
||||
} // END IsoTableRebuild()
|
|
@ -0,0 +1,32 @@
|
|||
/* tablerebuild.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TABLEREBUILD_H
|
||||
#define TABLEREBUILD_H
|
||||
|
||||
|
||||
// #define FUNCTION_WARNING_TABLEREBUILD
|
||||
|
||||
|
||||
extern void IsoTableRebuild(const char *filename);
|
||||
|
||||
|
||||
#endif /* TABLEREBUILD_H */
|
|
@ -0,0 +1,612 @@
|
|||
/* blockv2.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
#include <stdlib.h> // malloc()
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#include "zlib/zlib.h"
|
||||
|
||||
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#include "isofile.h" // IsoFile
|
||||
|
||||
#include "isocompress.h" // TableData, TableMap
|
||||
|
||||
#include "actualfile.h"
|
||||
|
||||
#include "blockv2.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
struct BlockV2Header {
|
||||
|
||||
char id[4];
|
||||
|
||||
unsigned int blocksize;
|
||||
|
||||
unsigned int numblocks;
|
||||
|
||||
unsigned int blockoffset;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2OpenTableForRead(struct IsoFile *isofile) {
|
||||
|
||||
int i;
|
||||
|
||||
int j;
|
||||
|
||||
off64_t offset;
|
||||
|
||||
int tableoffset;
|
||||
|
||||
int retval;
|
||||
|
||||
union TableMap tablemap;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: OpenTableForRead()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
// We pre-read the WHOLE offset table.
|
||||
|
||||
isofile->tabledata = (char *) malloc(isofile->filesectorsize * sizeof(struct TableData));
|
||||
|
||||
if(isofile->tabledata == NULL) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Couldn't allocate internal table!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Could not get enough memory to hold table data
|
||||
|
||||
|
||||
|
||||
offset = sizeof(struct BlockV2Header);
|
||||
|
||||
tableoffset = 0;
|
||||
|
||||
for(i = 0; i < isofile->filesectorsize; i++) {
|
||||
|
||||
retval = BlockV2Seek(isofile, offset);
|
||||
|
||||
if(retval != 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Failed to find sector %i!", i);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble finding a lsn id? Fail.
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle,
|
||||
|
||||
sizeof(int),
|
||||
|
||||
(char *) &j);
|
||||
|
||||
if(retval != sizeof(int)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Failed to read in sector %i!", i);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble reading in a lsn id? Table damaged... fail.
|
||||
|
||||
|
||||
|
||||
tablemap.table.offset = ConvertEndianUInt(j); // Actually, a lsn.
|
||||
|
||||
for(j = 0; j < sizeof(struct TableData); j++)
|
||||
|
||||
*(isofile->tabledata + tableoffset + j) = tablemap.ch[j];
|
||||
|
||||
offset += isofile->blocksize + 4;
|
||||
|
||||
tableoffset += sizeof(struct TableData);
|
||||
|
||||
} // NEXT i- reading in the sizes, and making offset as I go.
|
||||
|
||||
|
||||
|
||||
isofile->tablehandle = ACTUALHANDLENULL;
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BlockV2OpenTableForRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector) {
|
||||
|
||||
int i;
|
||||
|
||||
int tableoffset;
|
||||
|
||||
union TableMap tablemap;
|
||||
|
||||
off64_t filesectorstart;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: SeekTable(%lli)", sector);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
if((isofile->filesectorpos >= 0) &&
|
||||
|
||||
(isofile->filesectorpos < isofile->filesectorsize)) {
|
||||
|
||||
tableoffset = isofile->filesectorpos * sizeof(struct TableData);
|
||||
|
||||
for(i = 0; i < sizeof(struct TableData); i++)
|
||||
|
||||
tablemap.ch[i] = *(isofile->tabledata + tableoffset + i);
|
||||
|
||||
if(sector == tablemap.table.offset) {
|
||||
|
||||
return(0);
|
||||
|
||||
} // ENDIF- Are we already pointing at the right sector?
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
tablemap.table.offset = -1;
|
||||
|
||||
} // ENDIF- Is the file sector pointer within table limits?
|
||||
|
||||
|
||||
|
||||
filesectorstart = isofile->filesectorpos;
|
||||
|
||||
isofile->filesectorpos++;
|
||||
|
||||
if(isofile->filesectorpos >= isofile->filesectorsize)
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
while((isofile->filesectorpos != filesectorstart) &&
|
||||
|
||||
(tablemap.table.offset != sector)) {
|
||||
|
||||
tableoffset = isofile->filesectorpos * sizeof(struct TableData);
|
||||
|
||||
for(i = 0; i < sizeof(struct TableData); i++)
|
||||
|
||||
tablemap.ch[i] = *(isofile->tabledata + tableoffset + i);
|
||||
|
||||
|
||||
|
||||
if(tablemap.table.offset != sector) {
|
||||
|
||||
isofile->filesectorpos++;
|
||||
|
||||
if(isofile->filesectorpos >= isofile->filesectorsize)
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
} // ENDIF- Still didn't find it? move to next sector.
|
||||
|
||||
} // ENDWHILE- Scanning through whole sector list (starting at current pos)
|
||||
|
||||
|
||||
|
||||
if(isofile->filesectorpos == filesectorstart) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Did we loop through the whole file... and not find this sector?
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BlockV2SeekTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: ReadTable()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
table->offset = sizeof(int) + isofile->blocksize;
|
||||
|
||||
table->offset *= isofile->filesectorpos;
|
||||
|
||||
table->offset += sizeof(struct BlockV2Header) + 4;
|
||||
|
||||
table->size = isofile->blocksize;
|
||||
|
||||
isofile->filesectorpos++;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BlockV2ReadTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2OpenTableForWrite(struct IsoFile *isofile) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END BlockV2OpenTableForWrite()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END BlockV2WriteTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2OpenForRead(struct IsoFile *isofile) {
|
||||
|
||||
int retval;
|
||||
|
||||
struct BlockV2Header header;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: OpenForRead()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
isofile->handle = ActualFileOpenForRead(isofile->name);
|
||||
|
||||
if(isofile->handle == ACTUALHANDLENULL) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't open data file? Fail.
|
||||
|
||||
|
||||
|
||||
isofile->filebytesize = ActualFileSize(isofile->handle);
|
||||
|
||||
isofile->filebytepos = 0;
|
||||
|
||||
|
||||
|
||||
isofile->imageheader = 0;
|
||||
|
||||
isofile->numsectors = 1; // Sectors per block
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle,
|
||||
|
||||
sizeof(struct BlockV2Header),
|
||||
|
||||
(char *) &header);
|
||||
|
||||
if(retval != sizeof(struct BlockV2Header)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Couldn't read header!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF Could not read the first sector? Fail.
|
||||
|
||||
isofile->filebytepos += retval;
|
||||
|
||||
|
||||
|
||||
if((header.id[0] != 'B') ||
|
||||
|
||||
(header.id[1] != 'D') ||
|
||||
|
||||
(header.id[2] != 'V') ||
|
||||
|
||||
(header.id[3] != '2')) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Not a block dump v2 header!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- ID for this compression type doesn't match?
|
||||
|
||||
|
||||
|
||||
isofile->blocksize = ConvertEndianUInt(header.blocksize);
|
||||
|
||||
// isofile->filesectorsize = ConvertEndianUInt(header.numblocks);
|
||||
|
||||
isofile->blockoffset = ConvertEndianUInt(header.blockoffset);
|
||||
|
||||
isofile->filesectorsize = isofile->filebytesize;
|
||||
|
||||
isofile->filesectorsize -= 16;
|
||||
|
||||
isofile->filesectorsize /= (isofile->blocksize + sizeof(int));
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BlockV2OpenForRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2Seek(struct IsoFile *isofile, off64_t position) {
|
||||
|
||||
int retval;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Seek(%lli)", position);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
retval = ActualFileSeek(isofile->handle, position);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Couldn't find the start of the block!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't find the data entry? Fail.
|
||||
|
||||
isofile->filebytepos = position;
|
||||
|
||||
return(0);
|
||||
|
||||
|
||||
|
||||
return(-1); // Fail. (Due to lack of ambition?)
|
||||
|
||||
} // END BlockV2Seek()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Read(%i)", bytes);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle, isofile->blocksize, buffer);
|
||||
|
||||
if(retval > 0) isofile->filebytepos += retval;
|
||||
|
||||
if(retval != isofile->blocksize) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Cannot read bytes! Returned: (%i)", retval);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BLOCKV2 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble reading compressed sector? Abort.
|
||||
|
||||
|
||||
|
||||
return(isofile->blocksize);
|
||||
|
||||
} // END BlockV2Read()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2OpenForWrite(struct IsoFile *isofile) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END BlockV2OpenForWrite()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BlockV2Write(struct IsoFile *isofile, char *buffer) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // END BlockV2Write()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BlockV2Close(struct IsoFile *isofile) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
PrintLog("CDVDiso BlockV2: Close()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BLOCKV2 */
|
||||
|
||||
|
||||
|
||||
if(isofile->handle != ACTUALHANDLENULL) {
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
} // ENDIF- Is there a data file open? Close it.
|
||||
|
||||
|
||||
|
||||
if(isofile->tabledata != NULL) {
|
||||
|
||||
free(isofile->tabledata);
|
||||
|
||||
isofile->tabledata = NULL;
|
||||
|
||||
} // ENDIF- Do we have a read-in table to clear out?
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END BlockV2Close()
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* blockv2.h
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef BLOCKV2_H
|
||||
|
||||
#define BLOCKV2_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
|
||||
#include "isofile.h"
|
||||
|
||||
#include "isocompress.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_BLOCKV2
|
||||
|
||||
// #define VERBOSE_WARNING_BLOCKV2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int BlockV2OpenTableForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BlockV2SeekTable(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BlockV2ReadTable(struct IsoFile *isofile, struct TableData *table);
|
||||
|
||||
|
||||
|
||||
extern int BlockV2OpenTableForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BlockV2WriteTable(struct IsoFile *isofile, struct TableData table);
|
||||
|
||||
|
||||
|
||||
extern int BlockV2OpenForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BlockV2Seek(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BlockV2Read(struct IsoFile *isofile, int bytes, char *buffer);
|
||||
|
||||
extern void BlockV2Close(struct IsoFile *isofile);
|
||||
|
||||
|
||||
|
||||
extern int BlockV2OpenForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BlockV2Write(struct IsoFile *isofile, char *buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* BLOCKV2_H */
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
This program, "bzip2", the associated library "libbzip2", and all
|
||||
documentation, are copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@acm.org
|
||||
bzip2/libbzip2 version 1.0.3 of 15 February 2005
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
|
||||
This is the README for bzip2, a block-sorting file compressor, version
|
||||
1.0.3. This version is fully compatible with the previous public
|
||||
releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2.
|
||||
|
||||
bzip2-1.0.3 is distributed under a BSD-style license. For details,
|
||||
see the file LICENSE.
|
||||
|
||||
Complete documentation is available in Postscript form (manual.ps),
|
||||
PDF (manual.pdf) or html (manual.html). A plain-text version of the
|
||||
manual page is available as bzip2.txt. A statement about Y2K issues
|
||||
is now included in the file Y2K_INFO.
|
||||
|
||||
|
||||
HOW TO BUILD -- UNIX
|
||||
|
||||
Type `make'. This builds the library libbz2.a and then the
|
||||
programs bzip2 and bzip2recover. Six self-tests are run.
|
||||
If the self-tests complete ok, carry on to installation:
|
||||
|
||||
To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type
|
||||
make install
|
||||
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
|
||||
make install PREFIX=/xxx/yyy
|
||||
If you are (justifiably) paranoid and want to see what 'make install'
|
||||
is going to do, you can first do
|
||||
make -n install or
|
||||
make -n install PREFIX=/xxx/yyy respectively.
|
||||
The -n instructs make to show the commands it would execute, but
|
||||
not actually execute them.
|
||||
|
||||
|
||||
HOW TO BUILD -- UNIX, shared library libbz2.so.
|
||||
|
||||
Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for
|
||||
Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims
|
||||
that it works for any other platform, though I suspect it probably
|
||||
will work for most platforms employing both ELF and gcc.
|
||||
|
||||
bzip2-shared, a client of the shared library, is also built, but not
|
||||
self-tested. So I suggest you also build using the normal Makefile,
|
||||
since that conducts a self-test. A second reason to prefer the
|
||||
version statically linked to the library is that, on x86 platforms,
|
||||
building shared objects makes a valuable register (%ebx) unavailable
|
||||
to gcc, resulting in a slowdown of 10%-20%, at least for bzip2.
|
||||
|
||||
Important note for people upgrading .so's from 0.9.0/0.9.5 to version
|
||||
1.0.X. All the functions in the library have been renamed, from (eg)
|
||||
bzCompress to BZ2_bzCompress, to avoid namespace pollution.
|
||||
Unfortunately this means that the libbz2.so created by
|
||||
Makefile-libbz2_so will not work with any program which used an older
|
||||
version of the library. Sorry. I do encourage library clients to
|
||||
make the effort to upgrade to use version 1.0, since it is both faster
|
||||
and more robust than previous versions.
|
||||
|
||||
|
||||
HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
|
||||
|
||||
It's difficult for me to support compilation on all these platforms.
|
||||
My approach is to collect binaries for these platforms, and put them
|
||||
on the master web page (http://sources.redhat.com/bzip2). Look there.
|
||||
However (FWIW), bzip2-1.0.X is very standard ANSI C and should compile
|
||||
unmodified with MS Visual C. If you have difficulties building, you
|
||||
might want to read README.COMPILATION.PROBLEMS.
|
||||
|
||||
At least using MS Visual C++ 6, you can build from the unmodified
|
||||
sources by issuing, in a command shell:
|
||||
nmake -f makefile.msc
|
||||
(you may need to first run the MSVC-provided script VCVARS32.BAT
|
||||
so as to set up paths to the MSVC tools correctly).
|
||||
|
||||
|
||||
VALIDATION
|
||||
|
||||
Correct operation, in the sense that a compressed file can always be
|
||||
decompressed to reproduce the original, is obviously of paramount
|
||||
importance. To validate bzip2, I used a modified version of Mark
|
||||
Nelson's churn program. Churn is an automated test driver which
|
||||
recursively traverses a directory structure, using bzip2 to compress
|
||||
and then decompress each file it encounters, and checking that the
|
||||
decompressed data is the same as the original.
|
||||
|
||||
|
||||
|
||||
Please read and be aware of the following:
|
||||
|
||||
WARNING:
|
||||
|
||||
This program (attempts to) compress data by performing several
|
||||
non-trivial transformations on it. Unless you are 100% familiar
|
||||
with *all* the algorithms contained herein, and with the
|
||||
consequences of modifying them, you should NOT meddle with the
|
||||
compression or decompression machinery. Incorrect changes can and
|
||||
very likely *will* lead to disastrous loss of data.
|
||||
|
||||
|
||||
DISCLAIMER:
|
||||
|
||||
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
|
||||
USE OF THIS PROGRAM, HOWSOEVER CAUSED.
|
||||
|
||||
Every compression of a file implies an assumption that the
|
||||
compressed file can be decompressed to reproduce the original.
|
||||
Great efforts in design, coding and testing have been made to
|
||||
ensure that this program works correctly. However, the complexity
|
||||
of the algorithms, and, in particular, the presence of various
|
||||
special cases in the code which occur with very low but non-zero
|
||||
probability make it impossible to rule out the possibility of bugs
|
||||
remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS
|
||||
PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
|
||||
SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
|
||||
|
||||
That is not to say this program is inherently unreliable. Indeed,
|
||||
I very much hope the opposite is true. bzip2 has been carefully
|
||||
constructed and extensively tested.
|
||||
|
||||
|
||||
PATENTS:
|
||||
|
||||
To the best of my knowledge, bzip2 does not use any patented
|
||||
algorithms. However, I do not have the resources to carry out
|
||||
a patent search. Therefore I cannot give any guarantee of the
|
||||
above statement.
|
||||
|
||||
End of legalities.
|
||||
|
||||
|
||||
WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ?
|
||||
|
||||
* Approx 10% faster compression, 30% faster decompression
|
||||
* -t (test mode) is a lot quicker
|
||||
* Can decompress concatenated compressed files
|
||||
* Programming interface, so programs can directly read/write .bz2 files
|
||||
* Less restrictive (BSD-style) licensing
|
||||
* Flag handling more compatible with GNU gzip
|
||||
* Much more documentation, i.e., a proper user manual
|
||||
* Hopefully, improved portability (at least of the library)
|
||||
|
||||
WHAT'S NEW IN 0.9.5 ?
|
||||
|
||||
* Compression speed is much less sensitive to the input
|
||||
data than in previous versions. Specifically, the very
|
||||
slow performance caused by repetitive data is fixed.
|
||||
* Many small improvements in file and flag handling.
|
||||
* A Y2K statement.
|
||||
|
||||
WHAT'S NEW IN 1.0.0 ?
|
||||
|
||||
See the CHANGES file.
|
||||
|
||||
WHAT'S NEW IN 1.0.2 ?
|
||||
|
||||
See the CHANGES file.
|
||||
|
||||
WHAT'S NEW IN 1.0.3 ?
|
||||
|
||||
See the CHANGES file.
|
||||
|
||||
|
||||
I hope you find bzip2 useful. Feel free to contact me at
|
||||
jseward@bzip.org
|
||||
if you have any suggestions or queries. Many people mailed me with
|
||||
comments, suggestions and patches after the releases of bzip-0.15,
|
||||
bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and
|
||||
1.0.2, and the changes in bzip2 are largely a result of this feedback.
|
||||
I thank you for your comments.
|
||||
|
||||
At least for the time being, bzip2's "home" is (or can be reached via)
|
||||
http://www.bzip.org
|
||||
|
||||
Julian Seward
|
||||
jseward@bzip.org
|
||||
|
||||
Cambridge, UK.
|
||||
|
||||
18 July 1996 (version 0.15)
|
||||
25 August 1996 (version 0.21)
|
||||
7 August 1997 (bzip2, version 0.1)
|
||||
29 August 1997 (bzip2, version 0.1pl2)
|
||||
23 August 1998 (bzip2, version 0.9.0)
|
||||
8 June 1999 (bzip2, version 0.9.5)
|
||||
4 Sept 1999 (bzip2, version 0.9.5d)
|
||||
5 May 2000 (bzip2, version 1.0pre8)
|
||||
30 December 2001 (bzip2, version 1.0.2pre1)
|
||||
15 February 2005 (bzip2, version 1.0.3)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,323 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Public header file for the library. ---*/
|
||||
/*--- bzlib.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#ifndef _BZLIB_H
|
||||
#define _BZLIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BZ_RUN 0
|
||||
#define BZ_FLUSH 1
|
||||
#define BZ_FINISH 2
|
||||
|
||||
#define BZ_OK 0
|
||||
#define BZ_RUN_OK 1
|
||||
#define BZ_FLUSH_OK 2
|
||||
#define BZ_FINISH_OK 3
|
||||
#define BZ_STREAM_END 4
|
||||
#define BZ_SEQUENCE_ERROR (-1)
|
||||
#define BZ_PARAM_ERROR (-2)
|
||||
#define BZ_MEM_ERROR (-3)
|
||||
#define BZ_DATA_ERROR (-4)
|
||||
#define BZ_DATA_ERROR_MAGIC (-5)
|
||||
#define BZ_IO_ERROR (-6)
|
||||
#define BZ_UNEXPECTED_EOF (-7)
|
||||
#define BZ_OUTBUFF_FULL (-8)
|
||||
#define BZ_CONFIG_ERROR (-9)
|
||||
|
||||
typedef
|
||||
struct {
|
||||
char *next_in;
|
||||
unsigned int avail_in;
|
||||
unsigned int total_in_lo32;
|
||||
unsigned int total_in_hi32;
|
||||
|
||||
char *next_out;
|
||||
unsigned int avail_out;
|
||||
unsigned int total_out_lo32;
|
||||
unsigned int total_out_hi32;
|
||||
|
||||
void *state;
|
||||
|
||||
void *(*bzalloc)(void *,int,int);
|
||||
void (*bzfree)(void *,void *);
|
||||
void *opaque;
|
||||
}
|
||||
bz_stream;
|
||||
|
||||
|
||||
#ifndef BZ_IMPORT
|
||||
#define BZ_EXPORT
|
||||
#endif
|
||||
|
||||
#ifndef BZ_NO_STDIO
|
||||
/* Need a definitition for FILE */
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# ifdef small
|
||||
/* windows.h define small to char */
|
||||
# undef small
|
||||
# endif
|
||||
# ifdef BZ_EXPORT
|
||||
# define BZ_API(func) WINAPI func
|
||||
# define BZ_EXTERN extern
|
||||
# else
|
||||
/* import windows dll dynamically */
|
||||
# define BZ_API(func) (WINAPI * func)
|
||||
# define BZ_EXTERN
|
||||
# endif
|
||||
#else
|
||||
# define BZ_API(func) func
|
||||
# define BZ_EXTERN extern
|
||||
#endif
|
||||
|
||||
|
||||
/*-- Core (low-level) library functions --*/
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
|
||||
bz_stream* strm,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
|
||||
bz_stream* strm,
|
||||
int action
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
|
||||
bz_stream* strm
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
|
||||
bz_stream *strm,
|
||||
int verbosity,
|
||||
int small
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
|
||||
bz_stream* strm
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
|
||||
bz_stream *strm
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*-- High(er) level library functions --*/
|
||||
|
||||
#ifndef BZ_NO_STDIO
|
||||
#define BZ_MAX_UNUSED 5000
|
||||
|
||||
typedef void BZFILE;
|
||||
|
||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
|
||||
int* bzerror,
|
||||
FILE* f,
|
||||
int verbosity,
|
||||
int small,
|
||||
void* unused,
|
||||
int nUnused
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
|
||||
int* bzerror,
|
||||
BZFILE* b
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void** unused,
|
||||
int* nUnused
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzRead) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
);
|
||||
|
||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
|
||||
int* bzerror,
|
||||
FILE* f,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
int abandon,
|
||||
unsigned int* nbytes_in,
|
||||
unsigned int* nbytes_out
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
int abandon,
|
||||
unsigned int* nbytes_in_lo32,
|
||||
unsigned int* nbytes_in_hi32,
|
||||
unsigned int* nbytes_out_lo32,
|
||||
unsigned int* nbytes_out_hi32
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
/*-- Utility functions --*/
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
|
||||
char* dest,
|
||||
unsigned int* destLen,
|
||||
char* source,
|
||||
unsigned int sourceLen,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
|
||||
char* dest,
|
||||
unsigned int* destLen,
|
||||
char* source,
|
||||
unsigned int sourceLen,
|
||||
int small,
|
||||
int verbosity
|
||||
);
|
||||
|
||||
|
||||
/*--
|
||||
Code contributed by Yoshioka Tsuneo
|
||||
(QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
|
||||
to support better zlib compatibility.
|
||||
This code is not _officially_ part of libbzip2 (yet);
|
||||
I haven't tested it, documented it, or considered the
|
||||
threading-safeness of it.
|
||||
If this code breaks, please contact both Yoshioka and me.
|
||||
--*/
|
||||
|
||||
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
|
||||
void
|
||||
);
|
||||
|
||||
#ifndef BZ_NO_STDIO
|
||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
|
||||
const char *path,
|
||||
const char *mode
|
||||
);
|
||||
|
||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
|
||||
int fd,
|
||||
const char *mode
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzread) (
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
);
|
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzflush) (
|
||||
BZFILE* b
|
||||
);
|
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzclose) (
|
||||
BZFILE* b
|
||||
);
|
||||
|
||||
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
|
||||
BZFILE *b,
|
||||
int *errnum
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,537 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Private header file for the library. ---*/
|
||||
/*--- bzlib_private.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#ifndef _BZLIB_PRIVATE_H
|
||||
#define _BZLIB_PRIVATE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef BZ_NO_STDIO
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "bzlib.h"
|
||||
|
||||
|
||||
|
||||
/*-- General stuff. --*/
|
||||
|
||||
#define BZ_VERSION "1.0.3, 15-Feb-2005"
|
||||
|
||||
typedef char Char;
|
||||
typedef unsigned char Bool;
|
||||
typedef unsigned char UChar;
|
||||
typedef int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
|
||||
#define True ((Bool)1)
|
||||
#define False ((Bool)0)
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __inline__ /* */
|
||||
#endif
|
||||
|
||||
#ifndef BZ_NO_STDIO
|
||||
extern void BZ2_bz__AssertH__fail ( int errcode );
|
||||
#define AssertH(cond,errcode) \
|
||||
{ if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
|
||||
#if BZ_DEBUG
|
||||
#define AssertD(cond,msg) \
|
||||
{ if (!(cond)) { \
|
||||
fprintf ( stderr, \
|
||||
"\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
|
||||
exit(1); \
|
||||
}}
|
||||
#else
|
||||
#define AssertD(cond,msg) /* */
|
||||
#endif
|
||||
#define VPrintf0(zf) \
|
||||
fprintf(stderr,zf)
|
||||
#define VPrintf1(zf,za1) \
|
||||
fprintf(stderr,zf,za1)
|
||||
#define VPrintf2(zf,za1,za2) \
|
||||
fprintf(stderr,zf,za1,za2)
|
||||
#define VPrintf3(zf,za1,za2,za3) \
|
||||
fprintf(stderr,zf,za1,za2,za3)
|
||||
#define VPrintf4(zf,za1,za2,za3,za4) \
|
||||
fprintf(stderr,zf,za1,za2,za3,za4)
|
||||
#define VPrintf5(zf,za1,za2,za3,za4,za5) \
|
||||
fprintf(stderr,zf,za1,za2,za3,za4,za5)
|
||||
#else
|
||||
extern void bz_internal_error ( int errcode );
|
||||
#define AssertH(cond,errcode) \
|
||||
{ if (!(cond)) bz_internal_error ( errcode ); }
|
||||
#define AssertD(cond,msg) /* */
|
||||
#define VPrintf0(zf) /* */
|
||||
#define VPrintf1(zf,za1) /* */
|
||||
#define VPrintf2(zf,za1,za2) /* */
|
||||
#define VPrintf3(zf,za1,za2,za3) /* */
|
||||
#define VPrintf4(zf,za1,za2,za3,za4) /* */
|
||||
#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
|
||||
#endif
|
||||
|
||||
|
||||
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
|
||||
#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
|
||||
|
||||
|
||||
/*-- Header bytes. --*/
|
||||
|
||||
#define BZ_HDR_B 0x42 /* 'B' */
|
||||
#define BZ_HDR_Z 0x5a /* 'Z' */
|
||||
#define BZ_HDR_h 0x68 /* 'h' */
|
||||
#define BZ_HDR_0 0x30 /* '0' */
|
||||
|
||||
/*-- Constants for the back end. --*/
|
||||
|
||||
#define BZ_MAX_ALPHA_SIZE 258
|
||||
#define BZ_MAX_CODE_LEN 23
|
||||
|
||||
#define BZ_RUNA 0
|
||||
#define BZ_RUNB 1
|
||||
|
||||
#define BZ_N_GROUPS 6
|
||||
#define BZ_G_SIZE 50
|
||||
#define BZ_N_ITERS 4
|
||||
|
||||
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
|
||||
|
||||
|
||||
|
||||
/*-- Stuff for randomising repetitive blocks. --*/
|
||||
|
||||
extern Int32 BZ2_rNums[512];
|
||||
|
||||
#define BZ_RAND_DECLS \
|
||||
Int32 rNToGo; \
|
||||
Int32 rTPos \
|
||||
|
||||
#define BZ_RAND_INIT_MASK \
|
||||
s->rNToGo = 0; \
|
||||
s->rTPos = 0 \
|
||||
|
||||
#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
|
||||
|
||||
#define BZ_RAND_UPD_MASK \
|
||||
if (s->rNToGo == 0) { \
|
||||
s->rNToGo = BZ2_rNums[s->rTPos]; \
|
||||
s->rTPos++; \
|
||||
if (s->rTPos == 512) s->rTPos = 0; \
|
||||
} \
|
||||
s->rNToGo--;
|
||||
|
||||
|
||||
|
||||
/*-- Stuff for doing CRCs. --*/
|
||||
|
||||
extern UInt32 BZ2_crc32Table[256];
|
||||
|
||||
#define BZ_INITIALISE_CRC(crcVar) \
|
||||
{ \
|
||||
crcVar = 0xffffffffL; \
|
||||
}
|
||||
|
||||
#define BZ_FINALISE_CRC(crcVar) \
|
||||
{ \
|
||||
crcVar = ~(crcVar); \
|
||||
}
|
||||
|
||||
#define BZ_UPDATE_CRC(crcVar,cha) \
|
||||
{ \
|
||||
crcVar = (crcVar << 8) ^ \
|
||||
BZ2_crc32Table[(crcVar >> 24) ^ \
|
||||
((UChar)cha)]; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-- States and modes for compression. --*/
|
||||
|
||||
#define BZ_M_IDLE 1
|
||||
#define BZ_M_RUNNING 2
|
||||
#define BZ_M_FLUSHING 3
|
||||
#define BZ_M_FINISHING 4
|
||||
|
||||
#define BZ_S_OUTPUT 1
|
||||
#define BZ_S_INPUT 2
|
||||
|
||||
#define BZ_N_RADIX 2
|
||||
#define BZ_N_QSORT 12
|
||||
#define BZ_N_SHELL 18
|
||||
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
|
||||
|
||||
|
||||
|
||||
|
||||
/*-- Structure holding all the compression-side stuff. --*/
|
||||
|
||||
typedef
|
||||
struct {
|
||||
/* pointer back to the struct bz_stream */
|
||||
bz_stream* strm;
|
||||
|
||||
/* mode this stream is in, and whether inputting */
|
||||
/* or outputting data */
|
||||
Int32 mode;
|
||||
Int32 state;
|
||||
|
||||
/* remembers avail_in when flush/finish requested */
|
||||
UInt32 avail_in_expect;
|
||||
|
||||
/* for doing the block sorting */
|
||||
UInt32* arr1;
|
||||
UInt32* arr2;
|
||||
UInt32* ftab;
|
||||
Int32 origPtr;
|
||||
|
||||
/* aliases for arr1 and arr2 */
|
||||
UInt32* ptr;
|
||||
UChar* block;
|
||||
UInt16* mtfv;
|
||||
UChar* zbits;
|
||||
|
||||
/* for deciding when to use the fallback sorting algorithm */
|
||||
Int32 workFactor;
|
||||
|
||||
/* run-length-encoding of the input */
|
||||
UInt32 state_in_ch;
|
||||
Int32 state_in_len;
|
||||
BZ_RAND_DECLS;
|
||||
|
||||
/* input and output limits and current posns */
|
||||
Int32 nblock;
|
||||
Int32 nblockMAX;
|
||||
Int32 numZ;
|
||||
Int32 state_out_pos;
|
||||
|
||||
/* map of bytes used in block */
|
||||
Int32 nInUse;
|
||||
Bool inUse[256];
|
||||
UChar unseqToSeq[256];
|
||||
|
||||
/* the buffer for bit stream creation */
|
||||
UInt32 bsBuff;
|
||||
Int32 bsLive;
|
||||
|
||||
/* block and combined CRCs */
|
||||
UInt32 blockCRC;
|
||||
UInt32 combinedCRC;
|
||||
|
||||
/* misc administratium */
|
||||
Int32 verbosity;
|
||||
Int32 blockNo;
|
||||
Int32 blockSize100k;
|
||||
|
||||
/* stuff for coding the MTF values */
|
||||
Int32 nMTF;
|
||||
Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
|
||||
UChar selector [BZ_MAX_SELECTORS];
|
||||
UChar selectorMtf[BZ_MAX_SELECTORS];
|
||||
|
||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
/* second dimension: only 3 needed; 4 makes index calculations faster */
|
||||
UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
|
||||
|
||||
}
|
||||
EState;
|
||||
|
||||
|
||||
|
||||
/*-- externs for compression. --*/
|
||||
|
||||
extern void
|
||||
BZ2_blockSort ( EState* );
|
||||
|
||||
extern void
|
||||
BZ2_compressBlock ( EState*, Bool );
|
||||
|
||||
extern void
|
||||
BZ2_bsInitWrite ( EState* );
|
||||
|
||||
extern void
|
||||
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
|
||||
|
||||
extern void
|
||||
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
|
||||
|
||||
|
||||
|
||||
/*-- states for decompression. --*/
|
||||
|
||||
#define BZ_X_IDLE 1
|
||||
#define BZ_X_OUTPUT 2
|
||||
|
||||
#define BZ_X_MAGIC_1 10
|
||||
#define BZ_X_MAGIC_2 11
|
||||
#define BZ_X_MAGIC_3 12
|
||||
#define BZ_X_MAGIC_4 13
|
||||
#define BZ_X_BLKHDR_1 14
|
||||
#define BZ_X_BLKHDR_2 15
|
||||
#define BZ_X_BLKHDR_3 16
|
||||
#define BZ_X_BLKHDR_4 17
|
||||
#define BZ_X_BLKHDR_5 18
|
||||
#define BZ_X_BLKHDR_6 19
|
||||
#define BZ_X_BCRC_1 20
|
||||
#define BZ_X_BCRC_2 21
|
||||
#define BZ_X_BCRC_3 22
|
||||
#define BZ_X_BCRC_4 23
|
||||
#define BZ_X_RANDBIT 24
|
||||
#define BZ_X_ORIGPTR_1 25
|
||||
#define BZ_X_ORIGPTR_2 26
|
||||
#define BZ_X_ORIGPTR_3 27
|
||||
#define BZ_X_MAPPING_1 28
|
||||
#define BZ_X_MAPPING_2 29
|
||||
#define BZ_X_SELECTOR_1 30
|
||||
#define BZ_X_SELECTOR_2 31
|
||||
#define BZ_X_SELECTOR_3 32
|
||||
#define BZ_X_CODING_1 33
|
||||
#define BZ_X_CODING_2 34
|
||||
#define BZ_X_CODING_3 35
|
||||
#define BZ_X_MTF_1 36
|
||||
#define BZ_X_MTF_2 37
|
||||
#define BZ_X_MTF_3 38
|
||||
#define BZ_X_MTF_4 39
|
||||
#define BZ_X_MTF_5 40
|
||||
#define BZ_X_MTF_6 41
|
||||
#define BZ_X_ENDHDR_2 42
|
||||
#define BZ_X_ENDHDR_3 43
|
||||
#define BZ_X_ENDHDR_4 44
|
||||
#define BZ_X_ENDHDR_5 45
|
||||
#define BZ_X_ENDHDR_6 46
|
||||
#define BZ_X_CCRC_1 47
|
||||
#define BZ_X_CCRC_2 48
|
||||
#define BZ_X_CCRC_3 49
|
||||
#define BZ_X_CCRC_4 50
|
||||
|
||||
|
||||
|
||||
/*-- Constants for the fast MTF decoder. --*/
|
||||
|
||||
#define MTFA_SIZE 4096
|
||||
#define MTFL_SIZE 16
|
||||
|
||||
|
||||
|
||||
/*-- Structure holding all the decompression-side stuff. --*/
|
||||
|
||||
typedef
|
||||
struct {
|
||||
/* pointer back to the struct bz_stream */
|
||||
bz_stream* strm;
|
||||
|
||||
/* state indicator for this stream */
|
||||
Int32 state;
|
||||
|
||||
/* for doing the final run-length decoding */
|
||||
UChar state_out_ch;
|
||||
Int32 state_out_len;
|
||||
Bool blockRandomised;
|
||||
BZ_RAND_DECLS;
|
||||
|
||||
/* the buffer for bit stream reading */
|
||||
UInt32 bsBuff;
|
||||
Int32 bsLive;
|
||||
|
||||
/* misc administratium */
|
||||
Int32 blockSize100k;
|
||||
Bool smallDecompress;
|
||||
Int32 currBlockNo;
|
||||
Int32 verbosity;
|
||||
|
||||
/* for undoing the Burrows-Wheeler transform */
|
||||
Int32 origPtr;
|
||||
UInt32 tPos;
|
||||
Int32 k0;
|
||||
Int32 unzftab[256];
|
||||
Int32 nblock_used;
|
||||
Int32 cftab[257];
|
||||
Int32 cftabCopy[257];
|
||||
|
||||
/* for undoing the Burrows-Wheeler transform (FAST) */
|
||||
UInt32 *tt;
|
||||
|
||||
/* for undoing the Burrows-Wheeler transform (SMALL) */
|
||||
UInt16 *ll16;
|
||||
UChar *ll4;
|
||||
|
||||
/* stored and calculated CRCs */
|
||||
UInt32 storedBlockCRC;
|
||||
UInt32 storedCombinedCRC;
|
||||
UInt32 calculatedBlockCRC;
|
||||
UInt32 calculatedCombinedCRC;
|
||||
|
||||
/* map of bytes used in block */
|
||||
Int32 nInUse;
|
||||
Bool inUse[256];
|
||||
Bool inUse16[16];
|
||||
UChar seqToUnseq[256];
|
||||
|
||||
/* for decoding the MTF values */
|
||||
UChar mtfa [MTFA_SIZE];
|
||||
Int32 mtfbase[256 / MTFL_SIZE];
|
||||
UChar selector [BZ_MAX_SELECTORS];
|
||||
UChar selectorMtf[BZ_MAX_SELECTORS];
|
||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
|
||||
Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 minLens[BZ_N_GROUPS];
|
||||
|
||||
/* save area for scalars in the main decompress code */
|
||||
Int32 save_i;
|
||||
Int32 save_j;
|
||||
Int32 save_t;
|
||||
Int32 save_alphaSize;
|
||||
Int32 save_nGroups;
|
||||
Int32 save_nSelectors;
|
||||
Int32 save_EOB;
|
||||
Int32 save_groupNo;
|
||||
Int32 save_groupPos;
|
||||
Int32 save_nextSym;
|
||||
Int32 save_nblockMAX;
|
||||
Int32 save_nblock;
|
||||
Int32 save_es;
|
||||
Int32 save_N;
|
||||
Int32 save_curr;
|
||||
Int32 save_zt;
|
||||
Int32 save_zn;
|
||||
Int32 save_zvec;
|
||||
Int32 save_zj;
|
||||
Int32 save_gSel;
|
||||
Int32 save_gMinlen;
|
||||
Int32* save_gLimit;
|
||||
Int32* save_gBase;
|
||||
Int32* save_gPerm;
|
||||
|
||||
}
|
||||
DState;
|
||||
|
||||
|
||||
|
||||
/*-- Macros for decompression. --*/
|
||||
|
||||
#define BZ_GET_FAST(cccc) \
|
||||
s->tPos = s->tt[s->tPos]; \
|
||||
cccc = (UChar)(s->tPos & 0xff); \
|
||||
s->tPos >>= 8;
|
||||
|
||||
#define BZ_GET_FAST_C(cccc) \
|
||||
c_tPos = c_tt[c_tPos]; \
|
||||
cccc = (UChar)(c_tPos & 0xff); \
|
||||
c_tPos >>= 8;
|
||||
|
||||
#define SET_LL4(i,n) \
|
||||
{ if (((i) & 0x1) == 0) \
|
||||
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
|
||||
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
|
||||
}
|
||||
|
||||
#define GET_LL4(i) \
|
||||
((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
|
||||
|
||||
#define SET_LL(i,n) \
|
||||
{ s->ll16[i] = (UInt16)(n & 0x0000ffff); \
|
||||
SET_LL4(i, n >> 16); \
|
||||
}
|
||||
|
||||
#define GET_LL(i) \
|
||||
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
|
||||
|
||||
#define BZ_GET_SMALL(cccc) \
|
||||
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
||||
s->tPos = GET_LL(s->tPos);
|
||||
|
||||
|
||||
/*-- externs for decompression. --*/
|
||||
|
||||
extern Int32
|
||||
BZ2_indexIntoF ( Int32, Int32* );
|
||||
|
||||
extern Int32
|
||||
BZ2_decompress ( DState* );
|
||||
|
||||
extern void
|
||||
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
|
||||
Int32, Int32, Int32 );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
|
||||
|
||||
#ifdef BZ_NO_STDIO
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib_private.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,716 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Compression machinery (not incl block sorting) ---*/
|
||||
/*--- compress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
/*--
|
||||
CHANGES
|
||||
~~~~~~~
|
||||
0.9.0 -- original version.
|
||||
|
||||
0.9.0a/b -- no changes in this file.
|
||||
|
||||
0.9.0c
|
||||
* changed setting of nGroups in sendMTFValues() so as to
|
||||
do a bit better on small files
|
||||
--*/
|
||||
|
||||
#include "bzlib_private.h"
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- Bit stream I/O ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
void BZ2_bsInitWrite ( EState* s )
|
||||
{
|
||||
s->bsLive = 0;
|
||||
s->bsBuff = 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void bsFinishWrite ( EState* s )
|
||||
{
|
||||
while (s->bsLive > 0) {
|
||||
s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24);
|
||||
s->numZ++;
|
||||
s->bsBuff <<= 8;
|
||||
s->bsLive -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define bsNEEDW(nz) \
|
||||
{ \
|
||||
while (s->bsLive >= 8) { \
|
||||
s->zbits[s->numZ] \
|
||||
= (UChar)(s->bsBuff >> 24); \
|
||||
s->numZ++; \
|
||||
s->bsBuff <<= 8; \
|
||||
s->bsLive -= 8; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
__inline__
|
||||
void bsW ( EState* s, Int32 n, UInt32 v )
|
||||
{
|
||||
bsNEEDW ( n );
|
||||
s->bsBuff |= (v << (32 - s->bsLive - n));
|
||||
s->bsLive += n;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void bsPutUInt32 ( EState* s, UInt32 u )
|
||||
{
|
||||
bsW ( s, 8, (u >> 24) & 0xffL );
|
||||
bsW ( s, 8, (u >> 16) & 0xffL );
|
||||
bsW ( s, 8, (u >> 8) & 0xffL );
|
||||
bsW ( s, 8, u & 0xffL );
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void bsPutUChar ( EState* s, UChar c )
|
||||
{
|
||||
bsW( s, 8, (UInt32)c );
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- The back end proper ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void makeMaps_e ( EState* s )
|
||||
{
|
||||
Int32 i;
|
||||
s->nInUse = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
if (s->inUse[i]) {
|
||||
s->unseqToSeq[i] = s->nInUse;
|
||||
s->nInUse++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void generateMTFValues ( EState* s )
|
||||
{
|
||||
UChar yy[256];
|
||||
Int32 i, j;
|
||||
Int32 zPend;
|
||||
Int32 wr;
|
||||
Int32 EOB;
|
||||
|
||||
/*
|
||||
After sorting (eg, here),
|
||||
s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
|
||||
and
|
||||
((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
|
||||
holds the original block data.
|
||||
|
||||
The first thing to do is generate the MTF values,
|
||||
and put them in
|
||||
((UInt16*)s->arr1) [ 0 .. s->nblock-1 ].
|
||||
Because there are strictly fewer or equal MTF values
|
||||
than block values, ptr values in this area are overwritten
|
||||
with MTF values only when they are no longer needed.
|
||||
|
||||
The final compressed bitstream is generated into the
|
||||
area starting at
|
||||
(UChar*) (&((UChar*)s->arr2)[s->nblock])
|
||||
|
||||
These storage aliases are set up in bzCompressInit(),
|
||||
except for the last one, which is arranged in
|
||||
compressBlock().
|
||||
*/
|
||||
UInt32* ptr = s->ptr;
|
||||
UChar* block = s->block;
|
||||
UInt16* mtfv = s->mtfv;
|
||||
|
||||
makeMaps_e ( s );
|
||||
EOB = s->nInUse+1;
|
||||
|
||||
for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0;
|
||||
|
||||
wr = 0;
|
||||
zPend = 0;
|
||||
for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i;
|
||||
|
||||
for (i = 0; i < s->nblock; i++) {
|
||||
UChar ll_i;
|
||||
AssertD ( wr <= i, "generateMTFValues(1)" );
|
||||
j = ptr[i]-1; if (j < 0) j += s->nblock;
|
||||
ll_i = s->unseqToSeq[block[j]];
|
||||
AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
|
||||
|
||||
if (yy[0] == ll_i) {
|
||||
zPend++;
|
||||
} else {
|
||||
|
||||
if (zPend > 0) {
|
||||
zPend--;
|
||||
while (True) {
|
||||
if (zPend & 1) {
|
||||
mtfv[wr] = BZ_RUNB; wr++;
|
||||
s->mtfFreq[BZ_RUNB]++;
|
||||
} else {
|
||||
mtfv[wr] = BZ_RUNA; wr++;
|
||||
s->mtfFreq[BZ_RUNA]++;
|
||||
}
|
||||
if (zPend < 2) break;
|
||||
zPend = (zPend - 2) / 2;
|
||||
};
|
||||
zPend = 0;
|
||||
}
|
||||
{
|
||||
register UChar rtmp;
|
||||
register UChar* ryy_j;
|
||||
register UChar rll_i;
|
||||
rtmp = yy[1];
|
||||
yy[1] = yy[0];
|
||||
ryy_j = &(yy[1]);
|
||||
rll_i = ll_i;
|
||||
while ( rll_i != rtmp ) {
|
||||
register UChar rtmp2;
|
||||
ryy_j++;
|
||||
rtmp2 = rtmp;
|
||||
rtmp = *ryy_j;
|
||||
*ryy_j = rtmp2;
|
||||
};
|
||||
yy[0] = rtmp;
|
||||
j = ryy_j - &(yy[0]);
|
||||
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (zPend > 0) {
|
||||
zPend--;
|
||||
while (True) {
|
||||
if (zPend & 1) {
|
||||
mtfv[wr] = BZ_RUNB; wr++;
|
||||
s->mtfFreq[BZ_RUNB]++;
|
||||
} else {
|
||||
mtfv[wr] = BZ_RUNA; wr++;
|
||||
s->mtfFreq[BZ_RUNA]++;
|
||||
}
|
||||
if (zPend < 2) break;
|
||||
zPend = (zPend - 2) / 2;
|
||||
};
|
||||
zPend = 0;
|
||||
}
|
||||
|
||||
mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++;
|
||||
|
||||
s->nMTF = wr;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define BZ_LESSER_ICOST 0
|
||||
#define BZ_GREATER_ICOST 15
|
||||
|
||||
static
|
||||
void sendMTFValues ( EState* s )
|
||||
{
|
||||
Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
|
||||
Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
|
||||
Int32 nGroups, nBytes;
|
||||
|
||||
/*--
|
||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
is a global since the decoder also needs it.
|
||||
|
||||
Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
are also globals only used in this proc.
|
||||
Made global to keep stack frame size small.
|
||||
--*/
|
||||
|
||||
|
||||
UInt16 cost[BZ_N_GROUPS];
|
||||
Int32 fave[BZ_N_GROUPS];
|
||||
|
||||
UInt16* mtfv = s->mtfv;
|
||||
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
|
||||
"%d+2 syms in use\n",
|
||||
s->nblock, s->nMTF, s->nInUse );
|
||||
|
||||
alphaSize = s->nInUse+2;
|
||||
for (t = 0; t < BZ_N_GROUPS; t++)
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
s->len[t][v] = BZ_GREATER_ICOST;
|
||||
|
||||
/*--- Decide how many coding tables to use ---*/
|
||||
AssertH ( s->nMTF > 0, 3001 );
|
||||
if (s->nMTF < 200) nGroups = 2; else
|
||||
if (s->nMTF < 600) nGroups = 3; else
|
||||
if (s->nMTF < 1200) nGroups = 4; else
|
||||
if (s->nMTF < 2400) nGroups = 5; else
|
||||
nGroups = 6;
|
||||
|
||||
/*--- Generate an initial set of coding tables ---*/
|
||||
{
|
||||
Int32 nPart, remF, tFreq, aFreq;
|
||||
|
||||
nPart = nGroups;
|
||||
remF = s->nMTF;
|
||||
gs = 0;
|
||||
while (nPart > 0) {
|
||||
tFreq = remF / nPart;
|
||||
ge = gs-1;
|
||||
aFreq = 0;
|
||||
while (aFreq < tFreq && ge < alphaSize-1) {
|
||||
ge++;
|
||||
aFreq += s->mtfFreq[ge];
|
||||
}
|
||||
|
||||
if (ge > gs
|
||||
&& nPart != nGroups && nPart != 1
|
||||
&& ((nGroups-nPart) % 2 == 1)) {
|
||||
aFreq -= s->mtfFreq[ge];
|
||||
ge--;
|
||||
}
|
||||
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf5( " initial group %d, [%d .. %d], "
|
||||
"has %d syms (%4.1f%%)\n",
|
||||
nPart, gs, ge, aFreq,
|
||||
(100.0 * (float)aFreq) / (float)(s->nMTF) );
|
||||
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
if (v >= gs && v <= ge)
|
||||
s->len[nPart-1][v] = BZ_LESSER_ICOST; else
|
||||
s->len[nPart-1][v] = BZ_GREATER_ICOST;
|
||||
|
||||
nPart--;
|
||||
gs = ge+1;
|
||||
remF -= aFreq;
|
||||
}
|
||||
}
|
||||
|
||||
/*---
|
||||
Iterate up to BZ_N_ITERS times to improve the tables.
|
||||
---*/
|
||||
for (iter = 0; iter < BZ_N_ITERS; iter++) {
|
||||
|
||||
for (t = 0; t < nGroups; t++) fave[t] = 0;
|
||||
|
||||
for (t = 0; t < nGroups; t++)
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
s->rfreq[t][v] = 0;
|
||||
|
||||
/*---
|
||||
Set up an auxiliary length table which is used to fast-track
|
||||
the common case (nGroups == 6).
|
||||
---*/
|
||||
if (nGroups == 6) {
|
||||
for (v = 0; v < alphaSize; v++) {
|
||||
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
|
||||
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
|
||||
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
|
||||
}
|
||||
}
|
||||
|
||||
nSelectors = 0;
|
||||
totc = 0;
|
||||
gs = 0;
|
||||
while (True) {
|
||||
|
||||
/*--- Set group start & end marks. --*/
|
||||
if (gs >= s->nMTF) break;
|
||||
ge = gs + BZ_G_SIZE - 1;
|
||||
if (ge >= s->nMTF) ge = s->nMTF-1;
|
||||
|
||||
/*--
|
||||
Calculate the cost of this group as coded
|
||||
by each of the coding tables.
|
||||
--*/
|
||||
for (t = 0; t < nGroups; t++) cost[t] = 0;
|
||||
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
register UInt32 cost01, cost23, cost45;
|
||||
register UInt16 icv;
|
||||
cost01 = cost23 = cost45 = 0;
|
||||
|
||||
# define BZ_ITER(nn) \
|
||||
icv = mtfv[gs+(nn)]; \
|
||||
cost01 += s->len_pack[icv][0]; \
|
||||
cost23 += s->len_pack[icv][1]; \
|
||||
cost45 += s->len_pack[icv][2]; \
|
||||
|
||||
BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
|
||||
BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
|
||||
BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
|
||||
BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
|
||||
BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
|
||||
BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
|
||||
BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
|
||||
BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
|
||||
BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
|
||||
BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
|
||||
|
||||
# undef BZ_ITER
|
||||
|
||||
cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
|
||||
cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
|
||||
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
|
||||
|
||||
} else {
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
for (i = gs; i <= ge; i++) {
|
||||
UInt16 icv = mtfv[i];
|
||||
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
|
||||
}
|
||||
}
|
||||
|
||||
/*--
|
||||
Find the coding table which is best for this group,
|
||||
and record its identity in the selector table.
|
||||
--*/
|
||||
bc = 999999999; bt = -1;
|
||||
for (t = 0; t < nGroups; t++)
|
||||
if (cost[t] < bc) { bc = cost[t]; bt = t; };
|
||||
totc += bc;
|
||||
fave[bt]++;
|
||||
s->selector[nSelectors] = bt;
|
||||
nSelectors++;
|
||||
|
||||
/*--
|
||||
Increment the symbol frequencies for the selected table.
|
||||
--*/
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
|
||||
# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++
|
||||
|
||||
BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
|
||||
BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
|
||||
BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
|
||||
BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
|
||||
BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
|
||||
BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
|
||||
BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
|
||||
BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
|
||||
BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
|
||||
BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
|
||||
|
||||
# undef BZ_ITUR
|
||||
|
||||
} else {
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
for (i = gs; i <= ge; i++)
|
||||
s->rfreq[bt][ mtfv[i] ]++;
|
||||
}
|
||||
|
||||
gs = ge+1;
|
||||
}
|
||||
if (s->verbosity >= 3) {
|
||||
VPrintf2 ( " pass %d: size is %d, grp uses are ",
|
||||
iter+1, totc/8 );
|
||||
for (t = 0; t < nGroups; t++)
|
||||
VPrintf1 ( "%d ", fave[t] );
|
||||
VPrintf0 ( "\n" );
|
||||
}
|
||||
|
||||
/*--
|
||||
Recompute the tables based on the accumulated frequencies.
|
||||
--*/
|
||||
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
|
||||
comment in huffman.c for details. */
|
||||
for (t = 0; t < nGroups; t++)
|
||||
BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
|
||||
alphaSize, 17 /*20*/ );
|
||||
}
|
||||
|
||||
|
||||
AssertH( nGroups < 8, 3002 );
|
||||
AssertH( nSelectors < 32768 &&
|
||||
nSelectors <= (2 + (900000 / BZ_G_SIZE)),
|
||||
3003 );
|
||||
|
||||
|
||||
/*--- Compute MTF values for the selectors. ---*/
|
||||
{
|
||||
UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
|
||||
for (i = 0; i < nGroups; i++) pos[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
ll_i = s->selector[i];
|
||||
j = 0;
|
||||
tmp = pos[j];
|
||||
while ( ll_i != tmp ) {
|
||||
j++;
|
||||
tmp2 = tmp;
|
||||
tmp = pos[j];
|
||||
pos[j] = tmp2;
|
||||
};
|
||||
pos[0] = tmp;
|
||||
s->selectorMtf[i] = j;
|
||||
}
|
||||
};
|
||||
|
||||
/*--- Assign actual codes for the tables. --*/
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
minLen = 32;
|
||||
maxLen = 0;
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
|
||||
if (s->len[t][i] < minLen) minLen = s->len[t][i];
|
||||
}
|
||||
AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
|
||||
AssertH ( !(minLen < 1), 3005 );
|
||||
BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
|
||||
minLen, maxLen, alphaSize );
|
||||
}
|
||||
|
||||
/*--- Transmit the mapping table. ---*/
|
||||
{
|
||||
Bool inUse16[16];
|
||||
for (i = 0; i < 16; i++) {
|
||||
inUse16[i] = False;
|
||||
for (j = 0; j < 16; j++)
|
||||
if (s->inUse[i * 16 + j]) inUse16[i] = True;
|
||||
}
|
||||
|
||||
nBytes = s->numZ;
|
||||
for (i = 0; i < 16; i++)
|
||||
if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
if (inUse16[i])
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
|
||||
}
|
||||
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
|
||||
}
|
||||
|
||||
/*--- Now the selectors. ---*/
|
||||
nBytes = s->numZ;
|
||||
bsW ( s, 3, nGroups );
|
||||
bsW ( s, 15, nSelectors );
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
|
||||
bsW(s,1,0);
|
||||
}
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf1( "selectors %d, ", s->numZ-nBytes );
|
||||
|
||||
/*--- Now the coding tables. ---*/
|
||||
nBytes = s->numZ;
|
||||
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
Int32 curr = s->len[t][0];
|
||||
bsW ( s, 5, curr );
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ };
|
||||
while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ };
|
||||
bsW ( s, 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf1 ( "code lengths %d, ", s->numZ-nBytes );
|
||||
|
||||
/*--- And finally, the block data proper ---*/
|
||||
nBytes = s->numZ;
|
||||
selCtr = 0;
|
||||
gs = 0;
|
||||
while (True) {
|
||||
if (gs >= s->nMTF) break;
|
||||
ge = gs + BZ_G_SIZE - 1;
|
||||
if (ge >= s->nMTF) ge = s->nMTF-1;
|
||||
AssertH ( s->selector[selCtr] < nGroups, 3006 );
|
||||
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
UInt16 mtfv_i;
|
||||
UChar* s_len_sel_selCtr
|
||||
= &(s->len[s->selector[selCtr]][0]);
|
||||
Int32* s_code_sel_selCtr
|
||||
= &(s->code[s->selector[selCtr]][0]);
|
||||
|
||||
# define BZ_ITAH(nn) \
|
||||
mtfv_i = mtfv[gs+(nn)]; \
|
||||
bsW ( s, \
|
||||
s_len_sel_selCtr[mtfv_i], \
|
||||
s_code_sel_selCtr[mtfv_i] )
|
||||
|
||||
BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
|
||||
BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
|
||||
BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
|
||||
BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
|
||||
BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
|
||||
BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
|
||||
BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
|
||||
BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
|
||||
BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
|
||||
BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
|
||||
|
||||
# undef BZ_ITAH
|
||||
|
||||
} else {
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
for (i = gs; i <= ge; i++) {
|
||||
bsW ( s,
|
||||
s->len [s->selector[selCtr]] [mtfv[i]],
|
||||
s->code [s->selector[selCtr]] [mtfv[i]] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gs = ge+1;
|
||||
selCtr++;
|
||||
}
|
||||
AssertH( selCtr == nSelectors, 3007 );
|
||||
|
||||
if (s->verbosity >= 3)
|
||||
VPrintf1( "codes %d\n", s->numZ-nBytes );
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
void BZ2_compressBlock ( EState* s, Bool is_last_block )
|
||||
{
|
||||
if (s->nblock > 0) {
|
||||
|
||||
BZ_FINALISE_CRC ( s->blockCRC );
|
||||
s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
|
||||
s->combinedCRC ^= s->blockCRC;
|
||||
if (s->blockNo > 1) s->numZ = 0;
|
||||
|
||||
if (s->verbosity >= 2)
|
||||
VPrintf4( " block %d: crc = 0x%08x, "
|
||||
"combined CRC = 0x%08x, size = %d\n",
|
||||
s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
|
||||
|
||||
BZ2_blockSort ( s );
|
||||
}
|
||||
|
||||
s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
|
||||
|
||||
/*-- If this is the first block, create the stream header. --*/
|
||||
if (s->blockNo == 1) {
|
||||
BZ2_bsInitWrite ( s );
|
||||
bsPutUChar ( s, BZ_HDR_B );
|
||||
bsPutUChar ( s, BZ_HDR_Z );
|
||||
bsPutUChar ( s, BZ_HDR_h );
|
||||
bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) );
|
||||
}
|
||||
|
||||
if (s->nblock > 0) {
|
||||
|
||||
bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
|
||||
bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
|
||||
bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
|
||||
|
||||
/*-- Now the block's CRC, so it is in a known place. --*/
|
||||
bsPutUInt32 ( s, s->blockCRC );
|
||||
|
||||
/*--
|
||||
Now a single bit indicating (non-)randomisation.
|
||||
As of version 0.9.5, we use a better sorting algorithm
|
||||
which makes randomisation unnecessary. So always set
|
||||
the randomised bit to 'no'. Of course, the decoder
|
||||
still needs to be able to handle randomised blocks
|
||||
so as to maintain backwards compatibility with
|
||||
older versions of bzip2.
|
||||
--*/
|
||||
bsW(s,1,0);
|
||||
|
||||
bsW ( s, 24, s->origPtr );
|
||||
generateMTFValues ( s );
|
||||
sendMTFValues ( s );
|
||||
}
|
||||
|
||||
|
||||
/*-- If this is the last block, add the stream trailer. --*/
|
||||
if (is_last_block) {
|
||||
|
||||
bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
|
||||
bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
|
||||
bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
|
||||
bsPutUInt32 ( s, s->combinedCRC );
|
||||
if (s->verbosity >= 2)
|
||||
VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC );
|
||||
bsFinishWrite ( s );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end compress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,144 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Table for doing CRCs ---*/
|
||||
/*--- crctable.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#include "bzlib_private.h"
|
||||
|
||||
/*--
|
||||
I think this is an implementation of the AUTODIN-II,
|
||||
Ethernet & FDDI 32-bit CRC standard. Vaguely derived
|
||||
from code by Rob Warnock, in Section 51 of the
|
||||
comp.compression FAQ.
|
||||
--*/
|
||||
|
||||
UInt32 BZ2_crc32Table[256] = {
|
||||
|
||||
/*-- Ugly, innit? --*/
|
||||
|
||||
0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
|
||||
0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
|
||||
0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
|
||||
0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
|
||||
0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
|
||||
0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
|
||||
0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
|
||||
0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
|
||||
0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
|
||||
0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
|
||||
0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
|
||||
0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
|
||||
0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
|
||||
0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
|
||||
0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
|
||||
0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
|
||||
0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
|
||||
0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
|
||||
0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
|
||||
0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
|
||||
0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
|
||||
0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
|
||||
0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
|
||||
0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
|
||||
0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
|
||||
0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
|
||||
0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
|
||||
0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
|
||||
0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
|
||||
0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
|
||||
0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
|
||||
0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
|
||||
0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
|
||||
0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
|
||||
0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
|
||||
0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
|
||||
0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
|
||||
0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
|
||||
0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
|
||||
0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
|
||||
0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
|
||||
0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
|
||||
0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
|
||||
0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
|
||||
0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
|
||||
0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
|
||||
0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
|
||||
0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
|
||||
0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
|
||||
0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
|
||||
0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
|
||||
0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
|
||||
0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
|
||||
0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
|
||||
0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
|
||||
0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
|
||||
0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
|
||||
0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
|
||||
0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
|
||||
0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
|
||||
0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
|
||||
0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
|
||||
0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
|
||||
0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end crctable.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,666 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Decompression machinery ---*/
|
||||
/*--- decompress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#include "bzlib_private.h"
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void makeMaps_d ( DState* s )
|
||||
{
|
||||
Int32 i;
|
||||
s->nInUse = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
if (s->inUse[i]) {
|
||||
s->seqToUnseq[s->nInUse] = i;
|
||||
s->nInUse++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define RETURN(rrr) \
|
||||
{ retVal = rrr; goto save_state_and_return; };
|
||||
|
||||
#define GET_BITS(lll,vvv,nnn) \
|
||||
case lll: s->state = lll; \
|
||||
while (True) { \
|
||||
if (s->bsLive >= nnn) { \
|
||||
UInt32 v; \
|
||||
v = (s->bsBuff >> \
|
||||
(s->bsLive-nnn)) & ((1 << nnn)-1); \
|
||||
s->bsLive -= nnn; \
|
||||
vvv = v; \
|
||||
break; \
|
||||
} \
|
||||
if (s->strm->avail_in == 0) RETURN(BZ_OK); \
|
||||
s->bsBuff \
|
||||
= (s->bsBuff << 8) | \
|
||||
((UInt32) \
|
||||
(*((UChar*)(s->strm->next_in)))); \
|
||||
s->bsLive += 8; \
|
||||
s->strm->next_in++; \
|
||||
s->strm->avail_in--; \
|
||||
s->strm->total_in_lo32++; \
|
||||
if (s->strm->total_in_lo32 == 0) \
|
||||
s->strm->total_in_hi32++; \
|
||||
}
|
||||
|
||||
#define GET_UCHAR(lll,uuu) \
|
||||
GET_BITS(lll,uuu,8)
|
||||
|
||||
#define GET_BIT(lll,uuu) \
|
||||
GET_BITS(lll,uuu,1)
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define GET_MTF_VAL(label1,label2,lval) \
|
||||
{ \
|
||||
if (groupPos == 0) { \
|
||||
groupNo++; \
|
||||
if (groupNo >= nSelectors) \
|
||||
RETURN(BZ_DATA_ERROR); \
|
||||
groupPos = BZ_G_SIZE; \
|
||||
gSel = s->selector[groupNo]; \
|
||||
gMinlen = s->minLens[gSel]; \
|
||||
gLimit = &(s->limit[gSel][0]); \
|
||||
gPerm = &(s->perm[gSel][0]); \
|
||||
gBase = &(s->base[gSel][0]); \
|
||||
} \
|
||||
groupPos--; \
|
||||
zn = gMinlen; \
|
||||
GET_BITS(label1, zvec, zn); \
|
||||
while (1) { \
|
||||
if (zn > 20 /* the longest code */) \
|
||||
RETURN(BZ_DATA_ERROR); \
|
||||
if (zvec <= gLimit[zn]) break; \
|
||||
zn++; \
|
||||
GET_BIT(label2, zj); \
|
||||
zvec = (zvec << 1) | zj; \
|
||||
}; \
|
||||
if (zvec - gBase[zn] < 0 \
|
||||
|| zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \
|
||||
RETURN(BZ_DATA_ERROR); \
|
||||
lval = gPerm[zvec - gBase[zn]]; \
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
Int32 BZ2_decompress ( DState* s )
|
||||
{
|
||||
UChar uc;
|
||||
Int32 retVal;
|
||||
Int32 minLen, maxLen;
|
||||
bz_stream* strm = s->strm;
|
||||
|
||||
/* stuff that needs to be saved/restored */
|
||||
Int32 i;
|
||||
Int32 j;
|
||||
Int32 t;
|
||||
Int32 alphaSize;
|
||||
Int32 nGroups;
|
||||
Int32 nSelectors;
|
||||
Int32 EOB;
|
||||
Int32 groupNo;
|
||||
Int32 groupPos;
|
||||
Int32 nextSym;
|
||||
Int32 nblockMAX;
|
||||
Int32 nblock;
|
||||
Int32 es;
|
||||
Int32 N;
|
||||
Int32 curr;
|
||||
Int32 zt;
|
||||
Int32 zn;
|
||||
Int32 zvec;
|
||||
Int32 zj;
|
||||
Int32 gSel;
|
||||
Int32 gMinlen;
|
||||
Int32* gLimit;
|
||||
Int32* gBase;
|
||||
Int32* gPerm;
|
||||
|
||||
if (s->state == BZ_X_MAGIC_1) {
|
||||
/*initialise the save area*/
|
||||
s->save_i = 0;
|
||||
s->save_j = 0;
|
||||
s->save_t = 0;
|
||||
s->save_alphaSize = 0;
|
||||
s->save_nGroups = 0;
|
||||
s->save_nSelectors = 0;
|
||||
s->save_EOB = 0;
|
||||
s->save_groupNo = 0;
|
||||
s->save_groupPos = 0;
|
||||
s->save_nextSym = 0;
|
||||
s->save_nblockMAX = 0;
|
||||
s->save_nblock = 0;
|
||||
s->save_es = 0;
|
||||
s->save_N = 0;
|
||||
s->save_curr = 0;
|
||||
s->save_zt = 0;
|
||||
s->save_zn = 0;
|
||||
s->save_zvec = 0;
|
||||
s->save_zj = 0;
|
||||
s->save_gSel = 0;
|
||||
s->save_gMinlen = 0;
|
||||
s->save_gLimit = NULL;
|
||||
s->save_gBase = NULL;
|
||||
s->save_gPerm = NULL;
|
||||
}
|
||||
|
||||
/*restore from the save area*/
|
||||
i = s->save_i;
|
||||
j = s->save_j;
|
||||
t = s->save_t;
|
||||
alphaSize = s->save_alphaSize;
|
||||
nGroups = s->save_nGroups;
|
||||
nSelectors = s->save_nSelectors;
|
||||
EOB = s->save_EOB;
|
||||
groupNo = s->save_groupNo;
|
||||
groupPos = s->save_groupPos;
|
||||
nextSym = s->save_nextSym;
|
||||
nblockMAX = s->save_nblockMAX;
|
||||
nblock = s->save_nblock;
|
||||
es = s->save_es;
|
||||
N = s->save_N;
|
||||
curr = s->save_curr;
|
||||
zt = s->save_zt;
|
||||
zn = s->save_zn;
|
||||
zvec = s->save_zvec;
|
||||
zj = s->save_zj;
|
||||
gSel = s->save_gSel;
|
||||
gMinlen = s->save_gMinlen;
|
||||
gLimit = s->save_gLimit;
|
||||
gBase = s->save_gBase;
|
||||
gPerm = s->save_gPerm;
|
||||
|
||||
retVal = BZ_OK;
|
||||
|
||||
switch (s->state) {
|
||||
|
||||
GET_UCHAR(BZ_X_MAGIC_1, uc);
|
||||
if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
|
||||
|
||||
GET_UCHAR(BZ_X_MAGIC_2, uc);
|
||||
if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
|
||||
|
||||
GET_UCHAR(BZ_X_MAGIC_3, uc)
|
||||
if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
|
||||
|
||||
GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
|
||||
if (s->blockSize100k < (BZ_HDR_0 + 1) ||
|
||||
s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
|
||||
s->blockSize100k -= BZ_HDR_0;
|
||||
|
||||
if (s->smallDecompress) {
|
||||
s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
|
||||
s->ll4 = BZALLOC(
|
||||
((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
|
||||
);
|
||||
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
|
||||
} else {
|
||||
s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
|
||||
if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
|
||||
}
|
||||
|
||||
GET_UCHAR(BZ_X_BLKHDR_1, uc);
|
||||
|
||||
if (uc == 0x17) goto endhdr_2;
|
||||
if (uc != 0x31) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_BLKHDR_2, uc);
|
||||
if (uc != 0x41) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_BLKHDR_3, uc);
|
||||
if (uc != 0x59) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_BLKHDR_4, uc);
|
||||
if (uc != 0x26) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_BLKHDR_5, uc);
|
||||
if (uc != 0x53) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_BLKHDR_6, uc);
|
||||
if (uc != 0x59) RETURN(BZ_DATA_ERROR);
|
||||
|
||||
s->currBlockNo++;
|
||||
if (s->verbosity >= 2)
|
||||
VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
|
||||
|
||||
s->storedBlockCRC = 0;
|
||||
GET_UCHAR(BZ_X_BCRC_1, uc);
|
||||
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_BCRC_2, uc);
|
||||
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_BCRC_3, uc);
|
||||
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_BCRC_4, uc);
|
||||
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
|
||||
|
||||
GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
|
||||
|
||||
s->origPtr = 0;
|
||||
GET_UCHAR(BZ_X_ORIGPTR_1, uc);
|
||||
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
|
||||
GET_UCHAR(BZ_X_ORIGPTR_2, uc);
|
||||
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
|
||||
GET_UCHAR(BZ_X_ORIGPTR_3, uc);
|
||||
s->origPtr = (s->origPtr << 8) | ((Int32)uc);
|
||||
|
||||
if (s->origPtr < 0)
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
if (s->origPtr > 10 + 100000*s->blockSize100k)
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
|
||||
/*--- Receive the mapping table ---*/
|
||||
for (i = 0; i < 16; i++) {
|
||||
GET_BIT(BZ_X_MAPPING_1, uc);
|
||||
if (uc == 1)
|
||||
s->inUse16[i] = True; else
|
||||
s->inUse16[i] = False;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++) s->inUse[i] = False;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
if (s->inUse16[i])
|
||||
for (j = 0; j < 16; j++) {
|
||||
GET_BIT(BZ_X_MAPPING_2, uc);
|
||||
if (uc == 1) s->inUse[i * 16 + j] = True;
|
||||
}
|
||||
makeMaps_d ( s );
|
||||
if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
|
||||
alphaSize = s->nInUse+2;
|
||||
|
||||
/*--- Now the selectors ---*/
|
||||
GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
|
||||
if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
|
||||
GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
|
||||
if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
j = 0;
|
||||
while (True) {
|
||||
GET_BIT(BZ_X_SELECTOR_3, uc);
|
||||
if (uc == 0) break;
|
||||
j++;
|
||||
if (j >= nGroups) RETURN(BZ_DATA_ERROR);
|
||||
}
|
||||
s->selectorMtf[i] = j;
|
||||
}
|
||||
|
||||
/*--- Undo the MTF values for the selectors. ---*/
|
||||
{
|
||||
UChar pos[BZ_N_GROUPS], tmp, v;
|
||||
for (v = 0; v < nGroups; v++) pos[v] = v;
|
||||
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
v = s->selectorMtf[i];
|
||||
tmp = pos[v];
|
||||
while (v > 0) { pos[v] = pos[v-1]; v--; }
|
||||
pos[0] = tmp;
|
||||
s->selector[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/*--- Now the coding tables ---*/
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
GET_BITS(BZ_X_CODING_1, curr, 5);
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
while (True) {
|
||||
if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
|
||||
GET_BIT(BZ_X_CODING_2, uc);
|
||||
if (uc == 0) break;
|
||||
GET_BIT(BZ_X_CODING_3, uc);
|
||||
if (uc == 0) curr++; else curr--;
|
||||
}
|
||||
s->len[t][i] = curr;
|
||||
}
|
||||
}
|
||||
|
||||
/*--- Create the Huffman decoding tables ---*/
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
minLen = 32;
|
||||
maxLen = 0;
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
|
||||
if (s->len[t][i] < minLen) minLen = s->len[t][i];
|
||||
}
|
||||
BZ2_hbCreateDecodeTables (
|
||||
&(s->limit[t][0]),
|
||||
&(s->base[t][0]),
|
||||
&(s->perm[t][0]),
|
||||
&(s->len[t][0]),
|
||||
minLen, maxLen, alphaSize
|
||||
);
|
||||
s->minLens[t] = minLen;
|
||||
}
|
||||
|
||||
/*--- Now the MTF values ---*/
|
||||
|
||||
EOB = s->nInUse+1;
|
||||
nblockMAX = 100000 * s->blockSize100k;
|
||||
groupNo = -1;
|
||||
groupPos = 0;
|
||||
|
||||
for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
|
||||
|
||||
/*-- MTF init --*/
|
||||
{
|
||||
Int32 ii, jj, kk;
|
||||
kk = MTFA_SIZE-1;
|
||||
for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
|
||||
for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
|
||||
s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
|
||||
kk--;
|
||||
}
|
||||
s->mtfbase[ii] = kk + 1;
|
||||
}
|
||||
}
|
||||
/*-- end MTF init --*/
|
||||
|
||||
nblock = 0;
|
||||
GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
|
||||
|
||||
while (True) {
|
||||
|
||||
if (nextSym == EOB) break;
|
||||
|
||||
if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
|
||||
|
||||
es = -1;
|
||||
N = 1;
|
||||
do {
|
||||
if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
|
||||
if (nextSym == BZ_RUNB) es = es + (1+1) * N;
|
||||
N = N * 2;
|
||||
GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
|
||||
}
|
||||
while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
|
||||
|
||||
es++;
|
||||
uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
|
||||
s->unzftab[uc] += es;
|
||||
|
||||
if (s->smallDecompress)
|
||||
while (es > 0) {
|
||||
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
|
||||
s->ll16[nblock] = (UInt16)uc;
|
||||
nblock++;
|
||||
es--;
|
||||
}
|
||||
else
|
||||
while (es > 0) {
|
||||
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
|
||||
s->tt[nblock] = (UInt32)uc;
|
||||
nblock++;
|
||||
es--;
|
||||
};
|
||||
|
||||
continue;
|
||||
|
||||
} else {
|
||||
|
||||
if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
|
||||
|
||||
/*-- uc = MTF ( nextSym-1 ) --*/
|
||||
{
|
||||
Int32 ii, jj, kk, pp, lno, off;
|
||||
UInt32 nn;
|
||||
nn = (UInt32)(nextSym - 1);
|
||||
|
||||
if (nn < MTFL_SIZE) {
|
||||
/* avoid general-case expense */
|
||||
pp = s->mtfbase[0];
|
||||
uc = s->mtfa[pp+nn];
|
||||
while (nn > 3) {
|
||||
Int32 z = pp+nn;
|
||||
s->mtfa[(z) ] = s->mtfa[(z)-1];
|
||||
s->mtfa[(z)-1] = s->mtfa[(z)-2];
|
||||
s->mtfa[(z)-2] = s->mtfa[(z)-3];
|
||||
s->mtfa[(z)-3] = s->mtfa[(z)-4];
|
||||
nn -= 4;
|
||||
}
|
||||
while (nn > 0) {
|
||||
s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
|
||||
};
|
||||
s->mtfa[pp] = uc;
|
||||
} else {
|
||||
/* general case */
|
||||
lno = nn / MTFL_SIZE;
|
||||
off = nn % MTFL_SIZE;
|
||||
pp = s->mtfbase[lno] + off;
|
||||
uc = s->mtfa[pp];
|
||||
while (pp > s->mtfbase[lno]) {
|
||||
s->mtfa[pp] = s->mtfa[pp-1]; pp--;
|
||||
};
|
||||
s->mtfbase[lno]++;
|
||||
while (lno > 0) {
|
||||
s->mtfbase[lno]--;
|
||||
s->mtfa[s->mtfbase[lno]]
|
||||
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
|
||||
lno--;
|
||||
}
|
||||
s->mtfbase[0]--;
|
||||
s->mtfa[s->mtfbase[0]] = uc;
|
||||
if (s->mtfbase[0] == 0) {
|
||||
kk = MTFA_SIZE-1;
|
||||
for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
|
||||
for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
|
||||
s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
|
||||
kk--;
|
||||
}
|
||||
s->mtfbase[ii] = kk + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-- end uc = MTF ( nextSym-1 ) --*/
|
||||
|
||||
s->unzftab[s->seqToUnseq[uc]]++;
|
||||
if (s->smallDecompress)
|
||||
s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
|
||||
s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
|
||||
nblock++;
|
||||
|
||||
GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now we know what nblock is, we can do a better sanity
|
||||
check on s->origPtr.
|
||||
*/
|
||||
if (s->origPtr < 0 || s->origPtr >= nblock)
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
|
||||
/*-- Set up cftab to facilitate generation of T^(-1) --*/
|
||||
s->cftab[0] = 0;
|
||||
for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
|
||||
for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
|
||||
for (i = 0; i <= 256; i++) {
|
||||
if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
|
||||
/* s->cftab[i] can legitimately be == nblock */
|
||||
RETURN(BZ_DATA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
s->state_out_len = 0;
|
||||
s->state_out_ch = 0;
|
||||
BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
|
||||
s->state = BZ_X_OUTPUT;
|
||||
if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
|
||||
|
||||
if (s->smallDecompress) {
|
||||
|
||||
/*-- Make a copy of cftab, used in generation of T --*/
|
||||
for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
|
||||
|
||||
/*-- compute the T vector --*/
|
||||
for (i = 0; i < nblock; i++) {
|
||||
uc = (UChar)(s->ll16[i]);
|
||||
SET_LL(i, s->cftabCopy[uc]);
|
||||
s->cftabCopy[uc]++;
|
||||
}
|
||||
|
||||
/*-- Compute T^(-1) by pointer reversal on T --*/
|
||||
i = s->origPtr;
|
||||
j = GET_LL(i);
|
||||
do {
|
||||
Int32 tmp = GET_LL(j);
|
||||
SET_LL(j, i);
|
||||
i = j;
|
||||
j = tmp;
|
||||
}
|
||||
while (i != s->origPtr);
|
||||
|
||||
s->tPos = s->origPtr;
|
||||
s->nblock_used = 0;
|
||||
if (s->blockRandomised) {
|
||||
BZ_RAND_INIT_MASK;
|
||||
BZ_GET_SMALL(s->k0); s->nblock_used++;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
} else {
|
||||
BZ_GET_SMALL(s->k0); s->nblock_used++;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/*-- compute the T^(-1) vector --*/
|
||||
for (i = 0; i < nblock; i++) {
|
||||
uc = (UChar)(s->tt[i] & 0xff);
|
||||
s->tt[s->cftab[uc]] |= (i << 8);
|
||||
s->cftab[uc]++;
|
||||
}
|
||||
|
||||
s->tPos = s->tt[s->origPtr] >> 8;
|
||||
s->nblock_used = 0;
|
||||
if (s->blockRandomised) {
|
||||
BZ_RAND_INIT_MASK;
|
||||
BZ_GET_FAST(s->k0); s->nblock_used++;
|
||||
BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
|
||||
} else {
|
||||
BZ_GET_FAST(s->k0); s->nblock_used++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RETURN(BZ_OK);
|
||||
|
||||
|
||||
|
||||
endhdr_2:
|
||||
|
||||
GET_UCHAR(BZ_X_ENDHDR_2, uc);
|
||||
if (uc != 0x72) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_ENDHDR_3, uc);
|
||||
if (uc != 0x45) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_ENDHDR_4, uc);
|
||||
if (uc != 0x38) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_ENDHDR_5, uc);
|
||||
if (uc != 0x50) RETURN(BZ_DATA_ERROR);
|
||||
GET_UCHAR(BZ_X_ENDHDR_6, uc);
|
||||
if (uc != 0x90) RETURN(BZ_DATA_ERROR);
|
||||
|
||||
s->storedCombinedCRC = 0;
|
||||
GET_UCHAR(BZ_X_CCRC_1, uc);
|
||||
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_CCRC_2, uc);
|
||||
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_CCRC_3, uc);
|
||||
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
|
||||
GET_UCHAR(BZ_X_CCRC_4, uc);
|
||||
s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
|
||||
|
||||
s->state = BZ_X_IDLE;
|
||||
RETURN(BZ_STREAM_END);
|
||||
|
||||
default: AssertH ( False, 4001 );
|
||||
}
|
||||
|
||||
AssertH ( False, 4002 );
|
||||
|
||||
save_state_and_return:
|
||||
|
||||
s->save_i = i;
|
||||
s->save_j = j;
|
||||
s->save_t = t;
|
||||
s->save_alphaSize = alphaSize;
|
||||
s->save_nGroups = nGroups;
|
||||
s->save_nSelectors = nSelectors;
|
||||
s->save_EOB = EOB;
|
||||
s->save_groupNo = groupNo;
|
||||
s->save_groupPos = groupPos;
|
||||
s->save_nextSym = nextSym;
|
||||
s->save_nblockMAX = nblockMAX;
|
||||
s->save_nblock = nblock;
|
||||
s->save_es = es;
|
||||
s->save_N = N;
|
||||
s->save_curr = curr;
|
||||
s->save_zt = zt;
|
||||
s->save_zn = zn;
|
||||
s->save_zvec = zvec;
|
||||
s->save_zj = zj;
|
||||
s->save_gSel = gSel;
|
||||
s->save_gMinlen = gMinlen;
|
||||
s->save_gLimit = gLimit;
|
||||
s->save_gBase = gBase;
|
||||
s->save_gPerm = gPerm;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end decompress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,245 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Huffman coding low-level stuff ---*/
|
||||
/*--- huffman.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#include "bzlib_private.h"
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
||||
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
|
||||
#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
|
||||
|
||||
#define ADDWEIGHTS(zw1,zw2) \
|
||||
(WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
|
||||
(1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
|
||||
|
||||
#define UPHEAP(z) \
|
||||
{ \
|
||||
Int32 zz, tmp; \
|
||||
zz = z; tmp = heap[zz]; \
|
||||
while (weight[tmp] < weight[heap[zz >> 1]]) { \
|
||||
heap[zz] = heap[zz >> 1]; \
|
||||
zz >>= 1; \
|
||||
} \
|
||||
heap[zz] = tmp; \
|
||||
}
|
||||
|
||||
#define DOWNHEAP(z) \
|
||||
{ \
|
||||
Int32 zz, yy, tmp; \
|
||||
zz = z; tmp = heap[zz]; \
|
||||
while (True) { \
|
||||
yy = zz << 1; \
|
||||
if (yy > nHeap) break; \
|
||||
if (yy < nHeap && \
|
||||
weight[heap[yy+1]] < weight[heap[yy]]) \
|
||||
yy++; \
|
||||
if (weight[tmp] < weight[heap[yy]]) break; \
|
||||
heap[zz] = heap[yy]; \
|
||||
zz = yy; \
|
||||
} \
|
||||
heap[zz] = tmp; \
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
void BZ2_hbMakeCodeLengths ( UChar *len,
|
||||
Int32 *freq,
|
||||
Int32 alphaSize,
|
||||
Int32 maxLen )
|
||||
{
|
||||
/*--
|
||||
Nodes and heap entries run from 1. Entry 0
|
||||
for both the heap and nodes is a sentinel.
|
||||
--*/
|
||||
Int32 nNodes, nHeap, n1, n2, i, j, k;
|
||||
Bool tooLong;
|
||||
|
||||
Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
|
||||
Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
|
||||
Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
|
||||
|
||||
for (i = 0; i < alphaSize; i++)
|
||||
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
|
||||
|
||||
while (True) {
|
||||
|
||||
nNodes = alphaSize;
|
||||
nHeap = 0;
|
||||
|
||||
heap[0] = 0;
|
||||
weight[0] = 0;
|
||||
parent[0] = -2;
|
||||
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
parent[i] = -1;
|
||||
nHeap++;
|
||||
heap[nHeap] = i;
|
||||
UPHEAP(nHeap);
|
||||
}
|
||||
|
||||
AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
|
||||
|
||||
while (nHeap > 1) {
|
||||
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
|
||||
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
|
||||
nNodes++;
|
||||
parent[n1] = parent[n2] = nNodes;
|
||||
weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
|
||||
parent[nNodes] = -1;
|
||||
nHeap++;
|
||||
heap[nHeap] = nNodes;
|
||||
UPHEAP(nHeap);
|
||||
}
|
||||
|
||||
AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
|
||||
|
||||
tooLong = False;
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
j = 0;
|
||||
k = i;
|
||||
while (parent[k] >= 0) { k = parent[k]; j++; }
|
||||
len[i-1] = j;
|
||||
if (j > maxLen) tooLong = True;
|
||||
}
|
||||
|
||||
if (! tooLong) break;
|
||||
|
||||
/* 17 Oct 04: keep-going condition for the following loop used
|
||||
to be 'i < alphaSize', which missed the last element,
|
||||
theoretically leading to the possibility of the compressor
|
||||
looping. However, this count-scaling step is only needed if
|
||||
one of the generated Huffman code words is longer than
|
||||
maxLen, which up to and including version 1.0.2 was 20 bits,
|
||||
which is extremely unlikely. In version 1.0.3 maxLen was
|
||||
changed to 17 bits, which has minimal effect on compression
|
||||
ratio, but does mean this scaling step is used from time to
|
||||
time, enough to verify that it works.
|
||||
|
||||
This means that bzip2-1.0.3 and later will only produce
|
||||
Huffman codes with a maximum length of 17 bits. However, in
|
||||
order to preserve backwards compatibility with bitstreams
|
||||
produced by versions pre-1.0.3, the decompressor must still
|
||||
handle lengths of up to 20. */
|
||||
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
j = weight[i] >> 8;
|
||||
j = 1 + (j / 2);
|
||||
weight[i] = j << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
void BZ2_hbAssignCodes ( Int32 *code,
|
||||
UChar *length,
|
||||
Int32 minLen,
|
||||
Int32 maxLen,
|
||||
Int32 alphaSize )
|
||||
{
|
||||
Int32 n, vec, i;
|
||||
|
||||
vec = 0;
|
||||
for (n = minLen; n <= maxLen; n++) {
|
||||
for (i = 0; i < alphaSize; i++)
|
||||
if (length[i] == n) { code[i] = vec; vec++; };
|
||||
vec <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
void BZ2_hbCreateDecodeTables ( Int32 *limit,
|
||||
Int32 *base,
|
||||
Int32 *perm,
|
||||
UChar *length,
|
||||
Int32 minLen,
|
||||
Int32 maxLen,
|
||||
Int32 alphaSize )
|
||||
{
|
||||
Int32 pp, i, j, vec;
|
||||
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++)
|
||||
for (j = 0; j < alphaSize; j++)
|
||||
if (length[j] == i) { perm[pp] = j; pp++; };
|
||||
|
||||
for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
|
||||
for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
|
||||
|
||||
for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
|
||||
|
||||
for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
|
||||
vec = 0;
|
||||
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
vec += (base[i+1] - base[i]);
|
||||
limit[i] = vec-1;
|
||||
vec <<= 1;
|
||||
}
|
||||
for (i = minLen + 1; i <= maxLen; i++)
|
||||
base[i] = ((limit[i-1] + 1) << 1) - base[i];
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end huffman.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
|
@ -0,0 +1,124 @@
|
|||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Table for randomising repetitive blocks ---*/
|
||||
/*--- randtable.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/*--
|
||||
This file is a part of bzip2 and/or libbzip2, a program and
|
||||
library for lossless, block-sorting data compression.
|
||||
|
||||
Copyright (C) 1996-2005 Julian R Seward. 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. 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.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0 of 21 March 2000
|
||||
|
||||
This program is based on (at least) the work of:
|
||||
Mike Burrows
|
||||
David Wheeler
|
||||
Peter Fenwick
|
||||
Alistair Moffat
|
||||
Radford Neal
|
||||
Ian H. Witten
|
||||
Robert Sedgewick
|
||||
Jon L. Bentley
|
||||
|
||||
For more information on these sources, see the manual.
|
||||
--*/
|
||||
|
||||
|
||||
#include "bzlib_private.h"
|
||||
|
||||
|
||||
/*---------------------------------------------*/
|
||||
Int32 BZ2_rNums[512] = {
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end randtable.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,104 @@
|
|||
/* bzip2v2.h
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef BZIP2V2_H
|
||||
|
||||
#define BZIP2V2_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
|
||||
#include "isofile.h"
|
||||
|
||||
#include "isocompress.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_BZIP2V2
|
||||
|
||||
// #define VERBOSE_WARNING_BZIP2V2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int BZip2V2OpenTableForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V2SeekTable(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BZip2V2ReadTable(struct IsoFile *isofile, struct TableData *table);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V2OpenTableForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V2WriteTable(struct IsoFile *isofile, struct TableData table);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V2OpenForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V2Seek(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BZip2V2Read(struct IsoFile *isofile, int bytes, char *buffer);
|
||||
|
||||
extern void BZip2V2Close(struct IsoFile *isofile);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V2OpenForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V2Write(struct IsoFile *isofile, char *buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* BZIP2V2_H */
|
||||
|
|
@ -0,0 +1,968 @@
|
|||
/* bzip2v3.c
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stddef.h> // NULL
|
||||
|
||||
#include <stdlib.h> // malloc()
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
|
||||
|
||||
|
||||
#include "bzip2/bzlib.h"
|
||||
|
||||
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#include "isofile.h" // IsoFile
|
||||
|
||||
#include "isocompress.h" // TableData, TableMap
|
||||
|
||||
#include "actualfile.h"
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
#include "bzip2v3.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
struct BZip2V3Header {
|
||||
|
||||
char id[4];
|
||||
|
||||
unsigned short blocksize;
|
||||
|
||||
off64_t numblocks;
|
||||
|
||||
unsigned short blockoffset;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
struct BZip2V3Table {
|
||||
|
||||
off64_t offset;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3OpenTableForRead(struct IsoFile *isofile) {
|
||||
|
||||
int i;
|
||||
|
||||
int j;
|
||||
|
||||
char tableext[] = ".table\0";
|
||||
|
||||
off64_t numentries;
|
||||
|
||||
off64_t offset;
|
||||
|
||||
off64_t actual;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: OpenTableForRead()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
i = 0;
|
||||
|
||||
while((i < 256) && (isofile->name[i] != 0)) {
|
||||
|
||||
isofile->tablename[i] = isofile->name[i];
|
||||
|
||||
i++;
|
||||
|
||||
} // ENDWHILE- Copying the data name to the table name
|
||||
|
||||
j = 0;
|
||||
|
||||
while((i < 256) && (tableext[j] != 0)) {
|
||||
|
||||
isofile->tablename[i] = tableext[j];
|
||||
|
||||
i++;
|
||||
|
||||
j++;
|
||||
|
||||
} // ENDWHILE- Adding the ".table" extension.
|
||||
|
||||
isofile->tablename[i] = 0; // And 0-terminate.
|
||||
|
||||
|
||||
|
||||
isofile->tablehandle = ActualFileOpenForRead(isofile->tablename);
|
||||
|
||||
if(isofile->tablehandle == ACTUALHANDLENULL) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't open table!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Couldn't open table file? Fail.
|
||||
|
||||
|
||||
|
||||
numentries = isofile->filesectorsize / isofile->numsectors;
|
||||
|
||||
if((isofile->filesectorsize % isofile->numsectors) != 0) numentries++;
|
||||
|
||||
offset = numentries * sizeof(struct BZip2V3Table);
|
||||
|
||||
actual = ActualFileSize(isofile->tablehandle);
|
||||
|
||||
if(offset != actual) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Table not the correct size! (Should be %lli, is %lli)",
|
||||
|
||||
offset, actual);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Not the correct-sized table for the data file? Fail.
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3OpenTableForRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3SeekTable(struct IsoFile *isofile, off64_t sector) {
|
||||
|
||||
off64_t target;
|
||||
|
||||
int retval;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: SeekTable(%lli)", sector);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
target = sector / isofile->numsectors;
|
||||
|
||||
target *= sizeof(struct BZip2V3Table);
|
||||
|
||||
retval = ActualFileSeek(isofile->tablehandle, target);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't find sector!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Trouble finding the place? Fail.
|
||||
|
||||
|
||||
|
||||
isofile->filesectorpos = sector;
|
||||
|
||||
isofile->compsector = isofile->filesectorsize + isofile->numsectors;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3SeekTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3ReadTable(struct IsoFile *isofile, struct TableData *table) {
|
||||
|
||||
int retval;
|
||||
|
||||
struct BZip2V3Table temptable;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: ReadTable()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->tablehandle,
|
||||
|
||||
sizeof(struct BZip2V3Table),
|
||||
|
||||
(char *) &temptable);
|
||||
|
||||
if(retval != sizeof(struct BZip2V3Table)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't read table entry!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Trouble reading table entry? Fail.
|
||||
|
||||
|
||||
|
||||
table->offset = ConvertEndianOffset(temptable.offset);
|
||||
|
||||
table->size = 0;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3ReadTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3OpenTableForWrite(struct IsoFile *isofile) {
|
||||
|
||||
int i;
|
||||
|
||||
int j;
|
||||
|
||||
char tableext[] = ".table\0";
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: OpenTableForWrite()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
i = 0;
|
||||
|
||||
while((i < 256) && (isofile->name[i] != 0)) {
|
||||
|
||||
isofile->tablename[i] = isofile->name[i];
|
||||
|
||||
i++;
|
||||
|
||||
} // ENDWHILE- Copying the data name to the table name
|
||||
|
||||
j = 0;
|
||||
|
||||
while((i < 256) && (tableext[j] != 0)) {
|
||||
|
||||
isofile->tablename[i] = tableext[j];
|
||||
|
||||
i++;
|
||||
|
||||
j++;
|
||||
|
||||
} // ENDWHILE- Adding the ".table" extension.
|
||||
|
||||
isofile->tablename[i] = 0; // And 0-terminate.
|
||||
|
||||
|
||||
|
||||
isofile->tablehandle = ActualFileOpenForWrite(isofile->tablename);
|
||||
|
||||
if(isofile->tablehandle == ACTUALHANDLENULL) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't open table!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Couldn't open table file? Fail.
|
||||
|
||||
|
||||
|
||||
// isofile->filesectorsize = 0;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3OpenTableForWrite()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3WriteTable(struct IsoFile *isofile, struct TableData table) {
|
||||
|
||||
int retval;
|
||||
|
||||
struct BZip2V3Table bv3table;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: WriteTable(%lli, %i)", table.offset, table.size);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
bv3table.offset = ConvertEndianOffset(table.offset);
|
||||
|
||||
retval = ActualFileWrite(isofile->tablehandle,
|
||||
|
||||
sizeof(struct BZip2V3Table),
|
||||
|
||||
(char *) &bv3table);
|
||||
|
||||
if(retval != sizeof(struct BZip2V3Table)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't write table entry!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-2);
|
||||
|
||||
} // ENDIF- Trouble reading table entry? Fail.
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3WriteTable()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3OpenForRead(struct IsoFile *isofile) {
|
||||
|
||||
int retval;
|
||||
|
||||
struct BZip2V3Header header;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: OpenForRead()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
isofile->handle = ActualFileOpenForRead(isofile->name);
|
||||
|
||||
if(isofile->handle == ACTUALHANDLENULL) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't open data file? Fail.
|
||||
|
||||
|
||||
|
||||
isofile->filebytesize = ActualFileSize(isofile->handle);
|
||||
|
||||
isofile->filebytepos = 0;
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
|
||||
|
||||
isofile->imageheader = 0;
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle,
|
||||
|
||||
sizeof(struct BZip2V3Header),
|
||||
|
||||
(char *) &header);
|
||||
|
||||
if(retval != sizeof(struct BZip2V3Header)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't read header!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF Could not read the first sector? Fail.
|
||||
|
||||
isofile->filebytepos += retval;
|
||||
|
||||
|
||||
|
||||
if((header.id[0] != 'B') ||
|
||||
|
||||
(header.id[1] != 'Z') ||
|
||||
|
||||
(header.id[2] != 'V') ||
|
||||
|
||||
(header.id[3] != '3')) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Not a bzip2 v3 compression header!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- ID for this compression type doesn't match?
|
||||
|
||||
|
||||
|
||||
isofile->blocksize = ConvertEndianUShort(header.blocksize);
|
||||
|
||||
isofile->filesectorsize = ConvertEndianOffset(header.numblocks);
|
||||
|
||||
isofile->blockoffset = ConvertEndianUShort(header.blockoffset);
|
||||
|
||||
isofile->numsectors = (65536 / isofile->blocksize) - 1;
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
isofile->compsector = header.numblocks + isofile->numsectors;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3OpenForRead()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3Seek(struct IsoFile *isofile, off64_t position) {
|
||||
|
||||
int retval;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Seek(%lli)", position);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
retval = ActualFileSeek(isofile->handle, position);
|
||||
|
||||
if(retval < 0) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Couldn't find the start of the compressed block!");
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't find the data entry? Fail.
|
||||
|
||||
isofile->filebytepos = position;
|
||||
|
||||
return(0);
|
||||
|
||||
|
||||
|
||||
return(-1); // Fail. (Due to lack of ambition?)
|
||||
|
||||
} // END BZip2V3Seek()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3Read(struct IsoFile *isofile, int bytes, char *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
unsigned short tempsize;
|
||||
|
||||
char tempblock[65536];
|
||||
|
||||
unsigned int blocklen;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Read()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle,
|
||||
|
||||
sizeof(unsigned short),
|
||||
|
||||
(char *) &tempsize);
|
||||
|
||||
if(retval > 0) isofile->filebytepos += retval;
|
||||
|
||||
if(retval != sizeof(unsigned short)) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot read bytes! Returned: (%i)", retval);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble reading compressed sector? Abort.
|
||||
|
||||
tempsize = ConvertEndianUShort(tempsize);
|
||||
|
||||
|
||||
|
||||
retval = ActualFileRead(isofile->handle, tempsize, tempblock);
|
||||
|
||||
if(retval > 0) isofile->filebytepos += retval;
|
||||
|
||||
if(retval != tempsize) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot read bytes! Returned: (%i)", retval);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble reading compressed sector? Abort.
|
||||
|
||||
|
||||
|
||||
blocklen = 65536;
|
||||
|
||||
retval = BZ2_bzBuffToBuffDecompress(buffer, &blocklen, tempblock, tempsize, 0, 0);
|
||||
|
||||
if(retval != BZ_OK) {
|
||||
|
||||
#ifdef VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot decode block! Returned: (%i)", retval);
|
||||
|
||||
#endif /* VERBOSE_WARNING_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble decoding the sector? Abort.
|
||||
|
||||
|
||||
|
||||
return(tempsize + sizeof(unsigned short));
|
||||
|
||||
} // END BZip2V3Read()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3OpenForWrite(struct IsoFile *isofile) {
|
||||
|
||||
char garbage[sizeof(struct BZip2V3Header)];
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
if(isofile == NULL) return(-1);
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: OpenForWrite()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
isofile->handle = ActualFileOpenForWrite(isofile->name);
|
||||
|
||||
if(isofile->handle == ACTUALHANDLENULL) {
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Couldn't open data file? Fail.
|
||||
|
||||
for(i = 0; i < sizeof(struct BZip2V3Header); i++) garbage[i] = 0;
|
||||
|
||||
ActualFileWrite(isofile->handle, sizeof(struct BZip2V3Header), garbage);
|
||||
|
||||
|
||||
|
||||
isofile->filebytesize = 0;
|
||||
|
||||
isofile->filebytepos = sizeof(struct BZip2V3Header);
|
||||
|
||||
isofile->numsectors = (65536 / isofile->blocksize) - 1;
|
||||
|
||||
isofile->filesectorsize = 0;
|
||||
|
||||
isofile->filesectorpos = 0;
|
||||
|
||||
isofile->compsector = 0;
|
||||
|
||||
return(0);
|
||||
|
||||
} // END BZip2V3OpenForWrite()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int BZip2V3Write(struct IsoFile *isofile, char *buffer) {
|
||||
|
||||
int retval;
|
||||
|
||||
unsigned int blocklen;
|
||||
|
||||
char tempblock[65536];
|
||||
|
||||
unsigned short tempsize;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Write()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
blocklen = 65536;
|
||||
|
||||
retval = BZ2_bzBuffToBuffCompress(tempblock,
|
||||
|
||||
&blocklen,
|
||||
|
||||
buffer,
|
||||
|
||||
isofile->blocksize * isofile->numsectors,
|
||||
|
||||
9, 0, 250);
|
||||
|
||||
if(retval != BZ_OK) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot encode block! Returned: (%i)", retval);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble compressing a block? Abort.
|
||||
|
||||
|
||||
|
||||
tempsize = blocklen;
|
||||
|
||||
tempsize = ConvertEndianUShort(tempsize);
|
||||
|
||||
retval = ActualFileWrite(isofile->handle,
|
||||
|
||||
sizeof(unsigned short),
|
||||
|
||||
(char *) &tempsize);
|
||||
|
||||
if(retval > 0) isofile->filebytepos += retval;
|
||||
|
||||
if(retval < sizeof(unsigned short)) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot write bytes! Returned: (%i out of %llu)",
|
||||
|
||||
retval, sizeof(unsigned short));
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble writing out the compressed block? Abort.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
retval = ActualFileWrite(isofile->handle, blocklen, tempblock);
|
||||
|
||||
if(retval > 0) isofile->filebytepos += retval;
|
||||
|
||||
if(retval < blocklen) {
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Cannot write bytes! Returned: (%i out of %llu)",
|
||||
|
||||
retval, blocklen);
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
return(-1);
|
||||
|
||||
} // ENDIF- Trouble writing out the compressed block? Abort.
|
||||
|
||||
|
||||
|
||||
return(blocklen + sizeof(unsigned short)); // Not in list? Fail.
|
||||
|
||||
} // END BZip2V3Write()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BZip2V3Close(struct IsoFile *isofile) {
|
||||
|
||||
struct BZip2V3Header header;
|
||||
|
||||
struct TableData table;
|
||||
|
||||
int compptr;
|
||||
|
||||
int i;
|
||||
|
||||
int retval;
|
||||
|
||||
unsigned short tempsize;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
PrintLog("CDVDiso BZip2V3: Close()");
|
||||
|
||||
#endif /* VERBOSE_FUNCTION_BZIP2V3 */
|
||||
|
||||
|
||||
|
||||
if((isofile->tablehandle != ACTUALHANDLENULL) &&
|
||||
|
||||
(isofile->handle != ACTUALHANDLENULL)) {
|
||||
|
||||
if(isofile->openforread == 0) {
|
||||
|
||||
if(isofile->compsector != isofile->filesectorpos) {
|
||||
|
||||
compptr = isofile->filesectorpos - isofile->compsector;
|
||||
|
||||
compptr *= isofile->blocksize;
|
||||
|
||||
for(i = compptr; i < 65536; i++) isofile->compblock[i] = 0;
|
||||
|
||||
retval = BZip2V3Write(isofile, isofile->compblock);
|
||||
|
||||
table.offset = isofile->filebytepos - retval;
|
||||
|
||||
table.size = retval;
|
||||
|
||||
BZip2V3WriteTable(isofile, table);
|
||||
|
||||
isofile->compsector = isofile->filesectorpos;
|
||||
|
||||
} // ENDIF - still have buffers to write?
|
||||
|
||||
} // ENDIF- Opened for write? Don't forget to flush the file buffer!
|
||||
|
||||
} // ENDIF- Both data file and table file are open?
|
||||
|
||||
|
||||
|
||||
if(isofile->tablehandle != ACTUALHANDLENULL) {
|
||||
|
||||
ActualFileClose(isofile->tablehandle);
|
||||
|
||||
isofile->tablehandle = ACTUALHANDLENULL;
|
||||
|
||||
} // ENDIF- Is there a table file open? Close it.
|
||||
|
||||
|
||||
|
||||
if(isofile->handle != ACTUALHANDLENULL) {
|
||||
|
||||
if(isofile->openforread == 0) {
|
||||
|
||||
if(isofile->compsector != isofile->filesectorpos) {
|
||||
|
||||
compptr = isofile->filesectorpos - isofile->compsector;
|
||||
|
||||
compptr *= isofile->blocksize;
|
||||
|
||||
for(i = compptr; i < 65536; i++) isofile->compblock[i] = 0;
|
||||
|
||||
BZip2V3Write(isofile, isofile->compblock);
|
||||
|
||||
} // ENDIF - still have buffers to write?
|
||||
|
||||
header.id[0] = 'B';
|
||||
|
||||
header.id[1] = 'Z';
|
||||
|
||||
header.id[2] = 'V';
|
||||
|
||||
header.id[3] = '3';
|
||||
|
||||
tempsize = isofile->blocksize;
|
||||
|
||||
header.blocksize = ConvertEndianUShort(tempsize);
|
||||
|
||||
header.numblocks = ConvertEndianOffset(isofile->filesectorsize);
|
||||
|
||||
tempsize = isofile->blockoffset;
|
||||
|
||||
header.blockoffset = ConvertEndianUShort(tempsize);
|
||||
|
||||
ActualFileSeek(isofile->handle, 0);
|
||||
|
||||
ActualFileWrite(isofile->handle,
|
||||
|
||||
sizeof(struct BZip2V3Header),
|
||||
|
||||
(char *) &header);
|
||||
|
||||
} // ENDIF- Opened for write? Don't forget to update the header block!
|
||||
|
||||
|
||||
|
||||
ActualFileClose(isofile->handle);
|
||||
|
||||
isofile->handle = ACTUALHANDLENULL;
|
||||
|
||||
} // ENDIF- Is there a data file open? Close it.
|
||||
|
||||
|
||||
|
||||
if(isofile->tabledata != NULL) {
|
||||
|
||||
free(isofile->tabledata);
|
||||
|
||||
isofile->tabledata = NULL;
|
||||
|
||||
} // ENDIF- Do we have a read-in table to clear out?
|
||||
|
||||
|
||||
|
||||
return;
|
||||
|
||||
} // END BZip2V3Close()
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* bzip2v3.h
|
||||
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
|
||||
*
|
||||
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef BZIP2V3_H
|
||||
|
||||
#define BZIP2V3_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
|
||||
#include "isofile.h"
|
||||
|
||||
#include "isocompress.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #define VERBOSE_FUNCTION_BZIP2V3
|
||||
|
||||
// #define VERBOSE_WARNING_BZIP2V3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int BZip2V3OpenTableForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V3SeekTable(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BZip2V3ReadTable(struct IsoFile *isofile, struct TableData *table);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V3OpenTableForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V3WriteTable(struct IsoFile *isofile, struct TableData table);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V3OpenForRead(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V3Seek(struct IsoFile *isofile, off64_t sector);
|
||||
|
||||
extern int BZip2V3Read(struct IsoFile *isofile, int bytes, char *buffer);
|
||||
|
||||
extern void BZip2V3Close(struct IsoFile *isofile);
|
||||
|
||||
|
||||
|
||||
extern int BZip2V3OpenForWrite(struct IsoFile *isofile);
|
||||
|
||||
extern int BZip2V3Write(struct IsoFile *isofile, char *buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* BZIP2V3_H */
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/* convert.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
off64_t ConvertEndianOffset(off64_t number) {
|
||||
#ifndef CONVERTLITTLEENDIAN
|
||||
union {
|
||||
off64_t n;
|
||||
char c[sizeof(off64_t)];
|
||||
} oldnumber, newnumber;
|
||||
int i;
|
||||
|
||||
oldnumber.n = number;
|
||||
for(i = 0; i < sizeof(off64_t); i++)
|
||||
newnumber.c[i] = oldnumber.c[sizeof(off64_t) - 1 - i];
|
||||
return(newnumber.n);
|
||||
#else
|
||||
return(number);
|
||||
#endif /* CONVERTLITTLEENDIAN */
|
||||
} // END ConvertEndianOffset()
|
||||
|
||||
|
||||
unsigned int ConvertEndianUInt(unsigned int number) {
|
||||
#ifndef CONVERTLITTLEENDIAN
|
||||
union {
|
||||
unsigned int n;
|
||||
char c[sizeof(unsigned int)];
|
||||
} oldnumber, newnumber;
|
||||
int i;
|
||||
|
||||
oldnumber.n = number;
|
||||
for(i = 0; i < sizeof(unsigned int); i++)
|
||||
newnumber.c[i] = oldnumber.c[sizeof(unsigned int) - 1 - i];
|
||||
return(newnumber.n);
|
||||
#else
|
||||
return(number);
|
||||
#endif /* CONVERTLITTLEENDIAN */
|
||||
} // END ConvertEndianUInt()
|
||||
|
||||
|
||||
unsigned short ConvertEndianUShort(unsigned short number) {
|
||||
#ifndef CONVERTLITTLEENDIAN
|
||||
union {
|
||||
unsigned short n;
|
||||
char c[sizeof(unsigned short)];
|
||||
} oldnumber, newnumber;
|
||||
int i;
|
||||
|
||||
oldnumber.n = number;
|
||||
for(i = 0; i < sizeof(unsigned short); i++)
|
||||
newnumber.c[i] = oldnumber.c[sizeof(unsigned short) - 1 - i];
|
||||
return(newnumber.n);
|
||||
#else
|
||||
return(number);
|
||||
#endif /* CONVERTLITTLEENDIAN */
|
||||
} // END ConvertEndianUShort()
|
||||
|
||||
|
||||
// Note: deposits M/S/F data in buffer[0]/[1]/[2] respectively.
|
||||
void LBAtoMSF(unsigned long lsn, char *buffer) {
|
||||
unsigned long templsn;
|
||||
|
||||
if(lsn >= 0xFFFFFFFF - 150) {
|
||||
*(buffer + 2) = 75-1;
|
||||
*(buffer + 1) = 60-1;
|
||||
*(buffer) = 100-1;
|
||||
} // ENDIF- Out of range?
|
||||
|
||||
templsn = lsn;
|
||||
templsn += 150; // 2 second offset (75 Frames * 2 Seconds)
|
||||
*(buffer + 2) = templsn % 75; // Remainder in frames
|
||||
templsn -= *(buffer + 2);
|
||||
templsn /= 75;
|
||||
*(buffer + 1) = templsn % 60; // Remainder in seconds
|
||||
templsn -= *(buffer + 1);
|
||||
templsn /= 60;
|
||||
*(buffer) = templsn; // Leftover quotient in minutes
|
||||
} // END LBAtoMSF()
|
||||
|
||||
|
||||
unsigned long MSFtoLBA(char *buffer) {
|
||||
unsigned long templsn;
|
||||
|
||||
if(buffer == NULL) return(0xFFFFFFFF);
|
||||
|
||||
templsn = *(buffer); // Minutes
|
||||
templsn *= 60;
|
||||
templsn += *(buffer + 1); // Seconds
|
||||
templsn *= 75;
|
||||
templsn += *(buffer + 2); // Frames
|
||||
if(templsn < 150) return(0xFFFFFFFF);
|
||||
templsn -= 150; // Offset
|
||||
|
||||
return(templsn);
|
||||
} // END MSFtoLBA()
|
|
@ -0,0 +1,50 @@
|
|||
/* convert.h
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CONVERT_H
|
||||
#define CONVERT_H
|
||||
|
||||
|
||||
#include <sys/types.h> // off64_t
|
||||
#include "PS2Etypes.h"
|
||||
#ifdef __linux__
|
||||
#include "endian.h"
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define CONVERTLITTLEENDIAN
|
||||
#endif /* __BYTE_ORDER */
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define CONVERTLITTLEENDIAN
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define HEXTOBCD(i) (((i)/10*16) + ((i)%10))
|
||||
#define BCDTOHEX(i) (((i)/16*10) + ((i)%16))
|
||||
|
||||
|
||||
extern off64_t ConvertEndianOffset(off64_t number);
|
||||
extern unsigned int ConvertEndianUInt(unsigned int number);
|
||||
extern unsigned short ConvertEndianUShort(unsigned short number);
|
||||
|
||||
extern void LBAtoMSF(unsigned long lsn, char *buffer);
|
||||
extern unsigned long MSFtoLBA(char *buffer);
|
||||
|
||||
#endif /* CONVERT_H */
|
|
@ -0,0 +1,59 @@
|
|||
/* ecma119.c
|
||||
* Copyright (C) 2002-2005 PCSX2 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
|
||||
*
|
||||
* PCSX2 members can be contacted through their website at www.pcsx2.net.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// #ifndef __LINUX__
|
||||
// #ifdef __linux__
|
||||
// #define __LINUX__
|
||||
// #endif /* __linux__ */
|
||||
// #endif /* No __LINUX__ */
|
||||
|
||||
// #define CDVDdefs
|
||||
// #include "PS2Edefs.h"
|
||||
|
||||
#include "ecma119.h"
|
||||
|
||||
|
||||
const char ECMA119VolumeIDstdid[] = "CD001\0";
|
||||
|
||||
|
||||
int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume) {
|
||||
int i;
|
||||
|
||||
if(volume == NULL) return(-1);
|
||||
|
||||
// Volume ID
|
||||
if(volume->id.voltype != 1) return(-1); // Incorrect volume type
|
||||
if(volume->id.version != 1) return(-1); // Not a Standard Version?
|
||||
i = 0;
|
||||
while((ECMA119VolumeIDstdid[i] != 0) &&
|
||||
(ECMA119VolumeIDstdid[i] == volume->id.stdid[i])) i++;
|
||||
if(ECMA119VolumeIDstdid[i] != 0) return(-1); // "CD001" did not match?
|
||||
|
||||
// Looks like numblocksle might give us maximum sector count...
|
||||
// Looks like blocksizele can be compared to blocksize stored in isofile...
|
||||
|
||||
return(0);
|
||||
} // END ValidateECMA119PrimaryVolume()
|
||||
|
||||
|
||||
// Not sure the Partition Volume will be much help...
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue