mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 12:32:05 +01:00
man
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
_Rft_oda_id = nil
|
||||
_Rft_file = ""
|
||||
_Rft_crc_data = ""
|
||||
_Rft_file_segment = 0
|
||||
_Rft_crc_segment = 0
|
||||
_Rft_toggle = false
|
||||
_Rft_last_id = -1
|
||||
_Rft_version = 0
|
||||
_Rft_crc_mode = -1
|
||||
_Rft_crc = false
|
||||
_Rft_crc_mode = 0
|
||||
_Rft_crc_sent = false
|
||||
_Rft_aid = 0xFF7F
|
||||
|
||||
@@ -18,12 +21,11 @@ local function start_rft()
|
||||
local seg = _Rft_file_segment
|
||||
local base = seg * 5 + 1
|
||||
|
||||
if not _Rft_crc_sent and _Rft_crc_mode ~= -1 and (seg % 8 == 0) then
|
||||
--- TODO: warn that if we have over 511 segments, we can't have CRC if we want per-segment crc
|
||||
_Rft_crc_sent = true
|
||||
if _Rft_crc_mode ~= 0 then warn("rft: No other crc than mode 0 is supported as of now") end
|
||||
_Rft_crc_mode = 0
|
||||
return true, (2 << 14), _Rft_aid, (1 << 12) | (0 & 7) << 9 | (0 & 0x1ff), crc16(_Rft_file)
|
||||
if not _Rft_crc_sent and _Rft_crc and (seg % 16 == 0) then
|
||||
local c = (1 << 12) | (_Rft_crc_mode & 7) << 9 | (_Rft_crc_segment & 0x1ff)
|
||||
_Rft_crc_segment = _Rft_crc_segment + 1
|
||||
if _Rft_crc_segment > #_Rft_crc_segment then _Rft_crc_segment = 0 end
|
||||
return true, (2 << 14), _Rft_aid, c, crc16(_Rft_file)
|
||||
else
|
||||
_Rft_crc_sent = false
|
||||
end
|
||||
@@ -49,7 +51,7 @@ end
|
||||
---Loads the file into RFT and initializes it if needed, note that this needs RDR2 mode 2
|
||||
---@param path string
|
||||
---@param id integer
|
||||
---@param crc boolean
|
||||
---@param crc integer|boolean
|
||||
function load_station_logo(path, id, crc)
|
||||
local file = io.open(path, "rb")
|
||||
if not file then error("Could not open file") end
|
||||
@@ -63,15 +65,26 @@ function load_station_logo(path, id, crc)
|
||||
if _Rft_version > 7 then _Rft_version = 0 end
|
||||
end
|
||||
|
||||
if crc then
|
||||
_Rft_crc = (crc ~= false)
|
||||
if crc and (crc == 0 or crc == true) then
|
||||
_Rft_crc_data = string.char(crc16(_Rft_file))
|
||||
_Rft_crc_mode = 0
|
||||
else
|
||||
_Rft_crc_mode = -1
|
||||
elseif crc and crc == 1 then
|
||||
for i = 1, #_Rft_file, 5*16 do _Rft_crc_data = _Rft_crc_data + string.char(string.byte(_Rft_file, i, 5*16)) end
|
||||
_Rft_crc_mode = 1
|
||||
elseif crc and crc == 2 then
|
||||
for i = 1, #_Rft_file, 5*32 do _Rft_crc_data = _Rft_crc_data + string.char(string.byte(_Rft_file, i, 5*32)) end
|
||||
_Rft_crc_mode = 2
|
||||
elseif crc and crc == 3 then
|
||||
for i = 1, #_Rft_file, 5*64 do _Rft_crc_data = _Rft_crc_data + string.char(string.byte(_Rft_file, i, 5*64)) end
|
||||
_Rft_crc_mode = 3
|
||||
elseif crc and crc == 4 then
|
||||
for i = 1, #_Rft_file, 5*128 do _Rft_crc_data = _Rft_crc_data + string.char(string.byte(_Rft_file, i, 5*128)) end
|
||||
end
|
||||
|
||||
if #_Rft_file > 262143 then error("The file is too large", 2) end
|
||||
if _Rft_oda_id == nil then start_rft() end
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
set_oda_id_data_rds2(_Rft_oda_id, #_Rft_file | (id & 63) << 18 | (_Rft_version & 7) << 24 | ((_Rft_crc_mode ~= -1) and 1 or 0) << 27)
|
||||
set_oda_id_data_rds2(_Rft_oda_id, #_Rft_file | (id & 63) << 18 | (_Rft_version & 7) << 24 | (_Rft_crc and 1 or 0) << 27)
|
||||
_Rft_last_id = id
|
||||
end
|
||||
Reference in New Issue
Block a user