Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Snepulator! My SMS/GG/SG-1000 emulator

Reply to topic
Author Message
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Snepulator! My SMS/GG/SG-1000 emulator
Post Posted: Fri Feb 17, 2023 10:23 am
Hi all,

For a very long time, I'd wanted to make my own emulator. I made a start back in 2017, and have been poking at it in my spare time over the past six years. The 'Snep' in Snepulator is short for snow leopard :3

While I've had my work-in-progress code (Linux version) up on GitHub since the start, I think now it's finally ready to call "released".

I've tried to include a few features that some other emulators tend to leave out:
- Anaglyph 3d glasses support, (red-cyan, red-green, magenta-green), along with an option to decrease the colour saturation to improve the 3d effect.
- Light phaser support, click / touch to shoot
- Paddle support, translating left/right keys into movement on the paddle, or a touch-slider on the Android port
- Making use of the backdrop colour, using a dimmed version of it to fill the space around the active area in the window (the active area sticks to an integer multiple of the Master System's native resolutions)

Along with a few of the usual features, like bios support, scanlines, save states. The main missing feature is that I haven't yet gotten around to adding support for the FM add-on.

I've not yet ported it to Windows, but the code can be found on my Github and built for Linux:
- https://github.com/JoppyFurr/Snepulator

I've also had a go at making a port of this this into my first Android app to see if I can turn my hobby into beer money. For this I split it into two versions; one being a paid version with Master System and Game Gear support; the other being a free SG-1000 only version to make it easier to check compatibility with your device:
- https://play.google.com/store/apps/details?id=net.snepulator.sg
- https://play.google.com/store/apps/details?id=net.snepulator.ms

I do hope in the future, once I find some more free time, to add FM support and to port to more platforms (Windows, WebAssembly, and possibly the 3DS to have a play with its autostereoscopic display)

Any feedback is welcome :3
california_bmx.png (85.1 KB)
california_bmx.png

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14939
  • Location: London
Reply with quote
Post Posted: Fri Feb 17, 2023 12:03 pm
You mentioned integer sizing, but I guess you ought to think about pixel aspect ratios, especially for Game Gear. That adds complexity of course, especially to preserve crisp pixels while also needing to interpolate to the screen resolution. On a sufficiently high resolution screen this thankfully becomes much less of an issue.

How did you handle the light phaser emulation? Meka has some reverse engineered factors to ensure that the various games pick exactly the point clocked, as their hcounter set to point centre logic is quite variable.

I’d recommend making use of whatever CI platform you like to have multi platform builds as much as is reasonable, especially for us dumb Windows users :)
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8702
  • Location: Paris, France
Reply with quote
Post Posted: Fri Feb 17, 2023 2:03 pm
(Nice to see more emulators using Dear ImGui. It seems particularly fit to that purpose, e.g. building low-level tools for a VM. There's a memory editor you can grab here and use with 3 lines of code: https://github.com/ocornut/imgui_club

I ought to use it for MEKA and then we can drop Allegro, but at this rate MEKA will be the last emulator with a GUI not using Dear ImGui haha.)
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Fri Feb 17, 2023 10:48 pm
Maxim wrote

How did you handle the light phaser emulation? Meka has some reverse engineered factors to ensure that the various games pick exactly the point clocked, as their hcounter set to point centre logic is quite variable.


For the phaser, I try to simulate roughly how it would appear on a real Master System / CRT. From where the user's cursor is, I define a circle of radius 10px. This circle represents the area of the CRT that is visible to the phaser. Based on the line number that is being drawn, I set the h_counter latch to the position of the left-edge of the circle. This should correspond to the rising-edge seen by the phaser.

Through trying out a few different games, it appeared that this solution resulted in the aim being slightly off to the left. My assumption here is that on a real system, the 'seen' h-counter values may be offset due to propagation delays as the signal makes its way through the CRT and into the phaser's sensor; with games accounting for this. To handle this offset, I add +24 to the h-counter latch value, which seems to give a decent result on the games I have tested.
  View user's profile Send private message Visit poster's website
  • Joined: 30 Dec 2008
  • Posts: 28
  • Location: Naples,Italy
Reply with quote
Post Posted: Sat Feb 18, 2023 9:53 am
JoppyFurr wrote
To handle this offset, I add +24 to the h-counter latch value, which seems to give a decent result on the games I have tested.


Hoping of a windows port so i must try this emulator, i think that the best option is to permit to edit this value in the gui so i can adjust as per game setting.

Good work however.
  View user's profile Send private message
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Post Posted: Tue Feb 21, 2023 8:11 am
I'm always in the mood to try out emulators for Android, since I love the dedicated emulation handheld devices out there.

...the Retroid Pocket 3+ just displays a black screen when running any ROM. It sounds fine though!
  View user's profile Send private message
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Wed Feb 22, 2023 12:04 pm
unfnknblvbl wrote
I'm always in the mood to try out emulators for Android, since I love the dedicated emulation handheld devices out there.

