Snake in 260 bytes for MD

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
Sonic 65
Posts: 1
Joined: Tue Sep 08, 2009 12:52 am

Snake in 260 bytes for MD

Post by Sonic 65 » Sat Sep 12, 2009 6:00 am

Hi guys - like snkenjoi and andlabs before me, I'm also from Sonic Retro. =P

I read through snkenjoi's thread on the smallest useful MD ROM and also TascoDLX's Megadrive demo, both of which inspired me to see if I could make some sort of simple game within the 260-byte TMSS limit that still worked on all MD models (note: this is untested on real hardware, but it works on all emulators, even Fusion with the TMSS bios).

The game pretty much plays like a basic Snake clone (collect food to grow bigger, if you hit yourself or the edges of the stage you die). There is no sound in this demo (not enough space :(). It doesn't really look very pretty, but I guess that's to be expected.

ROM link.

Known issues are that when you get a food piece, a grey 8x8 tile appears in the top-left corner for a split second, and the controls aren't really as responsive as I'd have liked them to be. However, the game is still very playable.

I'll release the source after I comment it fully. If you're really impatient, you could try disassembling it or something. =P

If you seriously want a screenshot before downloading, behold:


Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow

Post by Shiru » Sat Sep 12, 2009 6:13 am

This is good, though I think you could fit much more in 260 bytes.

The smallest possible Snake game was my obsession some time ago, I wanted to make it into 128 bytes or less. I've made 256 bytes version for ZX Spectrum with sound effects and restarting after game over (it was easily possible to make it smaller without sound, but it would be far from 128 bytes anyway), and few versions for 8086 PC without sound, but with restarting (it was 189 bytes or so). The most smallest Snake implementations I know is 144 bytes for 8086 PC and 121 byte for ZX Spectrum (written in FP calculator code).

Very interested
Posts: 145
Joined: Sun Jan 28, 2007 2:01 am

Post by Christuserloeser » Sat Sep 12, 2009 4:02 pm

Hey, thanks a lot for sharing ! :D - Gigabytes of free Dreamcast software for you


TmEE co.(TM)
Very interested
Posts: 2403
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City

Post by TmEE co.(TM) » Sat Sep 12, 2009 5:28 pm

Problem with 68K is that your typical opcode takes minimally 2 bytes, and lot of them take 4 or more bytes. Z80, 8080 and other 8bit CPUs have things in 1 or 2 bytes usually so you can have much more in same space.

Anyway, this is nice :D
Mida sa loed ? Nagunii aru ei saa ;)
Files of all broken links and images of mine are found here :

Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Thu Sep 17, 2009 2:07 pm

An even bigger problem is that the word "SEGA" has to be located at $0100. Thus, no TMSS-compatible ROM can be less than 260 bytes.

Beyond this, there is quite a bit of overhead just to get it to start up: 8 bytes for initial A7 and PC, 4 bytes for "SEGA", and 20 bytes for handling TMSS. But loading A0 saves 4 bytes later, so that's really 8 + 4 + 16 = 28 bytes, before you can do anything useful.

Then the VDP has to be set up, taking 12 more bytes just to set the registers, then you have to clear VRAM, then you have to set up the joypad (but I don't see it storing $40 to set up the control port).

So you can't directly compare the size of this against the size something where the hardware has already been initialized for you.

Posts: 2
Joined: Tue Nov 03, 2009 5:07 am

Post by jeanetti » Wed Nov 04, 2009 11:26 am

Where can i download a donkey kong country rom that doesn't lag? i want to download a donkey kong country rom (first one) to play with my super nintendo emulator but everytime i download one it lags...where can i download one that i can play at normal game speed and doesn't lag.
market samurai ~ marketsamurai ~
Last edited by jeanetti on Sat Nov 07, 2009 9:46 am, edited 1 time in total.

Very interested
Posts: 60
Joined: Mon Sep 28, 2009 11:26 am

Post by Flygon » Wed Nov 04, 2009 11:34 am

Uh, jeanetti, you've both hit the completely wrong topic and forum to be asking that question.

I suggest asking that question somewhere else. :wink:

Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Post by LocalH » Wed Nov 04, 2009 3:47 pm

Back on topic...

For those of us unencumbered by TMSS, I wonder what the smallest possible version of this would be. I've got a TMSS-less Gen1 with my trusty SMD so I could test to make sure it works on real hardware. Based on 8bitwizard's post, I see a minimum of 24 bytes that can be discarded (since you don't have to handle TMSS) but I'm wondering if one could abuse the header area (since there are no restrictions on executing code between $0-$1FF AFAIK, even on TMSS MDs). I bet you could get a TMSS-less version of this comparable to other systems (I would guess 160-192 bytes given the differences in instruction set).

Posts: 5
Joined: Sat Sep 20, 2008 7:30 pm
Location: Sweden

Post by Fred » Tue Nov 17, 2009 2:00 pm

bot wrote:lololololdonkey konglolololol

Post Reply