Skip to content

Commit

Permalink
Implement Compiler dialog (#10)
Browse files Browse the repository at this point in the history
+ binary rendering of song data and proper rellocable player
  • Loading branch information
mborik committed Nov 20, 2022
1 parent 84a2c75 commit 5052547
Show file tree
Hide file tree
Showing 39 changed files with 1,621 additions and 11 deletions.
Binary file added assets/data/saa-player-i0-pp.bin
Binary file not shown.
Binary file added assets/data/saa-player-i0-pp.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i0.bin
Binary file not shown.
Binary file added assets/data/saa-player-i0.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i1-pp.bin
Binary file not shown.
Binary file added assets/data/saa-player-i1-pp.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i1.bin
Binary file not shown.
Binary file added assets/data/saa-player-i1.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i2-pp.bin
Binary file not shown.
Binary file added assets/data/saa-player-i2-pp.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i2.bin
Binary file not shown.
Binary file added assets/data/saa-player-i2.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i3-pp.bin
Binary file not shown.
Binary file added assets/data/saa-player-i3-pp.rtb
Binary file not shown.
Binary file added assets/data/saa-player-i3.bin
Binary file not shown.
Binary file added assets/data/saa-player-i3.rtb
Binary file not shown.
Binary file added assets/data/saa-player-z0.bin
Binary file not shown.
Binary file added assets/data/saa-player-z0.rtb
Binary file not shown.
Binary file added assets/data/saa-player-z1.bin
Binary file not shown.
Binary file added assets/data/saa-player-z1.rtb
Binary file not shown.
Binary file added assets/data/saa-player-z2.bin
Binary file not shown.
Binary file added assets/data/saa-player-z2.rtb
Binary file not shown.
Binary file added assets/data/saa-player-z3.bin
Binary file not shown.
Binary file added assets/data/saa-player-z3.rtb
Binary file not shown.
57 changes: 57 additions & 0 deletions src/commons/binary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* SAA1099Tracker: Binary utilities.
* Copyright (c) 2017-2019 Roman Borik <pmd85emu@gmail.com>
* Copyright (c) 2022 Martin Borik <martin@borik.net>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//---------------------------------------------------------------------------------------

export const equalsByteArrays = (
b1: Uint8Array, off1: number,
b2: Uint8Array, off2: number,
len: number
): boolean => {
if (len <= 0 || off1 < 0 || off1 >= b1.length || off2 < 0 || off2 >= b2.length) {
throw 'Argument(s) len, off1 or off2 is out of array ranges.';
}
if (off1 + len > b1.length || off2 + len > b2.length) {
return false;
}
for (let i: number = 0; i < len; i++) {
if (b1[off1 + i] !== b2[off2 + i]) {
return false;
}
}
return true;
};

export const stringToBytes = (str: string, asciiOnly?: boolean): Uint8Array =>
Uint8Array.from(
str.split('')
.map(c => c.charCodeAt(0))
.filter(c => asciiOnly ? (c >= 32 && c <= 126) : true)
);

export const bytesToString = (bytes: Uint8Array): string =>
String.fromCharCode.apply(null, bytes);

export const writeWordLE = (bytes: Uint8Array, offset: number, word: number) => {
bytes[offset] = (word & 0xFF);
bytes[offset + 1] = ((word >>> 8) & 0xFF);
};

0 comments on commit 5052547

Please sign in to comment.