mirror of
https://github.com/Tolik-Trek/Shared_Includes.git
synced 2026-06-15 09:01:33 +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,14 +22,15 @@ function Get_file_data(fname)
|
|||||||
file:close()
|
file:close()
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
-- ¢®§¢à é ¥â ç¨á«® ¨§ áâப¨ ¨«¨ ä ©« § ¤ ®© à §¬¥à®áâ¨
|
-- ¢®§¢à é ¥â ç¨á«® ¨§ áâப¨ ¨«¨ ä ©« § ¤ ®© à §¬¥à®áâ¨
|
||||||
-- get_number (file, offset, bytes)
|
-- get_number (file, offset, bytes)
|
||||||
|
|
||||||
function Get_number (str,offset, bytes)
|
function Get_number(str, offset, bytes)
|
||||||
local factor = 1
|
local factor = 1
|
||||||
local number = 0
|
local number = 0
|
||||||
if bytes > 8 then
|
if bytes > 8 then
|
||||||
@ -34,20 +38,21 @@ function Get_number (str,offset, bytes)
|
|||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = offset, offset+bytes-1, 1 do
|
for i = offset, offset + bytes - 1, 1 do
|
||||||
number = number + str:byte(i) * factor
|
number = number + str:byte(i) * factor
|
||||||
factor = factor * 256
|
factor = factor * 256
|
||||||
end
|
end
|
||||||
|
|
||||||
return number
|
return number
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
-- áç¨â ¥â ª®â஫ìãî á㬬㠤«ï ä ©«
|
-- áç¨â ¥â ª®â஫ìãî á㬬㠤«ï ä ©«
|
||||||
-- get_checksum(FileName, FileLength)
|
-- get_checksum(FileName, FileLength)
|
||||||
|
|
||||||
function Get_checksum(fname, fStart, fLength)
|
function Get_checksum(fname, fStart, fLength)
|
||||||
local reg_b = 0
|
local reg_b = 0
|
||||||
@ -61,7 +66,7 @@ function Get_checksum(fname, fStart, fLength)
|
|||||||
if (fLength == 0) or (fLength == nil) then fLength = data:len() end
|
if (fLength == 0) or (fLength == nil) then fLength = data:len() end
|
||||||
if (fStart == 0) or (fStart == nil) then fStart = 1 end
|
if (fStart == 0) or (fStart == nil) then fStart = 1 end
|
||||||
|
|
||||||
-- <09> áçñâ ª®â஫쮩 á㬬ë (ॣ¨áâàë BC - ¬« ¤è¨© ¨ DE - áâ à訩):
|
-- <09> áçñâ ª®â஫쮩 á㬬ë (ॣ¨áâàë BC - ¬« ¤è¨© ¨ DE - áâ à訩):
|
||||||
--print(fname, "fStart", fStart, "fLength", fLength)
|
--print(fname, "fStart", fStart, "fLength", fLength)
|
||||||
for i = fStart, fLength, 1 do
|
for i = fStart, fLength, 1 do
|
||||||
reg_c = reg_c + data:byte(i)
|
reg_c = reg_c + data:byte(i)
|
||||||
@ -80,12 +85,13 @@ function Get_checksum(fname, fStart, fLength)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--print (string.format("%x",i-1), string.format("%x", reg_d*16777216+reg_e*65536+reg_b*256+reg_c))
|
--print (string.format("%x",i-1), string.format("%x", reg_d*16777216+reg_e*65536+reg_b*256+reg_c))
|
||||||
end
|
end
|
||||||
|
|
||||||
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,31 +99,30 @@ 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,
|
||||||
bfOffBits = 10+1
|
bfOffBits = 10 + 1
|
||||||
}
|
}
|
||||||
local TBitmapInfoHeader = {
|
local TBitmapInfoHeader = {
|
||||||
biSize = 0+14+1,
|
biSize = 0 + 14 + 1,
|
||||||
biWidth = 4+14+1,
|
biWidth = 4 + 14 + 1,
|
||||||
biHeight = 8+14+1,
|
biHeight = 8 + 14 + 1,
|
||||||
biplanes = 12+14+1,
|
biplanes = 12 + 14 + 1,
|
||||||
biBitCount = 14+14+1,
|
biBitCount = 14 + 14 + 1,
|
||||||
biCompression = 16+14+1,
|
biCompression = 16 + 14 + 1,
|
||||||
biSizeImage = 20+14+1,
|
biSizeImage = 20 + 14 + 1,
|
||||||
biXPelsPerMeter = 24+14+1,
|
biXPelsPerMeter = 24 + 14 + 1,
|
||||||
biYPelsPerMeter = 28+14+1,
|
biYPelsPerMeter = 28 + 14 + 1,
|
||||||
biClrUsed = 32+14+1,
|
biClrUsed = 32 + 14 + 1,
|
||||||
biClrImportant = 36+14+1
|
biClrImportant = 36 + 14 + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
local bmp_height, bmp_width, bmp_image_size, bmp_colors, bmp_image_offset, temp_variable
|
local bmp_height, bmp_width, bmp_image_size, bmp_colors, bmp_image_offset, temp_variable
|
||||||
|
|
||||||
local data = Get_file_data(fname)
|
local data = Get_file_data(fname)
|
||||||
|
|
||||||
temp_variable = Get_number (data,TBitMapFileHeader.bfType, 2)
|
temp_variable = Get_number(data, TBitMapFileHeader.bfType, 2)
|
||||||
if temp_variable ~= 19778 then
|
if temp_variable ~= 19778 then
|
||||||
sj.error("error, not BMP file")
|
sj.error("error, not BMP file")
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
@ -129,33 +134,35 @@ function Get_bmp8bit_values(fname)
|
|||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
temp_variable = Get_number (data,TBitmapInfoHeader.biBitCount, 2)
|
temp_variable = Get_number(data, TBitmapInfoHeader.biBitCount, 2)
|
||||||
if temp_variable > 8 then
|
if temp_variable > 8 then
|
||||||
sj.error("error in BMP file, not 8-bit pallete, but", temp_variable)
|
sj.error("error in BMP file, not 8-bit pallete, but", temp_variable)
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
bmp_height = Get_number (data, TBitmapInfoHeader.biHeight, 4)
|
bmp_height = Get_number(data, TBitmapInfoHeader.biHeight, 4)
|
||||||
--[[
|
--[[
|
||||||
if bmp_height > 256 then
|
if bmp_height > 256 then
|
||||||
sj.error("error in BMP file, max height is 256, but", bmp_height)
|
sj.error("error in BMP file, max height is 256, but", bmp_height)
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
]]--
|
]] --
|
||||||
bmp_width = Get_number(data, TBitmapInfoHeader.biWidth, 4)
|
bmp_width = Get_number(data, TBitmapInfoHeader.biWidth, 4)
|
||||||
--[[
|
--[[
|
||||||
if bmp_width > 320 then
|
if bmp_width > 320 then
|
||||||
sj.error("error in BMP file, max width is 320, but", bmp_width)
|
sj.error("error in BMP file, max width is 320, but", bmp_width)
|
||||||
sj.exit(1)
|
sj.exit(1)
|
||||||
end
|
end
|
||||||
]]--
|
]] --
|
||||||
|
|
||||||
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,37 +171,47 @@ 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"
|
||||||
BinaryFormat == "so" then
|
elseif
|
||||||
if (os.execute("test -e /sbin/dynamic_pager")) then return "MacOS"
|
BinaryFormat == "dylib" then
|
||||||
else return "Linux"
|
return "MacOS"
|
||||||
end
|
elseif
|
||||||
|
BinaryFormat == "so" then
|
||||||
|
if (os.execute("test -e /sbin/dynamic_pager")) then
|
||||||
|
return "MacOS"
|
||||||
|
else
|
||||||
|
return "Linux"
|
||||||
|
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
|
||||||
if fstep + fskip ~= 0 then
|
if fstep + fskip ~= 0 then
|
||||||
local i = offset + 1
|
local i = offset + 1
|
||||||
repeat
|
repeat
|
||||||
file:write(string.sub(data, i, i+fstep-1))
|
file:write(string.sub(data, i, i + fstep - 1))
|
||||||
i = i+fstep+fskip
|
i = i + fstep + fskip
|
||||||
until i >= (offset + 1 + size - 1)
|
until i >= (offset + 1 + size - 1)
|
||||||
file:close()
|
file:close()
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
file:write(string.sub(data, offset+1, offset+1+size-1))
|
file:write(string.sub(data, offset + 1, offset + 1 + size - 1))
|
||||||
file:close()
|
file:close()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -203,113 +220,122 @@ function File_save(fname, new_fname, offset, size, fstep, fskip)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function Get_Full_Filename(pname, fname, OStype)
|
function Get_Full_Filename(pname, fname, OStype)
|
||||||
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
||||||
local psep = "/"
|
local psep = "/"
|
||||||
fname = string.gsub(string.match(fname, '\'.*\''), "'", "")
|
fname = string.gsub(string.match(fname, '\'.*\''), "'", "")
|
||||||
pname = string.gsub(string.match(pname, '\'.*\''), "'", "")
|
pname = string.gsub(string.match(pname, '\'.*\''), "'", "")
|
||||||
return (pname .. psep .. fname)
|
return (pname .. psep .. fname)
|
||||||
--print (fname, pname)
|
--print (fname, pname)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function INCLUDING_INFO_START()
|
function INCLUDING_INFO_START()
|
||||||
-- {ii_parent_num} = ii_count
|
-- {ii_parent_num} = ii_count
|
||||||
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
||||||
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
||||||
-- {ii_parent_num} = ii_count
|
-- {ii_parent_num} = ii_count
|
||||||
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
||||||
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
-- {ii_parent_num, ii_nested_level, ii_file_name, ii_start_addr, ii_end_addr, ii_its_size}
|
||||||
|
|
||||||
--ii_parent_num = 1
|
--ii_parent_num = 1
|
||||||
ii_nested_level = 1
|
ii_nested_level = 1
|
||||||
ii_file_name = 2
|
ii_file_name = 2
|
||||||
ii_start_addr = 3
|
ii_start_addr = 3
|
||||||
ii_end_addr = 4
|
ii_end_addr = 4
|
||||||
ii_its_size = 5
|
ii_its_size = 5
|
||||||
|
|
||||||
ii_array = {} -- nest level, data
|
ii_array = {} -- nest level, data
|
||||||
ii_count = 0
|
ii_count = 0
|
||||||
ii_nest = {}
|
ii_nest = {}
|
||||||
ii_nest_count = 0
|
ii_nest_count = 0
|
||||||
ii_tmp_nested_level = -1
|
ii_tmp_nested_level = -1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []---------------------------[]
|
-- []---------------------------[]
|
||||||
function INCLUDING_INFO_ADDstart()
|
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",
|
||||||
sj.exit(1)
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
elseif temp_cnt > 20 then
|
sj.exit(1)
|
||||||
print("Error in script INCLUDING_INFO_ADDstart: current nesting > 20\r\n","File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
elseif temp_cnt > 20 then
|
||||||
sj.exit(1)
|
print("Error in script INCLUDING_INFO_ADDstart: current nesting > 20\r\n",
|
||||||
end
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
|
sj.exit(1)
|
||||||
ii_array[ii_count] = {--ii_count, -- ii_parent_num
|
end
|
||||||
temp_cnt, -- ii_nested_level
|
|
||||||
sj.get_define("__FILE__"),
|
ii_array[ii_count] = { --ii_count, -- ii_parent_num
|
||||||
sj.current_address,
|
temp_cnt, -- ii_nested_level
|
||||||
0,0
|
sj.get_define("__FILE__"),
|
||||||
}
|
sj.current_address,
|
||||||
|
0, 0
|
||||||
ii_nest[ii_nest_count] = ii_count
|
}
|
||||||
ii_nest_count = ii_nest_count+1
|
|
||||||
ii_count = ii_count + 1
|
ii_nest[ii_nest_count] = ii_count
|
||||||
ii_tmp_nested_level = temp_cnt
|
ii_nest_count = ii_nest_count + 1
|
||||||
|
ii_count = ii_count + 1
|
||||||
|
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",
|
||||||
sj.exit(1)
|
"File: " .. sj.get_define("__FILE__"), "Line: " .. sj.get_define("__LINE__"))
|
||||||
end
|
sj.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
ii_nest_count = ii_nest_count-1
|
ii_nest_count = ii_nest_count - 1
|
||||||
temp_cnt = ii_nest[ii_nest_count]
|
temp_cnt = ii_nest[ii_nest_count]
|
||||||
ii_array[temp_cnt][ii_end_addr] = sj.current_address
|
ii_array[temp_cnt][ii_end_addr] = sj.current_address
|
||||||
ii_array[temp_cnt][ii_its_size] = sj.current_address - ii_array[temp_cnt][ii_start_addr]
|
ii_array[temp_cnt][ii_its_size] = sj.current_address - ii_array[temp_cnt][ii_start_addr]
|
||||||
|
|
||||||
ii_tmp_nested_level = ii_array[temp_cnt][ii_nested_level]
|
ii_tmp_nested_level = ii_array[temp_cnt][ii_nested_level]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []---------------------------[]
|
-- []---------------------------[]
|
||||||
function INCLUDING_INFO_END()
|
function INCLUDING_INFO_END()
|
||||||
local nest_sting_start = "Àó"
|
local nest_sting_start = "Àó"
|
||||||
local nest_sting_line = "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
|
local nest_sting_line = "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
|
||||||
local previous_nest = 0
|
local previous_nest = 0
|
||||||
|
|
||||||
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]))
|
|
||||||
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]))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function Hrust_File(cmdLine, firstPath, secondPath, firstName, secondName)
|
function Hrust_File(cmdLine, firstPath, secondPath, firstName, secondName)
|
||||||
cmdLine = string.gsub(string.match(cmdLine, '\'.*\''), "'", "")
|
cmdLine = string.gsub(string.match(cmdLine, '\'.*\''), "'", "")
|
||||||
firstPath = string.gsub(string.match(firstPath, '\'.*\''), "'", "")
|
firstPath = string.gsub(string.match(firstPath, '\'.*\''), "'", "")
|
||||||
secondPath = string.gsub(string.match(secondPath, '\'.*\''), "'", "")
|
secondPath = string.gsub(string.match(secondPath, '\'.*\''), "'", "")
|
||||||
firstName = string.gsub(string.match(firstName, '\'.*\''), "'", "")
|
firstName = string.gsub(string.match(firstName, '\'.*\''), "'", "")
|
||||||
secondName = string.gsub(string.match(secondName, '\'.*\''), "'", "")
|
secondName = string.gsub(string.match(secondName, '\'.*\''), "'", "")
|
||||||
|
|
||||||
local fullCmdLine = cmdLine .. firstPath .. firstName .. " " .. secondPath .. secondName
|
local fullCmdLine = cmdLine .. firstPath .. firstName .. " " .. secondPath .. secondName
|
||||||
print(fullCmdLine)
|
print(fullCmdLine)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
@ -317,101 +343,120 @@ end
|
|||||||
-- Š®¢¥àâ¨â ç¨á«® ¢ áâப㠥£® ¤¢®¨ç®£® ¯à¥¤áâ ¢«¥¨ï. bits - à §à冷áâì, ¥á«¨ ç¨á«® ¡®«ìè¥,
|
-- Š®¢¥àâ¨â ç¨á«® ¢ áâப㠥£® ¤¢®¨ç®£® ¯à¥¤áâ ¢«¥¨ï. bits - à §à冷áâì, ¥á«¨ ç¨á«® ¡®«ìè¥,
|
||||||
-- 祬 à §à冷áâì ¤«ï ¯à¥¤áâ ¢«¥¨ï í⮣® ç¨á« , â® ¡ã¤¥â ¡ £
|
-- 祬 à §à冷áâì ¤«ï ¯à¥¤áâ ¢«¥¨ï í⮣® ç¨á« , â® ¡ã¤¥â ¡ £
|
||||||
function Number2Binary(n, bits)
|
function Number2Binary(n, bits)
|
||||||
bits = bits-1
|
bits = bits - 1
|
||||||
local t = {}
|
local t = {}
|
||||||
for i = bits, 0, -1 do
|
for i = bits, 0, -1 do
|
||||||
t[#t+1] = math.floor(n/2^i)
|
t[#t + 1] = math.floor(n / 2 ^ i)
|
||||||
n = n%2^i
|
n = n % 2 ^ i
|
||||||
end
|
end
|
||||||
return table.concat(t)
|
return table.concat(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function DCP_Page2Table (DCP_PAGE)
|
function DCP_Page2Table(DCP_PAGE)
|
||||||
local portsTable = {}
|
local portsTable = {}
|
||||||
local bitAddress = 0
|
local bitAddress = 0
|
||||||
local bitTMPor = 0
|
local bitTMPor = 0
|
||||||
local bitMask = 0
|
local bitMask = 0
|
||||||
local CNFadr = 0
|
local CNFadr = 0
|
||||||
local CNFadrEnd = 0
|
local CNFadrEnd = 0
|
||||||
for Altera_Port = 1, 0xFF, 1 do
|
for Altera_Port = 1, 0xFF, 1 do
|
||||||
for CNF = 0, 3, 1 do
|
for CNF = 0, 3, 1 do
|
||||||
CNFadr = 1 + CNF * 0x1000
|
CNFadr = 1 + CNF * 0x1000
|
||||||
CNFadrEnd = CNFadr + 0x0FFF
|
CNFadrEnd = CNFadr + 0x0FFF
|
||||||
bitAddress = 0
|
bitAddress = 0
|
||||||
bitTMPor = 0
|
bitTMPor = 0
|
||||||
for address = CNFadr, CNFadrEnd, 1 do
|
for address = CNFadr, CNFadrEnd, 1 do
|
||||||
if (DCP_PAGE:byte(address) == Altera_Port) then
|
if (DCP_PAGE:byte(address) == Altera_Port) then
|
||||||
if bitAddress == 0 then
|
if bitAddress == 0 then
|
||||||
bitAddress = (address-1)
|
bitAddress = (address - 1)
|
||||||
bitTMPor = (address-1)
|
bitTMPor = (address - 1)
|
||||||
else
|
else
|
||||||
bitAddress = bitAddress & (address-1)
|
bitAddress = bitAddress & (address - 1)
|
||||||
bitTMPor = bitTMPor | (address-1)
|
bitTMPor = bitTMPor | (address - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (bitAddress ~= 0) then
|
if (bitAddress ~= 0) then
|
||||||
bitMask = ~bitAddress ~ bitTMPor
|
bitMask = ~bitAddress ~ bitTMPor
|
||||||
bitMask = bitMask & 0x3FFF
|
bitMask = bitMask & 0x3FFF
|
||||||
portsTable[#portsTable+1] = bitAddress
|
portsTable[#portsTable + 1] = bitAddress
|
||||||
portsTable[#portsTable+1] = bitMask
|
portsTable[#portsTable + 1] = bitMask
|
||||||
portsTable[#portsTable+1] = Altera_Port
|
portsTable[#portsTable + 1] = Altera_Port
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return portsTable
|
return portsTable
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
function Generate_DCPASM_fromPAGE (DCP_Page_file, DCP_new_ASM)
|
function Generate_DCPASM_fromPAGE(DCP_Page_file, DCP_new_ASM)
|
||||||
-- ¯®«ãç ¥¬ ¯®àâë ¨§ ä ©«
|
-- ¯®«ãç ¥¬ ¯®àâë ¨§ ä ©«
|
||||||
print(DCP_Page_file)
|
print(DCP_Page_file)
|
||||||
print(DCP_new_ASM)
|
print(DCP_new_ASM)
|
||||||
|
|
||||||
local data = Get_file_data(DCP_Page_file)
|
|
||||||
DCP_TABLE = DCP_Page2Table(data)
|
|
||||||
|
|
||||||
-- ®âªàë¢ ¥¬ ä ©« § ¯¨áì
|
local data = Get_file_data(DCP_Page_file)
|
||||||
local DCP_TABLE_CODE
|
DCP_TABLE = DCP_Page2Table(data)
|
||||||
|
|
||||||
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
-- ®âªàë¢ ¥¬ ä ©« § ¯¨áì
|
||||||
|
local DCP_TABLE_CODE
|
||||||
|
|
||||||
|
-- ã¡¨à ¥¬ ¨§ ¤¥ä © _¯ãâ¨_ä ©« ¢á直¥ â ¡ë ¨ ¯à®¡¥«ë «¨è¨¥. <20>ãâì ¤®«¦¥ ¡ëâì ®¡à ¬«ñ ®¤¨ à묨 ª ¢ëçª ¬¨
|
||||||
DCP_new_ASM = string.gsub(string.match(DCP_new_ASM, '\'.*\''), "'", "")
|
DCP_new_ASM = string.gsub(string.match(DCP_new_ASM, '\'.*\''), "'", "")
|
||||||
DCP_TABLE_CODE = assert(io.open(DCP_new_ASM, "w+"))
|
DCP_TABLE_CODE = assert(io.open(DCP_new_ASM, "w+"))
|
||||||
|
|
||||||
-- è ¯ª
|
-- è ¯ª
|
||||||
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
|
||||||
assert(DCP_TABLE_CODE:write(';', '\r\n'))
|
assert(DCP_TABLE_CODE:write(';', '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(' DW %', Number2Binary(DCP_TABLE[i], 14), '\r\n'))
|
assert(DCP_TABLE_CODE:write(' DW %', Number2Binary(DCP_TABLE[i], 14), '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(' DW %', Number2Binary(DCP_TABLE[i+1], 14), '\r\n'))
|
assert(DCP_TABLE_CODE:write(' DW %', Number2Binary(DCP_TABLE[i + 1], 14), '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(' DB #', string.format("%X",DCP_TABLE[i+2]), '\r\n'))
|
assert(DCP_TABLE_CODE:write(' DB #', string.format("%X", DCP_TABLE[i + 2]), '\r\n'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ¯®¤¢ «
|
-- ¯®¤¢ «
|
||||||
assert(DCP_TABLE_CODE:write('; DCP END MARKER', '\r\n'))
|
assert(DCP_TABLE_CODE:write('; DCP END MARKER', '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(' DW 0,0,0', '\r\n'))
|
assert(DCP_TABLE_CODE:write(' DW 0,0,0', '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(';-----------------------------------------------------------------------;', '\r\n'))
|
assert(DCP_TABLE_CODE:write(';-----------------------------------------------------------------------;', '\r\n'))
|
||||||
assert(DCP_TABLE_CODE:write(';'))
|
assert(DCP_TABLE_CODE:write(';'))
|
||||||
|
|
||||||
-- § ªàë⨥ ä ©«
|
-- § ªàë⨥ ä ©«
|
||||||
assert(DCP_TABLE_CODE:flush())
|
assert(DCP_TABLE_CODE:flush())
|
||||||
assert(DCP_TABLE_CODE:close())
|
assert(DCP_TABLE_CODE:close())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
|
|
||||||
|
|
||||||
-- []===========================[]
|
-- []===========================[]
|
||||||
-- Function reads number from file <fname>, increases it, creates define "BUILD" with the number and saves the number to <fname>.
|
-- Function reads number from file <fname>, increases it, creates define "BUILD" with the number and saves the number to <fname>.
|
||||||
-- With this function you can control count of compilations.
|
-- With this function you can control count of compilations.
|
||||||
function increase_build(fname)
|
function increase_build(fname)
|
||||||
|
local fp
|
||||||
|
local 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 fp
|
||||||
local build
|
local build
|
||||||
fp = assert(io.open(fname, "rb"))
|
fp = assert(io.open(fname, "rb"))
|
||||||
@ -420,14 +465,9 @@ function increase_build(fname)
|
|||||||
if type(build) == "nil" then
|
if type(build) == "nil" then
|
||||||
build = 0
|
build = 0
|
||||||
end
|
end
|
||||||
build = build + 1;
|
|
||||||
--sj.insert_define("BUILD", build)
|
|
||||||
fp = assert(io.open(fname, "wb"))
|
|
||||||
assert(fp:write(build))
|
|
||||||
assert(fp:flush())
|
|
||||||
assert(fp:close())
|
|
||||||
return build
|
return build
|
||||||
end
|
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