Author Topic: CPCBox, your CPC emulator in Javascript  (Read 105886 times)

0 Members and 2 Guests are viewing this topic.

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
CPCBox, your CPC emulator in Javascript
« on: 20:49, 09 September 10 »
Hi everyone!
 
We are undergoing a disruption in the world of Internet browsers with the rise of powerful Javascript engines.
So, I've been working hard on writing an Amstrad CPC emulator in Javascript :)
Now, I've released my work and named it CPCBox.
 
Developed from scratch, it is mainly an experiment to push HTML5 to the limits and propose a new alternative to more conventional emulators.
 
But please be aware that CPCBox is currently in beta state. There's not much functionality in it for now, but I hope to gradually improve it in the future.
 
You can use the emulator online at this address: http://www.cpcbox.com/
« Last Edit: 13:01, 10 September 10 by phi2x »
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #1 on: 00:37, 14 September 10 »
I've just rolled out a new version of CPCBox.
 
What changed noticeably:
- CPC joystick emulation is added. That should make it much easier to play games on the emu.
- And the Opera issue with canvas is solved. I've made the canvas instancing more robust in CPCBox. That should also fix some older browsers like Firefox 3.0 which had less advanced Canvas API support.
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline nurgle

  • CPC6128
  • ****
  • Posts: 200
  • Country: de
    • index.php?action=treasury
  • Liked: 7
  • Likes Given: 12
Re: CPCBox, your CPC emulator in Javascript
« Reply #2 on: 01:08, 14 September 10 »
Very nice. You must be a masochist to do this in Javascript.  ;)


If you add sound, this thing will actually become useful. I only get a Framerate ~20 fps right now, but my PC is a few years old. So performance should not be a big issue in the future.


Btw.: I just played Bombjack, and although I know there is no sound I swear I could hear all the sound effects I know very very faint. I even turned the volume nob on my speakers to reassure me that it is just my imagination. The human mind is a strange thing.  :)

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.178
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3009
  • Likes Given: 5350
Re: CPCBox, your CPC emulator in Javascript
« Reply #3 on: 13:33, 14 September 10 »
I was really wondering how come there were no replies in this thread, but didn't have the time to post...

Anyhow, this is a great exercise that shows lots of promise. Of course a few things are needed, like sound, more speed, more compatibility, maybe gfx filters if possible (probably not), but it's really something!!! Well done!

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.178
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3009
  • Likes Given: 5350
Re: CPCBox, your CPC emulator in Javascript
« Reply #4 on: 14:26, 14 September 10 »
Heheheh I went to add it to the wiki's homepage and it's already there... :)

Offline Alcofribas

  • CPC464
  • **
  • Posts: 33
  • Country: tr
  • Who Dares Wins!
    • Sizin AMSTRAD
  • Liked: 1
  • Likes Given: 22
Re: CPCBox, your CPC emulator in Javascript
« Reply #5 on: 14:45, 14 September 10 »
Btw.: I just played Bombjack, and although I know there is no sound I swear I could hear all the sound effects I know very very faint. I even turned the volume nob on my speakers to reassure me that it is just my imagination. The human mind is a strange thing.  :)

You're suffering from Proustian memory.

http://www.haverford.edu/psych/ddavis/p109g/proust.html

Keep playing! :)
----------------------------------------------------------------------------
http://www.amstradcpc.com/blog
----------------------------------------------------------------------------

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.178
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3009
  • Likes Given: 5350

Offline nurgle

  • CPC6128
  • ****
  • Posts: 200
  • Country: de
    • index.php?action=treasury
  • Liked: 7
  • Likes Given: 12
Re: CPCBox, your CPC emulator in Javascript
« Reply #7 on: 19:30, 15 September 10 »
That was a great one...


Yes. Read through it all the way. Very good links.

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #8 on: 20:18, 03 October 10 »
CPCBox has been updated today.
 
