All Posts

August 2021 Update

It’s been more than a month since the 8bitworkshop 3.8.0 release, and I’ve been doing lots of prototyping behind the scenes. Some of this work will end up in dead ends, but we might learn a thing or two along the way. So I thought I’d document everything here.

ECMAScript (aka JavaScript) did not have a standardized module system until ES6, which was published in 2015. The ecosystem is still catching up. For example, some browsers still don’t support ES6 modules in web workers, and Node.js only recently added module support. TypeScript has always supported ES6 modules, but good luck getting it to consume old-style IIFE (“immediately-invoked function expression”) modules, or getting it to play nicely with your Node unit tests … etc.

To handle this hodge-podge of module formats, “bundlers” were developed. These tools eat a pile of source code, images, CSS, whatever – and regurgitate it back in whatever format you need. The downside is that they add another level of complexity to your build system. So I’d been avoiding bundlers, and just using the output from the TypeScript compiler directly from the index.html file.

Read more ...


8bitworkshop 3.8.0 Release

The big change in this release is a new Verilog backend. It translates your modules into WebAssembly!

The new backend is based on Verilator 4. It has a modest performance gain (20-50%), 64-bit support, and increased test compliance.

Other changes in the Verilog platform:

Read more ...


Emulator Performance: WebAssembly vs. JavaScript

The 8bitworkshop IDE integrates several different kinds of emulators that run in the web browser, each kind with different characteristics. Ideally, our emulators would be:

Performant – They should load quickly, and run at native speeds in modern browsers.

Read more ...


8bitworkshop 3.7.2 Release

A minor update with some bug fixes and some new features.

Added better support for ca65 assembler, though DASM is probably still the better choice for VCS programming. DASM has better parsing of macros (you can step through them in the debugger) and improved error messages.

Improved cycle analysis tool that counts up to 76*4 scanlines and properly inspects JSR subroutines.

Read more ...


3.7.0 Release: BASIC

Click here to program BASIC in the 8bitworkshop IDE now!

Dartmouth professors John G. Kemeny and Thomas E. Kurtz had the idea that every student should have access to a computer. But in those days, batch processing was the law of the land. Programmers would fill out a coding sheet, then a keypunch operator would create a deck of punch cards. The cards were fed into machines, and hours later you might receive results from your program – or if you were unlucky, an error report.

The Dartmouth (student newspaper), December 2, 1966

Read more ...


Fuzzing the Z-Machine

Playing text adventure games is sort of fun, but takes a lot of brain power. Nowadays we have all this spare CPU capacity going to waste.

What if we let the computer solve the game, and we just sit back and watch? We don’t even need any fancy neural network, we just need good old brute force.

We’re going to throw tons of semi-random input at a text adventure and see what happens. In the security world, this is called fuzzing.

Read more ...


8bitworkshop 3.6.0 Release

The 8bitworkshop IDE 3.6.0 is out, and we’ve added five more awesome platforms, as well as some nifty new debugging features!

Commodore’s VIC-II graphics and SID sound chip were originally destined for a next-gen game console. Engineering convinced CEO Jack Tramiel that a low-cost 64KB computer would be profitable, and thanks to having their own semiconductor fab (acquired from MOS Technology, along with the 6502) they were able to design the chipset in about five months.

Read more ...


Retargeting a C Compiler to 6502

I’ve written before about cc65 and some of its optimization challenges. It’s a stable compiler with a robust toolchain, but its code generator doesn’t full advantage of the 6502 when performing 8-bit operations. It places function parameters and many local variables on a separate stack, which requires many calls to helper functions.

I’ve done a survey of 6502 high-level languages, and while many are intriguing, none have the stability and C compatiblity of cc65.

So what’s so hard about the 6502? What’s keeping us from just retargeting a modern C compiler, bringing its powerful optimization routines to 6502? Well, it’s complicated. Like, really complicated.

Read more ...


Compiling a C-64 Emulator to WebAssembly

We use a variety of emulators in 8bitworkshop. Many of them, like most of the Z80 emulators, are written from scratch in JavaScript directly against our Platform API. This facilitates deep introspection into the emulator state, which comes in handy for things like debugger support and CPU visualization.

To save effort, we also integrate a couple of open source emulators. Atari 2600 support is courtesy of Javatari, and NES support is courtesy of JSNES. Each of them requires significant patching to expose hooks for the extra features the IDE supports, like breakpoints and bus-monitoring.

We can also use MAME, compiling it to WebAssembly using Emscripten. The trouble is that it’s a bit heavyweight and monolithic, and wants to be treated as an application, not a library. Due to the way it’s architected, interacting with the debugger via JavaScript isn’t really feasible. Even simple things like re-loading the ROM require a ton of Lua scripting.

Read more ...


8bitworkshop 3.5.0 Release

