Giter Site home page Giter Site logo

gmarty / jssms Goto Github PK

View Code? Open in Web Editor NEW
145.0 14.0 22.0 4.67 MB

JavaScript Sega Master System & Game Gear dynamic recompiling emulator.

Home Page: https://gmarty.github.io/jsSMS/

License: GNU General Public License v3.0

JavaScript 90.91% HTML 0.92% Smarty 8.16%
sega-master emulator interpreter recompiler dynamic-compiler

jssms's Introduction

jsSMS

jsSMS is a dynamic recompiling emulator for Sega Master System & Game Gear ROMs written in JavaScript and designed to be fast on mobile browsers.

Code

Originally, this is a JavaScript port of JavaGear by Chris White.

Original copyright: Copyright (C) 2002-2008 Chris White

The code then evolved from a basic interpreter to a complex recompiler able to run on mobile at full speed.

The recompilation code is located in src/compiler folder as well as technical insights.

Related talk

Video of the talk about JSSMS I gave at Reject.js 2013. There are also the slides in HTML.

Current state

  • Though state save and load functions are ported, there are not used and should be more JavaScript friendly (using JSON for example, see JSNES for an example of implementation).
  • Lightgun is not yet supported.
  • The recompiler is not compatible with Closure Compiler in advanced optimizations mode and will likely never be.

Many parts of the script are borrowed from JSNES, a NES emulator in JavaScript by Ben Firsh.

If you are looking for another SMS emulator in JavaScript, go to Miracle.

ToDos

  • Support latest IE.
  • Experiment with web workers for recompiled code generation.
  • Experiment with generator for calling interrupts.
  • Experiment with asm.js.

License

jsSMS - A dynamic recompiling emulator for Sega Master System & Game Gear written in JavaScript

Copyright (C) 2018 Guillaume Cedric Marty (https://github.com/gmarty)

Based on JavaGear Copyright (c) 2002-2008 Chris White

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

jssms's People

Contributors

gmarty avatar neophob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jssms's Issues

Use remainingBuffer() from XAudioJS to clock up emulator for audio buffering.

Before you fully implement audio in jsSMS, I must warn you to not use timestamps to check how much you should buffer out. Rather, you should retrieve how many samples are left in the API's buffer and determine how much to clock your emulator more so than the "base clocks per setInterval iteration." Google Chrome, Firefox, and Opera all experience different setInterval accuracy, and using timestamps has accuracy issues and will cause issues (If someone puts their computer to sleep and re-opens it, you'll lock it up if clocking by timestamp.).

DynamicAudio does not support buffer checking, and this is the reason why I wrote XAudioJS (Besides also supporting the web audio api in addition to the moz audio api and flash fallback). I also support resampling in xaudiojs, so you can sample to the hardware APU's actual sample rate, and not hack around it. This is why JSNES has issues with audio (Because proper buffering of audio in it does not exist).

Faster uint8 to int8 conversion

https://github.com/gmarty/jsSMS/blob/master/src/z80.js#L988

You can rewrite and remove that branch by changing it to:

d = (d << 24) >> 24;

Basically force the top bit of the 8 bits here to be the sign bit in an int32 with a logical shift left by 24 bits. Javascript will correctly convert it to its int8 value when you arithmetic right shift back by 24 bits (Sign bit fills the top 24 bits). The bonus you get out of this is using pure integer arithmetic with no branches. This operation is simple enough that a modern JIT should pick up on it. If this was an LSR ( >>> ) operation instead of an ASR ( >> ) operation for pushing the bits back, it'd be a NOP, but because it's an ASR operation, we're using its sign bit fill difference on purpose (I HARDLY ever see a JS web app ever use it for its intended difference).

How to load a game on page load? (RomData/RomFileName and readRomDirectly/loadROM"

Hi, first off, great emulator! Particularly enjoyed the presentation, though as you're about to see a lot of it went over my head.

I've had my head in the .min version of this for about 4-6 hours (oops) now trying to tackle how exactly to go about having it load a game as soon as the page loads. After getting lost in the sea of a's and b's and c'd and d' it finally occurred to me to open up the dev script and finally found this.

" // File Loading Routines
/**

  • Bypass config file and directly load rom."

above readRomDirectly! Except, I still can't seem to do much with it. What are the differences between RomData and RomFileName? I've tried changing the following values:

isRunning: !0
romData: "Sega Master System", / romFileName: "/jsSMS/rom/sms/rom.sms", (with these two values swapped around)

as well as fiddling around with removing the return false from readRomDirectly function, and trying to assign the paths to this.romfilename = in readRomDirectly as well but it just won't budge for me. Could you perhaps nudge me in the right direction please my man?

only playable with Sonic?

I tested out jsSMS with over 200 roms for SMS and GG.
I used Chrome, FireFox and Opera.
Is that emulator in very early pre-alpha phase?
I was able to run only Sonic The Hedgehog (for both SMS and GG) and other roms made black screen or didnt go above title screen which in most cases was frozen.
When looking to console, I noticed many throws of unsupported instructions (I guess Z80 or graphics).
I know that there is Miracle, but it does not support GG.

Bad working or not working ROMs

I tested a lot of ROMs for Sega Master System and more than half of them don't work fully or work with issues. But all these ROMs work on other emulators.

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.