NDSSFC/CATSFC revival

Discussion in 'Supercard' started by Nebuleon, Dec 22, 2012.

?

What sort of additional hotkeys do you want?

  1. Quickly save/load a saved state

    50.0%
  2. Move emulation to/from the bottom screen

    28.1%
  3. Toggle aspect ratio: [3] Middle of screen to [4] Entire screen anti-aliased

    41.7%
  4. Toggle CPU frequency: 5 to 2

    26.0%
  5. Toggle 8-bit era sound, with triangle waves and noise

    26.0%
Multiple votes are allowed.
  1. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    1.43. I tried transplanting various things in isolation from 1.52 into NDSSFC-1.06-based-on-Snes9x-1.43 and failed for various reasons each time.

    Here's some background.

    After I tried transplanting source/tile.cpp, source/gfx.cpp, source/ppu.cpp and the new files they depended on, then adding the variables needed by 1.52 in the various "graphics state" data structures, I found that I could still compile it, but the frames per second dropped 2x! That was clearly unacceptable.

    There's way too much C++ in the brand new source/apu/ folder, and the DS2 SDK's C-or-C++-but-not-too-much-++-please compiler complained of missing internal functions from the C++ Standard Library, even if I removed -nostdlib in the Makefile to include it. Things that are quite essential, such as __cxa_atexit (exception handling at-exit code), __cxa_guard_acquire, __cxa_guard_release (for atomic locks), __preinit_array_start, __preinit_array_end, __init_array_start, __init_array_end, __fini_array_start, __fini_array_end (for initialisation of .data sections containing preallocated data, like lookup tables (?)), operator new, operator delete, operator new[], operator delete[] (for memory allocation, quite essential those four) and finally 'main' (!), though that one was easier to work around...

    Code:
    int main(int argc, char** argv) {
      ds2_main();
      return 0;
    }
    If one of you guys can get the new 1.52 APU code to a state that can even just compile as C++-but-not-too-much-++-please, without necessarily testing it (that means ShadauxCat can try this even if s/he doesn't have a DSTWO, just the SDK, hint hint :P), I would much appreciate it.
     


  2. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    I don't think so. I haven't seen a function to submit ARM7 or ARM9 code to the NDS; ds2_getrawInput does the communication for the controller, touch and lid; ds2_getAudiobuff and ds2_updateAudio handles the audio; and you can't get the NDS processor's hardware niceties like the vblank interrupt and hardware sprites/3D/rotation/etc.
     
  3. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    20,778
    9,781
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    Makes sense, but I wish I knew more about programming in C/C++ otherwise I'd give it a whirl. As for the Snes9x 1.52 APU/S-SMP code, that would be awesome if/when that gets implemented. The major issue I've seen with portable console emulators is the lack of decent audio emulation on both DS and PSP. Hopefully, that trend can end. Good luck!
     
  4. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    I had never programmed in C/C++ before this thread. Snes9x is one big codebase, and I learned by example.
     
  5. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    20,778
    9,781
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    Well, best of luck getting the better sound core implemented; I might get a DSTWO or whatever it's called just for that right there:P
     
  6. nl255

    nl255 GBAtemp Addict

    Member
    2,530
    348
    Apr 9, 2004
    Are you using the original SDK or Pate's modified version? Remember that while Pate's modified version supports sending code to the NDS it has absolutely no support for doing sound on the DSTwo. You might want to get in touch with him as I am sure he would love to hear from another DSTwo developer.
     
  7. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    I wasn't aware there was an "original version" to speak of, so it is indeed the original I'm using.
     
  8. Rydian

    Rydian Resident Furvertâ„¢

    Member
    27,883
    8,107
    Feb 4, 2010
    United States
    Cave Entrance, Watching Cyan Write Letters
  9. nl255

    nl255 GBAtemp Addict

    Member
    2,530
    348
    Apr 9, 2004
    Yes, he hacked the SDK to allow more transfer between the NDS and DSTwo side as well as make it more efficient. However, he also removed the sound support from it as the idea is that you implement the sound code on the NDS side rather than DSTwo side.
     
  10. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    Oh boy. Reimplementing the sound on the ARM7. :sad: It can only be done if, for 1 second, the 1.02 million instructions/sec of the APU and the audio rendering can fit in the ARM7's 32 33 million instructions/sec, and currently an APU instruction runs in 10-25 MIPS instructions (10-25 MHz). Can it be done?

    Perhaps more importantly:
    * Is it easy for any user to get Pate's SDK modifications and libnds/libdevkitARM to compile the ARM7'd CATSFC? I don't want to release stuff that essentially gets closed down and uncompilable, bogged down by unsatisfiable dependencies.
    * Would it be possible to transplant 1.52's sound code there, with all the C++ intact (and under the instruction limit detailed above)?
    * Is there a limit to how much code can be submitted to the ARM7?

    I looked, and there seem to be only timing charts and a high-level overview of what was changed, no code etc. Thanks for the link, though! :)
     
  11. Rydian

    Rydian Resident Furvertâ„¢

    Member
    27,883
    8,107
    Feb 4, 2010
    United States
    Cave Entrance, Watching Cyan Write Letters
    Oh, I linked mainly so you could see what sort of changes were made on a higher level. I've never programmed anything for the DSTwo (libnds is as complicated as I've gotten, I'm an amateur programmer at best).
     
  12. nl255

    nl255 GBAtemp Addict

    Member
    2,530
    348
    Apr 9, 2004
    Check his download page which has an updated ds2_firmware with source that lets you customize the DSTwo/NDS communication.
     
    Nebuleon likes this.
  13. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    Wow, I'm blind. I didn't see that download at the very bottom. And I didn't know he called that firmware. :mellow:
     
  14. nl255

    nl255 GBAtemp Addict

    Member
    2,530
    348
    Apr 9, 2004
    Well, that's what Supercard calls it in the SDK.
     
  15. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    A little progress update:

    Secret of Mana's sprite-in-Mode5 menu is fixed!
    mana-menu-sprite-20130105.png

    But, as of commit 3cd20e203f3b0af8c32921f86547a126d74b34eb, which fixed Secret of Mana's background (and messed up the sprite), Donkey Kong Country's start screen has a Rareware icon that gets split up by black...
    dkc-rareware-20130105.png

    Given that the Rareware icon goes to the next scanline AND gets split by exactly 4 pixels, I must be mishandling an on-screen X coordinate, but I tried to mess with everything to no avail.
     
  16. the_randomizer

    the_randomizer The Temp's official fox whisperer

    Member
    20,778
    9,781
    Apr 29, 2011
    United States
    Dr. Wahwee's castle
    I wonder if the 1.52 APU code will ever be implemented....
     
  17. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    I wonder if you will ever stop wondering about that...

    I post a progress update and you jump to another topic; it will be done when it will be done, and right now that's not on my plate at all. There's way too much C++ in the code, which needs to be converted to C if it goes to the MIPS side because of the crappy SDK. If I were to port that on the ARM7 side without any experience with Patrick's SDK modifications or planning, I'd end up with a huge hack or wasted effort. And I hate those.

    Given the quality of MoonShell's .spc file playing (which is very low) and the fact that MoonShell's control latency goes to 200-300ms when I play Super Bomberman 5 tracks, I'd say ARM7 doesn't have enough juice to emulate the SPC700 as used by a game, let alone emulating a .spc music snapshot. A game uses the SPC700 with I/O, synchronisation and sound effect overlays selected at run-time.

    So that leaves the MIPS side, which is already rather crowded by emulating CPUs and rendering graphics.
     
    Sicklyboy likes this.
  18. Rydian
    This message by Rydian has been removed from public view by GeekyGuy, Jan 6, 2013, Reason: Unnecessary.
    Jan 5, 2013
  19. Killermech

    Killermech Cookie Monster

    Member
    1,809
    2
    Mar 5, 2004
    Just when I thought I would never see any update to this. Many thanks for all the hard work and this getting revived again is getting me really excited.
    I just read the entire thread and didn't see (surprisingly) any mention about SMario RPG of how it would perform with the new improvements. I remember the last CATSFC actually managed to run it and it was playable to some extent. So I'm mainly curious if anyone has tried it and if they've seen any improvements. Or if Nebuleon has any specific plans for it to possibly improve it further, if possible that is.

    Again, thanks for picking up this project again Nebuleon :)
     
  20. the_randomizer
    This message by the_randomizer has been removed from public view by GeekyGuy, Jan 6, 2013, Reason: Reply to trashed post..
    Jan 5, 2013
  21. Nebuleon
    OP

    Nebuleon MAH BOI/GURL

    Member
    900
    465
    Dec 22, 2012
    Canada
    You're welcome - and I am too, because I can use the fruits of my labour :)

    For Super Mario RPG, I have no specific update planned. (I don't own the game.) It, along with Yoshi's Island and possibly Kirby Super Star (it runs with the same FPS as Yoshi's Island, so I'm assuming), use(s) a chip that's clocked 3 times higher than the regular chip in the SNES. If Yoshi's Island ends up playable, then Super Mario RPG probably also will. But apart from opcode patching, nothing will really help those games.

    technical term alert

    Opcode patching: Patching of loops with a "stop the image here" opcode. These loops can be found either automatically using loop analysis or manually using a disassembler or similar.

    Loop analysis: Looking at the target and source of emulated jump instructions while they're running in the emulator itself. If the CPU state at two runs of the same jump are identical AND the loop didn't access memory, then the jump can become a WAIT instead. It's a speedhack I tried, but unfortunately failed so hard at that half of my games wouldn't go past the title screen after a "Deleted jump that ran 257 times" message. Most loops aren't ideal like these two, though, so it's not very effective:
    Code:
    005661: JMP $5661
    Code:
    005661: WAI
    005662: BRA -3 ;to $5661
    Manual analysis: This is the method used by SNES Advance, and SNES Advance provides more support for finding these loops to be patched than NDSSFC ever will, sadly. But if someone has found -- or finds -- a wait-for-vertical-blank loop in Yoshi's Island and Super Mario RPG, via SNES Advance, I can try to implement that using their .dat file. Since I failed so hard at loop analysis, I may just implement those as has been requested.
     
  22. Rydian

    Rydian Resident Furvertâ„¢

    Member
    27,883
    8,107
    Feb 4, 2010
    United States
    Cave Entrance, Watching Cyan Write Letters
    The snesadvance.dat file I've got is dated Sept 27th, 2010, but Idunno' if that's when it was last transferred via FTP or something. Either way I didn't notice any difference on the PSP with speedhacks disabled, SMRPG still ran 60FPS, so I don't know if it'll be helpful or not since I don't know how to look into it anyways... but it does seem to have entries for it, since the emulator reports finding them for this game when it starts loading and speedhacks are enabled.
    http://filetrip.net/oldies-downloads/snes/download-speed-hack-01-f31372.html