Filetrip Logo


lolSnes git 01/01/2014



Thumbnail 1 for lolSnes
I hope this project will bring some new life into the SNES-on-DS scene. It looks like all the existing emulators for the DS are dormant or discontinued, which is sad.

lolSnes is a project I had started two years ago. I wanted to make a SNES emulator for the DS, that could render most sane games without glitches. But I followed a wrong approach with the PPU side: trying to make a line-accurate software renderer. The DS just isn't powerful enough to handle such a renderer. That discovery pretty much shattered my motivation and the project stayed dormant for two years.

And now, for some reason, I felt like working on it again. I trashed the software PPU attempt and coded the PPU using the DS's 2D video hardware.

So far, SMW is playable, to some extent. The background layer tends to obstruct text like menus and info boxes because per-tile priorities aren't emulated yet.

You also can't get past Donut Plains 2: for some reason, the camera keeps rewinding and moving forward a bit at the start of the level, keeping you from going further. Aside from this bug, gameplay is near perfect. The game also runs at fullspeed (albeit with a speedhack).

What's in?

* Main CPU: 99% -- all opcodes emulated, may miss some unimportant bits though
* PPU: ~30% -- Mode 1 BG and OBJ supported, as well as some of the priority
* SPC700: 80% -- most useful opcodes implemented, as well as I/O (SPC/CPU comm, timers)
* DSP: 0% -- what it says. No sound yet.
* Joypad input for joypad 1

Issues

* There is no interface for selecting a ROM-- it is hardcoded to load snes/rom.smc
* Tearing and black pixels tend to appear when backgrounds scroll, because writes to the BG scroll registers are applied directly and not synced to the DS display
* CPU bugs are hidden in the main CPU core, and possibly the SPC700 core. They may bite you when you expect it the least.

Github repo

For those who are interested, the source code is available in a Github repo.

Even though it isn't explicitly mentioned in the code files, the code is under the GPL license.

A lot of this is written in ARM ASM. If you don't have some knowledge of ARM ASM and GCC calling convention, the code may look like black magic to you...

If you're crazy enough to try it out

At the time of writing this, the latest revision should run on a DS, but there is no guarantee that it will always be the case. I mostly test on desmume, which is not 100% accurate. As such, issues may go unnoticed on desmume and cause trouble on a DS. Such issues being mainly accesses to invalid addresses-- desmume doesn't seem to emulate the memory protection unit.

Feel free to try it though, any feedback is recommended.

You need a recent devKitPro to build it. Then, place lolSnes.nds on your flashcart/whatever. Create a folder named 'snes' there, and put your ROM in it, under the name 'rom.smc'.

Run lolSnes.nds and it should automatically load your ROM. You'll get to see it either launch your game, or explode.


Have fun! ;)

Change log (git 01/01/2014):
Revision b1ddc811030fe2a3ef3e97187f0eeec4a4b3e353 — built on 01/01/2014 05:36:18

* working sleep mode when you close your DS
* reworked IRQ support, should fix quite a few games
* hook up HDMA emulation and fix a bug in indirect HDMA
* better handling of sprite refreshing, no more shitty sprite animations
* reload PPU OAM address upon VBlank (fixes DKC sprites)
* fix more bugs I forgot about

Revision c3f1f7ef75797ac999abb0a388b8a250d21401ca — built on 12/22/2013 23:24:10

* More proper implementation of IRQ (supports H, V and H+V modes)
* Code for HDMA, temporarily disabled
* Fix PPU bugs regarding BG scroll registers and VRAM reading
* Implement PPU H/V counters (only V counter is emulated accurately though)
* Add splashscreen

Revision c672c8a718ed0a5a65323259ed490e761f8e9146 — built on 12/15/2013 02:07:23

fuck you Joseph Y. Wang and your shitty fake site

Revision 661c7a7bf1b84004b16a53b262d676defa396e57 — built on 12/12/2013 12:10:58

* Fix the remaining bugs in the per-line prio system
* Fix bug where games that keep their OBJ base address to 0 would have no sprites
* Anti-lag mechanism temporarily disabled for it can cause severe issues
* Fix several issues with SRAM mapping, hopefully should fix many cases of piracy protections triggering
* Implement some missing SPC700 instructions

Revision b113fca7b2d4ba3e87707503f1838b6372b20586 — built on 12/09/2013 00:18:03

Add support for the missing video modes (5 and 6).

Revision 4f5d1f756b68dcc80e2c4c18b5f752ff37634077 — built on 12/08/2013 21:53:40

More work on priorities: handle high-prio tile rows by gross approximation. Not perfect but promising.

Revision d986b430d55db7d55587843b9683f01d2bc236a9 — built on 12/03/2013 19:58:16

Fix that bug with SMAS.

Revision c528176e1fb33285eae190ecc99eea92310109d0 — built on 11/29/2013 22:59:22

Update the README.

This build is exactly the same as the previous one. Don't distribute it.

Revision a5738a33f44cfed4bebe719e34c4a22668f5b6e4 — built on 11/27/2013 01:18:52

More work regarding priorities and shit.

DO NOT SPREAD THIS BUILD OVER THE INTERNET

Revision c04e969fa91ad4185f60c07f9c5d2bd23797db93 — built on 11/10/2013 02:34:37

** WORK IN PROGRESS **

Start working on PPU priorities. Not finished, still tons of bugs.
comments powered by Disqus