summaryrefslogtreecommitdiff
path: root/fym.js
diff options
context:
space:
mode:
authorDylan Muller <dylan.muller@corigine.com>2023-09-05 23:37:23 +0200
committerDylan Muller <dylan.muller@corigine.com>2023-09-05 23:37:23 +0200
commit008f39a5f4070332d547ad554088fc23d8936dd2 (patch)
tree4c11c9f0afa8fd0ed394f495daf8e96308348201 /fym.js
parentc1267582e2015c5077ea9ad93e29e5197491ce57 (diff)
downloademu8910-008f39a5f4070332d547ad554088fc23d8936dd2.tar.gz
emu8910-008f39a5f4070332d547ad554088fc23d8936dd2.zip
emu8910: core: Add demo files
Add demo files.
Diffstat (limited to 'fym.js')
-rw-r--r--fym.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/fym.js b/fym.js
new file mode 100644
index 0000000..8ee4cc3
--- /dev/null
+++ b/fym.js
@@ -0,0 +1,66 @@
+FYMReader = function(buffer) {
+ var psgDump = pako.inflate(new Uint8Array(buffer));
+ var ptr = 0;
+ var frame = 0;
+
+ function getInt() {
+ var r = 0;
+ for(var i = 0; i < 4; i++) r += psgDump[ptr++] << (8*i);
+ return r;
+ }
+
+ function getStr() {
+ var c, r = '';
+ while(c = psgDump[ptr++]) r += String.fromCharCode(c);
+ return r;
+ }
+
+ var offset = getInt();
+
+ var frameCount = getInt();
+ this.getFrameCount = function() {
+ return frameCount;
+ }
+
+ var loopFrame = getInt();
+ this.getLoopFrame = function() {
+ return loopFrame;
+ }
+
+ var clockRate = getInt();
+ this.getClockRate = function() {
+ return clockRate;
+ }
+
+ var frameRate = getInt();
+ this.getFrameRate = function() {
+ return frameRate;
+ }
+
+ var trackName = getStr();
+ this.getTrackName = function() {
+ return trackName;
+ }
+
+ var authorName = getStr();
+ this.getAuthorName = function() {
+ return authorName;
+ }
+
+ var loopCount = 0;
+ this.getLoopCount = function() {
+ return loopCount;
+ }
+
+ this.getNextFrame = function() {
+ var regs = [];
+ for(var r = 0; r < 14; r++) {
+ regs[r] = psgDump[r * frameCount + frame + offset];
+ }
+ if(++frame >= frameCount) {
+ loopCount++;
+ frame = loopFrame;
+ }
+ return regs;
+ }
+}