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