Here is the changelog:
- CPC joystick fire button has been remapped to ctrl instead of spacebar to workaround PC keyboard harware limitation (ie: the dirty PC keyboard matrix problems when hitting more than 2 keys at the same time).
- Optimized Javascript code, yielding to ~10% speed improvement.
- Fixed huge issue in the overflow flag computation that affected ADD / ADC / SUB / SBC / CP instructions.
- Fixed half-carry flag computation in ADD IX,pp / ADD IY,rr instructions.
- Fixed another half-carry flag bug affecting ADC / SBC instructions.
- Fixed DD/FD instruction prefix fetching.
- Fixed computation of the undocumented flags in: BIT b,(IX+d) / BIT b,(IY+d) / CPD / CPDR / CPI / CPIR.
« Last Edit: 20:20, 03 October 10 by phi2x »
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: CPCBox, your CPC emulator in Javascript
« Reply #9 on: 05:54, 04 October 10 »
I got a $4000 Laptop, and that CPC in a Java Box tells me that it won't run with my browser... So, which browser is the browser of choice to use it?
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #10 on: 10:01, 04 October 10 »
I got a $4000 Laptop, and that CPC in a Java Box tells me that it won't run with my browser... So, which browser is the browser of choice to use it?
Well, you are misinformed: Java != Javascript.
And $4000 on a laptop !? Seems you have some serious money to spend on such futile things.
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline mahlemiut

  • CPC6128
  • ****
  • Posts: 284
  • Country: nz
  • Liked: 139
  • Likes Given: 51
Re: CPCBox, your CPC emulator in Javascript
« Reply #11 on: 14:02, 04 October 10 »
I get ~7fps.  It recommends Chrome 6 or later (I'm using Firefox 3.6.10, under Ubuntu 10.04 x86_64, CPU is a 2.53GHz C2D E7200).

Reminds me of MAME running Naomi games...  ;)
- Barry Rodewald
Amstrad CPC, Sharp X68000, Neo Geo Pocket, and Neo Geo AES system leader at HARP
http://www.homeactionreplay.org/

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #12 on: 00:14, 05 October 10 »
Good news for Opera lovers!
I made a quickfix to desactivate default Opera keyboard behaviour.
So now, Opera keystrokes don't interfere with CPCBox anymore. :)
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: CPCBox, your CPC emulator in Javascript
« Reply #13 on: 04:30, 05 October 10 »
I got a $4000 Laptop, and that CPC in a Java Box tells me that it won't run with my browser... So, which browser is the browser of choice to use it?
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline dragon

  • 6128 Plus
  • ******
  • Posts: 1.380
  • Country: es
  • Liked: 572
  • Likes Given: 482
