mirror of
https://github.com/libretro/libretro-common.git
synced 2024-05-11 17:15:29 -04:00
Updates
This commit is contained in:
parent
4071054727
commit
f6e5583acd
|
@ -87,7 +87,7 @@ struct audio_mixer_sound
|
|||
const void* data;
|
||||
} ogg;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_DR_FLAC
|
||||
struct
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ struct audio_mixer_sound
|
|||
unsigned size;
|
||||
const void* data;
|
||||
} flac;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DR_MP3
|
||||
struct
|
||||
|
@ -104,7 +104,7 @@ struct audio_mixer_sound
|
|||
unsigned size;
|
||||
const void* data;
|
||||
} mp3;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IBXM
|
||||
struct
|
||||
|
@ -278,7 +278,7 @@ static bool one_shot_resample(const float* in, size_t samples_in,
|
|||
const retro_resampler_t* resampler = NULL;
|
||||
float ratio = (double)s_rate / (double)rate;
|
||||
|
||||
if (!retro_resampler_realloc(&data, &resampler, NULL,
|
||||
if (!retro_resampler_realloc(&data, &resampler, NULL,
|
||||
RESAMPLER_QUALITY_DONTCARE, ratio))
|
||||
return false;
|
||||
|
||||
|
@ -675,7 +675,6 @@ static bool audio_mixer_play_flac(
|
|||
void *resampler_data = NULL;
|
||||
const retro_resampler_t* resamp = NULL;
|
||||
drflac *dr_flac = drflac_open_memory((const unsigned char*)sound->types.flac.data,sound->types.flac.size);
|
||||
|
||||
|
||||
if (!dr_flac)
|
||||
return false;
|
||||
|
@ -1176,7 +1175,7 @@ static void audio_mixer_mix_mp3(float* buffer, size_t num_frames,
|
|||
{
|
||||
again:
|
||||
temp_samples = (unsigned)drmp3_read_f32(&voice->types.mp3.stream, AUDIO_MIXER_TEMP_BUFFER/2, temp_buffer) * 2;
|
||||
|
||||
|
||||
if (temp_samples == 0)
|
||||
{
|
||||
if (voice->repeat)
|
||||
|
|
|
@ -13,7 +13,7 @@ eq_gains = "6 9 12 7 6 5 7 9 11 6 0"
|
|||
reverb_damping = 0.8
|
||||
reverb_roomwidth = 0.25
|
||||
reverb_roomsize = 0.25
|
||||
|
||||
|
||||
# IIR - filters out some harsh sounds on the upper end
|
||||
iir_type = RIAA_CD
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ asflags := $(ASFLAGS) -fPIC $(extra_flags)
|
|||
objects :=
|
||||
|
||||
ifeq (1,$(use_neon))
|
||||
ASMFLAGS := -INEON/asm
|
||||
ASMFLAGS := -INEON/asm
|
||||
asflags += -mfpu=neon
|
||||
endif
|
||||
|
||||
|
|
|
@ -58,14 +58,14 @@ static void tremolocore_init(struct tremolo_core *core,float depth,int samplerat
|
|||
unsigned i;
|
||||
double env;
|
||||
core->index = 0;
|
||||
core->maxindex = samplerate/freq;
|
||||
core->maxindex = samplerate/freq;
|
||||
core->wavetable = malloc(core->maxindex*sizeof(float));
|
||||
memset(core->wavetable, 0, core->maxindex * sizeof(float));
|
||||
for (i = 0; i < core->maxindex; i++) {
|
||||
env = freq * i / samplerate;
|
||||
env = sin((M_PI*2) * fmod(env + 0.25, 1.0));
|
||||
core->wavetable[i] = env * (1 - fabs(offset)) + offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float tremolocore_core(struct tremolo_core *core,float in)
|
||||
|
|
|
@ -79,7 +79,7 @@ static void vibratocore_init(struct vibrato_core *core,float depth,int samplerat
|
|||
core->freq = freq;
|
||||
core->depth = depth;
|
||||
core->phase = 0;
|
||||
core->writeindex = 0;
|
||||
core->writeindex = 0;
|
||||
}
|
||||
|
||||
float vibratocore_core(struct vibrato_core *core,float in)
|
||||
|
|
|
@ -212,4 +212,3 @@ void audio_resampler_unlock(void)
|
|||
slock_unlock(s_resampler_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ static void resampler_nearest_free(void *re_)
|
|||
}
|
||||
|
||||
static void *resampler_nearest_init(const struct resampler_config *config,
|
||||
double bandwidth_mod,
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ static void resampler_null_free(void *re_)
|
|||
}
|
||||
|
||||
static void *resampler_null_init(const struct resampler_config *config,
|
||||
double bandwidth_mod,
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
|
|
|
@ -564,7 +564,7 @@ static void sinc_init_table_lanczos(rarch_sinc_resampler_t *resamp, double cutof
|
|||
}
|
||||
|
||||
static void *resampler_sinc_new(const struct resampler_config *config,
|
||||
double bandwidth_mod, enum resampler_quality quality,
|
||||
double bandwidth_mod, enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
double cutoff = 0.0;
|
||||
|
@ -662,6 +662,8 @@ static void *resampler_sinc_new(const struct resampler_config *config,
|
|||
if (!re->main_buffer)
|
||||
goto error;
|
||||
|
||||
memset(re->main_buffer, 0, sizeof(float) * elems);
|
||||
|
||||
re->phase_table = re->main_buffer;
|
||||
re->buffer_l = re->main_buffer + phase_elems;
|
||||
re->buffer_r = re->buffer_l + 2 * re->taps;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
process_sinc_neon_asm:
|
||||
_process_sinc_neon_asm:
|
||||
|
||||
push {r4, lr}
|
||||
push {r4, lr}
|
||||
vmov.f32 q0, #0.0
|
||||
vmov.f32 q8, #0.0
|
||||
|
||||
|
@ -68,7 +68,7 @@ _process_sinc_neon_asm:
|
|||
vadd.f32 d16, d16, d17
|
||||
vpadd.f32 d0, d0, d16
|
||||
vst1.f32 d0, [r0]
|
||||
|
||||
|
||||
pop {r4, pc}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ static int c89_vscprintf_retro__(const char *format, va_list pargs)
|
|||
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
|
||||
if (size != 0)
|
||||
{
|
||||
#if (_MSC_VER <= 1310)
|
||||
|
|
|
@ -509,13 +509,13 @@ unsigned cpu_features_get_core_amount(void)
|
|||
case 3:
|
||||
/*Old 3/2DS*/
|
||||
return 2;
|
||||
|
||||
|
||||
case 2:
|
||||
case 4:
|
||||
case 5:
|
||||
/*New 3/2DS*/
|
||||
return 4;
|
||||
|
||||
|
||||
default:
|
||||
/*Unknown Device Or Check Failed*/
|
||||
break;
|
||||
|
|
|
@ -305,7 +305,7 @@ const char *path_get_archive_delim(const char *path)
|
|||
*/
|
||||
const char *path_get_extension(const char *path)
|
||||
{
|
||||
const char *ext = !string_is_empty(path)
|
||||
const char *ext = !string_is_empty(path)
|
||||
? strrchr(path_basename(path), '.') : NULL;
|
||||
if (!ext)
|
||||
return "";
|
||||
|
@ -320,7 +320,7 @@ const char *path_get_extension(const char *path)
|
|||
* text after and including the last '.'.
|
||||
* Only '.'s after the last slash are considered.
|
||||
*
|
||||
* Returns:
|
||||
* Returns:
|
||||
* 1) If path has an extension, returns path with the
|
||||
* extension removed.
|
||||
* 2) If there is no extension, returns NULL.
|
||||
|
@ -328,7 +328,7 @@ const char *path_get_extension(const char *path)
|
|||
*/
|
||||
char *path_remove_extension(char *path)
|
||||
{
|
||||
char *last = !string_is_empty(path)
|
||||
char *last = !string_is_empty(path)
|
||||
? (char*)strrchr(path_basename(path), '.') : NULL;
|
||||
if (!last)
|
||||
return NULL;
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
extern nbio_intf_t nbio_linux;
|
||||
extern nbio_intf_t nbio_mmap_unix;
|
||||
extern nbio_intf_t nbio_mmap_win32;
|
||||
#if defined(ORBIS)
|
||||
extern nbio_intf_t nbio_orbis;
|
||||
#endif
|
||||
extern nbio_intf_t nbio_stdio;
|
||||
|
||||
#if defined(_linux__)
|
||||
|
|
|
@ -60,7 +60,6 @@ static void *nbio_orbis_open(const char * filename, unsigned int mode)
|
|||
return NULL;
|
||||
handle = (struct nbio_orbis_t*)malloc(sizeof(struct nbio_orbis_t));
|
||||
|
||||
|
||||
if (!handle)
|
||||
goto error;
|
||||
|
||||
|
@ -163,7 +162,6 @@ static bool nbio_orbis_iterate(void *data)
|
|||
amount = handle->len;
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate BIO_READ fd=%d readbytes=%d\n", handle->fd, orbisRead(handle->fd, (char*)handle->data, amount));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -190,7 +188,6 @@ static bool nbio_orbis_iterate(void *data)
|
|||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate write fd=%d writebytes=%d\n", handle->fd, orbisWrite(handle->fd, (char*)handle->data + handle->progress, amount));
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -281,16 +278,4 @@ nbio_intf_t nbio_orbis = {
|
|||
nbio_orbis_free,
|
||||
"nbio_orbis",
|
||||
};
|
||||
#else
|
||||
nbio_intf_t nbio_orbis = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"nbio_orbis",
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -952,7 +952,7 @@ chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **
|
|||
}
|
||||
|
||||
/* open the file */
|
||||
file = filestream_open(filename,
|
||||
file = filestream_open(filename,
|
||||
RETRO_VFS_FILE_ACCESS_READ,
|
||||
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||
|
||||
|
|
|
@ -1,163 +1,163 @@
|
|||
/***************************************************************************
|
||||
|
||||
libchdr_flac_codec.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/flac.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/***************************************************************************
|
||||
* CD FLAC DECOMPRESSOR
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------
|
||||
* cdfl_codec_blocksize - return the optimal block size
|
||||
*------------------------------------------------------
|
||||
*/
|
||||
|
||||
static uint32_t cdfl_codec_blocksize(uint32_t bytes)
|
||||
{
|
||||
/* determine FLAC block size, which must be 16-65535
|
||||
* clamp to 2k since that's supposed to be the sweet spot */
|
||||
uint32_t hunkbytes = bytes / 4;
|
||||
while (hunkbytes > 2048)
|
||||
hunkbytes /= 2;
|
||||
return hunkbytes;
|
||||
}
|
||||
|
||||
chd_error cdfl_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
#ifdef WANT_SUBCODE
|
||||
chd_error ret;
|
||||
#endif
|
||||
uint16_t native_endian = 0;
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
|
||||
/* make sure the CHD's hunk size is an even multiple of the frame size */
|
||||
if (hunkbytes % CD_FRAME_SIZE != 0)
|
||||
return CHDERR_CODEC_ERROR;
|
||||
|
||||
cdfl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdfl->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
/* determine whether we want native or swapped samples */
|
||||
*(uint8_t *)(&native_endian) = 1;
|
||||
cdfl->swap_endian = (native_endian & 1);
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
/* init zlib inflater */
|
||||
ret = zlib_codec_init(&cdfl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
/* flac decoder init */
|
||||
flac_decoder_init(&cdfl->decoder);
|
||||
if (cdfl->decoder.decoder == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdfl_codec_free(void *codec)
|
||||
{
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
flac_decoder_free(&cdfl->decoder);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdfl->subcode_decompressor);
|
||||
#endif
|
||||
if (cdfl->buffer)
|
||||
free(cdfl->buffer);
|
||||
}
|
||||
|
||||
chd_error cdfl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
uint32_t framenum;
|
||||
uint8_t *buffer;
|
||||
#ifdef WANT_SUBCODE
|
||||
uint32_t offset;
|
||||
chd_error ret;
|
||||
#endif
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
|
||||
/* reset and decode */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
|
||||
if (!flac_decoder_reset(&cdfl->decoder, 44100, 2, cdfl_codec_blocksize(frames * CD_MAX_SECTOR_DATA), src, complen))
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
buffer = &cdfl->buffer[0];
|
||||
if (!flac_decoder_decode_interleaved(&cdfl->decoder, (int16_t *)(buffer), frames * CD_MAX_SECTOR_DATA/4, cdfl->swap_endian))
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
/* inflate the subcode data */
|
||||
offset = flac_decoder_finish(&cdfl->decoder);
|
||||
ret = zlib_codec_decompress(&cdfl->subcode_decompressor, src + offset, complen - offset, &cdfl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#else
|
||||
flac_decoder_finish(&cdfl->decoder);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdfl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdfl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
}
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
/***************************************************************************
|
||||
|
||||
libchdr_flac_codec.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/flac.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/***************************************************************************
|
||||
* CD FLAC DECOMPRESSOR
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------
|
||||
* cdfl_codec_blocksize - return the optimal block size
|
||||
*------------------------------------------------------
|
||||
*/
|
||||
|
||||
static uint32_t cdfl_codec_blocksize(uint32_t bytes)
|
||||
{
|
||||
/* determine FLAC block size, which must be 16-65535
|
||||
* clamp to 2k since that's supposed to be the sweet spot */
|
||||
uint32_t hunkbytes = bytes / 4;
|
||||
while (hunkbytes > 2048)
|
||||
hunkbytes /= 2;
|
||||
return hunkbytes;
|
||||
}
|
||||
|
||||
chd_error cdfl_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
#ifdef WANT_SUBCODE
|
||||
chd_error ret;
|
||||
#endif
|
||||
uint16_t native_endian = 0;
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
|
||||
/* make sure the CHD's hunk size is an even multiple of the frame size */
|
||||
if (hunkbytes % CD_FRAME_SIZE != 0)
|
||||
return CHDERR_CODEC_ERROR;
|
||||
|
||||
cdfl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdfl->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
/* determine whether we want native or swapped samples */
|
||||
*(uint8_t *)(&native_endian) = 1;
|
||||
cdfl->swap_endian = (native_endian & 1);
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
/* init zlib inflater */
|
||||
ret = zlib_codec_init(&cdfl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
/* flac decoder init */
|
||||
flac_decoder_init(&cdfl->decoder);
|
||||
if (cdfl->decoder.decoder == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdfl_codec_free(void *codec)
|
||||
{
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
flac_decoder_free(&cdfl->decoder);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdfl->subcode_decompressor);
|
||||
#endif
|
||||
if (cdfl->buffer)
|
||||
free(cdfl->buffer);
|
||||
}
|
||||
|
||||
chd_error cdfl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
uint32_t framenum;
|
||||
uint8_t *buffer;
|
||||
#ifdef WANT_SUBCODE
|
||||
uint32_t offset;
|
||||
chd_error ret;
|
||||
#endif
|
||||
cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
|
||||
|
||||
/* reset and decode */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
|
||||
if (!flac_decoder_reset(&cdfl->decoder, 44100, 2, cdfl_codec_blocksize(frames * CD_MAX_SECTOR_DATA), src, complen))
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
buffer = &cdfl->buffer[0];
|
||||
if (!flac_decoder_decode_interleaved(&cdfl->decoder, (int16_t *)(buffer), frames * CD_MAX_SECTOR_DATA/4, cdfl->swap_endian))
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
/* inflate the subcode data */
|
||||
offset = flac_decoder_finish(&cdfl->decoder);
|
||||
ret = zlib_codec_decompress(&cdfl->subcode_decompressor, src + offset, complen - offset, &cdfl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#else
|
||||
flac_decoder_finish(&cdfl->decoder);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdfl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdfl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
}
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
|
|
@ -1,354 +1,351 @@
|
|||
/***************************************************************************
|
||||
|
||||
libchdr_lzma_codec.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/lzma.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/***************************************************************************
|
||||
* LZMA ALLOCATOR HELPER
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_fast_alloc - fast malloc for lzma, which
|
||||
* allocates and frees memory frequently
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
static void *lzma_fast_alloc(void *p, size_t size)
|
||||
{
|
||||
int scan;
|
||||
uint32_t *addr = NULL;
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* compute the size, rounding to the nearest 1k */
|
||||
size = (size + 0x3ff) & ~0x3ff;
|
||||
|
||||
/* reuse a hunk if we can */
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
uint32_t *ptr = codec->allocptr[scan];
|
||||
if (ptr != NULL && size == *ptr)
|
||||
{
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr |= 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* alloc a new one and put it into the list */
|
||||
addr = (uint32_t *)malloc(sizeof(uint32_t) * (size + sizeof(uint32_t)));
|
||||
if (!addr)
|
||||
return NULL;
|
||||
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
if (codec->allocptr[scan] == NULL)
|
||||
{
|
||||
codec->allocptr[scan] = addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*addr = size | 1;
|
||||
return addr + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_fast_free - fast free for lzma, which
|
||||
* allocates and frees memory frequently
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
static void lzma_fast_free(void *p, void *address)
|
||||
{
|
||||
int scan;
|
||||
uint32_t *ptr;
|
||||
lzma_allocator *codec;
|
||||
if (address == NULL)
|
||||
return;
|
||||
|
||||
codec = (lzma_allocator *)(p);
|
||||
|
||||
/* find the hunk */
|
||||
ptr = (uint32_t *)(address) - 1;
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
if (ptr == codec->allocptr[scan])
|
||||
{
|
||||
/* clear the low bit of the size to allow matches */
|
||||
*ptr &= ~1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_allocator_init
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_allocator_init(void* p)
|
||||
{
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* reset pointer list */
|
||||
memset(codec->allocptr, 0, sizeof(codec->allocptr));
|
||||
codec->Alloc = lzma_fast_alloc;
|
||||
codec->Free = lzma_fast_free;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_allocator_free
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_allocator_free(void* p )
|
||||
{
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* free our memory */
|
||||
int i;
|
||||
for (i = 0 ; i < MAX_LZMA_ALLOCS ; i++)
|
||||
{
|
||||
if (codec->allocptr[i] != NULL)
|
||||
free(codec->allocptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* LZMA DECOMPRESSOR
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_codec_init - constructor
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
chd_error lzma_codec_init(void* codec, uint32_t hunkbytes)
|
||||
{
|
||||
CLzmaEncProps encoder_props;
|
||||
CLzmaEncHandle enc;
|
||||
uint8_t decoder_props[LZMA_PROPS_SIZE];
|
||||
lzma_allocator* alloc;
|
||||
size_t props_size;
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
|
||||
/* construct the decoder */
|
||||
LzmaDec_Construct(&lzma_codec->decoder);
|
||||
|
||||
/* FIXME: this code is written in a way that makes it impossible to safely upgrade the LZMA SDK
|
||||
* This code assumes that the current version of the encoder imposes the same requirements on the
|
||||
* decoder as the encoder used to produce the file. This is not necessarily true. The format
|
||||
* needs to be changed so the encoder properties are written to the file.
|
||||
|
||||
* configure the properties like the compressor did */
|
||||
LzmaEncProps_Init(&encoder_props);
|
||||
encoder_props.level = 9;
|
||||
encoder_props.reduceSize = hunkbytes;
|
||||
LzmaEncProps_Normalize(&encoder_props);
|
||||
|
||||
/* convert to decoder properties */
|
||||
alloc = &lzma_codec->allocator;
|
||||
lzma_allocator_init(alloc);
|
||||
enc = LzmaEnc_Create((ISzAlloc*)alloc);
|
||||
if (!enc)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
if (LzmaEnc_SetProps(enc, &encoder_props) != SZ_OK)
|
||||
{
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)&alloc, (ISzAlloc*)&alloc);
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
}
|
||||
props_size = sizeof(decoder_props);
|
||||
if (LzmaEnc_WriteProperties(enc, decoder_props, &props_size) != SZ_OK)
|
||||
{
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
}
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
|
||||
|
||||
/* do memory allocations */
|
||||
if (LzmaDec_Allocate(&lzma_codec->decoder, decoder_props, LZMA_PROPS_SIZE, (ISzAlloc*)alloc) != SZ_OK)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
/* Okay */
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_codec_free
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_codec_free(void* codec)
|
||||
{
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
lzma_allocator* alloc = &lzma_codec->allocator;
|
||||
|
||||
/* free memory */
|
||||
lzma_allocator_free(alloc);
|
||||
LzmaDec_Free(&lzma_codec->decoder, (ISzAlloc*)&lzma_codec->allocator);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* decompress - decompress data using the LZMA
|
||||
* codec
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
chd_error lzma_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
ELzmaStatus status;
|
||||
SRes res;
|
||||
size_t consumedlen, decodedlen;
|
||||
/* initialize */
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
LzmaDec_Init(&lzma_codec->decoder);
|
||||
|
||||
/* decode */
|
||||
consumedlen = complen;
|
||||
decodedlen = destlen;
|
||||
res = LzmaDec_DecodeToBuf(&lzma_codec->decoder, dest, &decodedlen, src, &consumedlen, LZMA_FINISH_END, &status);
|
||||
if ((res != SZ_OK && res != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) || consumedlen != complen || decodedlen != destlen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/* cdlz */
|
||||
chd_error cdlz_codec_init(void* codec, uint32_t hunkbytes)
|
||||
{
|
||||
chd_error ret;
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
|
||||
|
||||
/* allocate buffer */
|
||||
cdlz->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdlz->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
ret = lzma_codec_init(&cdlz->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
ret = zlib_codec_init(&cdlz->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdlz_codec_free(void* codec)
|
||||
{
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
|
||||
|
||||
lzma_codec_free(&cdlz->base_decompressor);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdlz->subcode_decompressor);
|
||||
#endif
|
||||
if (cdlz->buffer)
|
||||
free(cdlz->buffer);
|
||||
}
|
||||
|
||||
chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
uint8_t *sector;
|
||||
#endif
|
||||
uint32_t framenum;
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*)codec;
|
||||
|
||||
/* determine header bytes */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
|
||||
uint32_t ecc_bytes = (frames + 7) / 8;
|
||||
uint32_t header_bytes = ecc_bytes + complen_bytes;
|
||||
|
||||
/* extract compressed length of base */
|
||||
uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
|
||||
if (complen_bytes > 2)
|
||||
complen_base = (complen_base << 8) | src[ecc_bytes + 2];
|
||||
|
||||
/* reset and decode */
|
||||
lzma_codec_decompress(&cdlz->base_decompressor, &src[header_bytes], complen_base, &cdlz->buffer[0], frames * CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
if (header_bytes + complen_base >= complen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
zlib_codec_decompress(&cdlz->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdlz->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdlz->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdlz->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
/* reconstitute the ECC data and sync header */
|
||||
sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
|
||||
if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
|
||||
{
|
||||
memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
|
||||
ecc_generate(sector);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
/***************************************************************************
|
||||
|
||||
libchdr_lzma_codec.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/lzma.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/***************************************************************************
|
||||
* LZMA ALLOCATOR HELPER
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_fast_alloc - fast malloc for lzma, which
|
||||
* allocates and frees memory frequently
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
static void *lzma_fast_alloc(void *p, size_t size)
|
||||
{
|
||||
int scan;
|
||||
uint32_t *addr = NULL;
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* compute the size, rounding to the nearest 1k */
|
||||
size = (size + 0x3ff) & ~0x3ff;
|
||||
|
||||
/* reuse a hunk if we can */
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
uint32_t *ptr = codec->allocptr[scan];
|
||||
if (ptr != NULL && size == *ptr)
|
||||
{
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr |= 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* alloc a new one and put it into the list */
|
||||
addr = (uint32_t *)malloc(sizeof(uint32_t) * (size + sizeof(uint32_t)));
|
||||
if (!addr)
|
||||
return NULL;
|
||||
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
if (codec->allocptr[scan] == NULL)
|
||||
{
|
||||
codec->allocptr[scan] = addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*addr = size | 1;
|
||||
return addr + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_fast_free - fast free for lzma, which
|
||||
* allocates and frees memory frequently
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
static void lzma_fast_free(void *p, void *address)
|
||||
{
|
||||
int scan;
|
||||
uint32_t *ptr;
|
||||
lzma_allocator *codec;
|
||||
if (address == NULL)
|
||||
return;
|
||||
|
||||
codec = (lzma_allocator *)(p);
|
||||
|
||||
/* find the hunk */
|
||||
ptr = (uint32_t *)(address) - 1;
|
||||
for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
|
||||
{
|
||||
if (ptr == codec->allocptr[scan])
|
||||
{
|
||||
/* clear the low bit of the size to allow matches */
|
||||
*ptr &= ~1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_allocator_init
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_allocator_init(void* p)
|
||||
{
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* reset pointer list */
|
||||
memset(codec->allocptr, 0, sizeof(codec->allocptr));
|
||||
codec->Alloc = lzma_fast_alloc;
|
||||
codec->Free = lzma_fast_free;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_allocator_free
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_allocator_free(void* p )
|
||||
{
|
||||
lzma_allocator *codec = (lzma_allocator *)(p);
|
||||
|
||||
/* free our memory */
|
||||
int i;
|
||||
for (i = 0 ; i < MAX_LZMA_ALLOCS ; i++)
|
||||
{
|
||||
if (codec->allocptr[i] != NULL)
|
||||
free(codec->allocptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* LZMA DECOMPRESSOR
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_codec_init - constructor
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
chd_error lzma_codec_init(void* codec, uint32_t hunkbytes)
|
||||
{
|
||||
CLzmaEncProps encoder_props;
|
||||
CLzmaEncHandle enc;
|
||||
uint8_t decoder_props[LZMA_PROPS_SIZE];
|
||||
lzma_allocator* alloc;
|
||||
size_t props_size;
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
|
||||
/* construct the decoder */
|
||||
LzmaDec_Construct(&lzma_codec->decoder);
|
||||
|
||||
/* FIXME: this code is written in a way that makes it impossible to safely upgrade the LZMA SDK
|
||||
* This code assumes that the current version of the encoder imposes the same requirements on the
|
||||
* decoder as the encoder used to produce the file. This is not necessarily true. The format
|
||||
* needs to be changed so the encoder properties are written to the file.
|
||||
|
||||
* configure the properties like the compressor did */
|
||||
LzmaEncProps_Init(&encoder_props);
|
||||
encoder_props.level = 9;
|
||||
encoder_props.reduceSize = hunkbytes;
|
||||
LzmaEncProps_Normalize(&encoder_props);
|
||||
|
||||
/* convert to decoder properties */
|
||||
alloc = &lzma_codec->allocator;
|
||||
lzma_allocator_init(alloc);
|
||||
enc = LzmaEnc_Create((ISzAlloc*)alloc);
|
||||
if (!enc)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
if (LzmaEnc_SetProps(enc, &encoder_props) != SZ_OK)
|
||||
{
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)&alloc, (ISzAlloc*)&alloc);
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
}
|
||||
props_size = sizeof(decoder_props);
|
||||
if (LzmaEnc_WriteProperties(enc, decoder_props, &props_size) != SZ_OK)
|
||||
{
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
}
|
||||
LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
|
||||
|
||||
/* do memory allocations */
|
||||
if (LzmaDec_Allocate(&lzma_codec->decoder, decoder_props, LZMA_PROPS_SIZE, (ISzAlloc*)alloc) != SZ_OK)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
/* Okay */
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* lzma_codec_free
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void lzma_codec_free(void* codec)
|
||||
{
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
lzma_allocator* alloc = &lzma_codec->allocator;
|
||||
|
||||
/* free memory */
|
||||
lzma_allocator_free(alloc);
|
||||
LzmaDec_Free(&lzma_codec->decoder, (ISzAlloc*)&lzma_codec->allocator);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
* decompress - decompress data using the LZMA
|
||||
* codec
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
chd_error lzma_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
ELzmaStatus status;
|
||||
SRes res;
|
||||
size_t consumedlen, decodedlen;
|
||||
/* initialize */
|
||||
lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
|
||||
LzmaDec_Init(&lzma_codec->decoder);
|
||||
|
||||
/* decode */
|
||||
consumedlen = complen;
|
||||
decodedlen = destlen;
|
||||
res = LzmaDec_DecodeToBuf(&lzma_codec->decoder, dest, &decodedlen, src, &consumedlen, LZMA_FINISH_END, &status);
|
||||
if ((res != SZ_OK && res != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) || consumedlen != complen || decodedlen != destlen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/* cdlz */
|
||||
chd_error cdlz_codec_init(void* codec, uint32_t hunkbytes)
|
||||
{
|
||||
chd_error ret;
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
|
||||
|
||||
/* allocate buffer */
|
||||
cdlz->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdlz->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
ret = lzma_codec_init(&cdlz->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
ret = zlib_codec_init(&cdlz->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdlz_codec_free(void* codec)
|
||||
{
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
|
||||
|
||||
lzma_codec_free(&cdlz->base_decompressor);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdlz->subcode_decompressor);
|
||||
#endif
|
||||
if (cdlz->buffer)
|
||||
free(cdlz->buffer);
|
||||
}
|
||||
|
||||
chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
uint8_t *sector;
|
||||
#endif
|
||||
uint32_t framenum;
|
||||
cdlz_codec_data* cdlz = (cdlz_codec_data*)codec;
|
||||
|
||||
/* determine header bytes */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
|
||||
uint32_t ecc_bytes = (frames + 7) / 8;
|
||||
uint32_t header_bytes = ecc_bytes + complen_bytes;
|
||||
|
||||
/* extract compressed length of base */
|
||||
uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
|
||||
if (complen_bytes > 2)
|
||||
complen_base = (complen_base << 8) | src[ecc_bytes + 2];
|
||||
|
||||
/* reset and decode */
|
||||
lzma_codec_decompress(&cdlz->base_decompressor, &src[header_bytes], complen_base, &cdlz->buffer[0], frames * CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
if (header_bytes + complen_base >= complen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
zlib_codec_decompress(&cdlz->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdlz->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdlz->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdlz->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
/* reconstitute the ECC data and sync header */
|
||||
sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
|
||||
if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
|
||||
{
|
||||
memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
|
||||
ecc_generate(sector);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
|
|
@ -1,298 +1,298 @@
|
|||
/***************************************************************************
|
||||
|
||||
libchdr_zlib.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <libchdr/libchdr_zlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* cdzl */
|
||||
|
||||
chd_error cdzl_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
chd_error ret;
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
/* make sure the CHD's hunk size is an even multiple of the frame size */
|
||||
if (hunkbytes % CD_FRAME_SIZE != 0)
|
||||
return CHDERR_CODEC_ERROR;
|
||||
|
||||
cdzl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdzl->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
ret = zlib_codec_init(&cdzl->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
ret = zlib_codec_init(&cdzl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdzl_codec_free(void *codec)
|
||||
{
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
zlib_codec_free(&cdzl->base_decompressor);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdzl->subcode_decompressor);
|
||||
#endif
|
||||
if (cdzl->buffer)
|
||||
free(cdzl->buffer);
|
||||
}
|
||||
|
||||
chd_error cdzl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
uint8_t *sector;
|
||||
#endif
|
||||
uint32_t framenum;
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
/* determine header bytes */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
|
||||
uint32_t ecc_bytes = (frames + 7) / 8;
|
||||
uint32_t header_bytes = ecc_bytes + complen_bytes;
|
||||
|
||||
/* extract compressed length of base */
|
||||
uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
|
||||
if (complen_bytes > 2)
|
||||
complen_base = (complen_base << 8) | src[ecc_bytes + 2];
|
||||
|
||||
/* reset and decode */
|
||||
zlib_codec_decompress(&cdzl->base_decompressor, &src[header_bytes], complen_base, &cdzl->buffer[0], frames * CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_decompress(&cdzl->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdzl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdzl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdzl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
/* reconstitute the ECC data and sync header */
|
||||
sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
|
||||
if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
|
||||
{
|
||||
memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
|
||||
ecc_generate(sector);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
ZLIB COMPRESSION CODEC
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_init - initialize the ZLIB codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
chd_error zlib_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
int zerr;
|
||||
chd_error err;
|
||||
zlib_codec_data *data = (zlib_codec_data*)codec;
|
||||
|
||||
/* clear the buffers */
|
||||
memset(data, 0, sizeof(zlib_codec_data));
|
||||
|
||||
/* init the inflater first */
|
||||
data->inflater.next_in = (Bytef *)data; /* bogus, but that's ok */
|
||||
data->inflater.avail_in = 0;
|
||||
data->inflater.zalloc = zlib_fast_alloc;
|
||||
data->inflater.zfree = zlib_fast_free;
|
||||
data->inflater.opaque = &data->allocator;
|
||||
zerr = inflateInit2(&data->inflater, -MAX_WBITS);
|
||||
|
||||
/* convert errors */
|
||||
if (zerr == Z_MEM_ERROR)
|
||||
err = CHDERR_OUT_OF_MEMORY;
|
||||
else if (zerr != Z_OK)
|
||||
err = CHDERR_CODEC_ERROR;
|
||||
else
|
||||
err = CHDERR_NONE;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_free - free data for the ZLIB
|
||||
codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
void zlib_codec_free(void *codec)
|
||||
{
|
||||
zlib_codec_data *data = (zlib_codec_data *)codec;
|
||||
|
||||
/* deinit the streams */
|
||||
if (data != NULL)
|
||||
{
|
||||
int i;
|
||||
zlib_allocator alloc;
|
||||
|
||||
inflateEnd(&data->inflater);
|
||||
|
||||
/* free our fast memory */
|
||||
alloc = data->allocator;
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (alloc.allocptr[i])
|
||||
free(alloc.allocptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_decompress - decomrpess data using
|
||||
the ZLIB codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
zlib_codec_data *data = (zlib_codec_data *)codec;
|
||||
int zerr;
|
||||
|
||||
/* reset the decompressor */
|
||||
data->inflater.next_in = (Bytef *)src;
|
||||
data->inflater.avail_in = complen;
|
||||
data->inflater.total_in = 0;
|
||||
data->inflater.next_out = (Bytef *)dest;
|
||||
data->inflater.avail_out = destlen;
|
||||
data->inflater.total_out = 0;
|
||||
zerr = inflateReset(&data->inflater);
|
||||
if (zerr != Z_OK)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
/* do it */
|
||||
zerr = inflate(&data->inflater, Z_FINISH);
|
||||
(void)zerr;
|
||||
if (data->inflater.total_out != destlen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_fast_alloc - fast malloc for ZLIB, which
|
||||
allocates and frees memory frequently
|
||||
-------------------------------------------------*/
|
||||
|
||||
voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
||||
UINT32 *ptr;
|
||||
int i;
|
||||
|
||||
/* compute the size, rounding to the nearest 1k */
|
||||
size = (size * items + 0x3ff) & ~0x3ff;
|
||||
|
||||
/* reuse a hunk if we can */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
{
|
||||
ptr = alloc->allocptr[i];
|
||||
if (ptr && size == *ptr)
|
||||
{
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr |= 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* alloc a new one */
|
||||
ptr = (UINT32 *)malloc(size + sizeof(UINT32));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
/* put it into the list */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (!alloc->allocptr[i])
|
||||
{
|
||||
alloc->allocptr[i] = ptr;
|
||||
break;
|
||||
}
|
||||
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr = size | 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_fast_free - fast free for ZLIB, which
|
||||
allocates and frees memory frequently
|
||||
-------------------------------------------------*/
|
||||
|
||||
void zlib_fast_free(voidpf opaque, voidpf address)
|
||||
{
|
||||
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
||||
UINT32 *ptr = (UINT32 *)address - 1;
|
||||
int i;
|
||||
|
||||
/* find the hunk */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (ptr == alloc->allocptr[i])
|
||||
{
|
||||
/* clear the low bit of the size to allow matches */
|
||||
*ptr &= ~1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/***************************************************************************
|
||||
|
||||
libchdr_zlib.c
|
||||
|
||||
MAME Compressed Hunks of Data file format
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Copyright Aaron Giles
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name 'MAME' nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libchdr/chd.h>
|
||||
#include <libchdr/minmax.h>
|
||||
#include <libchdr/cdrom.h>
|
||||
#include <libchdr/huffman.h>
|
||||
#include <libchdr/libchdr_zlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* cdzl */
|
||||
|
||||
chd_error cdzl_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
chd_error ret;
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
/* make sure the CHD's hunk size is an even multiple of the frame size */
|
||||
if (hunkbytes % CD_FRAME_SIZE != 0)
|
||||
return CHDERR_CODEC_ERROR;
|
||||
|
||||
cdzl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
|
||||
if (cdzl->buffer == NULL)
|
||||
return CHDERR_OUT_OF_MEMORY;
|
||||
|
||||
ret = zlib_codec_init(&cdzl->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
|
||||
#ifdef WANT_SUBCODE
|
||||
ret = zlib_codec_init(&cdzl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
|
||||
if (ret != CHDERR_NONE)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
void cdzl_codec_free(void *codec)
|
||||
{
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
zlib_codec_free(&cdzl->base_decompressor);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_free(&cdzl->subcode_decompressor);
|
||||
#endif
|
||||
if (cdzl->buffer)
|
||||
free(cdzl->buffer);
|
||||
}
|
||||
|
||||
chd_error cdzl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
uint8_t *sector;
|
||||
#endif
|
||||
uint32_t framenum;
|
||||
cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
|
||||
|
||||
/* determine header bytes */
|
||||
uint32_t frames = destlen / CD_FRAME_SIZE;
|
||||
uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
|
||||
uint32_t ecc_bytes = (frames + 7) / 8;
|
||||
uint32_t header_bytes = ecc_bytes + complen_bytes;
|
||||
|
||||
/* extract compressed length of base */
|
||||
uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
|
||||
if (complen_bytes > 2)
|
||||
complen_base = (complen_base << 8) | src[ecc_bytes + 2];
|
||||
|
||||
/* reset and decode */
|
||||
zlib_codec_decompress(&cdzl->base_decompressor, &src[header_bytes], complen_base, &cdzl->buffer[0], frames * CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
zlib_codec_decompress(&cdzl->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdzl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
/* reassemble the data */
|
||||
for (framenum = 0; framenum < frames; framenum++)
|
||||
{
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE], &cdzl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
|
||||
#ifdef WANT_SUBCODE
|
||||
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdzl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
|
||||
#endif
|
||||
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
/* reconstitute the ECC data and sync header */
|
||||
sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
|
||||
if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
|
||||
{
|
||||
memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
|
||||
ecc_generate(sector);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
ZLIB COMPRESSION CODEC
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_init - initialize the ZLIB codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
chd_error zlib_codec_init(void *codec, uint32_t hunkbytes)
|
||||
{
|
||||
int zerr;
|
||||
chd_error err;
|
||||
zlib_codec_data *data = (zlib_codec_data*)codec;
|
||||
|
||||
/* clear the buffers */
|
||||
memset(data, 0, sizeof(zlib_codec_data));
|
||||
|
||||
/* init the inflater first */
|
||||
data->inflater.next_in = (Bytef *)data; /* bogus, but that's ok */
|
||||
data->inflater.avail_in = 0;
|
||||
data->inflater.zalloc = zlib_fast_alloc;
|
||||
data->inflater.zfree = zlib_fast_free;
|
||||
data->inflater.opaque = &data->allocator;
|
||||
zerr = inflateInit2(&data->inflater, -MAX_WBITS);
|
||||
|
||||
/* convert errors */
|
||||
if (zerr == Z_MEM_ERROR)
|
||||
err = CHDERR_OUT_OF_MEMORY;
|
||||
else if (zerr != Z_OK)
|
||||
err = CHDERR_CODEC_ERROR;
|
||||
else
|
||||
err = CHDERR_NONE;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_free - free data for the ZLIB
|
||||
codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
void zlib_codec_free(void *codec)
|
||||
{
|
||||
zlib_codec_data *data = (zlib_codec_data *)codec;
|
||||
|
||||
/* deinit the streams */
|
||||
if (data != NULL)
|
||||
{
|
||||
int i;
|
||||
zlib_allocator alloc;
|
||||
|
||||
inflateEnd(&data->inflater);
|
||||
|
||||
/* free our fast memory */
|
||||
alloc = data->allocator;
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (alloc.allocptr[i])
|
||||
free(alloc.allocptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_codec_decompress - decomrpess data using
|
||||
the ZLIB codec
|
||||
-------------------------------------------------*/
|
||||
|
||||
chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||
{
|
||||
zlib_codec_data *data = (zlib_codec_data *)codec;
|
||||
int zerr;
|
||||
|
||||
/* reset the decompressor */
|
||||
data->inflater.next_in = (Bytef *)src;
|
||||
data->inflater.avail_in = complen;
|
||||
data->inflater.total_in = 0;
|
||||
data->inflater.next_out = (Bytef *)dest;
|
||||
data->inflater.avail_out = destlen;
|
||||
data->inflater.total_out = 0;
|
||||
zerr = inflateReset(&data->inflater);
|
||||
if (zerr != Z_OK)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
/* do it */
|
||||
zerr = inflate(&data->inflater, Z_FINISH);
|
||||
(void)zerr;
|
||||
if (data->inflater.total_out != destlen)
|
||||
return CHDERR_DECOMPRESSION_ERROR;
|
||||
|
||||
return CHDERR_NONE;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_fast_alloc - fast malloc for ZLIB, which
|
||||
allocates and frees memory frequently
|
||||
-------------------------------------------------*/
|
||||
|
||||
voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
|
||||
{
|
||||
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
||||
UINT32 *ptr;
|
||||
int i;
|
||||
|
||||
/* compute the size, rounding to the nearest 1k */
|
||||
size = (size * items + 0x3ff) & ~0x3ff;
|
||||
|
||||
/* reuse a hunk if we can */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
{
|
||||
ptr = alloc->allocptr[i];
|
||||
if (ptr && size == *ptr)
|
||||
{
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr |= 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* alloc a new one */
|
||||
ptr = (UINT32 *)malloc(size + sizeof(UINT32));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
/* put it into the list */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (!alloc->allocptr[i])
|
||||
{
|
||||
alloc->allocptr[i] = ptr;
|
||||
break;
|
||||
}
|
||||
|
||||
/* set the low bit of the size so we don't match next time */
|
||||
*ptr = size | 1;
|
||||
return ptr + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
zlib_fast_free - fast free for ZLIB, which
|
||||
allocates and frees memory frequently
|
||||
-------------------------------------------------*/
|
||||
|
||||
void zlib_fast_free(voidpf opaque, voidpf address)
|
||||
{
|
||||
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
||||
UINT32 *ptr = (UINT32 *)address - 1;
|
||||
int i;
|
||||
|
||||
/* find the hunk */
|
||||
for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
|
||||
if (ptr == alloc->allocptr[i])
|
||||
{
|
||||
/* clear the low bit of the size to allow matches */
|
||||
*ptr &= ~1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ bool scaler_ctx_gen_filter(struct scaler_ctx *ctx)
|
|||
case SCALER_FMT_ABGR8888:
|
||||
ctx->out_pixconv = conv_argb8888_abgr8888;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,13 @@ void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int
|
|||
const uint32_t *input_base_x = input + ctx->horiz.filter_pos[w];
|
||||
#if defined(__SSE2__)
|
||||
__m128i res = _mm_setzero_si128();
|
||||
|
||||
#ifndef __x86_64__
|
||||
union
|
||||
{
|
||||
uint32_t *u32;
|
||||
uint64_t *u64;
|
||||
} u;
|
||||
#endif
|
||||
for (x = 0; (x + 1) < ctx->horiz.filter_len; x += 2)
|
||||
{
|
||||
__m128i coeff = _mm_set_epi64x(filter_horiz[x + 1] * 0x0001000100010001ll, filter_horiz[x + 0] * 0x0001000100010001ll);
|
||||
|
@ -188,11 +194,6 @@ void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int
|
|||
#ifdef __x86_64__
|
||||
output[w] = _mm_cvtsi128_si64(res);
|
||||
#else /* 32-bit doesn't have si64. Do it in two steps. */
|
||||
union
|
||||
{
|
||||
uint32_t *u32;
|
||||
uint64_t *u64;
|
||||
} u;
|
||||
u.u64 = output + w;
|
||||
u.u32[0] = _mm_cvtsi128_si32(res);
|
||||
u.u32[1] = _mm_cvtsi128_si32(_mm_srli_si128(res, 4));
|
||||
|
|
154
glsm/glsm.c
154
glsm/glsm.c
|
@ -167,7 +167,7 @@ struct gl_cached_state
|
|||
GLenum mode;
|
||||
} frontface;
|
||||
|
||||
struct
|
||||
struct
|
||||
{
|
||||
bool used;
|
||||
GLenum mode;
|
||||
|
@ -193,7 +193,7 @@ struct gl_cached_state
|
|||
GLuint vao;
|
||||
GLuint framebuf;
|
||||
GLuint array_buffer;
|
||||
GLuint program;
|
||||
GLuint program;
|
||||
GLenum active_texture;
|
||||
int cap_state[SGL_CAP_MAX];
|
||||
int cap_translate[SGL_CAP_MAX];
|
||||
|
@ -468,7 +468,7 @@ void rglFrontFace(GLenum mode)
|
|||
glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL);
|
||||
glFrontFace(mode);
|
||||
gl_state.frontface.used = true;
|
||||
gl_state.frontface.mode = mode;
|
||||
gl_state.frontface.mode = mode;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -662,7 +662,7 @@ void rglBlendFuncSeparate(GLenum sfactor, GLenum dfactor)
|
|||
* Category: Textures
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.3
|
||||
* OpenGL : 1.3
|
||||
*/
|
||||
void rglActiveTexture(GLenum texture)
|
||||
{
|
||||
|
@ -723,7 +723,7 @@ void rglEnable(GLenum cap)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUseProgram(GLuint program)
|
||||
{
|
||||
|
@ -828,7 +828,7 @@ void rglLinkProgram(GLuint program)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglFramebufferTexture2D(GLenum target, GLenum attachment,
|
||||
|
@ -892,7 +892,7 @@ void rglCompressedTexImage2D(GLenum target, GLint level,
|
|||
#ifdef GLSM_DEBUG
|
||||
log_cb(RETRO_LOG_INFO, "glCompressedTexImage2D.\n");
|
||||
#endif
|
||||
glCompressedTexImage2D(target, level, internalformat,
|
||||
glCompressedTexImage2D(target, level, internalformat,
|
||||
width, height, border, imageSize, data);
|
||||
}
|
||||
|
||||
|
@ -915,7 +915,7 @@ void rglDeleteTextures(GLsizei n, const GLuint *textures)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGLES : 2.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglRenderbufferStorage(GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height)
|
||||
|
@ -931,7 +931,7 @@ void rglRenderbufferStorage(GLenum target, GLenum internalFormat,
|
|||
* Core in:
|
||||
*
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 2.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglBindRenderbuffer(GLenum target, GLuint renderbuffer)
|
||||
{
|
||||
|
@ -945,7 +945,7 @@ void rglBindRenderbuffer(GLenum target, GLuint renderbuffer)
|
|||
*
|
||||
* Core in:
|
||||
*
|
||||
* OpenGLES : 2.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
||||
{
|
||||
|
@ -960,7 +960,7 @@ void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
|||
* Core in:
|
||||
*
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 2.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
||||
{
|
||||
|
@ -975,7 +975,7 @@ void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
|||
* Core in:
|
||||
*
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 2.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglGenerateMipmap(GLenum target)
|
||||
{
|
||||
|
@ -989,7 +989,7 @@ void rglGenerateMipmap(GLenum target)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
*/
|
||||
GLenum rglCheckFramebufferStatus(GLenum target)
|
||||
{
|
||||
|
@ -1003,7 +1003,7 @@ GLenum rglCheckFramebufferStatus(GLenum target)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 2.0
|
||||
*/
|
||||
void rglFramebufferRenderbuffer(GLenum target, GLenum attachment,
|
||||
|
@ -1019,7 +1019,7 @@ void rglFramebufferRenderbuffer(GLenum target, GLenum attachment,
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
*/
|
||||
void rglBindFragDataLocation(GLuint program, GLuint colorNumber,
|
||||
const char * name)
|
||||
|
@ -1036,7 +1036,7 @@ void rglBindFragDataLocation(GLuint program, GLuint colorNumber,
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params)
|
||||
{
|
||||
|
@ -1050,7 +1050,7 @@ void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 4.1
|
||||
* OpenGL : 4.1
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglProgramParameteri( GLuint program,
|
||||
|
@ -1070,7 +1070,7 @@ void rglProgramParameteri( GLuint program,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize,
|
||||
GLsizei *length, GLint *size, GLenum *type, GLchar *name)
|
||||
|
@ -1141,7 +1141,7 @@ void rglEndQuery( GLenum target)
|
|||
*
|
||||
* Core in:
|
||||
*
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglGetActiveUniformBlockiv(GLuint program,
|
||||
|
@ -1273,7 +1273,7 @@ void rglUniformBlockBinding( GLuint program,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglUniform1ui(GLint location, GLuint v)
|
||||
|
@ -1289,7 +1289,7 @@ void rglUniform1ui(GLint location, GLuint v)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglUniform2ui(GLint location, GLuint v0, GLuint v1)
|
||||
|
@ -1305,7 +1305,7 @@ void rglUniform2ui(GLint location, GLuint v0, GLuint v1)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
|
||||
|
@ -1321,7 +1321,7 @@ void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
|
||||
|
@ -1337,7 +1337,7 @@ void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
|
||||
const GLfloat *value)
|
||||
|
@ -1352,7 +1352,7 @@ void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglDetachShader(GLuint program, GLuint shader)
|
||||
{
|
||||
|
@ -1366,7 +1366,7 @@ void rglDetachShader(GLuint program, GLuint shader)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params)
|
||||
{
|
||||
|
@ -1380,7 +1380,7 @@ void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglAttachShader(GLuint program, GLuint shader)
|
||||
{
|
||||
|
@ -1393,7 +1393,7 @@ void rglAttachShader(GLuint program, GLuint shader)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
GLint rglGetAttribLocation(GLuint program, const GLchar *name)
|
||||
{
|
||||
|
@ -1407,7 +1407,7 @@ GLint rglGetAttribLocation(GLuint program, const GLchar *name)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglShaderSource(GLuint shader, GLsizei count,
|
||||
const GLchar **string, const GLint *length)
|
||||
|
@ -1422,7 +1422,7 @@ void rglShaderSource(GLuint shader, GLsizei count,
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglCompileShader(GLuint shader)
|
||||
{
|
||||
|
@ -1436,7 +1436,7 @@ void rglCompileShader(GLuint shader)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
GLuint rglCreateProgram(void)
|
||||
{
|
||||
|
@ -1449,7 +1449,7 @@ GLuint rglCreateProgram(void)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.1
|
||||
* OpenGL : 1.1
|
||||
*/
|
||||
void rglGenTextures(GLsizei n, GLuint *textures)
|
||||
{
|
||||
|
@ -1462,7 +1462,7 @@ void rglGenTextures(GLsizei n, GLuint *textures)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength,
|
||||
GLsizei *length, GLchar *infoLog)
|
||||
|
@ -1476,7 +1476,7 @@ void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength,
|
||||
GLsizei *length, GLchar *infoLog)
|
||||
|
@ -1490,7 +1490,7 @@ void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
GLboolean rglIsProgram(GLuint program)
|
||||
{
|
||||
|
@ -1514,7 +1514,7 @@ void rglTexCoord2f(GLfloat s, GLfloat t)
|
|||
* Category: Generic vertex attributes
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*
|
||||
*/
|
||||
void rglDisableVertexAttribArray(GLuint index)
|
||||
|
@ -1530,7 +1530,7 @@ void rglDisableVertexAttribArray(GLuint index)
|
|||
* Category: Generic vertex attributes
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglEnableVertexAttribArray(GLuint index)
|
||||
{
|
||||
|
@ -1546,7 +1546,7 @@ void rglEnableVertexAttribArray(GLuint index)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglVertexAttribIPointer(
|
||||
GLuint index,
|
||||
|
@ -1582,7 +1582,7 @@ void rglVertexAttribLPointer(
|
|||
* Category: Generic vertex attributes
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglVertexAttribPointer(GLuint name, GLint size,
|
||||
GLenum type, GLboolean normalized, GLsizei stride,
|
||||
|
@ -1605,7 +1605,7 @@ void rglVertexAttribPointer(GLuint name, GLint size,
|
|||
* Category: Generic vertex attributes
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name)
|
||||
{
|
||||
|
@ -1618,7 +1618,7 @@ void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y,
|
||||
GLfloat z, GLfloat w)
|
||||
|
@ -1632,7 +1632,7 @@ void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglVertexAttrib4fv(GLuint name, GLfloat* v)
|
||||
{
|
||||
|
@ -1646,7 +1646,7 @@ void rglVertexAttrib4fv(GLuint name, GLfloat* v)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
GLuint rglCreateShader(GLenum shaderType)
|
||||
{
|
||||
|
@ -1660,7 +1660,7 @@ GLuint rglCreateShader(GLenum shaderType)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglDeleteProgram(GLuint program)
|
||||
{
|
||||
|
@ -1674,7 +1674,7 @@ void rglDeleteProgram(GLuint program)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglDeleteShader(GLuint shader)
|
||||
{
|
||||
|
@ -1688,7 +1688,7 @@ void rglDeleteShader(GLuint shader)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
GLint rglGetUniformLocation(GLuint program, const GLchar *name)
|
||||
{
|
||||
|
@ -1702,7 +1702,7 @@ GLint rglGetUniformLocation(GLuint program, const GLchar *name)
|
|||
* Category: VBO and PBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.5
|
||||
* OpenGL : 1.5
|
||||
*/
|
||||
void rglDeleteBuffers(GLsizei n, const GLuint *buffers)
|
||||
{
|
||||
|
@ -1716,7 +1716,7 @@ void rglDeleteBuffers(GLsizei n, const GLuint *buffers)
|
|||
* Category: VBO and PBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.5
|
||||
* OpenGL : 1.5
|
||||
*/
|
||||
void rglGenBuffers(GLsizei n, GLuint *buffers)
|
||||
{
|
||||
|
@ -1730,7 +1730,7 @@ void rglGenBuffers(GLsizei n, GLuint *buffers)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform1f(GLint location, GLfloat v0)
|
||||
{
|
||||
|
@ -1744,7 +1744,7 @@ void rglUniform1f(GLint location, GLfloat v0)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform1fv(GLint location, GLsizei count, const GLfloat *value)
|
||||
{
|
||||
|
@ -1758,7 +1758,7 @@ void rglUniform1fv(GLint location, GLsizei count, const GLfloat *value)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform1iv(GLint location, GLsizei count, const GLint *value)
|
||||
{
|
||||
|
@ -1793,7 +1793,7 @@ void rglTexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
const GLubyte* rglGetStringi(GLenum name, GLuint index)
|
||||
|
@ -1824,7 +1824,7 @@ void rglClearBufferfi( GLenum buffer,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglRenderbufferStorageMultisample( GLenum target,
|
||||
|
@ -1845,7 +1845,7 @@ void rglRenderbufferStorageMultisample( GLenum target,
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform1i(GLint location, GLint v0)
|
||||
{
|
||||
|
@ -1859,7 +1859,7 @@ void rglUniform1i(GLint location, GLint v0)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform2f(GLint location, GLfloat v0, GLfloat v1)
|
||||
{
|
||||
|
@ -1873,7 +1873,7 @@ void rglUniform2f(GLint location, GLfloat v0, GLfloat v1)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform2i(GLint location, GLint v0, GLint v1)
|
||||
{
|
||||
|
@ -1887,7 +1887,7 @@ void rglUniform2i(GLint location, GLint v0, GLint v1)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value)
|
||||
{
|
||||
|
@ -1901,7 +1901,7 @@ void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
|
||||
{
|
||||
|
@ -1915,7 +1915,7 @@ void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform3fv(GLint location, GLsizei count, const GLfloat *value)
|
||||
{
|
||||
|
@ -1943,7 +1943,7 @@ void rglUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
|
||||
{
|
||||
|
@ -1957,7 +1957,7 @@ void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3
|
|||
* Category: Shaders
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value)
|
||||
{
|
||||
|
@ -1970,7 +1970,7 @@ void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.0
|
||||
* OpenGL : 1.0
|
||||
*/
|
||||
void rglPolygonOffset(GLfloat factor, GLfloat units)
|
||||
{
|
||||
|
@ -1988,7 +1988,7 @@ void rglPolygonOffset(GLfloat factor, GLfloat units)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
*/
|
||||
void rglGenFramebuffers(GLsizei n, GLuint *ids)
|
||||
{
|
||||
|
@ -2002,7 +2002,7 @@ void rglGenFramebuffers(GLsizei n, GLuint *ids)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
*/
|
||||
void rglBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
|
@ -2018,7 +2018,7 @@ void rglBindFramebuffer(GLenum target, GLuint framebuffer)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglDrawBuffers(GLsizei n, const GLenum *bufs)
|
||||
|
@ -2035,7 +2035,7 @@ void rglDrawBuffers(GLsizei n, const GLenum *bufs)
|
|||
* Category: FBO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void *rglMapBufferRange( GLenum target,
|
||||
|
@ -2104,7 +2104,7 @@ void rglDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsiz
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 4.2
|
||||
* OpenGL : 4.2
|
||||
* OpenGLES : 3.1
|
||||
*/
|
||||
void rglMemoryBarrier( GLbitfield barriers)
|
||||
|
@ -2122,7 +2122,7 @@ void rglMemoryBarrier( GLbitfield barriers)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 4.2
|
||||
* OpenGL : 4.2
|
||||
* OpenGLES : 3.1
|
||||
*/
|
||||
void rglBindImageTexture( GLuint unit,
|
||||
|
@ -2223,7 +2223,7 @@ void rglTexImage3D( GLenum target,
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.5
|
||||
* OpenGL : 1.5
|
||||
*/
|
||||
void * rglMapBuffer( GLenum target, GLenum access)
|
||||
{
|
||||
|
@ -2240,7 +2240,7 @@ void * rglMapBuffer( GLenum target, GLenum access)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 1.5
|
||||
* OpenGL : 1.5
|
||||
*/
|
||||
GLboolean rglUnmapBuffer( GLenum target)
|
||||
{
|
||||
|
@ -2274,7 +2274,7 @@ void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
|
|||
* Category: Blending
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
*/
|
||||
void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
|
||||
{
|
||||
|
@ -2287,7 +2287,7 @@ void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
|
|||
/*
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 2.0
|
||||
* OpenGL : 2.0
|
||||
* OpenGLES : 3.2
|
||||
*/
|
||||
void rglCopyImageSubData( GLuint srcName,
|
||||
|
@ -2332,7 +2332,7 @@ void rglCopyImageSubData( GLuint srcName,
|
|||
* Category: VAO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglBindVertexArray(GLuint array)
|
||||
|
@ -2349,7 +2349,7 @@ void rglBindVertexArray(GLuint array)
|
|||
* Category: VAO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglGenVertexArrays(GLsizei n, GLuint *arrays)
|
||||
|
@ -2366,7 +2366,7 @@ void rglGenVertexArrays(GLsizei n, GLuint *arrays)
|
|||
* Category: VAO
|
||||
*
|
||||
* Core in:
|
||||
* OpenGL : 3.0
|
||||
* OpenGL : 3.0
|
||||
* OpenGLES : 3.0
|
||||
*/
|
||||
void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays)
|
||||
|
@ -2593,7 +2593,7 @@ static void glsm_state_setup(void)
|
|||
default_framebuffer = glsm_get_current_framebuffer();
|
||||
gl_state.framebuf = default_framebuffer;
|
||||
gl_state.cullface.mode = GL_BACK;
|
||||
gl_state.frontface.mode = GL_CCW;
|
||||
gl_state.frontface.mode = GL_CCW;
|
||||
|
||||
gl_state.blendfunc_separate.used = false;
|
||||
gl_state.blendfunc_separate.srcRGB = GL_ONE;
|
||||
|
@ -2602,7 +2602,7 @@ static void glsm_state_setup(void)
|
|||
gl_state.blendfunc_separate.dstAlpha = GL_ZERO;
|
||||
|
||||
gl_state.depthfunc.used = false;
|
||||
|
||||
|
||||
gl_state.colormask.used = false;
|
||||
gl_state.colormask.red = GL_TRUE;
|
||||
gl_state.colormask.green = GL_TRUE;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"""
|
||||
License statement applies to this file (glgen.py) only.
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
Permission is hereby granted, free of charge,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"""
|
||||
License statement applies to this file (glgen.py) only.
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
Permission is hereby granted, free of charge,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"""
|
||||
License statement applies to this file (xglgen.py) only.
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
Permission is hereby granted, free of charge,
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
* You can #define your own allocators, assertion and the amount of runtime
|
||||
* checking of indexes, see CONFIGURATION section in the code for more information.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This is heavily inspired by Sean Barrett's stretchy_buffer.h
|
||||
* ( see: https://github.com/nothings/stb/blob/master/stretchy_buffer.h )
|
||||
* However I wanted to have a struct that holds the array pointer and the length
|
||||
|
@ -52,7 +52,7 @@
|
|||
* Microsoft Visual Studio 6 and 2010 (32bit) and 2013 (32bit and 64bit).
|
||||
* I guess it works with all (recentish) C++ compilers and C compilers supporting
|
||||
* C99 or even C89 + C++ comments (otherwise converting the comments should help).
|
||||
*
|
||||
*
|
||||
* (C) 2016 Daniel Gibson
|
||||
*
|
||||
* LICENSE
|
||||
|
@ -69,9 +69,9 @@
|
|||
#if 0 /* Usage Example: */
|
||||
#define DG_DYNARR_IMPLEMENTATION /* this define is only needed in *one* .c/.cpp file! */
|
||||
#include "DG_dynarr.h"
|
||||
|
||||
|
||||
DA_TYPEDEF(int, MyIntArrType); /* creates MyIntArrType - a dynamic array for ints */
|
||||
|
||||
|
||||
void printIntArr(MyIntArrType* arr, const char* name)
|
||||
{
|
||||
/* note that arr is a pointer here, so use *arr in the da_*() functions. */
|
||||
|
@ -121,7 +121,7 @@
|
|||
int x=da_pop(a1);
|
||||
printf("x = %d\n", x); /* "x = 3" */
|
||||
printIntArr(&a1, "a1"); /* "a1 = { 42, 5, 6, 7 }" */
|
||||
|
||||
|
||||
da_free(a1); /* make sure not to leak memory! */
|
||||
da_free(a2);
|
||||
}
|
||||
|
@ -269,12 +269,12 @@
|
|||
|
||||
/* insert n elements into a at idx, initialize them from array vals
|
||||
* doesn't return anything
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
*/
|
||||
#define da_insertn(a, idx, vals, n) \
|
||||
dg_dynarr_insertn(a, idx, vals, n)
|
||||
|
||||
/* insert n elements into a at idx and zeroe them with memset()
|
||||
/* insert n elements into a at idx and zeroe them with memset()
|
||||
* returns pointer to first inserted element or NULL if out of memory
|
||||
*/
|
||||
#define da_insertn_zeroed(a, idx, n) \
|
||||
|
@ -292,7 +292,7 @@
|
|||
|
||||
/* overwrite n elements of a, starting at idx, with values from array vals
|
||||
* doesn't return anything
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
*/
|
||||
#define da_setn(a, idx, vals, n) \
|
||||
dg_dynarr_setn(a, idx, vals, n)
|
||||
|
@ -477,7 +477,7 @@
|
|||
|
||||
/* insert n elements into a at idx, initialize them from array vals
|
||||
* doesn't return anything
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
*/
|
||||
#define dg_dynarr_insertn(a, idx, vals, n) do { \
|
||||
DG_DYNARR_ASSERT((vals)!=NULL, "Don't pass NULL as vals to dg_dynarr_insertn!"); \
|
||||
|
@ -487,7 +487,7 @@
|
|||
while(i_ < e_) (a).p[i_++] = (vals)[v_++]; \
|
||||
}} DG__DYNARR_WHILE0
|
||||
|
||||
/* insert n elements into a at idx and zeroe them with memset()
|
||||
/* insert n elements into a at idx and zeroe them with memset()
|
||||
* returns pointer to first inserted element or NULL if out of memory
|
||||
*/
|
||||
#define dg_dynarr_insertn_zeroed(a, idx, n) \
|
||||
|
@ -510,7 +510,7 @@
|
|||
|
||||
/* overwrite n elements of a, starting at idx, with values from array vals
|
||||
* doesn't return anything
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
* ! vals (and all other args) is evaluated multiple times !
|
||||
*/
|
||||
#define dg_dynarr_setn(a, idx, vals, n) do { \
|
||||
DG_DYNARR_ASSERT((vals)!=NULL, "Don't pass NULL as vals to dg_dynarr_setn!"); \
|
||||
|
@ -690,7 +690,7 @@ static const size_t DG__DYNARR_SIZE_T_ALL_BUT_MSB = (((size_t)1) << (sizeof(size
|
|||
(void**)&(a).p, &(a).md, sizeof((a).p[0])
|
||||
|
||||
/* MSVC warns about "conditional expression is constant" when using the
|
||||
* do { ... } while(0) idiom in macros..
|
||||
* do { ... } while(0) idiom in macros..
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1400 // MSVC 2005 and newer
|
||||
|
@ -891,7 +891,7 @@ dg__dynarr_deletefast(void** arr, dg__dynarr_md* md, size_t itemsize, size_t idx
|
|||
/* by default, C's malloc(), realloc() and free() is used to allocate/free heap memory.
|
||||
* you can #define DG_DYNARR_MALLOC, DG_DYNARR_REALLOC and DG_DYNARR_FREE
|
||||
* to provide alternative implementations like Win32 Heap(Re)Alloc/HeapFree
|
||||
*/
|
||||
*/
|
||||
#ifndef DG_DYNARR_MALLOC
|
||||
#define DG_DYNARR_MALLOC(elemSize, numElems) malloc(elemSize*numElems)
|
||||
|
||||
|
@ -963,9 +963,9 @@ dg__dynarr_grow(void** arr, dg__dynarr_md* md, size_t itemsize, size_t min_neede
|
|||
{
|
||||
md->cap = 0;
|
||||
md->cnt = 0;
|
||||
|
||||
|
||||
DG_DYNARR_OUT_OF_MEMORY ;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -189,7 +189,6 @@ void config_file_dump(config_file_t *conf, FILE *file, bool val);
|
|||
void config_file_dump_orbis(config_file_t *conf, int fd);
|
||||
#endif
|
||||
|
||||
|
||||
bool config_file_exists(const char *path);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
|
|
@ -108,7 +108,7 @@ const char *path_get_extension(const char *path);
|
|||
* text after and including the last '.'.
|
||||
* Only '.'s after the last slash are considered.
|
||||
*
|
||||
* Returns:
|
||||
* Returns:
|
||||
* 1) If path has an extension, returns path with the
|
||||
* extension removed.
|
||||
* 2) If there is no extension, returns NULL.
|
||||
|
|
|
@ -150,7 +150,7 @@ RETRO_BEGIN_DECLS
|
|||
#define glUniformBlockBinding rglUniformBlockBinding
|
||||
#define glGetUniformBlockIndex rglGetUniformBlockIndex
|
||||
#define glGetActiveUniformBlockiv rglGetActiveUniformBlockiv
|
||||
#define glBindBufferBase rglBindBufferBase
|
||||
#define glBindBufferBase rglBindBufferBase
|
||||
#define glGetUniformIndices rglGetUniformIndices
|
||||
#define glGetActiveUniformsiv rglGetActiveUniformsiv
|
||||
#define glGetError rglGetError
|
||||
|
|
|
@ -875,12 +875,12 @@ enum retro_mod
|
|||
* types already defined in the libretro API.
|
||||
*
|
||||
* The core must pass an array of const struct retro_controller_info which
|
||||
* is terminated with a blanked out struct. Each element of the
|
||||
* is terminated with a blanked out struct. Each element of the
|
||||
* retro_controller_info struct corresponds to the ascending port index
|
||||
* that is passed to retro_set_controller_port_device() when that function
|
||||
* is called to indicate to the core that the frontend has changed the
|
||||
* active device subclass. SEE ALSO: retro_set_controller_port_device()
|
||||
*
|
||||
*
|
||||
* The ascending input port indexes provided by the core in the struct
|
||||
* are generally presented by frontends as ascending User # or Player #,
|
||||
* such as Player 1, Player 2, Player 3, etc. Which device subclasses are
|
||||
|
@ -892,7 +892,7 @@ enum retro_mod
|
|||
* User or Player, beginning with the generic Libretro device that the
|
||||
* subclasses are derived from. The second inner element of each entry is the
|
||||
* total number of subclasses that are listed in the retro_controller_description.
|
||||
*
|
||||
*
|
||||
* NOTE: Even if special device types are set in the libretro core,
|
||||
* libretro should only poll input based on the base input device types.
|
||||
*/
|
||||
|
|
|
@ -91,6 +91,12 @@ bool file_list_prepend(file_list_t *list,
|
|||
unsigned type, size_t directory_ptr,
|
||||
size_t entry_idx);
|
||||
|
||||
bool file_list_insert(file_list_t *list,
|
||||
const char *path, const char *label,
|
||||
unsigned type, size_t directory_ptr,
|
||||
size_t entry_idx,
|
||||
size_t idx);
|
||||
|
||||
void file_list_pop(file_list_t *list, size_t *directory_ptr);
|
||||
|
||||
void file_list_clear(file_list_t *list);
|
||||
|
|
|
@ -29,6 +29,19 @@
|
|||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum message_queue_icon
|
||||
{
|
||||
MESSAGE_QUEUE_ICON_DEFAULT = 0 /* default icon is tied to category */
|
||||
};
|
||||
|
||||
enum message_queue_category
|
||||
{
|
||||
MESSAGE_QUEUE_CATEGORY_INFO = 0,
|
||||
MESSAGE_QUEUE_CATEGORY_ERROR,
|
||||
MESSAGE_QUEUE_CATEGORY_WARNING,
|
||||
MESSAGE_QUEUE_CATEGORY_SUCCESS
|
||||
};
|
||||
|
||||
typedef struct msg_queue msg_queue_t;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +67,9 @@ msg_queue_t *msg_queue_new(size_t size);
|
|||
* Push a new message onto the queue.
|
||||
**/
|
||||
void msg_queue_push(msg_queue_t *queue, const char *msg,
|
||||
unsigned prio, unsigned duration);
|
||||
unsigned prio, unsigned duration,
|
||||
char *title,
|
||||
enum message_queue_icon icon, enum message_queue_category category);
|
||||
|
||||
/**
|
||||
* msg_queue_pull:
|
||||
|
|
|
@ -43,15 +43,16 @@ enum task_type
|
|||
};
|
||||
|
||||
typedef struct retro_task retro_task_t;
|
||||
typedef void (*retro_task_callback_t)(void *task_data,
|
||||
void *user_data, const char *error);
|
||||
typedef void (*retro_task_callback_t)(retro_task_t *task,
|
||||
void *task_data, void *user_data,
|
||||
const char *error);
|
||||
|
||||
typedef void (*retro_task_handler_t)(retro_task_t *task);
|
||||
|
||||
typedef bool (*retro_task_finder_t)(retro_task_t *task,
|
||||
void *userdata);
|
||||
|
||||
typedef void (*retro_task_queue_msg_t)(const char *msg,
|
||||
typedef void (*retro_task_queue_msg_t)(retro_task_t *task, const char *msg,
|
||||
unsigned prio, unsigned duration, bool flush);
|
||||
|
||||
typedef bool (*retro_task_retriever_t)(retro_task_t *task, void *data);
|
||||
|
@ -109,6 +110,13 @@ struct retro_task
|
|||
|
||||
enum task_type type;
|
||||
|
||||
/* task identifier */
|
||||
uint32_t ident;
|
||||
|
||||
/* frontend userdata
|
||||
* (e.g. associate a sticky notification to a task) */
|
||||
void *frontend_userdata;
|
||||
|
||||
/* don't touch this. */
|
||||
retro_task_t *next;
|
||||
};
|
||||
|
@ -231,6 +239,9 @@ void task_queue_deinit(void);
|
|||
* This must only be called from the main thread. */
|
||||
void task_queue_init(bool threaded, retro_task_queue_msg_t msg_push);
|
||||
|
||||
/* Allocs and inits a new retro_task_t */
|
||||
retro_task_t *task_init(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -85,12 +85,25 @@ bool file_list_prepend(file_list_t *list,
|
|||
unsigned type, size_t directory_ptr,
|
||||
size_t entry_idx)
|
||||
{
|
||||
unsigned i;
|
||||
return file_list_insert(list, path,
|
||||
label, type,
|
||||
directory_ptr, entry_idx,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
bool file_list_insert(file_list_t *list,
|
||||
const char *path, const char *label,
|
||||
unsigned type, size_t directory_ptr,
|
||||
size_t entry_idx,
|
||||
size_t idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!file_list_expand_if_needed(list))
|
||||
return false;
|
||||
|
||||
for (i = (unsigned)list->size; i > 0; i--)
|
||||
for (i = (unsigned)list->size; i > (int)idx; i--)
|
||||
{
|
||||
struct item_file *copy = (struct item_file*)
|
||||
calloc(1, sizeof(struct item_file));
|
||||
|
@ -103,7 +116,7 @@ bool file_list_prepend(file_list_t *list,
|
|||
free(copy);
|
||||
}
|
||||
|
||||
file_list_add(list, 0, path, label, type,
|
||||
file_list_add(list, idx, path, label, type,
|
||||
directory_ptr, entry_idx);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -368,7 +368,7 @@ void network_deinit(void)
|
|||
net_deinit();
|
||||
#elif defined(_3DS)
|
||||
socExit();
|
||||
|
||||
|
||||
if(_net_compat_net_memory)
|
||||
{
|
||||
free(_net_compat_net_memory);
|
||||
|
|
|
@ -121,7 +121,7 @@ bool net_ifinfo_new(net_ifinfo_t *list)
|
|||
/*
|
||||
actual interface
|
||||
can be wlan or eth (with a wiiu adapter)
|
||||
so we just use "switch" as a name
|
||||
so we just use "switch" as a name
|
||||
*/
|
||||
rc = nifmGetCurrentIpAddress(&id);
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ bool natt_open_port_any(struct natt_status *status,
|
|||
struct net_ifinfo_entry *entry = list.entries + i;
|
||||
|
||||
/* ignore localhost */
|
||||
if ( string_is_equal(entry->host, "127.0.0.1") ||
|
||||
if ( string_is_equal(entry->host, "127.0.0.1") ||
|
||||
string_is_equal(entry->host, "::1"))
|
||||
continue;
|
||||
|
||||
|
@ -233,7 +233,7 @@ bool natt_read(struct natt_status *status)
|
|||
}
|
||||
|
||||
#if 0
|
||||
/* If we want to remove redirects in the future, this is a
|
||||
/* If we want to remove redirects in the future, this is a
|
||||
* sample of how to do that. */
|
||||
|
||||
void upnp_rem_redir (int port)
|
||||
|
|
|
@ -33,6 +33,10 @@ struct queue_elem
|
|||
unsigned duration;
|
||||
unsigned prio;
|
||||
char *msg;
|
||||
|
||||
char *title;
|
||||
enum message_queue_icon icon;
|
||||
enum message_queue_category category;
|
||||
};
|
||||
|
||||
struct msg_queue
|
||||
|
@ -105,7 +109,9 @@ void msg_queue_free(msg_queue_t *queue)
|
|||
* Push a new message onto the queue.
|
||||
**/
|
||||
void msg_queue_push(msg_queue_t *queue, const char *msg,
|
||||
unsigned prio, unsigned duration)
|
||||
unsigned prio, unsigned duration,
|
||||
char *title,
|
||||
enum message_queue_icon icon, enum message_queue_category category)
|
||||
{
|
||||
size_t tmp_ptr = 0;
|
||||
struct queue_elem *new_elem = NULL;
|
||||
|
|
|
@ -62,6 +62,8 @@ static task_queue_t tasks_finished = {NULL, NULL};
|
|||
static struct retro_task_impl *impl_current = NULL;
|
||||
static bool task_threaded_enable = false;
|
||||
|
||||
static uint32_t task_count = 0;
|
||||
|
||||
static void task_queue_msg_push(retro_task_t *task,
|
||||
unsigned prio, unsigned duration,
|
||||
bool flush, const char *fmt, ...)
|
||||
|
@ -76,7 +78,7 @@ static void task_queue_msg_push(retro_task_t *task,
|
|||
va_end(ap);
|
||||
|
||||
if (impl_current->msg_push)
|
||||
impl_current->msg_push(buf, prio, duration, flush);
|
||||
impl_current->msg_push(task, buf, prio, duration, flush);
|
||||
}
|
||||
|
||||
static void task_queue_push_progress(retro_task_t *task)
|
||||
|
@ -138,7 +140,7 @@ static void retro_task_internal_gather(void)
|
|||
task_queue_push_progress(task);
|
||||
|
||||
if (task->callback)
|
||||
task->callback(task->task_data, task->user_data, task->error);
|
||||
task->callback(task, task->task_data, task->user_data, task->error);
|
||||
|
||||
if (task->cleanup)
|
||||
task->cleanup(task);
|
||||
|
@ -820,3 +822,18 @@ char* task_get_title(retro_task_t *task)
|
|||
|
||||
return title;
|
||||
}
|
||||
|
||||
static uint32_t task_get_next_ident()
|
||||
{
|
||||
return task_count++;
|
||||
}
|
||||
|
||||
retro_task_t *task_init()
|
||||
{
|
||||
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
||||
|
||||
task->ident = task_get_next_ident();
|
||||
task->frontend_userdata = NULL;
|
||||
|
||||
return task;
|
||||
}
|
|
@ -56,27 +56,27 @@ static INLINE int pthread_create(pthread_t *thread,
|
|||
{
|
||||
s32 prio = 0;
|
||||
Thread new_ctr_thread;
|
||||
|
||||
|
||||
if (!mutex_inited)
|
||||
{
|
||||
LightLock_Init(&safe_double_thread_launch);
|
||||
mutex_inited = true;
|
||||
}
|
||||
|
||||
|
||||
/*Must wait if attempting to launch 2 threads at once to prevent corruption of function pointer*/
|
||||
while (LightLock_TryLock(&safe_double_thread_launch) != 0);
|
||||
|
||||
|
||||
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
|
||||
|
||||
|
||||
start_routine_jump = start_routine;
|
||||
new_ctr_thread = threadCreate(ctr_thread_launcher, arg, STACKSIZE, prio - 1, -1/*No affinity, use any CPU*/, false);
|
||||
|
||||
|
||||
if (!new_ctr_thread)
|
||||
{
|
||||
LightLock_Unlock(&safe_double_thread_launch);
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
|
||||
*thread = new_ctr_thread;
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,14 +150,14 @@ static INLINE int pthread_cond_timedwait(pthread_cond_t *cond,
|
|||
struct timespec now = {0};
|
||||
/* Missing clock_gettime*/
|
||||
struct timeval tm;
|
||||
|
||||
|
||||
gettimeofday(&tm, NULL);
|
||||
now.tv_sec = tm.tv_sec;
|
||||
now.tv_nsec = tm.tv_usec * 1000;
|
||||
if (LightEvent_TryWait(cond) != 0 || now.tv_sec > abstime->tv_sec || (now.tv_sec == abstime->tv_sec && now.tv_nsec > abstime->tv_nsec))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ NET_IFINFO_C = \
|
|||
net_ifinfo_test.c
|
||||
|
||||
ifeq ($(platform), win)
|
||||
CFLAGS += -liphlpapi -lws2_32
|
||||
CFLAGS += -liphlpapi -lws2_32
|
||||
endif
|
||||
|
||||
NET_IFINFO_OBJS := $(NET_IFINFO_C:.c=.o)
|
||||
|
|
|
@ -59,7 +59,7 @@ CC := $(compiler)
|
|||
CXX := $(subst CC,++,$(compiler))
|
||||
flags := -I$(LIBRETRO_COMM_DIR)/include
|
||||
asflags := $(extra_flags)
|
||||
LDFLAGS :=
|
||||
LDFLAGS :=
|
||||
flags += -std=c99 -DMD5_BUILD_UTILITY -DSHA1_BUILD_UTILITY
|
||||
|
||||
ifeq (1,$(use_neon))
|
||||
|
|
|
@ -215,37 +215,37 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
char buf[4096];
|
||||
char subfmt[64];
|
||||
va_list args;
|
||||
|
||||
|
||||
const char * bufiter = buf;
|
||||
int64_t startpos = filestream_tell(stream);
|
||||
int ret = 0;
|
||||
int64_t maxlen = filestream_read(stream, buf, sizeof(buf)-1);
|
||||
|
||||
buf[maxlen] = '\0';
|
||||
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
|
||||
while (*format)
|
||||
{
|
||||
if (*format == '%')
|
||||
{
|
||||
int sublen;
|
||||
|
||||
|
||||
char* subfmtiter = subfmt;
|
||||
bool asterisk = false;
|
||||
|
||||
|
||||
*subfmtiter++ = *format++; /* '%' */
|
||||
|
||||
|
||||
/* %[*][width][length]specifier */
|
||||
|
||||
|
||||
if (*format == '*')
|
||||
{
|
||||
asterisk = true;
|
||||
*subfmtiter++ = *format++;
|
||||
}
|
||||
|
||||
|
||||
while (isdigit(*format)) *subfmtiter++ = *format++; /* width */
|
||||
|
||||
|
||||
/* length */
|
||||
if (*format == 'h' || *format == 'l')
|
||||
{
|
||||
|
@ -256,7 +256,7 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
{
|
||||
*subfmtiter++ = *format++;
|
||||
}
|
||||
|
||||
|
||||
/* specifier - always a single character (except ]) */
|
||||
if (*format == '[')
|
||||
{
|
||||
|
@ -264,11 +264,11 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
*subfmtiter++ = *format++;
|
||||
}
|
||||
else *subfmtiter++ = *format++;
|
||||
|
||||
|
||||
*subfmtiter++ = '%';
|
||||
*subfmtiter++ = 'n';
|
||||
*subfmtiter++ = '\0';
|
||||
|
||||
|
||||
if (sizeof(void*) != sizeof(long*)) abort(); /* all pointers must have the same size */
|
||||
if (asterisk)
|
||||
{
|
||||
|
@ -278,7 +278,7 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
{
|
||||
if (sscanf(bufiter, subfmt, va_arg(args, void*), &sublen) != 1) break;
|
||||
}
|
||||
|
||||
|
||||
ret++;
|
||||
bufiter += sublen;
|
||||
}
|
||||
|
@ -295,10 +295,10 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
format++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
va_end(args);
|
||||
filestream_seek(stream, startpos+(bufiter-buf), RETRO_VFS_SEEK_POSITION_START);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ RFILE* rfopen(const char *path, const char *mode)
|
|||
retro_mode = RETRO_VFS_FILE_ACCESS_READ;
|
||||
if (strstr(mode, "+"))
|
||||
{
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE |
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE |
|
||||
RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING;
|
||||
}
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ RFILE* rfopen(const char *path, const char *mode)
|
|||
}
|
||||
else if (strstr(mode, "a"))
|
||||
{
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_WRITE |
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_WRITE |
|
||||
RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING;
|
||||
position_to_end = true;
|
||||
if (strstr(mode, "+"))
|
||||
{
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE |
|
||||
retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE |
|
||||
RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,10 +238,10 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
|
|||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function is
|
||||
* called in filestream_open() */
|
||||
if (stream->mapped && stream->hints &
|
||||
if (stream->mapped && stream->hints &
|
||||
RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS)
|
||||
{
|
||||
/* fseek() returns error on under/overflow but
|
||||
/* fseek() returns error on under/overflow but
|
||||
* allows cursor > EOF for
|
||||
read-only file descriptors. */
|
||||
switch (whence)
|
||||
|
@ -377,7 +377,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
|||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
|
|||
{
|
||||
#ifdef ORBIS
|
||||
int64_t ret = orbisLseek(stream->fd, 0, SEEK_CUR);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_tell_impl orbisLseek fd=%d path=%s ret=%d\n", stream->fd, stream->orig_path, ret);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_tell_impl orbisLseek fd=%d path=%s ret=%d\n", stream->fd, stream->orig_path, ret);
|
||||
if(ret < 0)
|
||||
return -1;
|
||||
return ret;
|
||||
|
@ -675,7 +675,7 @@ int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream)
|
|||
return -1;
|
||||
#ifdef ORBIS
|
||||
return 0;
|
||||
#else
|
||||
#else
|
||||
return fflush(stream->fp)==0 ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
@ -801,7 +801,6 @@ const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *strea
|
|||
return stream->orig_path;
|
||||
}
|
||||
|
||||
|
||||
int retro_vfs_stat_impl(const char *path, int32_t *size)
|
||||
{
|
||||
bool is_dir, is_character_special;
|
||||
|
@ -978,7 +977,7 @@ struct libretro_vfs_implementation_dir
|
|||
CellFsDirent entry;
|
||||
#elif defined(ORBIS)
|
||||
int directory;
|
||||
struct dirent entry;
|
||||
struct dirent entry;
|
||||
#else
|
||||
DIR *directory;
|
||||
const struct dirent *entry;
|
||||
|
|
|
@ -106,7 +106,6 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void windowsize_path(wchar_t* path)
|
||||
{
|
||||
/* UWP deals with paths containing / instead of \ way worse than normal Windows */
|
||||
|
|
Loading…
Reference in a new issue