Homebrew lolSnes -- SNES emulator for DS

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
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.

You can't get past Donut Plains 2, though: 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).

Screenshots

Version 1.0:

rj6VWxY.png


Older screenshots: (pre-1.0, many issues there have since been fixed)

uIKsC7Q.png
YWA0zPl.png
dUfKTte.png


Emulator in emulator. Wee.

What is currently supported

* CPU -- 99% (all opcodes emulated; may miss a few unimportant bits about timing)
* PPU -- ~40% (mode 1 BGs, OBJs, mosaic, master brightness, giant kludge for BG3 prio)
* SPC700 -- 80% (most useful opcodes implemented, CPU/SPC I/O, timers)
* DSP -- 0% (yep, no sound)
* SRAM with auto-saving

Download link

Version 1.0

Unofficial Git builds

People may have built Git versions and distributed those. (if your lolSnes build's version is above the last released version, it's a Git build)

Keep in mind that Git builds may be unstable. They may explode in your face at any time, so don't be surprised.

Git builds can offer features that aren't in the last version, though.

How to use it

Place lolsnes.nds in your flashcart's root folder (or wherever DS ROMs are). In the same folder, create a folder
named 'snes', and place your ROMs in there.

You can place savefiles from other emulators too. They have to have the same name as the corresponding ROMs and have
.srm extensions.

lolSnes is able to properly detect the ROM type in most cases. Headered and headerless ROMs are supported, both
LoROM and HiROM.


Start lolSnes and select your ROM in the menu. If all goes well, you should see it run. If not, you'll stay in the
menu. Oh also, there's no pause/stop/reset feature yet, so if you want to run a different ROM, you need to reset your DS.

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...


Have fun! ;)
 

WoJjTeK

Well-Known Member
Member
Joined
Jun 27, 2012
Messages
131
Trophies
0
XP
1,402
Country
Poland
Holy crap, now that's what we need! I really hope this project will succeed, because currently the best SNES emulator for DS is SNEmulDS , which was abandoned, and with outdated source code no one wanted to continue that one. Keep up the good work ! Maybe one day we will have a nearly perfect SNES emu for DS :)
 

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
By the way, I'd have continued on SNemulDS if possible, the only problem is that the source code of the last version seems to be completely gone from the internet, and SNemulDS being a port of an emulator made for DOS, it won't be as efficient as an emulator made specifically for the DS.
 

WoJjTeK

Well-Known Member
Member
Joined
Jun 27, 2012
Messages
131
Trophies
0
XP
1,402
Country
Poland
Hmmm, with that in mind I think it's obvious that this emulator can be much better that SNemulDS, and SNemulDS is quite good, the only problems I experienced are with layers, and maybe freezing during loading save files. Hopefully some other people will also get interested and will contrubite to this project :)
 

Another World

Emulate the Planet!
Former Staff
Joined
Jan 3, 2008
Messages
10,579
Trophies
2
Age
48
Location
From Where???
Website
wiki.gbatemp.net
XP
5,535
Country
Colombia
this is an interesting bit of news. do you have plans to continue working on it? is this something you would like to see completed or are you hoping that the source code motivates someone to continue your work?

-another world
 

WiiUBricker

News Police
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,485
Country
Argentina
By the way, I'd have continued on SNemulDS if possible, the only problem is that the source code of the last version seems to be completely gone from the internet, and SNemulDS being a port of an emulator made for DOS, it won't be as efficient as an emulator made specifically for the DS.
Are you saying you are the SNemulDS dev?
 

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
this is an interesting bit of news. do you have plans to continue working on it? is this something you would like to see completed or are you hoping that the source code motivates someone to continue your work?

-another world
I'm going to complete it. If my motivation doesn't fail me, that is.

I'd mainly like graphics to have right priority and all without requiring to switch/disable layers or whatever game-dependent manual action.

Are you saying you are the SNemulDS dev?
I'm not. If I were him, I'd just have continued it instead of starting a whole new project...
 
  • Like
Reactions: SLiV3R

Another World

Emulate the Planet!
Former Staff
Joined
Jan 3, 2008
Messages
10,579
Trophies
2
Age
48
Location
From Where???
Website
wiki.gbatemp.net
XP
5,535
Country
Colombia
I'm going to complete it. If my motivation doesn't fail me, that is.

