mirror of
https://github.com/Tolik-Trek/Shared_Includes.git
synced 2026-06-18 02:20:20 +03:00
...
This commit is contained in:
parent
378f3fdd49
commit
399bf41c5c
@ -4,14 +4,17 @@
|
|||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
-- ¯à¥¢à é ¥â "YYYY-MM-DD" ¢ "DD", "MM", "YYYY"
|
-- ¯à¥¢à é ¥â "YYYY-MM-DD" ¢ "DD", "MM", "YYYY"
|
||||||
function Get_date_RU(str_date)
|
function Get_date_RU(str_date)
|
||||||
return string.char(string.byte(str_date,10), string.byte(str_date,11)), string.char(string.byte(str_date,7), string.byte(str_date,8)), string.char(string.byte(str_date,2), string.byte(str_date,3), string.byte(str_date,4), string.byte(str_date,5))
|
return string.char(string.byte(str_date, 10), string.byte(str_date, 11)),
|
||||||
|
string.char(string.byte(str_date, 7), string.byte(str_date, 8)),
|
||||||
|
string.char(string.byte(str_date, 2), string.byte(str_date, 3), string.byte(str_date, 4),
|
||||||
|
string.byte(str_date, 5))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function Get_file_data(fname)
|
function Get_file_data(fname)
|
||||||
|
|
||||||
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
||||||
fname = string.gsub(string.match(fname, '\'.*\''), "'", "")
|
fname = string.gsub(string.match(fname, '\'.*\''), "'", "")
|
||||||
local file = assert(io.open(fname, "rb"))
|
local file = assert(io.open(fname, "rb"))
|
||||||
@ -19,6 +22,7 @@ function Get_file_data(fname)
|
|||||||
file:close()
|
file:close()
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -41,6 +45,7 @@ function Get_number (str,offset, bytes)
|
|||||||
|
|
||||||
return number
|
return number
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +91,7 @@ function Get_checksum(fname, fStart, fLength)
|
|||||||
|
|
||||||
return reg_d * 16777216 + reg_e * 65536 + reg_b * 256 + reg_c
|
return reg_d * 16777216 + reg_e * 65536 + reg_b * 256 + reg_c
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -93,7 +99,6 @@ end
|
|||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
-- ¤®áâ ñâ ¨§ BMP-8bit à §à¥è¥¨¥, à §¬¥à à áâà , ᬥ饨¥ à áâà , ª®«-¢® 梥⮢
|
-- ¤®áâ ñâ ¨§ BMP-8bit à §à¥è¥¨¥, à §¬¥à à áâà , ᬥ饨¥ à áâà , ª®«-¢® 梥⮢
|
||||||
function Get_bmp8bit_values(fname)
|
function Get_bmp8bit_values(fname)
|
||||||
|
|
||||||
local TBitMapFileHeader = {
|
local TBitMapFileHeader = {
|
||||||
bfType = 0 + 1,
|
bfType = 0 + 1,
|
||||||
bfSize = 2 + 1,
|
bfSize = 2 + 1,
|
||||||
@ -152,10 +157,12 @@ function Get_bmp8bit_values(fname)
|
|||||||
|
|
||||||
bmp_image_offset = Get_number(data, TBitMapFileHeader.bfOffBits, 4)
|
bmp_image_offset = Get_number(data, TBitMapFileHeader.bfOffBits, 4)
|
||||||
bmp_image_size = bmp_height * bmp_width
|
bmp_image_size = bmp_height * bmp_width
|
||||||
bmp_colors = (Get_number (data, TBitMapFileHeader.bfOffBits, 4) - Get_number (data, TBitmapInfoHeader.biSize, 4) - (TBitmapInfoHeader.biSize - 1))/4
|
bmp_colors = (Get_number(data, TBitMapFileHeader.bfOffBits, 4) - Get_number(data, TBitmapInfoHeader.biSize, 4) - (TBitmapInfoHeader.biSize - 1)) /
|
||||||
|
4
|
||||||
|
|
||||||
return bmp_width, bmp_height, bmp_image_size, bmp_image_offset, bmp_colors
|
return bmp_width, bmp_height, bmp_image_size, bmp_image_offset, bmp_colors
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -164,24 +171,34 @@ end
|
|||||||
function Detect_os()
|
function Detect_os()
|
||||||
local BinaryFormat = package.cpath:match("%p[\\|/][?]%p(%a+)")
|
local BinaryFormat = package.cpath:match("%p[\\|/][?]%p(%a+)")
|
||||||
|
|
||||||
if BinaryFormat == "dll" then return "Windows" elseif
|
if BinaryFormat == "dll" then
|
||||||
BinaryFormat == "dylib" then return "MacOS" elseif
|
return "Windows"
|
||||||
|
elseif
|
||||||
|
BinaryFormat == "dylib" then
|
||||||
|
return "MacOS"
|
||||||
|
elseif
|
||||||
BinaryFormat == "so" then
|
BinaryFormat == "so" then
|
||||||
if (os.execute("test -e /sbin/dynamic_pager")) then return "MacOS"
|
if (os.execute("test -e /sbin/dynamic_pager")) then
|
||||||
else return "Linux"
|
return "MacOS"
|
||||||
|
else
|
||||||
|
return "Linux"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("--[ ERROR! OS is not detected!!! ]--")
|
print("--[ ERROR! OS is not detected!!! ]--")
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function File_save(fname, new_fname, offset, size, fstep, fskip)
|
function File_save(fname, new_fname, offset, size, fstep, fskip)
|
||||||
if (fstep and fskip) == nil then fstep = 0 fskip = 0 end
|
if (fstep and fskip) == nil then
|
||||||
|
fstep = 0
|
||||||
|
fskip = 0
|
||||||
|
end
|
||||||
local data = Get_file_data(fname)
|
local data = Get_file_data(fname)
|
||||||
local file = assert(io.open(new_fname, "w+b"))
|
local file = assert(io.open(new_fname, "w+b"))
|
||||||
if (io.type(file) == "file") then
|
if (io.type(file) == "file") then
|
||||||
@ -203,6 +220,7 @@ function File_save(fname, new_fname, offset, size, fstep, fskip)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
@ -214,6 +232,7 @@ function Get_Full_Filename(pname, fname, OStype)
|
|||||||
return (pname .. psep .. fname)
|
return (pname .. psep .. fname)
|
||||||
--print (fname, pname)
|
--print (fname, pname)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -245,10 +264,12 @@ function INCLUDING_INFO_ADDstart()
|
|||||||
local temp_cnt = tonumber(sj.get_define("__INCLUDE_LEVEL__"))
|
local temp_cnt = tonumber(sj.get_define("__INCLUDE_LEVEL__"))
|
||||||
|
|
||||||
if temp_cnt < ii_tmp_nested_level then
|
if temp_cnt < ii_tmp_nested_level then
|
||||||
print("Error in script INCLUDING_INFO_ADDstart: new nesting < old nesting\r\n","File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
print("Error in script INCLUDING_INFO_ADDstart: new nesting < old nesting\r\n",
|
||||||
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
elseif temp_cnt > 20 then
|
elseif temp_cnt > 20 then
|
||||||
print("Error in script INCLUDING_INFO_ADDstart: current nesting > 20\r\n","File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
print("Error in script INCLUDING_INFO_ADDstart: current nesting > 20\r\n",
|
||||||
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -264,12 +285,14 @@ function INCLUDING_INFO_ADDstart()
|
|||||||
ii_count = ii_count + 1
|
ii_count = ii_count + 1
|
||||||
ii_tmp_nested_level = temp_cnt
|
ii_tmp_nested_level = temp_cnt
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []---------------------------[]
|
-- []---------------------------[]
|
||||||
function INCLUDING_INFO_ADDend()
|
function INCLUDING_INFO_ADDend()
|
||||||
local temp_cnt = tonumber(sj.get_define("__INCLUDE_LEVEL__"))
|
local temp_cnt = tonumber(sj.get_define("__INCLUDE_LEVEL__"))
|
||||||
|
|
||||||
if temp_cnt > ii_tmp_nested_level then
|
if temp_cnt > ii_tmp_nested_level then
|
||||||
print("Error in script INCLUDING_INFO_ADDend: current nesting > old nesting\r\n","File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
print("Error in script INCLUDING_INFO_ADDend: current nesting > old nesting\r\n",
|
||||||
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -290,12 +313,14 @@ function INCLUDING_INFO_END()
|
|||||||
print(" File\t\t\t\t\t", "Start \tEnd \tSize ")
|
print(" File\t\t\t\t\t", "Start \tEnd \tSize ")
|
||||||
for i = 0, ii_count - 1, 1 do
|
for i = 0, ii_count - 1, 1 do
|
||||||
--print(tostring(ii_array[i][ii_nested_level]) .. " " .. ii_array[i][ii_file_name]:sub(ii_array[i][ii_file_name]:find("/")+1,-1),"\r\t\t\t\t\t", tostring(ii_array[i][ii_start_addr]), tostring(ii_array[i][ii_end_addr]), tostring(ii_array[i][ii_its_size]))
|
--print(tostring(ii_array[i][ii_nested_level]) .. " " .. ii_array[i][ii_file_name]:sub(ii_array[i][ii_file_name]:find("/")+1,-1),"\r\t\t\t\t\t", tostring(ii_array[i][ii_start_addr]), tostring(ii_array[i][ii_end_addr]), tostring(ii_array[i][ii_its_size]))
|
||||||
print(tostring(ii_array[i][ii_nested_level]) .. " " .. ii_array[i][ii_file_name]:sub(ii_array[i][ii_file_name]:find("/")+1,-1),"\r\t\t\t\t\t", string.format("%X",ii_array[i][ii_start_addr]), string.format("%X",ii_array[i][ii_end_addr]), tostring(ii_array[i][ii_its_size]))
|
print(
|
||||||
|
tostring(ii_array[i][ii_nested_level]) ..
|
||||||
|
" " .. ii_array[i][ii_file_name]:sub(ii_array[i][ii_file_name]:find("/") + 1, -1), "\r\t\t\t\t\t",
|
||||||
|
string.format("%X", ii_array[i][ii_start_addr]), string.format("%X", ii_array[i][ii_end_addr]),
|
||||||
|
tostring(ii_array[i][ii_its_size]))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -310,6 +335,7 @@ function Hrust_File(cmdLine, firstPath, secondPath, firstName, secondName)
|
|||||||
local fullCmdLine = cmdLine .. firstPath .. firstName .. " " .. secondPath .. secondName
|
local fullCmdLine = cmdLine .. firstPath .. firstName .. " " .. secondPath .. secondName
|
||||||
print(fullCmdLine)
|
print(fullCmdLine)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -325,6 +351,7 @@ function Number2Binary(n, bits)
|
|||||||
end
|
end
|
||||||
return table.concat(t)
|
return table.concat(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -364,6 +391,7 @@ function DCP_Page2Table (DCP_PAGE)
|
|||||||
end
|
end
|
||||||
return portsTable
|
return portsTable
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -385,7 +413,8 @@ function Generate_DCPASM_fromPAGE (DCP_Page_file, DCP_new_ASM)
|
|||||||
|
|
||||||
-- è ¯ª
|
-- è ¯ª
|
||||||
assert(DCP_TABLE_CODE:write(';', '\r\n'))
|
assert(DCP_TABLE_CODE:write(';', '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(';-----------------------------------------------------------------------;', '\r\n', '\r\n'))
|
assert(DCP_TABLE_CODE:write(';-----------------------------------------------------------------------;', '\r\n',
|
||||||
|
'\r\n'))
|
||||||
|
|
||||||
-- â ¡«¨æ
|
-- â ¡«¨æ
|
||||||
for i = 1, #DCP_TABLE, 3 do
|
for i = 1, #DCP_TABLE, 3 do
|
||||||
@ -405,6 +434,7 @@ function Generate_DCPASM_fromPAGE (DCP_Page_file, DCP_new_ASM)
|
|||||||
assert(DCP_TABLE_CODE:flush())
|
assert(DCP_TABLE_CODE:flush())
|
||||||
assert(DCP_TABLE_CODE:close())
|
assert(DCP_TABLE_CODE:close())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -414,20 +444,30 @@ end
|
|||||||
function increase_build(fname)
|
function increase_build(fname)
|
||||||
local fp
|
local fp
|
||||||
local build
|
local build
|
||||||
fp = assert(io.open(fname, "rb"))
|
build = get_build(fname) + 1
|
||||||
build = tonumber(fp:read("*all"))
|
|
||||||
assert(fp:close())
|
|
||||||
if type(build) == "nil" then
|
|
||||||
build = 0
|
|
||||||
end
|
|
||||||
build = build + 1;
|
|
||||||
--sj.insert_define("BUILD", build)
|
|
||||||
fp = assert(io.open(fname, "wb"))
|
fp = assert(io.open(fname, "wb"))
|
||||||
assert(fp:write(build))
|
assert(fp:write(build))
|
||||||
assert(fp:flush())
|
assert(fp:flush())
|
||||||
assert(fp:close())
|
assert(fp:close())
|
||||||
return build
|
return build
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
|
-- []===========================[]
|
||||||
|
function get_build(fname)
|
||||||
|
local fp
|
||||||
|
local build
|
||||||
|
fp = assert(io.open(fname, "rb"))
|
||||||
|
build = tonumber(fp:read("*all"))
|
||||||
|
assert(fp:close())
|
||||||
|
if type(build) == "nil" then
|
||||||
|
build = 0
|
||||||
|
end
|
||||||
|
return build
|
||||||
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -435,4 +475,5 @@ end
|
|||||||
function make_string_version(ver_, mod_, build_)
|
function make_string_version(ver_, mod_, build_)
|
||||||
return (tostring(ver_) .. "." .. tostring(mod_) .. "." .. tostring(build_))
|
return (tostring(ver_) .. "." .. tostring(mod_) .. "." .. tostring(build_))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
Loading…
Reference in New Issue
Block a user