trunk/makefile
| r242406 | r242407 | |
| 959 | 959 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 960 | 960 | endif |
| 961 | 961 | |
| 962 | | $(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR_TARGET) |
| 962 | $(OBJ)/%.lh: $(SRC)/%.lay $(SRC)/build/file2str.py |
| 963 | 963 | @echo Converting $<... |
| 964 | | @$(FILE2STR) $< $@ layout_$(basename $(notdir $<)) |
| 964 | @$(PYTHON) $(SRC)/build/file2str.py $< $@ layout_$(basename $(notdir $<)) |
| 965 | 965 | |
| 966 | | $(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC_TARGET) $(FILE2STR_TARGET) |
| 966 | $(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC_TARGET) $(SRC)/build/file2str.py |
| 967 | 967 | @echo Converting $<... |
| 968 | 968 | @$(PNG2BDC) $< $(OBJ)/temp.bdc |
| 969 | | @$(FILE2STR) $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8 |
| 969 | @$(PYTHON) $(SRC)/build/file2str.py $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8 |
| 970 | 970 | |
| 971 | 971 | $(DRIVLISTOBJ): $(DRIVLISTSRC) |
| 972 | 972 | @echo Compiling $<... |
trunk/src/build/build.mak
| r242406 | r242407 | |
| 18 | 18 | # set of build targets |
| 19 | 19 | #------------------------------------------------- |
| 20 | 20 | |
| 21 | | FILE2STR_TARGET = $(BUILDOUT)/file2str$(BUILD_EXE) |
| 22 | 21 | MAKEDEP_TARGET = $(BUILDOUT)/makedep$(BUILD_EXE) |
| 23 | 22 | MAKEMAK_TARGET = $(BUILDOUT)/makemak$(BUILD_EXE) |
| 24 | 23 | MAKELIST_TARGET = $(BUILDOUT)/makelist$(BUILD_EXE) |
| 25 | 24 | PNG2BDC_TARGET = $(BUILDOUT)/png2bdc$(BUILD_EXE) |
| 26 | 25 | VERINFO_TARGET = $(BUILDOUT)/verinfo$(BUILD_EXE) |
| 27 | 26 | |
| 28 | | FILE2STR = $(FILE2STR_TARGET) |
| 29 | 27 | MAKEDEP = $(MAKEDEP_TARGET) |
| 30 | 28 | MAKEMAK = $(MAKEMAK_TARGET) |
| 31 | 29 | MAKELIST = $(MAKELIST_TARGET) |
| r242406 | r242407 | |
| 34 | 32 | |
| 35 | 33 | ifneq ($(TERM),cygwin) |
| 36 | 34 | ifeq ($(TARGETOS),win32) |
| 37 | | FILE2STR = $(subst /,\,$(FILE2STR_TARGET)) |
| 38 | 35 | MAKEDEP = $(subst /,\,$(MAKEDEP_TARGET)) |
| 39 | 36 | MAKEMAK = $(subst /,\,$(MAKEMAK_TARGET)) |
| 40 | 37 | MAKELIST = $(subst /,\,$(MAKELIST_TARGET)) |
| r242406 | r242407 | |
| 45 | 42 | |
| 46 | 43 | ifneq ($(CROSS_BUILD),1) |
| 47 | 44 | BUILD += \ |
| 48 | | $(FILE2STR_TARGET) \ |
| 49 | 45 | $(MAKEDEP_TARGET) \ |
| 50 | 46 | $(MAKEMAK_TARGET) \ |
| 51 | 47 | $(MAKELIST_TARGET) \ |
| r242406 | r242407 | |
| 55 | 51 | |
| 56 | 52 | |
| 57 | 53 | #------------------------------------------------- |
| 58 | | # file2str |
| 59 | | #------------------------------------------------- |
| 60 | | |
| 61 | | FILE2STROBJS = \ |
| 62 | | $(BUILDOBJ)/file2str.o \ |
| 63 | | |
| 64 | | $(FILE2STR_TARGET): $(FILE2STROBJS) $(LIBOCORE) |
| 65 | | @echo Linking $@... |
| 66 | | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ |
| 67 | | |
| 68 | | |
| 69 | | |
| 70 | | #------------------------------------------------- |
| 71 | 54 | # makedep |
| 72 | 55 | #------------------------------------------------- |
| 73 | 56 | |
| r242406 | r242407 | |
| 155 | 138 | #------------------------------------------------- |
| 156 | 139 | # It's a CROSS_BUILD. Ensure the targets exist. |
| 157 | 140 | #------------------------------------------------- |
| 158 | | $(FILE2STR_TARGET): |
| 159 | | @echo $@ should be built natively. Nothing to do. |
| 160 | | |
| 161 | 141 | $(MAKEDEP_TARGET): |
| 162 | 142 | @echo $@ should be built natively. Nothing to do. |
| 163 | 143 | |
trunk/src/build/file2str.c
| r242406 | r242407 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | file2str.c |
| 4 | | |
| 5 | | Simple file to string converter. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | ***************************************************************************/ |
| 11 | | |
| 12 | | #include <stdio.h> |
| 13 | | #include <stdlib.h> |
| 14 | | |
| 15 | | |
| 16 | | /*------------------------------------------------- |
| 17 | | main - primary entry point |
| 18 | | -------------------------------------------------*/ |
| 19 | | |
| 20 | | int main(int argc, char *argv[]) |
| 21 | | { |
| 22 | | const char *srcfile, *dstfile, *varname, *type; |
| 23 | | FILE *src, *dst; |
| 24 | | unsigned char *buffer; |
| 25 | | int bytes, offs; |
| 26 | | int terminate = 1; |
| 27 | | |
| 28 | | /* needs at least three arguments */ |
| 29 | | if (argc < 4) |
| 30 | | { |
| 31 | | fprintf(stderr, |
| 32 | | "Usage:\n" |
| 33 | | " laytostr <source.lay> <output.h> <varname> [<type>]\n" |
| 34 | | "\n" |
| 35 | | "The default <type> is char, with an assumed NULL terminator\n" |
| 36 | | ); |
| 37 | | return 0; |
| 38 | | } |
| 39 | | |
| 40 | | /* extract arguments */ |
| 41 | | srcfile = argv[1]; |
| 42 | | dstfile = argv[2]; |
| 43 | | varname = argv[3]; |
| 44 | | type = (argc >= 5) ? argv[4] : "char"; |
| 45 | | if (argc >= 5) |
| 46 | | terminate = 0; |
| 47 | | |
| 48 | | /* open source file */ |
| 49 | | src = fopen(srcfile, "rb"); |
| 50 | | if (src == NULL) |
| 51 | | { |
| 52 | | fprintf(stderr, "Unable to open source file '%s'\n", srcfile); |
| 53 | | return 1; |
| 54 | | } |
| 55 | | |
| 56 | | /* determine file size */ |
| 57 | | fseek(src, 0, SEEK_END); |
| 58 | | bytes = ftell(src); |
| 59 | | fseek(src, 0, SEEK_SET); |
| 60 | | |
| 61 | | /* allocate memory */ |
| 62 | | buffer = (unsigned char *)malloc(bytes + 1); |
| 63 | | if (buffer == NULL) |
| 64 | | { |
| 65 | | fclose(src); |
| 66 | | fprintf(stderr, "Out of memory allocating %d byte buffer\n", bytes); |
| 67 | | return 1; |
| 68 | | } |
| 69 | | |
| 70 | | /* read the source file */ |
| 71 | | fread(buffer, 1, bytes, src); |
| 72 | | buffer[bytes] = 0; |
| 73 | | fclose(src); |
| 74 | | |
| 75 | | /* open dest file */ |
| 76 | | dst = fopen(dstfile, "w"); |
| 77 | | if (dst == NULL) |
| 78 | | { |
| 79 | | free(buffer); |
| 80 | | fprintf(stderr, "Unable to open output file '%s'\n", dstfile); |
| 81 | | return 1; |
| 82 | | } |
| 83 | | |
| 84 | | /* write the initial header */ |
| 85 | | fprintf(dst, "extern const %s %s[];\n", type, varname); |
| 86 | | fprintf(dst, "const %s %s[] =\n{\n\t", type, varname); |
| 87 | | |
| 88 | | /* write out the data */ |
| 89 | | for (offs = 0; offs < bytes + terminate; offs++) |
| 90 | | { |
| 91 | | fprintf(dst, "0x%02x%s", buffer[offs], (offs != bytes + terminate - 1) ? "," : ""); |
| 92 | | if (offs % 16 == 15) |
| 93 | | fprintf(dst, "\n\t"); |
| 94 | | } |
| 95 | | fprintf(dst, "\n};\n"); |
| 96 | | |
| 97 | | /* close the files */ |
| 98 | | free(buffer); |
| 99 | | fclose(dst); |
| 100 | | return 0; |
| 101 | | } |
trunk/src/build/file2str.py
| r0 | r242407 | |
| 1 | #!/usr/bin/python |
| 2 | |
| 3 | import string |
| 4 | import sys |
| 5 | import os |
| 6 | |
| 7 | if (len(sys.argv) < 4) : |
| 8 | print('Usage:') |
| 9 | print(' file2str <source.lay> <output.h> <varname> [<type>]') |
| 10 | print('') |
| 11 | print('The default <type> is char, with an assumed NULL terminator') |
| 12 | sys.exit(0) |
| 13 | |
| 14 | terminate = 1 |
| 15 | srcfile = sys.argv[1] |
| 16 | dstfile = sys.argv[2] |
| 17 | varname = sys.argv[3] |
| 18 | |
| 19 | if (len(sys.argv) >= 5) : |
| 20 | type = sys.argv[4] |
| 21 | terminate = 0 |
| 22 | else: |
| 23 | type = 'char' |
| 24 | |
| 25 | try: |
| 26 | myfile = open(srcfile, 'rb') |
| 27 | except IOError: |
| 28 | print("Unable to open source file '%s'" % srcfile) |
| 29 | sys.exit(-1) |
| 30 | |
| 31 | bytes = os.path.getsize(srcfile) |
| 32 | try: |
| 33 | dst = open(dstfile,'w') |
| 34 | dst.write('extern const %s %s[];\n' % ( type, varname )); |
| 35 | dst.write('const %s %s[] =\n{\n\t' % ( type, varname)); |
| 36 | offs = 0 |
| 37 | with open(srcfile, "rb") as src: |
| 38 | while True: |
| 39 | chunk = src.read(16) |
| 40 | if chunk: |
| 41 | for b in chunk: |
| 42 | dst.write('0x%02x' % ord(b)) |
| 43 | offs = offs + 1 |
| 44 | if offs != bytes: |
| 45 | dst.write(',') |
| 46 | else: |
| 47 | break |
| 48 | if offs != bytes: |
| 49 | dst.write('\n\t') |
| 50 | if terminate == 1: |
| 51 | dst.write(',0x00') |
| 52 | dst.write('\n};\n') |
| 53 | dst.close() |
| 54 | except IOError: |
| 55 | print("Unable to open output file '%s'" % dstfile) |
| 56 | sys.exit(-1) |
| | No newline at end of file |
trunk/src/osd/sdl/input.c
| r242406 | r242407 | |
| 757 | 757 | |
| 758 | 758 | osd_printf_verbose("Joystick: %s\n", devinfo->name.cstr()); |
| 759 | 759 | osd_printf_verbose("Joystick: ... %d axes, %d buttons %d hats %d balls\n", SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumBalls(joy)); |
| 760 | | osd_printf_verbose("Joystick: ... Physical id %d mapped to logical id %d\n", physical_stick, stick + 1); |
| 760 | osd_printf_verbose("Joystick: ... Physical id %d mapped to logical id %d\n", physical_stick, stick); |
| 761 | 761 | |
| 762 | 762 | // loop over all axes |
| 763 | 763 | for (axis = 0; axis < SDL_JoystickNumAxes(joy); axis++) |