Skip to content

Commit

Permalink
Initial checkin of MAME 0.121.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsgiles committed Dec 17, 2007
1 parent 3da7f47 commit 7b77f12
Show file tree
Hide file tree
Showing 3,304 changed files with 2,069,565 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3,303 changes: 3,303 additions & 0 deletions .gitattributes

Large diffs are not rendered by default.

586 changes: 586 additions & 0 deletions makefile

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/build/build.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
###########################################################################
#
# build.mak
#
# MAME build tools makefile
#
# Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
# Visit http://mamedev.org for licensing and usage restrictions.
#
###########################################################################


BUILDSRC = $(SRC)/build
BUILDOBJ = $(OBJ)/build
BUILDOUT = $(BUILDOBJ)

OBJDIRS += \
$(BUILDOBJ) \



#-------------------------------------------------
# set of build targets
#-------------------------------------------------

FILE2STR = $(BUILDOUT)/file2str$(EXE)
PNG2BDC = $(BUILDOUT)/png2bdc$(EXE)

BUILD += \
$(FILE2STR) \
$(PNG2BDC) \



#-------------------------------------------------
# file2str
#-------------------------------------------------

FILE2STROBJS = \
$(BUILDOBJ)/file2str.o \

$(FILE2STR): $(FILE2STROBJS) $(LIBOCORE)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@



#-------------------------------------------------
# png2bdc
#-------------------------------------------------

PNG2BDCOBJS = \
$(BUILDOBJ)/png2bdc.o \

$(PNG2BDC): $(PNG2BDCOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB) $(EXPAT)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@
98 changes: 98 additions & 0 deletions src/build/file2str.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/***************************************************************************
file2str.c
Simple file to string converter.
Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
***************************************************************************/

#include <stdio.h>
#include "osdcore.h"


/*-------------------------------------------------
main - primary entry point
-------------------------------------------------*/

int main(int argc, char *argv[])
{
const char *srcfile, *dstfile, *varname, *type;
FILE *src, *dst;
UINT8 *buffer;
int bytes, offs;
int terminate = 1;

/* needs at least three arguments */
if (argc < 4)
{
fprintf(stderr,
"Usage:\n"
" laytostr <source.lay> <output.h> <varname> [<type>]\n"
"\n"
"The default <type> is char, with an assumed NULL terminator\n"
);
return 0;
}

/* extract arguments */
srcfile = argv[1];
dstfile = argv[2];
varname = argv[3];
type = (argc >= 5) ? argv[4] : "char";
if (argc >= 5)
terminate = 0;

/* open source file */
src = fopen(srcfile, "rb");
if (src == NULL)
{
fprintf(stderr, "Unable to open source file '%s'\n", srcfile);
return 1;
}

/* determine file size */
fseek(src, 0, SEEK_END);
bytes = ftell(src);
fseek(src, 0, SEEK_SET);

/* allocate memory */
buffer = malloc(bytes + 1);
if (buffer == NULL)
{
fprintf(stderr, "Out of memory allocating %d byte buffer\n", bytes);
return 1;
}

/* read the source file */
fread(buffer, 1, bytes, src);
buffer[bytes] = 0;
fclose(src);

/* open dest file */
dst = fopen(dstfile, "w");
if (dst == NULL)
{
fprintf(stderr, "Unable to open output file '%s'\n", dstfile);
return 1;
}

/* write the initial header */
fprintf(dst, "const %s %s[] =\n{\n\t", type, varname);

/* write out the data */
for (offs = 0; offs < bytes + terminate; offs++)
{
fprintf(dst, "0x%02x%s", buffer[offs], (offs != bytes + terminate - 1) ? "," : "");
if (offs % 16 == 15)
fprintf(dst, "\n\t");
}
fprintf(dst, "\n};\n");

/* close the files */
free(buffer);
fclose(dst);
return 0;
}
Loading

0 comments on commit 7b77f12

Please sign in to comment.