From b9fcacdbfdb96ea249dad60f9c8dc4711644d8cd Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 4 Nov 2017 21:30:32 +1000 Subject: [PATCH] Fix an overflow bug with f32 to s32 conversion. --- resources/format_conversions.txt | 3 ++- tools/malgen/source/malgen.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/format_conversions.txt b/resources/format_conversions.txt index a1d7e3c5..d62b8c9c 100644 --- a/resources/format_conversions.txt +++ b/resources/format_conversions.txt @@ -15,6 +15,7 @@ # clip [output] [a] -> output = clamp(a, -1, 1) # # int [name] -> Declare an uninitialized 32-bit integer +# lng [name] -> Declare an uninitialized 64-bit integer # flt [name] -> Declare an uninitialized 32-bit float # r = (x - 128) << 8 @@ -159,7 +160,7 @@ f32->s24 { # r = clip(x) * (0x7FFFFFFF + sign(x)) f32->s32 { flt c; - int s; + lng s; clip c x; sig s x; add s s 2147483647; diff --git a/tools/malgen/source/malgen.cpp b/tools/malgen/source/malgen.cpp index 99ba2884..bbcae632 100644 --- a/tools/malgen/source/malgen.cpp +++ b/tools/malgen/source/malgen.cpp @@ -455,6 +455,9 @@ std::string malgen_generate_code__conversion_func_inst(malgen_context* pContext, if (strcmp(pInst->name, "int") == 0) { code += "int "; code += pInst->params[0]; } + if (strcmp(pInst->name, "lng") == 0) { + code += "long long "; code += pInst->params[0]; + } if (strcmp(pInst->name, "flt") == 0) { code += "float "; code += pInst->params[0]; }