Skip to content

Commit ef98dd9

Browse files
committed
TH_GDB: improve GraphMode byte handling from LogicalJoe's findings.
1 parent 0accd2b commit ef98dd9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/TypeHandlers/TH_GDB.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,19 @@ namespace
396396
}
397397
}
398398

399+
/*
400+
* Some info from LogicalJoe:
401+
* For the Graph Mode byte it doesn't check for 0x10, 0x20, 0x40, and 0x80;
402+
* Instead, if bit 4 is set, then it is read as a Function GDB, else if bit 5 then Polar, else if bit 6 then Parametric, else Sequential.
403+
* i.e. Mode byte 0x60 is interpreted as Polar (0x20).
404+
* The calculator will (should) never return a GDB where this matters
405+
*/
406+
static GraphMode getGraphModeFromRawValue(uint8_t val)
407+
{
408+
const uint8_t m = (val & 0x70) | 0x80;
409+
return static_cast<GraphMode>(m & -m);
410+
}
411+
399412
namespace tivars::TypeHandlers
400413
{
401414
data_t TH_GDB::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
@@ -482,7 +495,7 @@ namespace tivars::TypeHandlers
482495
}
483496

484497
GDB gdb = {
485-
.graphMode = static_cast<GraphMode>(data[3]),
498+
.graphMode = getGraphModeFromRawValue(data[3]),
486499
.formatSettings = *((FormatSettings*)(&data[4])),
487500
.seqSettings = *((SeqSettings*)(&data[5])),
488501
.extSettings = *((ExtModeSettings*)(&data[6])),

0 commit comments

Comments
 (0)