the best motivation is the reaction from the community. you should post about your project on as many ds/homebrew sites as possible. you should also get a compiled binary into the hands of beta testers. i am happy to give you front page posts, here on gbatemp. just PM me whenever you have an update and i'll sort the news out.

-another world
 

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
I'm thinking about it. I'll likely release a binary when I get SMW to a better state (ie make it so that the background layer doesn't block menus/whatever, and fix the bug that breaks autoscroll in Donut Plains 2).

I may also add support for SuperDAT (snesadvance.dat) speedhacks. Right now it applies speedhacks if it detects a SMW-style idle loop, but I figure that idle loops vary wildly from one game to another, and autopatching wouldn't be feasible.
Problem with the SuperDAT is that it contains all sorts of hacks, not only about speed. Some hacks are about fixing graphics or skipping SPC700 code or other stuff I don't want.

For information: SMW doesn't run at fullspeed without speedhacks. Not a big surprise, though, given the DS's power.


As for SCDSTwo, I'm not planning on supporting it. I don't have one so I couldn't test. And not everyone has it, either.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
cool. Just saw the source code..

on ARM7 source:
https://github.com/Mega-Mario/lolSnes/blob/master/arm7/source/main.c


Code:
//checks EXMEMSTAT flag busy?? (ARM7)
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u32[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000210[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]|=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0x00000008[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]
//timer value set to 64489 cycles ?? (0) (arm7)
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u16[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000100[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0xFBE9[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]
//timer value set to 192 cycles 2 bytes after??
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u16[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000102[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0x00C0[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]

great work!
 

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
cool. Just saw the source code..

on ARM7 source:
https://github.com/Mega-Mario/lolSnes/blob/master/arm7/source/main.c


Code:
//checks EXMEMSTAT flag busy?? (ARM7)
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u32[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000210[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]|=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0x00000008[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]
//timer value set to 64489 cycles ?? (0) (arm7)
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u16[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000100[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0xFBE9[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]
//timer value set to 192 cycles 2 bytes after??
[B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333]([/COLOR][/FONT][/SIZE][SIZE=12px][FONT=Consolas][COLOR=#333333]u16[/COLOR][/FONT][/SIZE][B][SIZE=12px][FONT=Consolas][COLOR=#333333]*[/COLOR][/FONT][/SIZE][/B][SIZE=12px][FONT=Consolas][COLOR=#333333])[/COLOR][/FONT][/SIZE][COLOR=#009999][SIZE=12px][FONT=Consolas]0x04000102[/FONT][/SIZE][/COLOR][B][SIZE=12px][FONT=Consolas][COLOR=#333333]=[/COLOR][/FONT][/SIZE][/B][COLOR=#009999][SIZE=12px][FONT=Consolas]0x00C0[/FONT][/SIZE][/COLOR][SIZE=12px][FONT=Consolas][COLOR=#333333];[/COLOR][/FONT][/SIZE]

great work!
I'd recommend you read GBAtek a bit ;)

The first write enables timer 0 IRQ in IE. The second write sets the reload value for timer 0, and the third configures timer 0 to run.

This is all I get when trying to run SMW through it in Desmume:
http://i.imgur.com/0V5BkDj.png


EDIT: Same thing when running on my DS.
That's weird. It looks like a bad ROM or some other weird issue.

It'd be helpful if you opened desmume's disassemblers and gave me a screenshot of the ARM9 disassembler.
 

Arisotura

rise of melonism
OP
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
This looks like the SRAM size entry in the ROM is set to an insanely big value. The computed SRAM mask is 0xFFFFFFFF, which causes the code to allocate a zero-byte buffer and then proceed to zerofill the whole 4GB of memory.

I have no idea why that would be, but I'll add some code to make sure the SRAM size remains reasonable.

Edit- nevermind, it was a silly issue in my code (forgetting to set a variable, leaving it unitinialized). I don't get how this hasn't broken shit on my side yet.

It's fixed, anyway. I also added a line to ensure the SRAM size stays reasonable.
 

Site & Scene News

Popular threads in this forum

Recent Content

General chit-chat
Help Users
  • No one is chatting at the moment.
    Xdqwerty @ Xdqwerty: good night