Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoadFiles() function help #12

Open
forahobby opened this issue Mar 15, 2019 · 0 comments
Open

LoadFiles() function help #12

forahobby opened this issue Mar 15, 2019 · 0 comments

Comments

@forahobby
Copy link

Can anyone tell me what is wrong with the follwing function? It reads the rom and base64 encodes the file but for some reason it won't load. vice.js

The console log shows the following:
UTOSTART: Autodetecting image type of disk-image.d64'. Filesystem Image: Error - Cannot open file disk-image.d64'.
Tape: Error - Cannot open file disk-image.d64' AUTOSTART: Error - Cannot open disk-image.d64'.
AUTOSTART: Error - `disk-image.d64' is not a valid file.

// Convert file to base64 string
function loadFiles(){
var xhr = new XMLHttpRequest();
xhr.open("GET", 'roms/last_ninja_s1.g64', true);
xhr.responseType = "blob";
xhr.onload = function () {
var reader = new FileReader();
reader.onload = function(event) {
var base64encoded = event.target.result;
var base64array = base64encoded.split(',');
var base64EncodedFile = base64array[1];
console.log(base64EncodedFile);
FS.createDataFile('/', 'disk-image.d64', window.atob(base64EncodedFile), true, true);
}
var file = this.response;
reader.readAsDataURL(file);
};
xhr.send();
}

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant