From 89e6b9c554cea3ec5a09c2928bffc5fd3c8e25a2 Mon Sep 17 00:00:00 2001 From: Andy Sloane Date: Thu, 19 Nov 2015 20:24:00 -0800 Subject: [PATCH] fix Dxx effect argument is BCD, so 0x10 actually means 10 decimal --- test/effects.js | 23 ++++++++++++++++------- xmeffects.js | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/effects.js b/test/effects.js index e30be1c..45ae79f 100644 --- a/test/effects.js +++ b/test/effects.js @@ -2,7 +2,6 @@ var XMPlayer = window.XMPlayer; // tests TODO: // - bxx: song jump -// - dxx: pattern jump // - rxy: retrigger w/ volume changes // low priority TODO (trivial or already covered by other tests): // - 5xy: porta+vol @@ -207,13 +206,23 @@ exports['test Dxx pattern jump'] = function(assert) { var xm = testdata.resetXMData(); xm.tempo = 2; xm.patterns[0] = [ - [[-1, -1, -1, 0x0, 0x00]], // --- -- -- 000 - [[49, 1, -1, 0x0, 0x00]], // C#4 1 -- 000 - [[-1, -1, -1, 0x0, 0x00]], // --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 00 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 01 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 02 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 03 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 04 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 05 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 06 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 07 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 08 --- -- -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 09 --- -- -- 000 + [[49, 1, -1, 0x0, 0x00]], // 0a C#4 1 -- 000 + [[-1, -1, -1, 0x0, 0x00]], // 0b --- -- -- 000 ]; + // argument is BCD, so 0x10 actually means 10 (decimal) xm.patterns[1] = [ [[-1, -1, -1, 0x0, 0x00]], // --- -- -- 000 - [[48, 1, -1, 0xd, 0x01]], // C-4 1 -- D01 + [[48, 1, -1, 0xd, 0x10]], // C-4 1 -- D10 [[-1, -1, -1, 0x0, 0x00]], // --- -- -- 000 ]; xm.songpats = [1, 0]; @@ -228,12 +237,12 @@ exports['test Dxx pattern jump'] = function(assert) { assert.equal(xm.channelinfo[0].period, 1152, "play C-4 on Dxx row"); - XMPlayer.nextTick(); // play C#4 1 -- 000 in pattern 0 + XMPlayer.nextTick(); // play row 0x0a C#4 1 -- 000 in pattern 0 assert.equal(xm.channelinfo[0].period, 1136, "play C#4 on following row"); assert.equal(XMPlayer.cur_songpos, 1, "songpos 0"); assert.equal(XMPlayer.cur_pat, 0, "pattern 1"); - assert.equal(XMPlayer.cur_row, 1, "row 1"); + assert.equal(XMPlayer.cur_row, 10, "row 10"); }; exports['test Gxx global volume'] = function(assert) { diff --git a/xmeffects.js b/xmeffects.js index e75d96f..0e8a7f1 100644 --- a/xmeffects.js +++ b/xmeffects.js @@ -122,7 +122,7 @@ function eff_t0_d(ch, data) { // pattern jump if (player.cur_songpos >= player.xm.songpats.length) player.cur_songpos = player.xm.song_looppos; player.cur_pat = player.xm.songpats[player.cur_songpos]; - player.cur_row = data - 1; + player.cur_row = (data >> 4) * 10 + (data & 0x0f) - 1; } function eff_t0_e(ch, data) { // extended effects!