bsnes/snesreader/unrar/unrar.h

165 lines
5.9 KiB
C
Raw Normal View History

Include all the code from the bsnes v068 tarball. byuu describes the changes since v067: This release officially introduces the accuracy and performance cores, alongside the previously-existing compatibility core. The accuracy core allows the most accurate SNES emulation ever seen, with every last processor running at the lowest possible clock synchronization level. The performance core allows slower computers the chance to finally use bsnes. It is capable of attaining 60fps in standard games even on an entry-level Intel Atom processor, commonly found in netbooks. The accuracy core is absolutely not meant for casual gaming at all. It is meant solely for getting as close to 100% perfection as possible, no matter the cost to speed. It should only be used for testing, development or debugging. The compatibility core is identical to bsnes v067 and earlier, but is now roughly 10% faster. This is the default and recommended core for casual gaming. The performance core contains an entirely new S-CPU core, with range-tested IRQs; and uses blargg's heavily-optimized S-DSP core directly. Although there are very minor accuracy tradeoffs to increase speed, I am confident that the performance core is still more accurate and compatible than any other SNES emulator. The S-CPU, S-SMP, S-DSP, SuperFX and SA-1 processors are all clock-based, just as in the accuracy and compatibility cores; and as always, there are zero game-specific hacks. Its compatibility is still well above 99%, running even the most challenging games flawlessly. If you have held off from using bsnes in the past due to its system requirements, please give the performance core a try. I think you will be impressed. I'm also not finished: I believe performance can be increased even further. I would also strongly suggest Windows Vista and Windows 7 users to take advantage of the new XAudio2 driver by OV2. Not only does it give you a performance boost, it also lowers latency and provides better sound by way of skipping an API emulation layer. Changelog: - Split core into three profiles: accuracy, compatibility and performance - Accuracy core now takes advantage of variable-bitlength integers (eg uint24_t) - Performance core uses a new S-CPU core, written from scratch for speed - Performance core uses blargg's snes_dsp library for S-DSP emulation - Binaries are now compiled using GCC 4.5 - Added a workaround in the SA-1 core for a bug in GCC 4.5+ - The clock-based S-PPU renderer has greatly improved OAM emulation; fixing Winter Gold and Megalomania rendering issues - Corrected pseudo-hires color math in the clock-based S-PPU renderer; fixing Super Buster Bros backgrounds - Fixed a clamping bug in the Cx4 16-bit triangle operation [Jonas Quinn]; fixing Mega Man X2 "gained weapon" star background effect - Updated video renderer to properly handle mixed-resolution screens with interlace enabled; fixing Air Strike Patrol level briefing screen - Added mightymo's 2010-08-19 cheat code pack - Windows port: added XAudio2 output support [OV2] - Source: major code restructuring; virtual base classes for processor - cores removed, build system heavily modified, etc.
2010-08-22 01:02:42 +00:00
/** RAR archive scanning and extraction \file */
/* unrar_core 3.8.5 */
#ifndef UNRAR_H
#define UNRAR_H
#include <stddef.h>
#include <limits.h>
#if !defined (UNRAR_NO_LONG_LONG) && defined (LLONG_MAX)
typedef long long unrar_long_long;
#else
typedef long unrar_long_long;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** Error code, or 0 if function was successful. See Errors for more. Except
where noted, once an operation returns an error, that archive should not be
used any further, other than with unrar_close(). */
#ifndef unrar_err_t /* (#ifndef allows better testing of library) */
typedef int unrar_err_t;
#endif
/** First parameter of most functions is unrar_t*, or const unrar_t* if nothing
is changed. */
typedef struct unrar_t unrar_t;
/** File position */
typedef unrar_long_long unrar_pos_t;
/** Boolean, where 0 is false and 1 is true */
typedef int unrar_bool;
/******** Open/close ********/
/** Initializes static tables used by library. Automatically called by
unrar_open(). OK to call more than once. */
void unrar_init( void );
/** Opens archive and points *out at it. If error, sets *out to NULL. */
unrar_err_t unrar_open( unrar_t** out, const char path [] );
/** User archive read callback. When called, user_data is a copy of that passed
to unrar_open_custom(). Callback must do the following: Read avail bytes from
file at offset pos and set *count to avail, where avail is the lesser of *count
and file_size-pos. Put read bytes into *out and return unrar_ok. If fewer than
avail bytes could be read successfully, return a non-zero error code. */
typedef unrar_err_t (*unrar_read_func)( void* user_data,
void* out, int* count, unrar_pos_t pos );
/** Same as unrar_open(), except data is read using supplied function rather
than from file. */
unrar_err_t unrar_open_custom( unrar_t** unrar_out,
unrar_read_func, void* user_data );
/** Closes archive and frees memory. OK to pass NULL. */
void unrar_close( unrar_t* );
/******** Scanning ********/
/** True if at end of archive. Must be called after unrar_open() or
unrar_rewind(), as an archive might contain no files. */
unrar_bool unrar_done( const unrar_t* );
/** Goes to next file in archive. If there are no more files, unrar_done() will
now return true. */
unrar_err_t unrar_next( unrar_t* );
/** Goes back to first file in archive, as if it were just opened with
unrar_open(). */
unrar_err_t unrar_rewind( unrar_t* );
/** Position of current file in archive. Will never return zero. */
unrar_pos_t unrar_tell( const unrar_t* );
/** Returns to file at previously-saved position. */
unrar_err_t unrar_seek( unrar_t*, unrar_pos_t );
/**** Info ****/
/** Information about current file */
typedef struct unrar_info_t
{
unrar_pos_t size; /**< Uncompressed size */
const char* name; /**< Name, in Unicode if is_unicode is true */
const wchar_t* name_w; /**< Name in Unicode, "" if unavailable */
unrar_bool is_unicode; /**< True if name is Unicode (UTF-8) */
unsigned int dos_date; /**< Date in DOS-style format, 0 if unavailable */
unsigned int crc; /**< Checksum; algorithm depends on archive */
unrar_bool is_crc32; /**< True if crc is CRC-32 */
} unrar_info_t;
/** Information about current file. Pointer is valid until unrar_next(),
unrar_rewind(), unrar_seek(), or unrar_close(). */
const unrar_info_t* unrar_info( const unrar_t* );
/**** Extraction ****/
/** Returns unrar_ok if current file can be extracted, otherwise error
indicating why it can't be extracted (too new/old compression algorithm,
encrypted, segmented). Archive is still usable if this returns error,
just the current file can't be extracted. */
unrar_err_t unrar_try_extract( const unrar_t* );
/** Extracts at most size bytes from current file into out. If file is larger,
discards excess bytes. If file is smaller, only writes unrar_size() bytes. */
unrar_err_t unrar_extract( unrar_t*, void* out, unrar_pos_t size );
/** Extracts data to memory and returns pointer to it in *out. Pointer is
valid until unrar_next(), unrar_rewind(), unrar_seek(), or unrar_close(). OK to
call more than once for same file. Optimized to avoid allocating memory when
entire file will already be kept in internal window. */
unrar_err_t unrar_extract_mem( unrar_t* p, void const** out );
/** User extracted data write callback. When called, user_data is a copy of
that passed to unrar_extract_custom(). Callback must do the following: Write
count bytes from *in to wherever extracted data goes and return unrar_ok. If
data cannot be written successfully, return a non-zero error code. */
typedef unrar_err_t (*unrar_write_func)( void* user_data,
const void* in, int count );
/** Extracts current file and writes data using supplied function. Any error
it returns will be returned by this function, and archive will still be
usable. */
unrar_err_t unrar_extract_custom( unrar_t*,
unrar_write_func, void* user_data );
/******** Errors ********/
/** Error string associated with unrar error code. Always returns valid
pointer to a C string; never returns NULL. Returns "" for unrar_ok. */
const char* unrar_err_str( unrar_err_t );
enum {
unrar_ok = 0,/**< No error; success. Guaranteed to be zero. */
unrar_err_memory = 1,/**< Out of memory */
unrar_err_open = 2,/**< Couldn't open file (not found/permissions) */
unrar_err_not_arc = 3,/**< Not a RAR archive */
unrar_err_corrupt = 4,/**< Archive is corrupt */
unrar_err_io = 5,/**< Read failed */
unrar_err_arc_eof = 6,/**< At end of archive; no more files */
unrar_err_encrypted = 7,/**< Encryption not supported */
unrar_err_segmented = 8,/**< Segmentation not supported */
unrar_err_huge = 9,/**< Huge (2GB+) archives not supported */
unrar_err_old_algo = 10,/**< Compressed with unsupported old algorithm */
unrar_err_new_algo = 11,/**< Compressed with unsupported new algorithm */
unrar_next_err = 100/**< Errors range from 0 to unrar_next_err-1 */
};
#ifdef __cplusplus
}
#endif
#endif