a1k0n / jsxm

FastTracker 2 .xm module player in Javascript
http://www.a1k0n.net/code/jsxm/
MIT License
485 stars 36 forks source link

Fix non-existing pattern error #11

Closed hillerstorm closed 8 years ago

hillerstorm commented 8 years ago

Tested against remember_by_stalker_offyllecell303.xm.

The pattern at the last song position in player.xm.songpats is 26 which doesn't exist in player.xm.patterns. This causes p in the following line to return undefined resulting in multiple errors being logged:

var p = player.xm.patterns[player.cur_pat];
var r = p[player.cur_row];

To jump to the last pattern instantly set a breakpoint in xm.js:play(), run the following code in the debugger and then resume:

player.cur_songpos=29;player.cur_pat=25;player.cur_row=0
a1k0n commented 8 years ago

Ah, that's annoying. Thanks for adding, and nice tests! I am gonna have dinner and take a closer look.

My only concern is that it's an infinite loop if the song has length 0, but it might bail out earlier in that case. Not sure.

a1k0n commented 8 years ago

This makes sense and looks good. Would you mind adding a test for the song_looppos logic?

hillerstorm commented 8 years ago

Sure, I'll add a test or two and rebase

a1k0n commented 8 years ago

Awesome. Thanks!