Emulating a 6502 system in JavaScript • Matt Godbolt • GOTO 2016

preview_player
Показать описание
This presentation was recorded at GOTO Chicago 2016. #gotocon #gotochgo

Matt Godbolt - Low-level Latency Geek, DRW @MattGodbolt

RESOURCES

ABSTRACT
It's said you should never meet your heroes. They're wrong! This is the story of Matt meeting and getting to know one of his heroes: the 6502 microprocessor. It powered the Apple IIe, the Commodore 64 and PET, the Atari 2600 and the NES.

And more importantly - to Matt, anyway - it powered the BBC Micro; a British computer that revolutionized and democratized computing in the UK in the 1980s. Keeping this piece of computer history alive is important. And what better way than to write a full-system, cycle-accurate emulator of the BBC Micro ... in Javascript?

Matt did just that and in this talk he'll explain how. Along the way we'll encounter Javascript performance issues, what it means to be completely accurate (and why it matters), 1980s game protection systems and processor bugs. We get to play some cool games too! [...]

Read the full abstract here:

#JavaScript #JS #6502 #Programming #MattGodbolt

Looking for a unique learning experience?

SUBSCRIBE TO OUR CHANNEL - new videos posted almost daily.
Рекомендации по теме
Комментарии
Автор

My proudest magazine moment was when after my (atari ST) game was published on the ST Format cover disk and I got my 50 quid, I got a random floppy disk in the post from some cracking group who'd taken the time to make a cracked and trained version of my game, that was used as a filler with a cracked commercial game. For some reason I found that way cooler :-)

This visual-6502 stuff is bonkers. Very cool.

howardjones
Автор

Amazing video, brings me back to 13 years old trying to learn assembly on my Apple II+. This completely demystifies emulators for me. Thanks

unclefreddy
Автор

Pretty much everyone, who's anyone in computing today, learned computing using BASIC and assembler, but we're still trying to push Python and Javascript on 9 year olds. We need to go back to simple machines, simple computing environments to make kids learn about computing. we're teaching them gigantic obj-oriented frameworks and it's really not fair to kids.

AbaseenPodcast
Автор

One error in the talk: You certainly can compare with both X and Y index registers on the 6502.

jcl
Автор

I liked the JIT English->American translations that were going on ;-)

jamesgrimwood
Автор

That was frustrating. He spends almost all his time on a read-through of how the original 8bits worked and very little time on describing how the emulator works.

vapourmile
Автор

This video brought back some good memories from the many hours I spent hacking games on the BBC micro, stepping through code with Exmon II looking for infinite lives pokes and other cheats. I too tried to write an emulator to crack one of my games that used hardware timers s in it's copy protection, but I had to admit defeat; it was a great challenge though.

stephenbrown
Автор

My proudest magazine moment was when after my (atari ST) game was published on the ST Format cover disk and I got my 50 quid, I got a random floppy disk in the post from some cracking group who'd taken the time to make a cracked and trained version of my game, that was used as a filler with a cracked commercial game. For some reason I found that way cooler :-)

This visual-6502 stuff is bonkers. Very cool.

nickolasnielson
Автор

Wow. Just 3510 transistors. And look at what it could do! The latest AMD K10 has 758 MILLION transistors. Crazy.

JustWastedHoursHere
Автор

What a 8 bit chip could do is impressive !

aymaneeljahrani
Автор

excellent talk! amazingly in-depth but very understandable. and didn't waste any of my time!

vaendryl
Автор

The thing he said about varying the volume register to play digitized sounds. On the C64 at least, the original SID chip had a leaky op-amp at the output pin (the designer, Yannes, knew this but didn't have the time to fix it properly) which output a DC level proportional to the master volume. What this meant was you could play 4-bit digis by piping them directly to the volume register. I love this kind of stuff!

DavidRomigJr
Автор

Gosh, it seems so ironic that In Britain, a television studio would foster educational programs in such a profound way; whereas in the States, television has been deliberately dumbing us down...

TheGenericNerd
Автор

Just thought...
Just need someone now to take an ARM processor that is running Javascript, placed in/on a board with some additional logic that emulates the 6502 signals on the processor pins. The board would be the same size as the original 6502 and have the inline pins down each side of the package. So basically you would have a 6502 processor, but inside it there will be an ARM chip running Javascript on top of an OS etc. You could then take a real BBC computer, place the ARM/Javascript/6502 processor in the original 6502 processor slot on the BBCs PCB and run BBC software on it. Then in 50 years time someone will write an emulator that mimics the ARM/Javascript/6502 processor using a Quantum processor using QSscript, then someone will suggest making an processor. Then in 100 years...

electricfutures
Автор

Hey is that a noopcat in the front row? :)

cellularmitosis
Автор

is there a reason the var pc started out at the address 0xfffe? Something special about RAM that I'm missing?

Calm_Energy
Автор

I'd like to know what the actual speed of the emulation is. Since you mentioned things that needed special optimization, I gather that the detailed timing-step emulation has trouble keeping up with real-time?

JohnDlugosz
Автор

Fascinating how you count cycles to change graphics modes in the middle of generating the display. This clever hack essentially implements what the Atari 800's graphics system did with a display list. Essentially it was a program for the graphics chip that said what mode to use for each line (with the option for an interrupt at the end of any given line). But Atari set it's processor speed to match the speed of the CRT scan to allow the exact same tricks you described. There are games where they used cycle counting to know how far over in each line the drawing was so that they could change the color registers for a section of the screen. (On the Atari, you had one-byte color registers, but depending on the graphics mode, usually had only four available (two bits per pixel identifying the color register to use.) I suspect the Atari 2600 pioneered such techniques, so system designers after that made sure the timings would work correctly. Interestingly, this means the PAL Ataris ran at a slightly different speed from the NTSC Ataris, and not all games took this into account.

All that means that many arcade-style games did all the logic during the vertical blank period where the electron beam was turned off to reset from the bottom right to the top left for the next frame. The vast majority of the CPU power was used to manage the graphics, even with Atari's advanced (for the day) graphics chips.

pfcrow
Автор

Calling the 1980's BBC The Computer Programme "Universally dreadful"?! How very dare you! Shame on you, they were fucking awesome. Respeck your elders, boy! Ian McNaught-Davis 'Mac' would be spinning in his grave hearing you slander his show like that. xP

rooneye
Автор

Using a switch case statement for emulation is bad practise and leads to bad performance. You may want to use an array of functions with a function for every instruction. That way the opcode can be used as an index into that array instead of doing hundreds of compares per instruction.

zzador