diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 73642bef2..f64d7340e 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -724,7 +724,7 @@ {"id":{"name":"buttonGradient","path":"scripts/buttonGradient/buttonGradient.yy",},}, {"id":{"name":"buttonGroup","path":"scripts/buttonGroup/buttonGroup.yy",},}, {"id":{"name":"buttonPalette","path":"scripts/buttonPalette/buttonPalette.yy",},}, - {"id":{"name":"byte_reader","path":"scripts/byte_reader/byte_reader.yy",},}, + {"id":{"name":"byte_read_function","path":"scripts/byte_read_function/byte_read_function.yy",},}, {"id":{"name":"byte_writer","path":"scripts/byte_writer/byte_writer.yy",},}, {"id":{"name":"canvas_actions_transform","path":"scripts/canvas_actions_transform/canvas_actions_transform.yy",},}, {"id":{"name":"canvas_draw_functions","path":"scripts/canvas_draw_functions/canvas_draw_functions.yy",},}, diff --git a/scripts/ase_object/ase_object.gml b/scripts/ase_object/ase_object.gml index 4be6bec8e..25656a986 100644 --- a/scripts/ase_object/ase_object.gml +++ b/scripts/ase_object/ase_object.gml @@ -21,18 +21,18 @@ function ase_cel(_layer, _data, _file) constructor { if(color == 16) { //grey repeat(size) { - var bin = buffer_read(data[? "Buffer"], buffer_u16); - buffer_write(buff, buffer_u8, bin); - buffer_write(buff, buffer_u8, bin); - buffer_write(buff, buffer_u8, bin); - buffer_write(buff, buffer_u8, bin >> 8); + var _bin = buffer_read(data[? "Buffer"], buffer_u16); + buffer_write(buff, buffer_u8, _bin); + buffer_write(buff, buffer_u8, _bin); + buffer_write(buff, buffer_u8, _bin); + buffer_write(buff, buffer_u8, _bin >> 8); } } else if(color == 8) { //index var palet = file[? "Palette"]; repeat(size) { - var bin = buffer_read(data[? "Buffer"], buffer_u8); - var cc = array_safe_get_fast(palet, bin); + var _bin = buffer_read(data[? "Buffer"], buffer_u8); + var cc = array_safe_get_fast(palet, _bin); for( var i = 0; i < 4; i++ ) buffer_write(buff, buffer_u8, cc[i]); } diff --git a/scripts/ase_reader/ase_reader.gml b/scripts/ase_reader/ase_reader.gml index ec263eac5..7e59211be 100644 --- a/scripts/ase_reader/ase_reader.gml +++ b/scripts/ase_reader/ase_reader.gml @@ -288,32 +288,32 @@ __ase_format_chunk_tileset = [ [_BIN_TYPE.pixel, "Compressed image", "Data length", function(chunk) { return chunk[? "Flag"] & (1 << 2); }], ]; -function read_format_type(bin, datType, outMap) { +function read_format_type(_bin, datType, outMap) { switch(datType) { - case _BIN_TYPE.byte: return bin_read_byte(bin); - case _BIN_TYPE.word: return bin_read_word(bin); - case _BIN_TYPE.short: return bin_read_short(bin); - case _BIN_TYPE.dword: return bin_read_dword(bin); - case _BIN_TYPE.long: return bin_read_long(bin); - case _BIN_TYPE.fixed: return bin_read_fixed(bin); - case _BIN_TYPE.float: return bin_read_float(bin); - case _BIN_TYPE.double: return bin_read_double(bin); - case _BIN_TYPE.qword: return bin_read_qword(bin); - case _BIN_TYPE.long64: return bin_read_long64(bin); + case _BIN_TYPE.byte: return bin_read_byte(_bin); + case _BIN_TYPE.word: return bin_read_word(_bin); + case _BIN_TYPE.short: return bin_read_short(_bin); + case _BIN_TYPE.dword: return bin_read_dword(_bin); + case _BIN_TYPE.long: return bin_read_long(_bin); + case _BIN_TYPE.fixed: return bin_read_fixed(_bin); + case _BIN_TYPE.float: return bin_read_float(_bin); + case _BIN_TYPE.double: return bin_read_double(_bin); + case _BIN_TYPE.qword: return bin_read_qword(_bin); + case _BIN_TYPE.long64: return bin_read_long64(_bin); - case _BIN_TYPE.string: return bin_read_string(bin); - case _BIN_TYPE.point: return bin_read_point(bin); - case _BIN_TYPE.size: return bin_read_size(bin); - case _BIN_TYPE.rect: return bin_read_rect(bin); - case _BIN_TYPE.color: return bin_read_color(bin); - case _BIN_TYPE.pixel: return bin_read_pixel(bin, outMap[? "Color depth"]); + case _BIN_TYPE.string: return bin_read_string(_bin); + case _BIN_TYPE.point: return bin_read_point(_bin); + case _BIN_TYPE.size: return bin_read_size(_bin); + case _BIN_TYPE.rect: return bin_read_rect(_bin); + case _BIN_TYPE.color: return bin_read_color(_bin); + case _BIN_TYPE.pixel: return bin_read_pixel(_bin, outMap[? "Color depth"]); } return 0; } -function read_format(bin, format, outMap) { +function read_format(_bin, format, outMap) { var datType = array_safe_get_fast(format, 0, 0); var key = array_safe_get_fast(format, 1, ""); var amount = array_safe_get_fast(format, 2, 1); @@ -323,25 +323,25 @@ function read_format(bin, format, outMap) { amount = amount(outMap); if(amount == 1) { - var val = read_format_type(bin, datType, outMap); + var val = read_format_type(_bin, datType, outMap); outMap[? key] = val; return val; } else { var a = array_create(amount); for( var i = 0; i < amount; i++ ) - a[i] = read_format_type(bin, datType, outMap); + a[i] = read_format_type(_bin, datType, outMap); outMap[? key] = a; return a; } } -function read_format_array(bin, formatArr, outMap) { +function read_format_array(_bin, formatArr, outMap) { for( var i = 0, n = array_length(formatArr); i < n; i++ ) { if(array_length(formatArr[i]) >= 4 && !formatArr[i][3](outMap)) continue; - var pos = file_bin_position(bin); - var val = read_format(bin, formatArr[i], outMap); - //printIf(global.FLAG.ase_import, "Pos " + dec_to_hex(pos) + " - " + dec_to_hex(file_bin_position(bin))); + var pos = file_bin_position(_bin); + var val = read_format(_bin, formatArr[i], outMap); + //printIf(global.FLAG.ase_import, "Pos " + dec_to_hex(pos) + " - " + dec_to_hex(file_bin_position(_bin))); if(formatArr[i][1] == "Type") printIf(global.FLAG.ase_import, "\t" + formatArr[i][1] + ":\t 0x" + dec_to_hex(val, 4)); diff --git a/scripts/byte_read_function/byte_read_function.gml b/scripts/byte_read_function/byte_read_function.gml new file mode 100644 index 000000000..45cd9b231 --- /dev/null +++ b/scripts/byte_read_function/byte_read_function.gml @@ -0,0 +1,145 @@ + +function bin_read_byte(_bin) { + return file_bin_read_byte(_bin); +} + +function bin_read_word(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + return b0 + (b1 << 8); +} + +function bin_read_short(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + + var short = b0 + (b1 << 8); + var sig = short >> 15; + short = short & ~(1 << 15); + return sig? -power(2, 15) + short : short; +} + +function bin_read_dword(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var dword = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + return dword; +} + +function bin_read_long(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + + var sig = long >> 31; + long = long & ~(1 << 31); + return sig? -power(2, 31) : long; +} + +function bin_read_fixed(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + + var fixInt = b0 + (b1 << 8); + var fixFrc = b2 + (b3 << 8); + return fixInt + bin_fraction(fixFrc, 16); +} + +function bin_read_float(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var float = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + + var sig = float >> 31; + var expo = (float & ~(1 << 31)) >> 23; + var mant = float & 0b00000000_01111111_11111111_11111111; + + var val = (1 + mant) * power(2, expo - 127); + return sig? -val : val; +} + +function bin_read_double(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var b4 = file_bin_read_byte(_bin); + var b5 = file_bin_read_byte(_bin); + var b6 = file_bin_read_byte(_bin); + var b7 = file_bin_read_byte(_bin); + var double = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); + + var sig = double >> 63; + var expo = (double & ~(1 << 63)) >> 52; + var mant = double & 0b00000000_00001111_11111111_11111111_11111111_11111111_11111111_11111111; + + var val = (1 + mant) * power(2, expo - 1023); + return sig? -val : val; +} + +function bin_read_qword(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var b4 = file_bin_read_byte(_bin); + var b5 = file_bin_read_byte(_bin); + var b6 = file_bin_read_byte(_bin); + var b7 = file_bin_read_byte(_bin); + return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); +} + +function bin_read_long64(_bin) { + var b0 = file_bin_read_byte(_bin); + var b1 = file_bin_read_byte(_bin); + var b2 = file_bin_read_byte(_bin); + var b3 = file_bin_read_byte(_bin); + var b4 = file_bin_read_byte(_bin); + var b5 = file_bin_read_byte(_bin); + var b6 = file_bin_read_byte(_bin); + var b7 = file_bin_read_byte(_bin); + var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); + var sig = long >> 63; + long = long & ~(1 << 63); + return sig? -long : long; +} + +// +function bin_read_string(_bin) { + var len = bin_read_word(_bin); + var ss = ""; + repeat(len) { + var utf = bin_read_byte(_bin); + ss += chr(utf); + } + return ss; +} + +function bin_read_point(_bin) { return [ bin_read_long(_bin), bin_read_long(_bin) ]; } +function bin_read_size(_bin) { return [ bin_read_long(_bin), bin_read_long(_bin) ]; } +function bin_read_rect(_bin) { return [ bin_read_point(_bin), bin_read_size(_bin) ]; } + +function bin_read_color(_bin) { + var r = bin_read_byte(_bin); + var g = bin_read_byte(_bin); + var b = bin_read_byte(_bin); + + return make_color_rgb(r, g, b); +} + +function bin_read_pixel(_bin, type) { + switch(type) { + case 0 : return [ bin_read_byte(_bin), bin_read_byte(_bin), bin_read_byte(_bin), bin_read_byte(_bin) ]; + case 1 : return [ bin_read_byte(_bin), bin_read_byte(_bin) ]; + case 2 : return [ bin_read_byte(_bin) ]; + } + return 0; +} \ No newline at end of file diff --git a/scripts/byte_reader/byte_reader.yy b/scripts/byte_read_function/byte_read_function.yy similarity index 76% rename from scripts/byte_reader/byte_reader.yy rename to scripts/byte_read_function/byte_read_function.yy index 0411aaa78..483289f7f 100644 --- a/scripts/byte_reader/byte_reader.yy +++ b/scripts/byte_read_function/byte_read_function.yy @@ -1,9 +1,9 @@ { "$GMScript":"v1", - "%Name":"byte_reader", + "%Name":"byte_read_function", "isCompatibility":false, "isDnD":false, - "name":"byte_reader", + "name":"byte_read_function", "parent":{ "name":"importers", "path":"folders/functions/importers.yy", diff --git a/scripts/byte_reader/byte_reader.gml b/scripts/byte_reader/byte_reader.gml deleted file mode 100644 index 3a88b0858..000000000 --- a/scripts/byte_reader/byte_reader.gml +++ /dev/null @@ -1,136 +0,0 @@ -function bin_read_byte(bin) { - return file_bin_read_byte(bin); -} -function bin_read_word(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - return b0 + (b1 << 8); -} -function bin_read_short(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - - var short = b0 + (b1 << 8); - var sig = short >> 15; - short = short & ~(1 << 15); - return sig? -power(2, 15) + short : short; -} -function bin_read_dword(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var dword = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - return dword; -} -function bin_read_long(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - - var sig = long >> 31; - long = long & ~(1 << 31); - return sig? -power(2, 31) : long; -} -function bin_read_fixed(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - - var fixInt = b0 + (b1 << 8); - var fixFrc = b2 + (b3 << 8); - return fixInt + bin_fraction(fixFrc, 16); -} -function bin_read_float(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var float = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - - var sig = float >> 31; - var expo = (float & ~(1 << 31)) >> 23; - var mant = float & 0b00000000_01111111_11111111_11111111; - - var val = (1 + mant) * power(2, expo - 127); - return sig? -val : val; -} -function bin_read_double(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var b4 = file_bin_read_byte(bin); - var b5 = file_bin_read_byte(bin); - var b6 = file_bin_read_byte(bin); - var b7 = file_bin_read_byte(bin); - var double = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); - - var sig = double >> 63; - var expo = (double & ~(1 << 63)) >> 52; - var mant = double & 0b00000000_00001111_11111111_11111111_11111111_11111111_11111111_11111111; - - var val = (1 + mant) * power(2, expo - 1023); - return sig? -val : val; -} -function bin_read_qword(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var b4 = file_bin_read_byte(bin); - var b5 = file_bin_read_byte(bin); - var b6 = file_bin_read_byte(bin); - var b7 = file_bin_read_byte(bin); - return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); -} -function bin_read_long64(bin) { - var b0 = file_bin_read_byte(bin); - var b1 = file_bin_read_byte(bin); - var b2 = file_bin_read_byte(bin); - var b3 = file_bin_read_byte(bin); - var b4 = file_bin_read_byte(bin); - var b5 = file_bin_read_byte(bin); - var b6 = file_bin_read_byte(bin); - var b7 = file_bin_read_byte(bin); - var long = b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b2 << 32) + (b3 << 40) + (b2 << 48) + (b3 << 56); - var sig = long >> 63; - long = long & ~(1 << 63); - return sig? -long : long; -} -// -function bin_read_string(bin) { - var len = bin_read_word(bin); - var ss = ""; - repeat(len) { - var utf = bin_read_byte(bin); - ss += chr(utf); - } - return ss; -} -function bin_read_point(bin) { - return [bin_read_long(bin), bin_read_long(bin)]; -} -function bin_read_size(bin) { - return [bin_read_long(bin), bin_read_long(bin)]; -} -function bin_read_rect(bin) { - return [bin_read_point(bin), bin_read_size(bin)]; -} -function bin_read_color(bin) { - var r = bin_read_byte(bin); - var g = bin_read_byte(bin); - var b = bin_read_byte(bin); - return make_color_rgb(r, g, b); -} -function bin_read_pixel(bin, type) { - switch(type) { - case 0 : return [ bin_read_byte(bin), bin_read_byte(bin), bin_read_byte(bin), bin_read_byte(bin) ]; - case 1 : return [ bin_read_byte(bin), bin_read_byte(bin) ]; - case 2 : return [ bin_read_byte(bin) ]; - } - return 0; -} \ No newline at end of file diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index cf5d5ee81..c4315e54e 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -38,7 +38,7 @@ LATEST_VERSION = 11700; VERSION = 11760; SAVE_VERSION = 11700; - VERSION_STRING = "1.17.6.005"; + VERSION_STRING = "1.17.6.006"; BUILD_NUMBER = 11760; globalvar HOTKEYS, HOTKEY_CONTEXT;