diff options
author | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2021-06-01 20:40:27 -0400 |
---|---|---|
committer | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2021-06-01 20:40:27 -0400 |
commit | f0b41debc35c2084aad6d369eab11a2d2df4ab44 (patch) | |
tree | 9b720ab0b617fa207051efc7ff9373669f7dc47b /tools | |
parent | a839463c849679974c986bf9c9c260eff0e94cb7 (diff) | |
parent | 9f5bf65fb336cf7a3ba68d32267bf993f0f6a494 (diff) |
Merge branch 'master' of https://github.com/pret/pokeemerald into remove-temps
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aif2pcm/main.c | 27 | ||||
-rw-r--r-- | tools/gbafix/gbafix.c | 8 | ||||
-rw-r--r-- | tools/mapjson/mapjson.cpp | 2 |
3 files changed, 30 insertions, 7 deletions
diff --git a/tools/aif2pcm/main.c b/tools/aif2pcm/main.c index cd5ac4a50..3dad6fcf8 100644 --- a/tools/aif2pcm/main.c +++ b/tools/aif2pcm/main.c @@ -351,6 +351,12 @@ const int gDeltaEncodingTable[] = { -64, -49, -36, -25, -16, -9, -4, -1, }; +#define POSITIVE_DELTAS_START 0 +#define POSITIVE_DELTAS_END 8 + +#define NEGATIVE_DELTAS_START 8 +#define NEGATIVE_DELTAS_END 16 + struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length) { struct Bytes *pcm = malloc(sizeof(struct Bytes)); @@ -418,15 +424,32 @@ struct Bytes *delta_decompress(struct Bytes *delta, unsigned int expected_length return pcm; } +#define U8_TO_S8(value) ((value) < 128 ? (value) : (value) - 256) +#define ABS(value) ((value) >= 0 ? (value) : -(value)) + int get_delta_index(uint8_t sample, uint8_t prev_sample) { int best_error = INT_MAX; int best_index = -1; + int delta_table_start_index; + int delta_table_end_index; + int sample_signed = U8_TO_S8(sample); + int prev_sample_signed = U8_TO_S8(prev_sample); + + // if we're going up (or equal), only choose positive deltas + if (prev_sample_signed <= sample_signed) { + delta_table_start_index = POSITIVE_DELTAS_START; + delta_table_end_index = POSITIVE_DELTAS_END; + } else { + delta_table_start_index = NEGATIVE_DELTAS_START; + delta_table_end_index = NEGATIVE_DELTAS_END; + } - for (int i = 0; i < 16; i++) + for (int i = delta_table_start_index; i < delta_table_end_index; i++) { uint8_t new_sample = prev_sample + gDeltaEncodingTable[i]; - int error = sample > new_sample ? sample - new_sample : new_sample - sample; + int new_sample_signed = U8_TO_S8(new_sample); + int error = ABS(new_sample_signed - sample_signed); if (error < best_error) { diff --git a/tools/gbafix/gbafix.c b/tools/gbafix/gbafix.c index 598e43aa0..d62a9c661 100644 --- a/tools/gbafix/gbafix.c +++ b/tools/gbafix/gbafix.c @@ -28,14 +28,14 @@ // gbafix.c //--------------------------------------------------------------------------------- /* - Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Diegoisawesome) + Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Sierraffinity) Validates header of GBA roms. History ------- v1.07 - added support for ELF input, (PikalaxALT) - v1.06 - added output silencing, (Diegoisawesome) - v1.05 - added debug offset argument, (Diegoisawesome) + v1.06 - added output silencing, (Sierraffinity) + v1.05 - added debug offset argument, (Sierraffinity) v1.04 - converted to plain C, (WinterMute) v1.03 - header.fixed, header.device_type v1.02 - redefined the options (rgbfix style), checksum=0 @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) // show syntax if (argc <= 1) { - printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n"); + printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Sierraffinity \n"); printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>] [--silent]\n"); printf("\n"); printf("parameters:\n"); diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 5e246ff24..d767b469e 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -395,7 +395,7 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) { int group_num = 0; for (auto &group : groups_data["group_order"].array_items()) { - text << "// Map Group " << group_num << "\n"; + text << "// " << group.string_value() << "\n"; vector<Json> map_ids; size_t max_length = 0; |