diff --git a/src/compiler/index.ts b/src/compiler/index.ts index b0070f5..31a287e 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -473,15 +473,37 @@ export default class Compiler extends CompilerRender implements CompilerOptions } private async preparePlayer() { - const playerTypeResult = + let playerTypeResult = (this.playerType < 0) ? this.playerTypeByData : Math.max(this.playerType, this.playerTypeByData); + if (this.songData != null) { + this.log(`Song data length: ${this.songData.length} bytes`); + this.log(`Minimal player version by song data: ${constants.CURRENT_PLAYER_MAJOR_VERSION}.${this.playerTypeByData}`); + } + if (this.playerType >= 0 && playerTypeResult !== this.playerType) { - this.log(`Requested player type (${this.playerType}) is ${ + this.log(`WARNING: Requested player version (1.${this.playerType}) is ${ (this.playerType > playerTypeResult) ? 'higher' : 'lower' - } than is needed for song data (${playerTypeResult})`, true); + } than is needed for song data (1.${playerTypeResult})!`); + + if (this.verbose && this.playerType < playerTypeResult) { + this.log('All unsupported commands by selected version of player will be ignored.'); + } + } + + /* + * FIXME Temporary solution for unfinished player versions 2 and 3 + * (https://github.com/mborik/SAA1099Tracker/issues/28) + */ + if (playerTypeResult > 1) { + if (this.playerType >= 0 && this.playerType < 2) { + playerTypeResult = this.playerType; + } + else { + throw 'Players of version 1.2 and 1.3 are not yet supported!'; + } } const resourceFileName = `assets/data/saa-player-${ @@ -527,14 +549,7 @@ export default class Compiler extends CompilerRender implements CompilerOptions } private finalizeOutputBinary() { - let totalLen = 0; - - if (this.songData != null) { - totalLen += this.songData.length; - - this.log(`Song data length: ${this.songData.length} bytes`); - this.log(`Minimal player type by song data: ${constants.CURRENT_PLAYER_MAJOR_VERSION}.${this.playerTypeByData}`); - } + let totalLen = this.songData?.length ?? 0; if (this.playerData != null) { totalLen += this.playerData.length; diff --git a/src/compiler/renderer.ts b/src/compiler/renderer.ts index 814eb77..deda3bb 100644 --- a/src/compiler/renderer.ts +++ b/src/compiler/renderer.ts @@ -167,11 +167,9 @@ export default class CompilerRender extends CompilerOptimizer { case 0x1 : // PORTAMENTO UP case 0x2 : // PORTAMENTO DOWN case 0x3 : // GLISSANDO TO GIVEN NOTE - case 0xA : // VOLUME SLIDE if ( (dat & 0x0F) === 0 || (dat & 0xF0) === 0 || // `period` nor `pitch` cannot be 0 - (cmd === 0xA && (dat & 0x0F) === 0x08) || // value change for VOLUME SLIDE cannot be 8 - (cmd === 0x3 && ton === 0) // missing tone for GLISSANDO + (cmd === 0x3 && ton === 0) // missing tone for GLISSANDO ) { removedCmd.add(cmdStr); cmd = 0; @@ -197,6 +195,9 @@ export default class CompilerRender extends CompilerOptimizer { } break; + case 0xA : // VOLUME SLIDE + break; + case 0xB : // BREAK CURRENT CHANNEL-PATTERN AND LOOP FROM LINE if (dat < 0 || dat >= i) { // line number cannot be >= actual line number removedCmd.add(cmdStr); @@ -349,12 +350,12 @@ export default class CompilerRender extends CompilerOptimizer { // vX.3 - 123+45+6789ABCDEF this.playerTypeByData = 3; } - else if (usedCmdId.has(6) || usedCmdId.has(7) || usedCmdId.has(8) || usedCmdId.has(9)) { - // vX.2 - 123+6789+ABCDEF + else if (usedCmdId.has(3) || usedCmdId.has(6) || usedCmdId.has(7) || usedCmdId.has(8) || usedCmdId.has(9)) { + // vX.2 - 12+36789+ABCDEF this.playerTypeByData = 2; } - else if (usedCmdId.has(1) || usedCmdId.has(2) || usedCmdId.has(3) || usedCmdId.has(10)) { - // vX.1 - 123A+BCDEF + else if (usedCmdId.has(1) || usedCmdId.has(2) || usedCmdId.has(10)) { + // vX.1 - 12A+BCDEF this.playerTypeByData = 1; } else { diff --git a/templates/dlg-compiler.html b/templates/dlg-compiler.html index da7d8e9..028d04d 100644 --- a/templates/dlg-compiler.html +++ b/templates/dlg-compiler.html @@ -30,8 +30,8 @@
-
-
+
+