Skip to content

Commit

Permalink
fix: clipped import of banks
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Jul 9, 2024
1 parent 02ec3c4 commit 1ea61ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions __tests__/bas2txt.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ test('else if (2.08)', (t) => {
res = line2txt(src.basic); // to text
t.is(res, text, 'new IF correctly rendered');
});

test('lines are not being clipped', async (t) => {
const src = await readFile(__dirname + '/fixtures/clipped-lines.bnk');
const lines = file2txt(src).split('\n').filter(Boolean);

t.is(lines.length, 4);
});
Binary file added __tests__/fixtures/clipped-lines.bnk
Binary file not shown.
7 changes: 6 additions & 1 deletion bas2txt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export function bas2txt(data) {
C$checksum`
);

let txt = bas2txtLines(data.slice(unpack.offset, 128 + header.hFileLength));
// if hType is 0, then we're a type of program, so it's possible
// there's variables at the end of the file (as defined by hOffset)
// otherwise, the hFileLength is the length of the file
const length = header.hType === 0 ? header.hOffset : header.hFileLength;

let txt = bas2txtLines(data.slice(unpack.offset, 128 + length));

if (
header.autostart &&
Expand Down

0 comments on commit 1ea61ba

Please sign in to comment.