lolSnes -- SNES emulator for DS

Discussion in 'NDS - Emulation and Homebrew' started by StapleButter, Aug 19, 2013.

  1. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    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:

    [​IMG]

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

    [​IMG] [​IMG] [​IMG]

    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! ;)
     


  2. WoJjTeK

    WoJjTeK GBAtemp Regular

    Member
    122
    45
    Jun 27, 2012
    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 :)
     
  3. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    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.
     
  4. WoJjTeK

    WoJjTeK GBAtemp Regular

    Member
    122
    45
    Jun 27, 2012
    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 :)
     
  5. Another World

    Another World Emulate the Planet!

    Former Staff
    10,495
    1,653
    Jan 3, 2008
    Colombia
    From Where???
    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
     
  6. Luigi2012SM64DS

    Luigi2012SM64DS G-old member

    Banned
    2,060
    309
    Aug 27, 2011
    Canada
    Minecrapt
    And the fact that I was just unbanned to see this!!! Good work!
     
  7. WiiUBricker

    WiiUBricker Fake News Reporter

    Member
    6,871
    3,847
    Sep 19, 2009
    Argentina
    Espresso
    Are you saying you are the SNemulDS dev?
     
  8. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    France
    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.

    I'm not. If I were him, I'd just have continued it instead of starting a whole new project...
     
    SLiV3R likes this.
  9. Xuio

    Xuio GBAtemp Regular

    Member
    158
    4
    Aug 19, 2007
    Poland
    I hope that You will finish it!
     
  10. stanleyopar2000

    stanleyopar2000 The Official GBATEMP Thread Killer. No Mercy.

    Member
    3,976
    600
    Jun 22, 2007
    United States
    and a few days before this a full speed DS emulator, DraStic gets released for Android hehe
     
  11. Another World

    Another World Emulate the Planet!

    Former Staff
    10,495
    1,653
    Jan 3, 2008
    Colombia
    From Where???
    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
     
  12. reprep

    reprep GBAtemp Advanced Fan

    Member
    934
    300
    Jul 5, 2012
    a supercard dstwo version would be great too, if you need some extra juice. though it is a totally different architecture.
     
  13. WiiUBricker

    WiiUBricker Fake News Reporter

    Member
    6,871
    3,847
    Sep 19, 2009
    Argentina
    Espresso
    Oh sorry, my bad. I just realized you are the OP. When I asked you the question I thought you weren't the OP because I had forgotten your name and avatar so quickly :p1ng:
     
  14. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    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.
     
  15. Coto

    Coto GBAtemp Addict

    Member
    2,343
    395
    Jun 4, 2010
    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!
     
  16. windwakr

    windwakr GBAtemp Fan

    Member
    482
    110
    Sep 13, 2009
    United States
  17. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    France
    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.

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

    windwakr GBAtemp Fan

    Member
    482
    110
    Sep 13, 2009
    United States
  19. StapleButter
    OP

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    773
    1,465
    Dec 5, 2009
    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.
     
  20. loco365

    loco365 GBAtemp Guru

    Member
    5,458
    2,673
    Sep 1, 2010
    Looking forward to trying this. Is it hardcoded to run only Super Mario World, or could one dare attempt to run another game?