Git Product home page Git Product logo

Comments (15)

Lorengamboa avatar Lorengamboa commented on May 29, 2024 1

from jsgbc.

ardean avatar ardean commented on May 29, 2024

Hi @Lorengamboa

  1. question:
    You can open the .gbc / .gb files directly from your file explorer:
    image

or using the menu item "Open ROM...":

image

note that I'm currently working on the Windows and Linux build, so we have just a MacOS Release.

  1. question:
    There is currently no guide, but there will be one soon...

from jsgbc.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

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.

ardean avatar ardean commented on May 29, 2024

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.

ardean avatar ardean commented on May 29, 2024

@Lorengamboa if you need any features or help with you're project, don't hesitate to ask.

from jsgbc.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

ardean avatar ardean commented on May 29, 2024

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.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

ardean avatar ardean commented on May 29, 2024

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.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

ardean avatar ardean commented on May 29, 2024

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.

Lorengamboa avatar Lorengamboa commented on May 29, 2024

from jsgbc.

ardean avatar ardean commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.