diff options
author | YamaArashi <shadow962@live.com> | 2016-09-10 13:27:38 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-09-10 13:27:38 -0700 |
commit | 9cbf1aae195248d010bda8dabf7f72e1ffb58bf4 (patch) | |
tree | d323be8793ab9982c36398cfe30eb752365413e8 | |
parent | f20d0afa16e2a2cd18692bc90ab79a5d5ce10a8e (diff) |
make aif2pcm compatible with VS2015
-rw-r--r-- | src/pokemon_2.c | 2 | ||||
-rw-r--r-- | tools/aif2pcm/LICENSE | 1 | ||||
-rw-r--r-- | tools/aif2pcm/extended.c | 6 | ||||
-rw-r--r-- | tools/aif2pcm/main.c | 39 |
4 files changed, 35 insertions, 13 deletions
diff --git a/src/pokemon_2.c b/src/pokemon_2.c index 0f3fc73c5..9936fa2a6 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -830,7 +830,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const u8 *data) break; case MON_DATA_IVS: { - u32 ivs = *data; // Bug: Only the HP / Attack IVs are read. The rest become 0. + u32 ivs = *data; // Bug: Only the HP IV and the lower 3 bits of the Attack IV are read. The rest become 0. substruct3->hpIV = ivs & 0x1F; substruct3->attackIV = (ivs >> 5) & 0x1F; substruct3->defenseIV = (ivs >> 10) & 0x1F; diff --git a/tools/aif2pcm/LICENSE b/tools/aif2pcm/LICENSE index 60c9e63c4..966b92bd6 100644 --- a/tools/aif2pcm/LICENSE +++ b/tools/aif2pcm/LICENSE @@ -1,4 +1,5 @@ Copyright (c) 2016 huderlem +Copyright (c) 2005, 2006 by Marco Trillo <marcotrillo@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/tools/aif2pcm/extended.c b/tools/aif2pcm/extended.c index 067019661..7ec74a887 100644 --- a/tools/aif2pcm/extended.c +++ b/tools/aif2pcm/extended.c @@ -44,11 +44,11 @@ /* * IEEE 754 Extended Precision - * + * * Implementation here is the 80-bit extended precision * format of Motorola 68881, Motorola 68882 and Motorola * 68040 FPUs, as well as Intel 80x87 FPUs. - * + * * See: * http://www.freescale.com/files/32bit/doc/fact_sheet/BR509.pdf */ @@ -112,7 +112,7 @@ ieee754_write_extended(double in, unsigned char* out) done: lexp = ((unsigned int) exp) >> 8; hexp = ((unsigned int) exp) & 0xFF; - + /* big endian */ out[0] = ((unsigned char) sgn) << 7; out[0] |= (unsigned char) lexp; diff --git a/tools/aif2pcm/main.c b/tools/aif2pcm/main.c index 8b8729743..1258cf3fa 100644 --- a/tools/aif2pcm/main.c +++ b/tools/aif2pcm/main.c @@ -32,7 +32,7 @@ double ieee754_read_extended (unsigned char*); #define FATAL_ERROR(format, ...) \ do \ { \ - fprintf(stderr, format, __VA_ARGS__,); \ + fprintf(stderr, format, __VA_ARGS__); \ exit(1); \ } while (0) @@ -227,12 +227,24 @@ AifData *read_aif(char * aif_file_data, unsigned long aif_file_data_size) void aif2pcm(const char *aif_filename) { // Get .pcm filename. - char pcm_filename[strlen(aif_filename) + 1]; + char *pcm_filename = malloc(strlen(aif_filename) + 1); + + if (!pcm_filename) + { + FATAL_ERROR("Failed to allocate space for pcm filename.\n"); + } + strcpy(pcm_filename, aif_filename); change_file_extension(pcm_filename, "pcm"); // Get .metadata filename. - char metadata_filename[strlen(aif_filename) + 1]; + char *metadata_filename = malloc(strlen(aif_filename) + 1); + + if (!metadata_filename) + { + FATAL_ERROR("Failed to allocate space for metadata filename.\n"); + } + strcpy(metadata_filename, aif_filename); change_file_extension(metadata_filename, "bin"); @@ -255,7 +267,7 @@ void aif2pcm(const char *aif_filename) { FATAL_ERROR("Failed to allocate buffer for aif file data!\n"); } - + // Populate buffer from file. unsigned long read = fread(aif_file_data, aif_file_length, 1, aif_file); fclose(aif_file); @@ -285,6 +297,8 @@ void aif2pcm(const char *aif_filename) free(aif_data->samples); free(aif_data); free(aif_file_data); + free(metadata_filename); + free(pcm_filename); } // Reads a .pcm file containing an array of 8-bit samples and produces an .aif file. @@ -292,7 +306,13 @@ void aif2pcm(const char *aif_filename) void pcm2aif(const char *pcm_filename, char base_note, long pitch_adjust, long loop_start) { // Get .aif filename. - char aif_filename[strlen(pcm_filename)]; + char *aif_filename = malloc(strlen(pcm_filename) + 1); + + if (!aif_filename) + { + FATAL_ERROR("Failed to allocate space for aif filename.\n"); + } + strcpy(aif_filename, pcm_filename); change_file_extension(aif_filename, "aif"); @@ -508,7 +528,7 @@ void pcm2aif(const char *pcm_filename, char base_note, long pitch_adjust, long l aif_buffer[pos++] = 0; // Sound Data Chunk soundData - for (unsigned int i = 0; i < loop_start; i++) + for (int i = 0; i < loop_start; i++) { aif_buffer[pos++] = pcm_samples[i]; } @@ -533,18 +553,19 @@ void pcm2aif(const char *pcm_filename, char base_note, long pitch_adjust, long l free(aif_buffer); free(pcm_samples); + free(aif_filename); } int main(int argc, char **argv) { if (argc < 2) { - FATAL_ERROR("Usage: aif2pcm <aif_file>\n"); + FATAL_ERROR("Usage: aif2pcm <aif_file>\n"); } char *input_filename = argv[1]; char *extension = get_file_extension(input_filename); - + if (strcmp(extension, "aif") == 0) { aif2pcm(input_filename); @@ -566,5 +587,5 @@ int main(int argc, char **argv) FATAL_ERROR("Input file must be .aif or .pcm: '%s'\n", input_filename); } - return 0; + return 0; } |