8bitworkshop now supports five additional 8-bit platforms!

Bally Astrocade

ColecoVision

Read more ...


The Mango One

In 1976, the first 6502-based hobbyist computers were just starting to appear. MOS Technology’s own KIM-1 had a numeric pad and seven-segment display. The competing SYM-1 could draw simple characters on an oscilloscope.

But the real breakthrough would come when the computer could receive input from a full keyboard, and output to a television set. Steve Wozniak demonstrated such a device at Homebrew Computer Club, a 6502-based machine that could drive a 40 column by 24 row character display, and could run Woz’s own Integer BASIC. This device would later be sold as the Apple I.

We’re going to create a similar device in the 8bitworkshop IDE using Verilog.

Read more ...


8bitworkshop 3.4.0 Release

We’ve added yet another platform to the 8bitworkshop IDE, the legendary Nintendo Entertainment System (NES)!

You can program in both C and 6502 assembler, and there are a ton of examples to get you started.

The IDE lets you write C using the cc65 compiler toolchain. While it has lower performance and greater code size than a well-written assembly program, you can still write a pretty good game in C. We use a fork of Shriu’s NESLib library to interface with NES hardware features, and Famitone to play music and sound.

Read more ...


Optimizing C array lookups for the 6502

Most of the platforms in the IDE that are powerful enough to support a C compiler are Z80-based. The Z80 isn’t the easiest target for C, but at least it has a lot of registers.

While the 6502 only has three 8-bit registers, the 6502 has strengths the Z80 doesn’t, as we’ll see here.

Let’s compare the two dominant C compilers for these CPUs. We’ll compile a function with the CC65 C compiler for the 6502, and then with the SDCC (Small Device C Compiler) for the Z80. We’ll call the function getValue():

Read more ...


Designing Hardware with Verilog

Big news! You can use the 8bitworkshop IDE to write Verilog code, and see it executed instantly in real-time on a simulated CRT. Most computers are fast enough to render a game at 60 Hz, which requires simulating Verilog at almost 5 million ticks per second. This is all done in JavaScript!

For example, here’s a simple clock divider module:

The IDE instantly compiles this and starts simulating, showing the output signals on the scope:

Read more ...


3.2.1: batari BASIC; the Sidebar

I came across Fred Quimby’s batari BASIC while developing the first version of 8bitworkshop, and was intrigued. This is a BASIC compiler that targets the 6502, and has specific support for Atari 2600 features. For example, you might define the playfield like this:

You could then set the foreground and background colors:

And animate the playfield, scrolling it downward each frame:

Read more ...


New Frontiers in High-Level 6502 Programming

Programming directly in 6502 gets a little fiddly, so a higher-level language can make things easier. There have been many attempts to tame the 6502 to make programming more palatable. Interpreted languages like BASIC, FORTH, and Pascal were popular back in the day, and Infocom games had their own custom VM to run on many platforms. But programmers are a stubborn bunch, and want speed as well as usability.

One approach is to just write a really powerful macro assembler that almost looks like a high-level language. In the 1980s, Lucasfilm developed Macross as “an assembler for people who hate assembly language”. More recently, NESHLA is targeted at NES development, but hasn’t seen much new development since 2005.

It’s been more than 40 years since Chuck Peddle sold the first 6502 samples out of a jar at a trade show. Intrepid developers are still making new languages for the CPU. Here’s a quick survey of some that have been active in the last few years:

Read more ...


3.2.0: Font tools, bankswitching, and cassette loading

New features in 8bitworkshop 3.2.0:

Keyboard Shortcuts for debugging:

Shotrcut

Read more ...


3.1.0: VCS Love, Instant Replay and Playable Links

In 8bitworkshop 3.1.0, we’ve given the VCS platform plenty of love:

Header Files: Header/include files are now viewable and editable via the IDE. But don’t use angle brackets in your includes, because they’ll pull in the old header file versions. Instead, use double quotes, for example:

Bugs Squashed: The emulator was suddenly stopping and displaying a blank screen, requiring a browser refresh. There were also problems when trying to load a ROM of the wrong size. Also, the Program Counter is no longer wonky when single-stepping.

Read more ...


Version 3.0.0 Released!

Version 3.0.0 of the 8bitworkshop IDE is out! Under the hood, there are lots of changes:

There’s a new browser storage backend, and your local changes will be migrated over the first time you start the IDE. This means you can save many more projects locally.

The site also now supports HTTPS, but be aware that local changes made on the HTTPS site won’t affect the HTTP site, and vice-versa.

Read more ...


Sincere Flattery in the Early Arcade Industry

“If I have seen a little further, it is by standing on the shoulders of giants.” – Isaac Newton

“Imitation is the sincerest form of flattery.” – Charles Caleb Colton

“Art is theft.” – Pablo Picasso

Read more ...