Skip to content

Commit

Permalink
Updates (#1525)
Browse files Browse the repository at this point in the history
* convert cpp comments and add alexkidd1 fighter encrypted sets as working

* make the core c89 compatable like it should be
  • Loading branch information
MistyDreams authored Jan 17, 2023
1 parent ec4bb7b commit f34453a
Show file tree
Hide file tree
Showing 145 changed files with 3,417 additions and 3,409 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ endif
ifeq ($(platform), unix)
TARGET = $(TARGET_NAME)_libretro.so
fpic = -fPIC
CFLAGS += $(fpic)
CFLAGS += $(fpic) -std=c89
LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T

# Linux Portable
Expand Down
10 changes: 5 additions & 5 deletions src/artwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -2295,10 +2295,10 @@ static int artwork_load(const struct GameDriver *driver, int width, int height,
/* A negative values will use the default opacity for the overlay. */
opacity = options.overlay_opacity;
if (opacity != 0 && list) {
if (opacity < 0) { // Default overlay opacity
if (opacity < 0) { /* Default overlay opacity */
if (!generate_overlay(list, width, height))
return 0;
} else { // Opacity is > 0
} else { /* Opacity is > 0 */
struct overlay_piece *newlist;
/* Count elements in list */
int count = 0;
Expand All @@ -2312,8 +2312,8 @@ static int artwork_load(const struct GameDriver *driver, int width, int height,
/* Modify opacity as set to user defined value */
tmp = newlist;
while (tmp->type != OVERLAY_TYPE_END) {
tmp->color = tmp->color & ~(0xff << 24); // Clear
tmp->color = tmp->color | (((opacity) & 0xff) << 24); // Set
tmp->color = tmp->color & ~(0xff << 24); /* Clear */
tmp->color = tmp->color | (((opacity) & 0xff) << 24); /* Set */
tmp++;
}
if (!generate_overlay(newlist, width, height))
Expand Down Expand Up @@ -3367,7 +3367,7 @@ static int generate_overlay(const struct overlay_piece *list, int width, int hei
piece->layer = LAYER_OVERLAY;
piece->priority = priority++;
piece->blendflags = list->type & OVERLAY_FLAG_MASK;
piece->tag = list->tag; // Handle someone using a different tag, for example, cocktail mode
piece->tag = list->tag; /* Handle someone using a different tag, for example, cocktail mode */

/* switch off the type */
switch (list->type & ~OVERLAY_FLAG_MASK)
Expand Down
2 changes: 1 addition & 1 deletion src/artwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct artwork_callbacks

struct overlay_piece
{
char *tag; // Usually set to OVERLAY_TAG
char *tag; /* Usually set to OVERLAY_TAG */
UINT8 type;
rgb_t color;
float left, top, right, bottom;
Expand Down
62 changes: 31 additions & 31 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <string/stdstring.h>
#include "libretro-deps/libFLAC/include/FLAC/all.h"
#include "log.h"
//#define LOG_LOAD
/*#define LOG_LOAD */


char *chd_error_text[] =
Expand Down Expand Up @@ -45,9 +45,9 @@ char *chd_error_text[] =
Constants
***************************************************************************/

// VERY IMPORTANT: osd_alloc_bitmap must allocate also a "safety area" 16 pixels wide all
// around the bitmap. This is required because, for performance reasons, some graphic
// routines don't clip at boundaries of the bitmap.
/* VERY IMPORTANT: osd_alloc_bitmap must allocate also a "safety area" 16 pixels wide all */
/* around the bitmap. This is required because, for performance reasons, some graphic */
/* routines don't clip at boundaries of the bitmap. */
#define BITMAP_SAFETY 16

#define MAX_MALLOCS 4096
Expand Down Expand Up @@ -237,13 +237,13 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
return NULL;

if (memcmp(&buf[0], "RIFF", 4) == 0)
f_type = 1; // WAV
f_type = 1; /* WAV */
else if (memcmp(&buf[0], "fLaC", 4) == 0)
f_type = 2; // FLAC
f_type = 2; /* FLAC */
else
return NULL; // No idea what file this is.
return NULL; /* No idea what file this is. */

// Load WAV file.
/* Load WAV file. */
if(f_type == 1) {
/* get the total size */
offset += mame_fread(f, &filesize, 4);
Expand Down Expand Up @@ -316,7 +316,7 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
return NULL;
}

// For small samples, lets force them to pre load into memory.
/* For small samples, lets force them to pre load into memory. */
if(length <= GAME_SAMPLE_LARGE)
b_data = 1;

Expand All @@ -339,18 +339,18 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
result->resolution = bits;

if(b_data == 1) {
// read the data in
/* read the data in */
if (bits == 8)
{
mame_fread(f, result->data, length);

// convert 8-bit data to signed samples
/* convert 8-bit data to signed samples */
for (temp32 = 0; temp32 < length; temp32++)
result->data[temp32] ^= 0x80;
}
else
{
// 16-bit data is fine as-is
/* 16-bit data is fine as-is */
mame_fread_lsbfirst(f, result->data, length);
}

Expand All @@ -361,7 +361,7 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co

return result;
}
else if(f_type == 2) { // Load FLAC file.
else if(f_type == 2) { /* Load FLAC file. */
int f_length;
flac_reader flac_file;
FLAC__StreamDecoder *decoder;
Expand All @@ -370,18 +370,18 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
f_length = mame_ftell(f);
mame_fseek(f, 0, 0);

// For small samples, lets force them to pre load into memory.
/* For small samples, lets force them to pre load into memory. */
if (f_length <= GAME_SAMPLE_LARGE)
b_data = 1;

flac_file.length = f_length;
flac_file.position = 0;
flac_file.decoded_size = 0;

// Allocate space for the data.
/* Allocate space for the data. */
flac_file.rawdata = malloc(f_length);

// Read the sample data in.
/* Read the sample data in. */
mame_fread(f, flac_file.rawdata, f_length);
decoder = FLAC__stream_decoder_new();

Expand All @@ -391,12 +391,12 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
}

if(FLAC__stream_decoder_init_stream(decoder, my_read_callback,
NULL, //my_seek_callback, // or NULL
NULL, //my_tell_callback, // or NULL
NULL, //my_length_callback, // or NULL
NULL, //my_eof_callback, // or NULL
NULL, /*my_seek_callback, // or NULL */
NULL, /*my_tell_callback, // or NULL */
NULL, /*my_length_callback, // or NULL */
NULL, /*my_eof_callback, // or NULL */
my_write_callback,
my_metadata_callback, //my_metadata_callback, // or NULL
my_metadata_callback, /*my_metadata_callback, // or NULL */
my_error_callback,
(void*)&flac_file) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
return NULL;
Expand All @@ -407,14 +407,14 @@ static struct GameSample *read_wav_sample(mame_file *f, const char *gamename, co
return NULL;
}

// only Mono supported
/* only Mono supported */
if (flac_file.channels != 1) {
free(flac_file.rawdata);
FLAC__stream_decoder_delete(decoder);
return NULL;
}

// only support 16 bit.
/* only support 16 bit. */
if (flac_file.bits_per_sample != 16) {
free(flac_file.rawdata);
FLAC__stream_decoder_delete(decoder);
Expand Down Expand Up @@ -472,7 +472,7 @@ void readsample(struct GameSample *SampleInfo, int channel, struct GameSamples *
mame_file *f;
struct GameSample *SampleFile;

// Try opening the file.
/* Try opening the file. */
f = mame_fopen(SampleInfo->gamename,SampleInfo->filename,SampleInfo->filetype,0);

if (f != 0) {
Expand All @@ -483,10 +483,10 @@ void readsample(struct GameSample *SampleInfo, int channel, struct GameSamples *
strcpy(gamename, SampleInfo->gamename);
strcpy(filename, SampleInfo->filename);

// Free up some memory.
/* Free up some memory. */
free(SamplesData->sample[channel]);

// Reload or load a sample into memory.
/* Reload or load a sample into memory. */
SamplesData->sample[channel] = read_wav_sample(f, gamename, filename, filetype, load);

mame_fclose(f);
Expand Down Expand Up @@ -535,15 +535,15 @@ struct GameSamples *readsamples(const char **samplenames,const char *basename)

if (samplenames[i+skipfirst][0])
{
// Try opening FLAC samples first.
/* Try opening FLAC samples first. */
if ((f = mame_fopen(basename,samplenames[i+skipfirst],FILETYPE_SAMPLE_FLAC,0)) == 0)
{
if (skipfirst) {
f = mame_fopen(samplenames[0]+1,samplenames[i+skipfirst],FILETYPE_SAMPLE_FLAC,0);
f_skip = 1;
}

// Fall back to WAV if it exists.
/* Fall back to WAV if it exists. */
if (!f)
{
f_type = 1;
Expand All @@ -557,17 +557,17 @@ struct GameSamples *readsamples(const char **samplenames,const char *basename)
}
}

// Get sample info. Small sample files will pre load into memory at this point.
/* Get sample info. Small sample files will pre load into memory at this point. */
if (f != 0)
{
// Open FLAC.
/* Open FLAC. */
if(f_type == 0) {
if (f_skip == 1)
samples->sample[i] = read_wav_sample(f, samplenames[0]+1, samplenames[i+skipfirst], FILETYPE_SAMPLE_FLAC, 0);
else
samples->sample[i] = read_wav_sample(f, basename, samplenames[i+skipfirst], FILETYPE_SAMPLE_FLAC, 0);
}
else { // Open WAV.
else { /* Open WAV. */
if (f_skip == 1)
samples->sample[i] = read_wav_sample(f, samplenames[0]+1, samplenames[i+skipfirst], FILETYPE_SAMPLE, 0);
else
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct GameSamples
struct GameSample *sample[1]; /* extendable */
};

#define GAME_SAMPLE_LARGE 10000000 // 10MB
#define GAME_SAMPLE_LARGE 10000000 /* 10MB */

/***************************************************************************
Expand Down
22 changes: 11 additions & 11 deletions src/cpu/v60/am.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

// NOTE for bit string/field addressing
// ************************************
// modDim must be passed as 10 for bit string instructions,
// and as 11 for bit field instructions
/* NOTE for bit string/field addressing */
/* ************************************ */
/* modDim must be passed as 10 for bit string instructions, */
/* and as 11 for bit field instructions */



// Output variables for ReadAMAddress()
/* Output variables for ReadAMAddress() */
static UINT8 amFlag;
static UINT32 amOut;
static UINT32 bamOffset;

// Appo temp var
/* Appo temp var */
static UINT32 amLength1,amLength2;


// Global vars used by AM functions
/* Global vars used by AM functions */
static UINT32 modAdd;
static UINT8 modM;
static UINT8 modVal;
Expand All @@ -25,10 +25,10 @@ static UINT16 modWriteValH;
static UINT32 modWriteValW;
static UINT8 modDim;

// Addressing mode functions and tables
#include "am1.c" // ReadAM
#include "am2.c" // ReadAMAddress
#include "am3.c" // WriteAM
/* Addressing mode functions and tables */
#include "am1.c" /* ReadAM */
#include "am2.c" /* ReadAMAddress */
#include "am3.c" /* WriteAM */

/*
Input:
Expand Down
10 changes: 5 additions & 5 deletions src/cpu/v60/am1.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// AM1 Functions (for ReadAM)
// **************************
/* AM1 Functions (for ReadAM) */
/* ************************** */

static UINT32 am1Register(void)
{
Expand Down Expand Up @@ -1071,7 +1071,7 @@ static UINT32 am1Immediate(void)
break;
}

// It should not be here! Written to avoid warning
/* It should not be here! Written to avoid warning */
assert(0);
return 1;
}
Expand All @@ -1085,8 +1085,8 @@ static UINT32 am1ImmediateQuick(void)



// AM1 Tables (for ReadAM)
// ***********************
/* AM1 Tables (for ReadAM) */
/* *********************** */

static UINT32 am1Error1(void)
{
Expand Down
12 changes: 6 additions & 6 deletions src/cpu/v60/am2.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// AM2 Functions (for ReadAMAddress)
// *********************************
/* AM2 Functions (for ReadAMAddress) */
/* ********************************* */

static UINT32 am2Register(void)
{
Expand Down Expand Up @@ -940,19 +940,19 @@ static UINT32 bam2DirectAddressDeferredIndexed(void)

static UINT32 am2Immediate(void)
{
// Fuck off LDPR
/* Fuck off LDPR */
return am1Immediate();
}

static UINT32 am2ImmediateQuick(void)
{
// fuck off LDPR
/* fuck off LDPR */
return am1ImmediateQuick();
}


// AM2 Tables (for ReadAMAddress)
// ******************************
/* AM2 Tables (for ReadAMAddress) */
/* ****************************** */

static UINT32 am2Error1(void)
{
Expand Down
8 changes: 4 additions & 4 deletions src/cpu/v60/am3.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// AM3 Functions (for ReadAM)
// **************************
/* AM3 Functions (for ReadAM) */
/* ************************** */

static UINT32 am3Register(void)
{
Expand Down Expand Up @@ -730,8 +730,8 @@ static UINT32 am3ImmediateQuick(void)



// AM3 Tables (for ReadAMAddress)
// ******************************
/* AM3 Tables (for ReadAMAddress) */
/* ****************************** */

static UINT32 am3Error1(void)
{
Expand Down
Loading

0 comments on commit f34453a

Please sign in to comment.