diff --git a/test.txt b/test.txt
new file mode 100644
index 0000000..35f7388
Binary files /dev/null and b/test.txt differ
diff --git a/vif.html b/vif.html
index e69de29..21ec7d7 100644
--- a/vif.html
+++ b/vif.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/vif.js b/vif.js
index e69de29..72e33a6 100644
--- a/vif.js
+++ b/vif.js
@@ -0,0 +1,197 @@
+/* JVIV - JavaScript Voxel Image Viewer */
+JVIV = function() {
+ this.requires = ["CBDL/CBDL_graphics.js"];
+ var state = 0;
+ var vif_loader;
+ var loop;
+ var display;
+ var buffer = [];
+ this.Main = function() {
+ display = new CBDL.Graphics.Display(document.body, new CBDL.Graphics.VideoMode(512, 512, CBDL.Graphics.VM_SCALE), CBDL.Graphics.BACKEND.DIV);
+ display.Init();
+ display.Fill(25, 75, 25);
+ vif_loader = new VL.Loader('test.txt');
+ (loop = new CBDL.Loop(this, onLoop)).start();
+ };
+
+ var offset = 0;
+ var version = 0;
+ var type = 0;
+ var width = 0;
+ var height = 0;
+ var depth = 0;
+ var palette_size = 0;
+ var palettes = [];
+ var voxels = [];
+ var boxels = [];
+ function onLoop(loop_time) {
+ if (state == 0) {
+ if (vif_loader.state == 1) {
+ display.Fill(50, 50, 50);
+ loadVoxel(vif_loader.raw_data);
+ // We're done with the vif_loader, remove it
+ vif_loader = null;
+ // create our voxels as CBDL.Box(es)
+ for (var i=0;i= 0; i--) {
+ palette_size = (palette_size * 256) + buffer[offset+i];
+ }
+ palette_size += 1; // TODO: palette size in test.vif should be changed to 00 00 00 01, NOT absolutely 0
+ offset += 4; // move past pallete byte range
+ console.log("pallete size: "+palette_size);
+ palettes = [];
+ for (var i=0;i= 0; j--) {
+ voxels[i][3] = (voxels[i][3] * 256) + buffer[offset+j]; // pallete reference
+ }
+ offset += 4; // move past pallete byte range
+ console.log("voxel("+i+"): "+voxels[i]);
+ i++;
+ }
+
+ };
+}; CBDL.extend(CBDL.App, JVIV);
+
+/* VIF Library */
+var VL = VL || {};
+/** int loadVif(url, &byte_array)
+Attempts to load the first parameter using XMLHttpRequest() as binary data into byte_array.
+Returns 1 on failure, 0 on success
+**/
+VL.Loader = function(vif_file) {
+ this.state = 0;
+ this.raw_data = [];
+ var iframe = document.createElement('iframe');
+ iframe.content = 'text\/plain; charset=x-user-defined'
+ iframe.style.display = 'none';
+ document.body.appendChild(iframe);
+ CBDL.addEvent(iframe, 'load', (function(iframe, scope) {
+ return function() {
+ var doc = (iframe.contentDocument || iframe.contentWindow.document || window[iframe.id].document);
+ var pre = doc.body.getElementsByTagName("pre");
+ if (typeof pre[0] === 'undefined') {
+ data = doc.body.innerHTML;
+ } else {
+ data = pre[0].innerHTML;
+ }
+ for(var i=0;i