Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Players finishing improvements #33

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/data/saa-player-i0-pp.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i0-pp.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i0.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i0.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i1-pp.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i1-pp.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i1.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i1.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i2-pp.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i2-pp.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i2.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i2.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i3-pp.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i3-pp.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-i3.bin
Binary file not shown.
Binary file modified assets/data/saa-player-i3.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-z0.bin
Binary file not shown.
Binary file modified assets/data/saa-player-z0.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-z1.bin
Binary file not shown.
Binary file modified assets/data/saa-player-z1.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-z2.bin
Binary file not shown.
Binary file modified assets/data/saa-player-z2.rtb
Binary file not shown.
Binary file modified assets/data/saa-player-z3.bin
Binary file not shown.
Binary file modified assets/data/saa-player-z3.rtb
Binary file not shown.
11 changes: 7 additions & 4 deletions doc/export_data_format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ focusing on shortest data length. All pointers in header are offsets from the
|---|---|---|---|---|---|---|---|
1. | 0 | T | T | T | T | T | T | T | # bit.7 not set for pattern data
|---|---|---|---|---|---|---|---|
2. | V | P | | S | S | S | S | S |
|---|---|---|---|---|---|---|---|
3. | C | C | C | C | O | O | O | O |
2. | V | P | N | S | S | S | S | S |
|---|---|---|---|---|---|---|---|
...
|---|---|---|---|---|---|---|---|
(4) | L | L | L | L | R | R | R | R |
(3) | C | C | C | C | O | O | O | O |
|---|---|---|---|---|---|---|---|
(4) | R | R | R | R | L | L | L | L |
|---|---|---|---|---|---|---|---|
(5) | D | D | D | D | D | D | D | D |
|---|---|---|---|---|---|---|---|
Expand All @@ -88,6 +88,9 @@ S - sample number:
[0] - no change
[1 - 31] - samples (1 - V)

N - no changing sample/ornament/command:
[1] - nothing more than note was changed (S = 0)

O - ornament number:
[0] - no change
[1 - 15] - ornaments (1 - F)
Expand Down
45 changes: 35 additions & 10 deletions src/compiler/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ export class CompilerOptimizer {
return this.patList.reduce<Set<number>>(
(set, patData) => {
for (let i = 0; i < patData.length; i++) {
const v = patData[i];
if ((v & 0x80) > 0) {
const t = patData[i];
if ((t & 0x80) > 0) {
// omit empty lines
continue;
}
let s = patData[++i];
if ((s & 0x20) > 0) {
// omit only tone changes
continue;
}
let o = patData[++i];
if ((s & 0x80) > 0) {
i++;
Expand Down Expand Up @@ -208,11 +213,16 @@ export class CompilerOptimizer {
private replaceSampleInPatterns(oldSmpNum: number, newSmpNum: number) {
this.patList?.forEach(patData => {
for (let i = 0; i < patData.length; i++) {
const v = patData[i];
if ((v & 0x80) > 0) {
const t = patData[i];
if ((t & 0x80) > 0) {
// omit empty lines
continue;
}
const s = patData[++i];
if ((s & 0x20) > 0) {
// omit only tone changes
continue;
}
const si = i;
const o = patData[++i];
if ((s & 0x80) > 0) {
Expand All @@ -238,11 +248,16 @@ export class CompilerOptimizer {
private renumberSamplesInPatterns(smpNum: number): void {
this.patList?.forEach(patData => {
for (let i = 0; i < patData.length; i++) {
const v = patData[i];
if ((v & 0x80) > 0) {
const t = patData[i];
if ((t & 0x80) > 0) {
// omit empty lines
continue;
}
const s = patData[++i];
if ((s & 0x20) > 0) {
// omit only tone changes
continue;
}
const si = i;
const o = patData[++i];
if ((s & 0x80) > 0) {
Expand Down Expand Up @@ -377,11 +392,16 @@ export class CompilerOptimizer {
private replaceOrnamentInPatterns(oldOrnNum: number, newOrnNum: number): void {
this.patList?.forEach(patData => {
for (let i = 0; i < patData.length; i++) {
const v = patData[i];
if ((v & 0x80) > 0) {
const t = patData[i];
if ((t & 0x80) > 0) {
// omit empty lines
continue;
}
const s = patData[++i];
if ((s & 0x20) > 0) {
// omit only tone changes
continue;
}
const o = patData[++i];
const oi = i;
if ((s & 0x80) > 0) {
Expand All @@ -407,11 +427,16 @@ export class CompilerOptimizer {
private renumberOrnamentsInPatterns(ornNum: number): void {
this.patList?.forEach(patData => {
for (let i = 0; i < patData.length; i++) {
const v = patData[i];
if ((v & 0x80) > 0) {
const t = patData[i];
if ((t & 0x80) > 0) {
// omit empty lines
continue;
}
const s = patData[++i];
if ((s & 0x20) > 0) {
// omit only tone changes
continue;
}
const o = patData[++i];
const oi = i;
if ((s & 0x80) > 0) {
Expand Down
31 changes: 19 additions & 12 deletions src/compiler/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,27 @@ export default class CompilerRender extends CompilerOptimizer {
else {
lastEmptyLines = 0;
data[offY++] = b1;
data[offY++] = b2;
data[offY++] = b3;
if (vol > 0) {
data[offY++] = vol;
}
if (cmd > 0) {
if (cmd === 0xB) { // Cmd-B
const backOffset = offY - breakToLineOffset + 2;
writeWordLE(data, offY, -backOffset);
offY += 2;
break;

if (b2 > 0 || b3 > 0) {
data[offY++] = b2;
data[offY++] = b3;
if (vol > 0) {
data[offY++] = vol;
}
if (cmd > 0) {
if (cmd === 0xB) { // Cmd-B
const backOffset = offY - breakToLineOffset + 2;
writeWordLE(data, offY, -backOffset);
offY += 2;
break;
}

data[offY++] = dat;
data[offY++] = dat;
}
}
else {
// optimization for only note changed
data[offY++] = 0x20;
}
}
}
Expand Down