Comments (15)
from jsgbc.
Hi @Lorengamboa
or using the menu item "Open ROM...":
note that I'm currently working on the Windows and Linux build, so we have just a MacOS Release.
- question:
There is currently no guide, but there will be one soon...
from jsgbc.
Lets say i want to save the game for the users so they can play anytime back when they return to the emulator.
Is there any way i can do that?
from jsgbc.
You can do this using Save States.
But they are currently broken, I will look at it this weekend.
A currently working solution could be the Battery Data File. This data is stored in the localstorage when the game modifies the cartridge RAM, so you're savegame should be restored automatically like a real gameboy is doing.
from jsgbc.
@Lorengamboa if you need any features or help with you're project, don't hesitate to ask.
from jsgbc.
from jsgbc.
You could use jsGBC-core in your project and load the game or savegame (from the server) into the gameboy.
Here is a basic example-implementation and this is the result.
from jsgbc.
from jsgbc.
The constructor needs a HTML canvas element as first argument.
once you've created your gameboy you can use the following api functions:
const gameboy = new GameBoy(canvasElement);
gameboy.replaceCartridge(romFileContent); // insert / change rom file (.gbc, .gb)
gameboy.loadBatteryFileArrayBuffer(savFileContent); // load a battery file (.sav)
UPDATE:
note that the arguments are file contents (Array Buffer). There are util functions you can use:
import { util } from "jsgbc-core";
util.uploadFile(["sav"]).then((savFileContent) => {
// code from above
});
from jsgbc.
from jsgbc.
from jsgbc.
from jsgbc.
I'm using JavaScript (ECMAScript 2016), so just the newest version of JavaScript. You can start the demo in jsGBC-core using:
npm start
but before you need to install the jspm_packages with:
jspm i
from jsgbc.
from jsgbc.
Yes, the only way to load ROMs or Battery Saves into the gameboy is using ArrayBuffers.
This is by design, because you have a lot of ways to load these data on your website.
(e.g. fetch Api, xhr requests, upload using input type file)
I could add a function to the util part of jsGBC-core:
async function loadRomFromServerIntoGameboy(url) {
const romFileContent = await util.fetchFileAsArrayBuffer(url);
gameboy.replaceCartridge(romFileContent);
}
But until then you can use the following functions:
async function loadRomFromServerIntoGameboy(url) {
const romFileContent = await fetchFileAsArrayBuffer(url);
gameboy.replaceCartridge(romFileContent);
}
async function fetchFileAsArrayBuffer(url) {
const res = await fetch(url);
return await res.arrayBuffer(); // Chrome, Opera, Firefox and Edge support only!
}
For question 2:
The only reasons you need a http server would be:
- loading HTML, CSS, JavaScript files and other assets for the website itself
- loading ROMs or Battery Saves from your server's database (using fetch api or other solutions)
jsGBC-core by itself does not require a http server, just a html canvas element to draw on.
If you do not want to use async / await, you can easily replace them with Promises
from jsgbc.
Related Issues (12)
- Use of createScriptProcessor HOT 3
- Embedding This Onto Github Website HOT 2
- Save States vs. Battery Files HOT 1
- How do I auto load a rom?
- add cheat system HOT 1
- add save states HOT 1
- move pixelated css class to jsGBC-ui HOT 1
- platform releases HOT 1
- add battery file HOT 1
- Action required: Greenkeeper could not be activated 🚨
- mobile releases HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsgbc.