Commit 2a94b3ae authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 6ab1ac11
......@@ -414,7 +414,7 @@ else ifeq ($(platform), emscripten)
#HAVE_SHARED_CONTEXT := 1
# Windows
else ifneq (,$(findstring win,$(platform)))
else
EXT ?= dll
TARGET := $(TARGET_NAME)_libretro.$(EXT)
SHARED := -shared -shared -static-libgcc -static-libstdc++ -Wl,--version-script=link.T
......
......@@ -19,25 +19,24 @@ unsigned long temp_value;
unsigned long ask_type(FILE *fsource, long header_position)
{
unsigned char filename_length;
unsigned long track_mode;
fseek(fsource, header_position, SEEK_SET);
fread(&temp_value, 4, 1, fsource);
if (temp_value != 0)
fseek(fsource, 8, SEEK_CUR); // extra data (DJ 3.00.780 and up)
fseek(fsource, 24, SEEK_CUR);
fread(&filename_length, 1, 1, fsource);
fseek(fsource, filename_length, SEEK_CUR);
fseek(fsource, 19, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0x80000000)
fseek(fsource, 8, SEEK_CUR); // DJ4
fseek(fsource, 16, SEEK_CUR);
fread(&track_mode, 4, 1, fsource);
fseek(fsource, header_position, SEEK_SET);
return (track_mode);
unsigned char filename_length;
unsigned long track_mode;
fseek(fsource, header_position, SEEK_SET);
fread(&temp_value, 4, 1, fsource);
if (temp_value != 0)
fseek(fsource, 8, SEEK_CUR); // extra data (DJ 3.00.780 and up)
fseek(fsource, 24, SEEK_CUR);
fread(&filename_length, 1, 1, fsource);
fseek(fsource, filename_length, SEEK_CUR);
fseek(fsource, 19, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0x80000000)
fseek(fsource, 8, SEEK_CUR); // DJ4
fseek(fsource, 16, SEEK_CUR);
fread(&track_mode, 4, 1, fsource);
fseek(fsource, header_position, SEEK_SET);
return (track_mode);
}
......@@ -46,98 +45,97 @@ unsigned long track_mode;
void CDI_read_track (FILE *fsource, image_s *image, track_s *track)
{
unsigned char TRACK_START_MARK[10] = { 0, 0, 0x01, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF };
unsigned char current_start_mark[10];
fread(&temp_value, 4, 1, fsource);
if (temp_value != 0)
fseek(fsource, 8, SEEK_CUR); // extra data (DJ 3.00.780 and up)
fread(&current_start_mark, 10, 1, fsource);
if (memcmp(TRACK_START_MARK, current_start_mark, 10)) printf( "Unsupported format: Could not find the track start mark");
fread(&current_start_mark, 10, 1, fsource);
if (memcmp(TRACK_START_MARK, current_start_mark, 10)) printf( "Unsupported format: Could not find the track start mark");
fseek(fsource, 4, SEEK_CUR);
fread(&track->filename_length, 1, 1, fsource);
fseek(fsource, track->filename_length, SEEK_CUR);
fseek(fsource, 11, SEEK_CUR);
fseek(fsource, 4, SEEK_CUR);
fseek(fsource, 4, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0x80000000)
fseek(fsource, 8, SEEK_CUR); // DJ4
fseek(fsource, 2, SEEK_CUR);
fread(&track->pregap_length, 4, 1, fsource);
fread(&track->length, 4, 1, fsource);
fseek(fsource, 6, SEEK_CUR);
fread(&track->mode, 4, 1, fsource);
fseek(fsource, 12, SEEK_CUR);
fread(&track->start_lba, 4, 1, fsource);
fread(&track->total_length, 4, 1, fsource);
fseek(fsource, 16, SEEK_CUR);
fread(&track->sector_size_value, 4, 1, fsource);
switch(track->sector_size_value)
{
case 0 : track->sector_size = 2048; break;
case 1 : track->sector_size = 2336; break;
case 2 : track->sector_size = 2352; break;
default: printf("Unsupported sector size");
}
if (track->mode > 2) printf( "Unsupported format: Track mode not supported");
fseek(fsource, 29, SEEK_CUR);
if (image->version != CDI_V2)
{
fseek(fsource, 5, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0xffffffff)
fseek(fsource, 78, SEEK_CUR); // extra data (DJ 3.00.780 and up)
}
unsigned char TRACK_START_MARK[10] = { 0, 0, 0x01, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF };
unsigned char current_start_mark[10];
fread(&temp_value, 4, 1, fsource);
if (temp_value != 0)
fseek(fsource, 8, SEEK_CUR); // extra data (DJ 3.00.780 and up)
fread(&current_start_mark, 10, 1, fsource);
if (memcmp(TRACK_START_MARK, current_start_mark, 10)) printf( "Unsupported format: Could not find the track start mark");
fread(&current_start_mark, 10, 1, fsource);
if (memcmp(TRACK_START_MARK, current_start_mark, 10)) printf( "Unsupported format: Could not find the track start mark");
fseek(fsource, 4, SEEK_CUR);
fread(&track->filename_length, 1, 1, fsource);
fseek(fsource, track->filename_length, SEEK_CUR);
fseek(fsource, 11, SEEK_CUR);
fseek(fsource, 4, SEEK_CUR);
fseek(fsource, 4, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0x80000000)
fseek(fsource, 8, SEEK_CUR); // DJ4
fseek(fsource, 2, SEEK_CUR);
fread(&track->pregap_length, 4, 1, fsource);
fread(&track->length, 4, 1, fsource);
fseek(fsource, 6, SEEK_CUR);
fread(&track->mode, 4, 1, fsource);
fseek(fsource, 12, SEEK_CUR);
fread(&track->start_lba, 4, 1, fsource);
fread(&track->total_length, 4, 1, fsource);
fseek(fsource, 16, SEEK_CUR);
fread(&track->sector_size_value, 4, 1, fsource);
switch(track->sector_size_value)
{
case 0 : track->sector_size = 2048; break;
case 1 : track->sector_size = 2336; break;
case 2 : track->sector_size = 2352; break;
default: printf("Unsupported sector size");
}
if (track->mode > 2) printf( "Unsupported format: Track mode not supported");
fseek(fsource, 29, SEEK_CUR);
if (image->version != CDI_V2)
{
fseek(fsource, 5, SEEK_CUR);
fread(&temp_value, 4, 1, fsource);
if (temp_value == 0xffffffff)
fseek(fsource, 78, SEEK_CUR); // extra data (DJ 3.00.780 and up)
}
}
void CDI_skip_next_session (FILE *fsource, image_s *image)
{
fseek(fsource, 4, SEEK_CUR);
fseek(fsource, 8, SEEK_CUR);
if (image->version != CDI_V2) fseek(fsource, 1, SEEK_CUR);
fseek(fsource, 4, SEEK_CUR);
fseek(fsource, 8, SEEK_CUR);
if (image->version != CDI_V2)
fseek(fsource, 1, SEEK_CUR);
}
void CDI_get_tracks (FILE *fsource, image_s *image)
{
fread(&image->tracks, 2, 1, fsource);
fread(&image->tracks, 2, 1, fsource);
}
void CDI_init (FILE *fsource, image_s *image, char *fsourcename)
{
image->length = core_fsize(fsource);
image->length = core_fsize(fsource);
if (image->length < 8) printf( "Image file is too short");
if (image->length < 8) printf( "Image file is too short");
fseek(fsource, image->length-8, SEEK_SET);
fread(&image->version, 4, 1, fsource);
fread(&image->header_offset, 4, 1, fsource);
fseek(fsource, image->length-8, SEEK_SET);
fread(&image->version, 4, 1, fsource);
fread(&image->header_offset, 4, 1, fsource);
// if (errno != 0) printf( fsourcename);
if (image->header_offset == 0) printf( "Bad image format");
if (image->header_offset == 0) printf( "Bad image format");
}
void CDI_get_sessions (FILE *fsource, image_s *image)
{
#ifndef DEBUG_CDI
if (image->version == CDI_V35)
fseek(fsource, (image->length - image->header_offset), SEEK_SET);
else
fseek(fsource, image->header_offset, SEEK_SET);
if (image->version == CDI_V35)
fseek(fsource, (image->length - image->header_offset), SEEK_SET);
else
fseek(fsource, image->header_offset, SEEK_SET);
#else
fseek(fsource, 0L, SEEK_SET);
fseek(fsource, 0L, SEEK_SET);
#endif
fread(&image->sessions, 2, 1, fsource);
fread(&image->sessions, 2, 1, fsource);
}
......@@ -529,13 +529,13 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **
EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
/* find the codec interface */
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == newchd->header.compression)
{
newchd->codecintf = &codec_interfaces[intfnum];
break;
}
if (intfnum == ARRAY_LENGTH(codec_interfaces))
if (intfnum == ARRAY_SIZE(codec_interfaces))
EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
/* initialize the codec */
......@@ -968,10 +968,10 @@ static chd_error header_validate(const chd_header *header)
return CHDERR_INVALID_PARAMETER;
/* require a supported compression mechanism */
for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
for (intfnum = 0; intfnum < ARRAY_SIZE(codec_interfaces); intfnum++)
if (codec_interfaces[intfnum].compression == header->compression)
break;
if (intfnum == ARRAY_LENGTH(codec_interfaces))
if (intfnum == ARRAY_SIZE(codec_interfaces))
return CHDERR_INVALID_PARAMETER;
/* require a valid hunksize */
......
#include <retro_miscellaneous.h>
#include "types.h"
typedef u64 UINT64;
......@@ -14,5 +14,3 @@ typedef s8 INT8;
#ifndef INLINE
#define INLINE inline
#endif
#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment