Close

Assembly Language and More

A project log for Dodo: 6502 Game System

Handheld Game System featuring the 6502

Peter NoyesPeter Noyes 12/20/2016 at 02:560 Comments

The Dodo Playground now supports writing games in 6502 assembly. Some of the initial feedback I received for Dodo is that C is great and all, but a big part of the nostalgia for a 6502 retro system is to be able to write in 6502 assembly. I totally get it, I have had a lot of fun writing the system firmware in assembly. Now in the Playground, it is easy to make a language choice using the dropdown in the top navigation bar.

Here is a working example in Assembly

https://play.dodolabs.io/?code=51447f62

Making the change wasn't all that difficult, the back end compilation still uses cc65. Basically I just needed to author a thin set of assembly routines for calling each API, and update the backend with two different make files. The thin wrappers each hardcode an index into the API's jump table. The calling convention for C is pretty friendly for making assembly calls so that is left in place. Basically each parameter needs to be pushed onto a stack and I incorporated helper functions to do so. Here is a simple API call example:

        lda #<message
        ldx #>message
        jsr pushax
        jsr draw_string

To support this new functionality involved making changes across the board so it was a good opportunity to finally make the last changes to fully take advantage of the updated address space in Dodo 1.2 and above. Video memory and user code space are now moved around to now give a game 22KB of available RAM.

Another reason for supporting assembly in the playground is to make it much easier to iterate while implementing my 1KB challenge submission, which is to implement image compression for Dodo.

The challenge for 1KB is to compress a single image such that the image data and algorithm all fit under the 1KB limit. As an extension to this I also want to challenge myself to fit 20 compressed images into 8KB. With 20 images, the new 22KB of avilable RAM and the fact that Dodo operates at 20FPS, it should be possible to store 1s of looping video in memory and be able to play it back! I just need to find the perfect idea for a 1s monochrome video loop. Any ideas?

Discussions