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

Support mobile #21

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
miss files for mobile
  • Loading branch information
keicoon committed Dec 27, 2020
commit 470110b5ce9a6cec32c616d30ca7ec4ae6b4db4a
16 changes: 14 additions & 2 deletions js/gba.js
Original file line number Diff line number Diff line change
@@ -300,7 +300,19 @@ class GameBoyAdvance {
this.WARN("No save data available");
return null;
}
return new Blob([sram.buffer], { type: "application/octet-stream" });
if (window.URL) {
var url = window.URL.createObjectURL(
new Blob([sram.buffer], { type: "application/octet-stream" })
);
window.open(url);
} else {
var data = this.encodeBase64(sram.view);
window.open(
"data:application/octet-stream;base64," + data,
this.rom.code + ".sav"
);
}

}
storeSavedata() {
var sram = this.mmu.save;
@@ -344,7 +356,7 @@ class GameBoyAdvance {
this.irq.defrost(frost.irq);
this.io.defrost(frost.io);
}
log(level, message) {}
log(level, message) { }
setLogger(logger) {
this.log = logger;
}
30 changes: 16 additions & 14 deletions js/keypad.js
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ class GameBoyAdvanceKeypad {
}

virtualpadHandler(code, e) {
if(canVibrate) navigator.vibrate(50);
if (canVibrate) navigator.vibrate(50);

var toggle = 0;

@@ -213,19 +213,21 @@ class GameBoyAdvanceKeypad {
}
}
registerHandlers() {
var childNodes = document.getElementById('virtual-pad').childNodes;
for (var i = 0; i < childNodes.length; i++) {
var childNode = childNodes[i];
if (childNode.nodeName === "BUTTON") {
var code = childNode.id;
childNode.addEventListener(
'touchstart',
this.virtualpadHandler.bind(this, code)
);
childNode.addEventListener(
'touchend',
this.virtualpadHandler.bind(this, code)
);
if (g_bMobile) {
var childNodes = document.getElementById('virtual-pad').childNodes;
for (var i = 0; i < childNodes.length; i++) {
var childNode = childNodes[i];
if (childNode.nodeName === "BUTTON") {
var code = childNode.id;
childNode.addEventListener(
'touchstart',
this.virtualpadHandler.bind(this, code)
);
childNode.addEventListener(
'touchend',
this.virtualpadHandler.bind(this, code)
);
}
}
}
window.addEventListener(
8 changes: 1 addition & 7 deletions mobile.html
Original file line number Diff line number Diff line change
@@ -121,6 +121,7 @@
<script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
<!-- for rom-->
<script>
var g_bMobile = true;
var gba;
var runCommands = [];
var selected_rom_name = "";
@@ -209,9 +210,6 @@

function save() {
if (selected_rom_name === "") return updateStatus("NON SELECTED", 3000);

// save data
//var data = gba.downloadSavedata();
// save stat
try {
console.log('1', Serializer);
@@ -250,10 +248,6 @@
updateStatus("LOADED", 3000);
var data = this.response;

// save data
// runCommands.push(function () {
// gba.loadSavedataFromFile(loaded_data);
// });
// save stat
Serializer.deserialize(data, function (out) {
gba.pause();
Loading