1 (edited by castpixel 2018-04-23 09:17:51)

Topic: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Hi all.

I'm making an (emulated) LCD handheld game, like game and watch.
The graphics/coding part is taken care of, but I was wondering, is it possible to coax anything better than beeps from the Sharp SM-510 MCU melody module?

Even pc-beeper arpeggios, something. Is Monotone my best bet if I want to be somewhat authentic?


edit: example https://www.youtube.com/watch?v=_cc2rMAigBA this sounds so promising. we could make some cool 1-bit music for those things. I'm not sure what hardware this runs on though. Those beeps are very sweet

or this https://www.youtube.com/watch?v=wWFPcHDAqX0

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Hi there!

Well, in order to be totally authentic, you'd need to implement an SM-510 emulator, and write your own player. In that case you're looking at quite a bit of work, obviously. It's not impossible, though wink MAME has some SM-510 emulation code, and it's even BSD licensed, yay!
https://github.com/mamedev/mame/blob/ma … 10/sm510.h
And there is an SM-5 series assembler, written in Java:
https://web.archive.org/web/20160112051 … arpasm.zip
as well as an emulator, from the same guy, though I'm not sure how useful it is or if it even does sound:
https://web.archive.org/web/20160112051 … tchman.zip

The problem is that the SM-510 is slow af, so you're not going to get really advanced stuff out of it. However if I understand correctly it actually has 4 bit output so maybe that's enough to mix two voices.

I have yet to find a full instruction set of that thing, though. However, appearantly it's similar to the TMS-1100... hmmm... also no idea what this "melody module" thing is all about.

The other, slightly less authentic route would be to implement a generic piezo emulator, and write a player for that. As neither PFM nor pulse interleaving will work on an actual piezo, I'd go for a Squeeker-type player. See here  for a technical discussion. Basically you generate pulse waves with reasonably low duties (say, 10-25 %) and OR them together for the final output.

In any case, please keep me up to date about this project, and let me know if I can help in any way.

3 (edited by castpixel 2018-04-23 13:02:32)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

utz you're the best, thank you so much for the info!
I'm not good enough to program my own engine, either the SM-510 or even the Squeeker. I'd like something that works out of the box, I can (barely) handle text-mode trackers. I don't even need 2 voices (although it would be great). Anything I can work with?

