From 3337738dcc0a694e34ce06c58304fd4200fe0c96 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Mon, 11 May 2026 19:58:08 +0200 Subject: [PATCH] conversion script: fix silly bugs --- Source/scripts/convert_dvb.cpp | 7 ++++--- Source/scripts/convert_dvb.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/scripts/convert_dvb.cpp b/Source/scripts/convert_dvb.cpp index e09f609f..158e817a 100644 --- a/Source/scripts/convert_dvb.cpp +++ b/Source/scripts/convert_dvb.cpp @@ -70,7 +70,7 @@ u32 GetVoltageAndIndex(u32 dvbShift, u32 emc, u32 processId, DvbEntry *dvbTable, } s32 GetShift(u32 oldVoltage, u32 processId, DvbEntry *dvbTable, u32 index) { - return (oldVoltage - dvbTable[index].volts[processId]) / 25; + return (static_cast(oldVoltage) - static_cast(dvbTable[index].volts[processId])) / 25; } int main() { @@ -81,10 +81,11 @@ int main() { u32 emcMaxKhz = emcMaxMhz * 1000; u32 processId = GetProcessId(speedo); - u32 tableIndex = 0; + #define INVALID_TABLE_INDEX 32 + u32 tableIndex = INVALID_TABLE_INDEX; u32 oldVoltage = GetVoltageAndIndex(oldDvb, emcMaxKhz, processId, oldDvbTable, tableIndex); - if (oldVoltage == 0 || tableIndex == 0) { + if (oldVoltage == 0 || tableIndex == INVALID_TABLE_INDEX) { printf("Invalid values!\n"); return -1; } diff --git a/Source/scripts/convert_dvb.py b/Source/scripts/convert_dvb.py index b6b59d17..6f162548 100644 --- a/Source/scripts/convert_dvb.py +++ b/Source/scripts/convert_dvb.py @@ -12,7 +12,7 @@ class DvbEntry: volts: List[u32] -old_dvb_table = [ +oldDvbTable = [ DvbEntry(204000, [637, 637, 637]), DvbEntry(1331200, [650, 637, 637]), DvbEntry(1600000, [675, 650, 637]), @@ -24,7 +24,7 @@ old_dvb_table = [ DvbEntry(3200000, [800, 800, 775]), ] -new_dvb_table = [ +newDvbTable = [ DvbEntry(204000, [637, 637, 637]), DvbEntry(1331200, [650, 637, 637]), DvbEntry(1600000, [675, 650, 637]), @@ -36,7 +36,8 @@ new_dvb_table = [ DvbEntry(3200000, [1050, 1025, 1000]), ] -DVB_TABLE_SIZE = len(old_dvb_table) +DVB_TABLE_SIZE = len(oldDvbTable) +INVALID_TABLE_INDEX = 32 def print_and_scan(message: str) -> u32: @@ -67,7 +68,7 @@ def get_voltage_and_index( voltage = dvb_table[i].volts[process_id] + (25 * dvb_shift) return voltage, i - return 0, 0 + return 0, INVALID_TABLE_INDEX def get_shift( @@ -91,17 +92,17 @@ def main(): old_dvb, emc_max_khz, process_id, - old_dvb_table, + oldDvbTable, ) - if old_voltage == 0 or table_index == 0: + if old_voltage == 0 or table_index == INVALID_TABLE_INDEX: print("Invalid values!") return new_shift = get_shift( old_voltage, process_id, - new_dvb_table, + newDvbTable, table_index, ) @@ -109,4 +110,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file