mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-30 16:59:15 +02:00
rft fucking works
This commit is contained in:
+5
-1
@@ -350,4 +350,8 @@ function set_oda_id_data_rds2(oda_id, data) end
|
|||||||
---@param data integer
|
---@param data integer
|
||||||
---@param file_related boolean
|
---@param file_related boolean
|
||||||
---@return integer oda_id
|
---@return integer oda_id
|
||||||
function register_oda_rds2(aid, data, file_related) end
|
function register_oda_rds2(aid, data, file_related) end
|
||||||
|
|
||||||
|
---Loads the file into RFT and initializes it if needed, note that this needs RDR2 mode 2
|
||||||
|
---@param path string
|
||||||
|
function load_rft_file(path) end
|
||||||
|
|||||||
+10
-26
@@ -7,30 +7,21 @@ local function start_rft()
|
|||||||
if _Rft_oda_id == nil then
|
if _Rft_oda_id == nil then
|
||||||
_Rft_oda_id = register_oda_rds2(0xFF7F, 0, true)
|
_Rft_oda_id = register_oda_rds2(0xFF7F, 0, true)
|
||||||
set_oda_handler_rds2(_Rft_oda_id, function ()
|
set_oda_handler_rds2(_Rft_oda_id, function ()
|
||||||
if #_Rft_file == 0 then
|
if #_Rft_file == 0 then return false, 0, 0, 0, 0 end
|
||||||
return false, 0, 0, 0, 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local total_segments = math.ceil(#_Rft_file / 5)
|
local total_segments = math.ceil(#_Rft_file / 5)
|
||||||
local seg = _Rft_file_segment
|
local seg = _Rft_file_segment
|
||||||
local base = seg * 5 + 1
|
local base = seg * 5 + 1
|
||||||
|
|
||||||
local function b(i)
|
local function b(i) return string.byte(_Rft_file, base + i) or 0 end
|
||||||
return string.byte(_Rft_file, base + i) or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local word1 =
|
local word1 = (((_Rft_toggle and 1 or 0) << 7) | ((seg >> 8) & 0x7F))
|
||||||
(((_Rft_toggle and 1 or 0) << 7) |
|
|
||||||
((seg >> 8) & 0x7F))
|
|
||||||
|
|
||||||
local word2 =
|
local word2 = ((seg & 0xFF) << 8) | b(0)
|
||||||
((seg & 0xFF) << 8) | b(0)
|
|
||||||
|
|
||||||
local word3 =
|
local word3 = (b(1) << 8) | b(2)
|
||||||
(b(1) << 8) | b(2)
|
|
||||||
|
|
||||||
local word4 =
|
local word4 = (b(3) << 8) | b(4)
|
||||||
(b(3) << 8) | b(4)
|
|
||||||
|
|
||||||
_Rft_file_segment = seg + 1
|
_Rft_file_segment = seg + 1
|
||||||
if _Rft_file_segment >= total_segments then
|
if _Rft_file_segment >= total_segments then
|
||||||
@@ -40,23 +31,16 @@ local function start_rft()
|
|||||||
|
|
||||||
return true, (2 << 12) | word1, word2, word3, word4
|
return true, (2 << 12) | word1, word2, word3, word4
|
||||||
end)
|
end)
|
||||||
set_rds2_mode(2)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function load_rft_file()
|
function load_rft_file(path)
|
||||||
local file = io.open("/tmp/rft_test", "rb")
|
local file = io.open(path, "rb")
|
||||||
if not file then error("Could not open file") end
|
if not file then error("Could not open file") end
|
||||||
_Rft_file = file:read("*a")
|
_Rft_file = file:read("*a")
|
||||||
file:close()
|
file:close()
|
||||||
if #_Rft_file > 262143 then error("The file is too large", 2) end
|
if #_Rft_file > 262143 then error("The file is too large", 2) end
|
||||||
if _Rft_oda_id == nil then start_rft() end
|
if _Rft_oda_id == nil then start_rft() end
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
set_oda_id_data_rds2(_Rft_oda_id, #_Rft_file | 48 << 18) --- 48 for testing, change to 0 or something else in the future
|
set_oda_id_data_rds2(_Rft_oda_id, #_Rft_file | 0 << 18)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local _old_on_state_rft = on_state
|
|
||||||
-- function on_state()
|
|
||||||
-- start_rft()
|
|
||||||
-- if type(_old_on_state_rft) == "function" then _old_on_state_rft() end
|
|
||||||
-- end
|
|
||||||
Reference in New Issue
Block a user