mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-14 12:20:02 -04:00
Added Gameboy Emulator
This commit is contained in:
parent
b17dff81d6
commit
98487c2906
28 changed files with 6063 additions and 1 deletions
36
src/rom/ajax_reader.js
Normal file
36
src/rom/ajax_reader.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
var GameboyJS;
|
||||
(function (GameboyJS) {
|
||||
"use strict";
|
||||
|
||||
// A RomAjaxReader is able to load a file through an AJAX request
|
||||
var RomAjaxReader = function() {
|
||||
|
||||
};
|
||||
|
||||
// The callback argument will be called when a file is successfully
|
||||
// read, with the data as argument (Uint8Array)
|
||||
RomAjaxReader.prototype.setCallback = function(onLoadCallback) {
|
||||
this.callback = onLoadCallback;
|
||||
};
|
||||
|
||||
// This function should be called by application code
|
||||
// and will trigger the AJAX call itself and push data to the ROM object
|
||||
RomAjaxReader.prototype.loadFromUrl = function(url) {
|
||||
if (!url) {
|
||||
throw 'No url has been set in order to load a ROM file.';
|
||||
}
|
||||
var cb = this.callback;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.onload = function() {
|
||||
var rom = new Uint8Array(xhr.response);
|
||||
cb && cb(rom);
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
GameboyJS.RomAjaxReader = RomAjaxReader;
|
||||
}(GameboyJS || (GameboyJS = {})));
|
Loading…
Add table
Add a link
Reference in a new issue