(irrelevant, but the arduboy piezo can be made to do PWM

https://www.youtube.com/watch?v=_t2MVpXfFzE )

thanks again

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Don't know of anything ready-made as such, but a Squeeker type generator would be trivial to implement. What language is your game written in? Simple (if slightly unsafe) C++ example:

uint16_t suma = 0;
uint16_t fdiva = 0;
uint16_t sumb = 0;
uint16_t fdivb = 0;

int16_t generate_pcm_sample() {
    suma += fdiva;
    sumb += fdivb;
    return ((suma | sumb) < 0x2000) ? 0x7000 : 0;

You'd just call this repeatedly to fill your sound buffer.

On the other hand, why not simply use some ZX Spectrum music? With an engine like Huby, you'd get some pretty authentic sound.
Example: https://irrlichtproject.bandcamp.com/tr … ny-fingers
I'd even make a track for you, though we'd need to talk about the budget in case you're planning for a commercial or ad-supported release.

Or you could use Shiru's PCSPE VSTi and whip up something in FL or Ableton.

5 (edited by castpixel 2018-04-23 14:26:05)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Tx so so much again.
My "language" is construct 2, I'm one of them artsy types who can't code properly

Well shiru's beepola is my favorite tracker anyway so huby it is!

Edit: and i would definitely hire you if someday someone wants to make a real lcd handheld outta my game. (a dual screen pinball rpg)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Ah ok. Yeah in that case you'd have to deal with HTML5 Audio API which might be slightly, err, unnerving yikes

Just fyi, Beepola is by Chris Cowley, but yeah, it's great smile Good luck and please post the game here when it's finished!

7 (edited by castpixel 2018-04-23 16:35:38)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

oh damn. Apologies to Chris Cowley then. I've never looked at the about screen, it's super charming too! And I sure will post here when it's done

8 (edited by Shiru 2018-04-25 12:33:39)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

As an alternative for Monotone, you can use my PCSPE VST plugin. It allows to create very complicated single channel music for actual PC Speaker, and you can use it with your favorite DAW. You can use some of my impulse responses to make it sound like a piezo as well.

Tamagotchi said to have a 6502 core inside. Bandai's LCD game is probably something along the lines of TMS1000.

It is sure possible to make some music routine for SM-510 that would sound more interesting than simple beeps. However, nothing has been done in this area yet, because this isn't some popular thing, it was reverse engineered and emulated just recently, and there is simply no development infrastructure yet. Like, you need an instruction set doc, an assembler, an emulator that allows to test your code, and you likely won't be able to run it on the original HW, as it uses mask ROM.

website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

Remembered a fun fact, by the way - there is some quite extensive docs on the instruction set of SM-510 and its internals in Russian. It has been published in an IT mag back in 1987, because the Game & Watch has been cloned back then, complete with the MCU and mask ROM containing the Game & Watch program and Nintendo word in an unused area of the ROM.

website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

You rock so much, thank you Shiru!

I'm using PCSPE and FLstudio's arpegiator, because ChipArp messes with the pitch bend too much hmm

Because of the arpegiator though, I can't be sure this would be playable by a piezo, although it sounds close enough. Maybe I should learn to use your 1-tracker

Played through your impulse responses (amazing work again).

Here's the first few measures of the Space Quest 3 intro. Do you think it sounds ok?


11 (edited by Shiru 2018-04-26 17:24:52)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

I would keep the overall pitch a little bit higher, it will sound better. That's due the way 8253 works, it does not restart count right away once a new divider is loaded, so if your pitch gets very low, like in a kick drum slide, to a few dozen hz, then you need a high pitched sound, it won't start until one period of the low pitched sound gets completed. So if the pitch was at, say, 24 Hz, it may take up to 1/24 second before higher pitch will take effect, but that maybe a time to play another pitch (arpeggiated) already, and it will sound distorted and kind of like having weird gaps or drop outs.

If you always keep pitch weil above the 'frame rate', it will sound good. I.e. if you use 60 hz update rate, try to keep your pitch not lower than 60 Hz, better to keep it higher than 60 Hz most of the time.

Arpeggios is not a problem for piezo speaker itself. Frequency response is, it cuts most of the low and mid-low end (like up to 700 Hz), and has various resonances in the higher end. Take a look:


website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

I will absolutely do that <3 Thank you so much Shiru. Even if it isn't true emulation, I want to be true to the spirit of the thing

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

if you want to do an authentic sound of a LCD game, you should also consider memory constrains. The early games didn't have much of jingles and complex sound effects just because the mask ROM size is so limited on SM-510 or TMS1x00. It is just 1024 to 4096 bytes for everything, and it seems the code is quite sparse on those 4-bit MCUs - I mean, it needs more operations to do things because of limitations of the architecture.

Later LCD games, however, had quite a lot of music pieces, sometimes polyphonic, with white noise, or even actual (not LPC encoded) voice samples - for example, some of Brick Game versions. Those might be using some kind of 6502 core, but it is not known for sure.

So I guess you need to pick a period of LCD gaming, and if you want to stick to early ones, keep everything at minimum, if you going for later ones, add more stuff.

website - 1bit music - other music - youtube - bandcamp - patreon (latest news there)

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

I'm going for more recent ones. Monophonic, to cut down cost, but maybe some cheap voice samples, and with enough space for programming at least one tune.

And two LCDs, like https://www.youtube.com/watch?v=F988Y0d4wrY

Thanks for all your help!

Re: Sharp SM-510 MCU (handheld LCD game) emulator/ tracker?

And by the way, I'm here if either of you ever need 1-bit pixels