Re: CPCBox, your CPC emulator in Javascript
« Reply #14 on: 11:08, 05 October 10 »
Not work in playstation 3 webbrowser  :(

(is netfront 3.5)
« Last Edit: 11:10, 05 October 10 by dragon »

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: CPCBox, your CPC emulator in Javascript
« Reply #15 on: 23:58, 05 October 10 »
Are you dumb or something ?
It's clearly stated on the website.

Thank you for your extraordinary kind help  :D
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline Xyphoe

  • 6128 Plus
  • ******
  • Posts: 888
  • Country: gb
    • GX4000.CO.UK
  • Liked: 316
  • Likes Given: 177
Re: CPCBox, your CPC emulator in Javascript
« Reply #16 on: 07:14, 06 October 10 »
Are you dumb or something ?
It's clearly stated on the website.

Yea that was a bit snappy and rude ... no need for that dude - people just want to try your stuff. We all appreciate any hard work done for the CPC scene, so chill out  :police:


TFM - It's using the new HTML5 standard for it's clever stuff, only some browsers will work 'properly' with this and other HTML5 based bits and bobs. The latest version of Google Chrome will do the trick. Running the site in Firefox on a very high end PC will still end up with stutter.

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1011
  • Likes Given: 926
Re: CPCBox, your CPC emulator in Javascript
« Reply #17 on: 11:59, 06 October 10 »
For me it also don't work  :'(
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline remax

  • 6128 Plus
  • ******
  • Posts: 1.077
  • Country: fr
  • Liked: 385
  • Likes Given: 421
Re: CPCBox, your CPC emulator in Javascript
« Reply #18 on: 14:42, 06 October 10 »
You only surf with your integrated browser?  :D

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1011
  • Likes Given: 926
Re: CPCBox, your CPC emulator in Javascript
« Reply #19 on: 18:25, 06 October 10 »
You only surf with your integrated browser?  :D

Pssssssssssssssssst....  :P
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 853
  • Liked: 409
  • Likes Given: 72
Re: CPCBox, your CPC emulator in Javascript
« Reply #20 on: 18:34, 06 October 10 »
Oddly, it seems to think IE9 doesn't support Javascript 1.5, which I'm pretty sure it does. Maybe some of the detection logic is not quite right?

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #21 on: 19:39, 06 October 10 »
Nope. I was as surprised as you are when I tested CPCBox on IE9 beta. But the truth is that Javascript support in Internet Explorer has been freezed on version 1.3.  :o

Microsoft has since switched to an edulcorated language called "JScript".
That thing is technically ECMAScript compatible but is in fact just another case of "Embrace, Extend and Extinguish technology". Needless to say that no other browser supports this JScript stuff.

Another approach to please IE would be to backport CPCBox to Javascript 1.3.
The main difference between Javascript 1.3 and 1.5 for CPCBox is the support of const declarations. These const could be switched to var declarations easily to be Javascript 1.3 compatible. The downside would be some performance impact. Not nice given how slow CPCBox currently is :/
But the point is I could have backported CPCBox to Javascript 1.3 to please IE. And in fact, I was really considering doing just that.

But then I stumbled upon another issue with IE. It doesn't support binary strings.
It's big issue because in Javascript, files can only be retrieved from the server as strings.
To workaround this, it would be necessary to convert binary files (ie: CPC snapshots) to Base64 encoded strings to store them on the server. And then decoding Base64 strings with Javascript on the client to retrieve the binary data.

To keep it short, pleasing IE9 means lots of specific code and dedicated effort to workaround its deficiencies and it's not worth it for a spare-time project.

To put the nail in the coffin, IE9 Javascript performance is not exactly stellar. From my own tests, it's around 30-40% the speed of Chrome 6. So it's not like CPCBox would be really usable in IE9 anyway.
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: CPCBox, your CPC emulator in Javascript
« Reply #22 on: 20:41, 06 October 10 »
TFM - It's using the new HTML5 standard for it's clever stuff, only some browsers will work 'properly' with this and other HTML5 based bits and bobs. The latest version of Google Chrome will do the trick. Running the site in Firefox on a very high end PC will still end up with stutter.

Ok, thank's a lot for the info. Will install Chrome and see what happens then.
Now, I also found the information onto his site, but who expects that you have to scroll down an empty page (that is displayed when using IE). You just see an error message on top of the screen, 90% below is just empty, then you scroll down a long way (depending on monitor and resolution) to find at the very bottom in small letters some message about Chrome 6+. The designer of that site should be sued  ;)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 468
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 162
  • Likes Given: 187
Re: CPCBox, your CPC emulator in Javascript
« Reply #23 on: 21:12, 06 October 10 »

Ok, thank's a lot for the info. Will install Chrome and see what happens then.
Now, I also found the information onto his site, but who expects that you have to scroll down an empty page (that is displayed when using IE). You just see an error message on top of the screen, 90% below is just empty, then you scroll down a long way (depending on monitor and resolution) to find at the very bottom in small letters some message about Chrome 6+. The designer of that site should be sued  ;)

I have tested CPCBox under IE6, IE7, IE8 and IE9 beta on standard 1024x768 resolution.
CPCBox is displayed somehow correctly (minus some odd IE CSS bugs :o ).
It doesn't show empty space. You don't have to scroll much to see the whole page, and the message about Chrome 6 is clearly visible.

You must have some weird Windows configuration. ::)
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: CPCBox, your CPC emulator in Javascript
« Reply #24 on: 21:44, 06 October 10 »
It doesn't matter if you have to scroll _much_. What matters is that you have to scroll, and nobody expects that. So you can't get the information easiely, just by looking at it.
If I ask then which browser would be good, you insult me instead of answering me "Take Chrome". What kind of guy are you???
 
But I had now a closer look at it (Quad Core, 3.8 GHz) and I only can tell you it's soooooo slow! It crashes more often and IMHO it's a piece of filty crap.
It's quality is as good as the "nice character" of it's producer. You better go back in your box and overwork it _completely_. And if you ever come back with something usable, then please _before_ also overwork your manners - they really need it!
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus