Series of blog posts on C64 JavaScript emulator from scratch

Topics pertaining to the emulation or simulation of the 65xx microprocessors and their peripheral chips.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

There's no doubt Klaus has revolutionised our world with his test suite. Many thanks to him for that.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by Dr Jefyll »

BigEd wrote:
There's no doubt Klaus has revolutionised our world with his test suite. Many thanks to him for that.
Hear, hear!
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

I can't agree more.

Klaus's test suite and Visual6502 are two essential tools to have in your toolset when taking on a 6502 emulation project.
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

I just released part 9 of this series. In this blog I will be booting the C64 system with its Kernel Rom and Basic Rom. Here is the link:

https://emufromscratch.blogspot.co.za/2 ... ystem.html

Enjoy!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

Interesting development... is there a repo or a download for the final code at the end of each of the episodes?
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

There is indeed a way to access the final source code for each episode. When visiting my github site https://github.com/ovalcode/c64jscript just click on releases and you will see the source available for each episode as a zip file. The source code for my last post, for example, will be ch9.zip

Iuse the main branch for new development, so if you peek at this branch at any time you will get an idea what I was up to recently.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

That's great, thanks! I just wanted to test something - and it turns out Python's built-in one-line web server is enough for this purpose:

Code: Select all

ed$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [21/May/2016 15:59:30] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [21/May/2016 15:59:30] "GET /Memory.js HTTP/1.1" 200 -
127.0.0.1 - - [21/May/2016 15:59:30] "GET /Cpu.js HTTP/1.1" 200 -
127.0.0.1 - - [21/May/2016 15:59:30] "GET /basic.bin HTTP/1.1" 200 -
127.0.0.1 - - [21/May/2016 15:59:30] "GET /kernal.bin HTTP/1.1" 200 -
which might be easier, for some, than setting up a full-sized webserver. (Some people won't have Python and might not want it, but it's available for all platforms.)

Cheers
Ed
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

This is really awesome! I see it works out of the box for Ubuntu. The nice things is that it takes the current directory from which you invoked python as the context root of the web pages it is serving.

This is definitely going to be of great help since I always end up with copies of the source code in two places (e.g. tomcat webapps folder and the folder that is under git source control) and copying between the two.

Thanks Ed!
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

You're welcome - eventually I used this so often I didn't have to keep looking up how to do it! You can give a port number as a parameter - sometimes I run several, in different dirs.
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

Hi all!

I just released Part 10 of my series on a Emulator from scratch. In this blog we will code the emulation of a very basic C64 screen.

http://emufromscratch.blogspot.co.za/20 ... creen.html
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

Drawing text in the browser using the emulated character ROM - very nice!
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by whartung »

If you wanted to eliminate the web server requirement, you could shove the ROMs in to an uncompressed GIF, render the GIF to a (offscreen) canvas, and then get the pixel values (RGB, RGBA) from the image. That way you could bundle ROMS as simple static images.

Bit of a hack, but it should work.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by BigEd »

That's a neat idea! The visual6502 abuses 24-bit colour - each node's polygons carry their ID in the low bits of the colour space, which allows for easy ID of which polygon you clicked.
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

Very interesting concept! I am going to play a bit with this idea and see if I can give some feedback in my next Blog.

Thanks Whartung!
fastgear
Posts: 141
Joined: 27 Apr 2016
Location: South Africa

Re: Series of blog posts on C64 JavaScript emulator from scr

Post by fastgear »

Hi Whartung and BigEd

I had some spare time to play with the off screen GIF idea. This method works perfectly in Debian's Iceweasel browser.

Unfortunately, it looks like Google chrome and browsers on Android doesn't like this approach.

My first try on Chrome yielded the following error: Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.

Some Googling suggested the use of

imageObj.crossOrigin = "Anonymous";

Where imageObj is the JavaScript Image that used to load the gif into.

This yielded the following error:

Image from origin 'file://' has been blocked from loading by Cross-Origin Resource Sharing policy: Invalid response. Origin 'null' is therefore not allowed access.

It appears that with recent HTML specifications they have become more strict for situations where you try to access the data from a IMG tag:

https://developer.mozilla.org/en-US/doc ... bled_image

Anyway, in my next blog I will provide access to my code attempt.
Post Reply