...the Retroid Pocket 3+ just displays a black screen when running any ROM. It sounds fine though!


Hi unfnknblvbl,

I'm not too familiar with the Retroid, but I can take a look in the weekend to see if there's anything special that needs to be done to support its graphics hardware. I think what I've got is all pretty standard OpenGL ES3.

Just to check:
* Did the Snepulator logo show in the middle of the screen before opening the menu to load a rom?
* Did it make any difference to select a different shader option (eg, Nearest)?

Cheers,
Joppy
  View user's profile Send private message Visit poster's website
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Post Posted: Fri Feb 24, 2023 11:59 pm
Heya!

No logos or splash. The only things I can see are the overlays (which I've disabled because the device has physical controls) and the text "this text should not be visible"
Changing the shader made no difference.

Does the app output a log I can send you?
  View user's profile Send private message
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Sun Feb 26, 2023 6:33 am
unfnknblvbl wrote
Heya!

No logos or splash. The only things I can see are the overlays (which I've disabled because the device has physical controls) and the text "this text should not be visible"
Changing the shader made no difference.

Does the app output a log I can send you?


Cheers for the info. The behaviour you describe suggests that the problem is with the GLSL shader. I was able to reproduce the behaviour on a simulator. It looks like some graphics drivers are a bit more picky than others, and will only compile if the GLSL version number is on the very first line (I previously had the first line empty, with the version number on the following line).

I've made a new build and will let you know once it's been rolled out to Google Play. Hopefully this gets Snepulator running on your device

Edit: The update has now been rolled out, let me know if this fixes Snepulator on your device
  View user's profile Send private message Visit poster's website
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Post Posted: Fri Mar 03, 2023 12:47 pm
I thought it might be something like that - the Sonic Mania decompilation project had a similar issue with GLES. I think they ended up switching to Vulkan to solve the issues.

Anyway, whatever you did, it worked! Most excellent! I'm always excited for new Android-based emulators!
  View user's profile Send private message
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Sun May 12, 2024 12:19 am
An update on this: I've now added Windows support, so it should be easier for more people to try :3

Windows Version:

https://github.com/JoppyFurr/Snepulator/releases/tag/v24.05

For Linux, I eventually plan on using a tool like AppImage to build releases. For now, the code can be build from source:

https://github.com/JoppyFurr/Snepulator


Changes since the first post:

v24.05:
- Windows support using mingw
- Support 4 MiB Master System ROMs
- VGM playback (PSG + YM2413)
- tms99xx collision detection
- tms99xx 5th sprite behaviour improvements
- tms99xx multicolour-mode
- Use 2 KiB of RAM for the SG-1000 to improve homebrew compatibility

v24.03:
- Improvements to sound buffer handling

v24.02:
- YM2413 implementation (FM Sound)
- Fix the SN76489 volume curve

v23.04:
- Band-limited sound synthesis for the PSG
- Initial implementation of TMS99xx fifth-sprite value
- Janggun mapper
- SG-1000 Graphic Board support
  View user's profile Send private message Visit poster's website
  • Joined: 19 Jun 2005
  • Posts: 42
Reply with quote
Post Posted: Thu May 16, 2024 5:20 am
Hey, Joppy! Does your emulator offer crisp video? Because all the other ones want to blur up SG-1000 games. It's a pain in the butt. Who told emulator designers that gamers love seeing games slathered in Vasoline, anyway? Hint: they don't. Really. Bilinear filtering is just a pseudonym for sucky sadness.
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Thu May 16, 2024 5:46 am
ArugulaZ wrote
Hey, Joppy! Does your emulator offer crisp video? Because all the other ones want to blur up SG-1000 games.


At the moment, the following video options are available:
* Nearest - Crisp integer scaled pixels, this is probably the setting you're looking for
* Linear - The usual blurry-looking bilinear filter. Only really there because it comes free with pretty much any graphics API :P
* Scanlines (default) - Does an integer scale, draws scanlines, and then does a small amount of bilinear interpolation afterwards, to get something looking vaguely CRT-like.
* Dot Matrix - Draws with a grid of thin black lines, separating the pixels from one another. This effect works best on mobile, where the small high-density screens makes it look a bit like a Gameboy Colour LCD.

For SG-1000 games, there are also three palettes to select from (gamma-corrected, non-gamma-corrected, and the palette used by the SMS).

For now all video modes use a 1:1 pixel aspect ratio, and the scaling is always a integer multiple of the game's native resolution.


Now that I've got the Windows version sorted out, over the next couple of months I plan on adding some improvements to the video.
My next few tasks will be:
* Reworking thread timing to reduce video stutter
* Adding support for non-integer scaling
* Adding support for non 1:1 pixel aspect rations, to match PAL and NTSC consoles.
  View user's profile Send private message Visit poster's website
  • Joined: 30 Dec 2008
  • Posts: 28
  • Location: Naples,Italy
Reply with quote
Post Posted: Sat May 18, 2024 7:41 pm
Good work. Is it possible open zipped roms?
  View user's profile Send private message
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Sat May 18, 2024 10:11 pm
Shion wrote
Good work. Is it possible open zipped roms?


Not yet

However, that is something I've got on my todo list
  View user's profile Send private message Visit poster's website
  • Joined: 19 Jun 2005
  • Posts: 42
Reply with quote
Post Posted: Wed Jun 05, 2024 3:59 am
Please consider ColecoVision support, thanks!
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Wed Jun 05, 2024 11:49 am
ArugulaZ wrote
Please consider ColecoVision support, thanks!


While it's not in the Android version yet, there is already basic ColecoVision support in the Linux and Windows versions.

The main limitation is incomplete controller support. For now, the player-1 keypad is hard coded to the row of numbers on the keyboard.
Type a 2 for number '2', type Shift+3 for a '#', etc.
This appears to be enough to get most games started; the keypad mostly seems to be used for choosing the difficulty.

I've not tried all ColecoVision games though, so there are probably some out there that rely on the keypad in-game, or need the "Super Action Controller" with extra buttons I've not yet implemented.
  View user's profile Send private message Visit poster's website
  • Joined: 19 Jun 2005
  • Posts: 42
Reply with quote
Post Posted: Thu Jun 06, 2024 1:10 am
Just tried it. Yeah, it works well! Really makes the ordinarily crummy ColecoVision colors quite vivid. I tested my own game Whack 'Em Smack 'Em Byrons (you may have heard of it, because I never shut up about it), and Byron approaches a color you might actually see on a bear.

(Yes, bear. Let's just say you're not the only furry on this forum.)

However, Snep doesn't recognize ColecoVision games in the .ROM format. Seems to look specifically for .COL files, but changing the extension fools it into running the games anyway.
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Thu Jun 06, 2024 11:33 am
ArugulaZ wrote
Just tried it. Yeah, it works well! Really makes the ordinarily crummy ColecoVision colors quite vivid. I tested my own game Whack 'Em Smack 'Em Byrons (you may have heard of it, because I never shut up about it), and Byron approaches a color you might actually see on a bear.

(Yes, bear. Let's just say you're not the only furry on this forum.)

However, Snep doesn't recognize ColecoVision games in the .ROM format. Seems to look specifically for .COL files, but changing the extension fools it into running the games anyway.


Yep, I've tried Byrons, it's a neat and cute game :3

As for the file extensions; the extension is currently the only thing used to determine which console to emulate when opening a rom. If the extension doesn't match a known one (.vgm, .vgz, .col, .gg, .sg, .sms), it will default to emulating a Master System.

I've just had a quick look, and it appears that the ColecoVision games do have a header for the BIOS to read, beginning with {0xaa, 0x55} or {0x55, 0xaa}. I could add a check for this when encountering an unknown extension and run as ColecoVision when the header is detected.
  View user's profile Send private message Visit poster's website
  • Joined: 16 May 2002
  • Posts: 1378
  • Location: italy
Reply with quote
Post Posted: Thu Jun 06, 2024 1:32 pm
Alternatively, you could pull a dialog:
Unknown extension ".xyz", how would you like to treat it?
( ) master system
( ) colecovision

[ ] remember this choice
  View user's profile Send private message Visit poster's website
  • Joined: 19 Jun 2005
  • Posts: 42
Reply with quote
Post Posted: Sat Jun 15, 2024 1:03 am
Any chance we'll get Super Game Module support in the future? That would be nifty.
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Sat Jun 15, 2024 2:09 am
ArugulaZ wrote
Any chance we'll get Super Game Module support in the future? That would be nifty.


I won't rule it out as something to add in the future, but the Super Game Module is not on my active to-do list. I hadn't actually heard of it before you mentioned it just now :P

A rough plan of the next few things I'd like to add:

- Video improvements
-> Smoother video output (done, will be in the next release)
-> Option for non-integer scaling for full-height display (just starting on this now)
-> Option for pixel aspect ratios other than 1:1

- Save State improvements
-> Quick-save
-> Screenshots to help choose which save to load
-> Undo for when you accidentally overwrite a save

- Sports Pad for SMS

- Super Action Controller for ColecoVision

- A 3DS port, mostly because I'd like to see it running 3D SMS games using the autostereoscopic screen


But this list will probably keep me busy for quite a few months
  View user's profile Send private message Visit poster's website
  • Joined: 11 Mar 2018
  • Posts: 81
  • Location: New Zealand
Reply with quote
Post Posted: Sat Sep 14, 2024 11:54 pm
I've just uploaded a new build:

https://github.com/JoppyFurr/Snepulator/releases/tag/v24.09

New changes in v24.09:
- Selectable pixel-aspect-ratio
- Improved video smoothness
- Option for non-integer scaling (pc-only, doesn't work well with some shader options)
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!