show the instruments

This commit is contained in:
Andy Sloane 2015-10-31 11:39:04 -07:00
commit 6dee1787f3
2 changed files with 16 additions and 3 deletions

15
xm.js
View file

@ -52,7 +52,9 @@ function RenderPattern(canv, pattern) {
// render instrument
var inst = data[1];
if (inst != -1) { // no instrument = render nothing
ctx.drawImage(fontimg, 8*(inst>>4), 4*8, 4, 8, dx, dy, 4, 8);
if (inst > 15) {
ctx.drawImage(fontimg, 8*(inst>>4), 4*8, 4, 8, dx, dy, 4, 8);
}
ctx.drawImage(fontimg, 8*(inst&15), 4*8, 4, 8, dx+4, dy, 4, 8);
}
dx += 12;
@ -1137,6 +1139,17 @@ function playXM(arrayBuf) {
var gfxpattern = document.getElementById("gfxpattern");
gfxpattern.width = _pattern_cellwidth * nchan + _pattern_border;
var instrlist = document.getElementById("instruments");
var list = [];
for (var i = 0; i < ninst; i++) {
var inst = instruments[i];
if (inst == null) continue;
var n = (i+1).toString(16);
if (i < 15) n = ' ' + n;
list.push(n + " " + inst.name);
}
instrlist.innerHTML = list.join("\n");
// start playing
gainNode.connect(audioctx.destination);
}