Skip to content

Commit 4e766b9

Browse files
committed
fix: review findings for 61cc762
A random NFC pick from a TeensyROM directory counted the directory's full size, so on a C64 it could pick the GEOS 128 row the menu hides and fail with "needs a C128". It now counts the rows the menu lists.
1 parent 61cc762 commit 4e766b9

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎Source/Teensy/nfcScan.ino‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ bool nfcReadTagLaunch(uint8_t* uid, uint8_t uidLength)
360360
{
361361
//point at sub-dir
362362
LocalDirMenu = (StructMenuItem*)TeensyROMMenu[MenuNum].Code_Image;
363-
LocalNumItems = TeensyROMMenu[MenuNum].Size/sizeof(StructMenuItem);
363+
LocalNumItems = TeensyDirItemCount(&TeensyROMMenu[MenuNum]);
364364
}
365365
Printf_dbg("TR Dir Num = %d\n", MenuNum);
366366
}

‎Source/Teensy/tests/menu-selection.test.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ test('a menu change drops the old selection along with the old item count', () =
2525
const source = blankComments(fs.readFileSync(path.join(FIRMWARE_ROOT, 'Teensy.ino'), 'utf8'));
2626
assert.match(functionBody(source, 'SetMenu'), /\bSelItemFullIdx\s*=\s*0\s*;/);
2727
});
28+
29+
test('a random NFC pick from a TeensyROM directory chooses among the rows the menu lists', () => {
30+
// On a C64 the menu hides the GEOS 128 row, which a pick over the directory's full size can still land on
31+
const source = blankComments(fs.readFileSync(path.join(FIRMWARE_ROOT, 'nfcScan.ino'), 'utf8'));
32+
const body = functionBody(source, 'nfcReadTagLaunch');
33+
assert.doesNotMatch(body, /\.Size\s*\/\s*sizeof\s*\(\s*StructMenuItem\s*\)/);
34+
assert.match(body, /\bTeensyDirItemCount\s*\(\s*&\s*TeensyROMMenu\s*\[\s*MenuNum\s*\]\s*\)/);
35+
});

0 commit comments

Comments
 (0)