don't click here

Gens/GS II planning

Discussion in 'Engineering & Reverse Engineering' started by GerbilSoft, Apr 19, 2010.

  1. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    I've noticed that there seem to be some unfixable issues in the Gens/GS codebase. Most notably, these issues include random slowdown on various machines.

    So, in order to fix these issues, I'm going to attempt to do a partial rewrite, tentatively titled Gens/GS II.

    Main features of the rewrite:
    - Separated emulation code from UI code. (libgens / gens-qt4)
    - Qt4 UI for all major platforms.
    - CMake-based build system.
    - SDL video, audio, and input handling for all platforms. (no more separate DirectX code on Windows)
    - Multithreaded emulation code. (Emulation runs in one thread; UI runs in another.)
    - I will probably use pipes for inter-thread communication. Either that or SDL events, but SDL events are one-way. (That is, UI to SDL.)

    I haven't started the rewrite yet, but I plan to start working on it sometime this week.
     
  2. Mad Echidna

    Mad Echidna

    Gone Oldbie
    5,219
    0
    0
    I like the multithreading idea a lot. That was one of the big things on BeOS back in the day was the strong thread support. Some apps used dozens, even the simpler apps.
     
  3. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,218
    965
    93
    Long-term happiness
    Multithreading would be great, yeah - computers with multiple CPU cores are only going to increase from here on out. One hopes this doesn't end up comparing to Gens/GS how SHWP II compared to SHWP. ;P
     
  4. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    lol no.

    Jeopardy! System, which I mentioned previously on #retro, uses multithreading for various things, including audio and Wii Remote handling. On JS, audio isn't synchronized with video at all, since it isn't necessary. For Gens/GS II, it will be necessary, so I'll have to do that differently.

    In other news: <a href="http://gs_server.gerbilsoft.ddns.info/cgi-bin/gitweb.cgi?p=gens-gs-ii.git;a=summary" target="_blank">http://gs_server.gerbilsoft.ddns.info/cgi-...I.git;a=summary</a> - I managed to get starscream and mdZ80 to build correctly using CMake. Starscream, in particular, is annoying because it's a C program that generates assembly, which is then assembled using NASM. NASM also isn't directly supported by CMake, but someone posted NASM modules for CMake on the CMake bug tracker, so I used that.

    The next step will be writing the main libgens code, which will include porting the emulation code from Gens/GS and adding the SDL loop. I also have to add two thread-safe queues for communication between Gens/GS and the UI. (The initial UI for the first preview release will probably be command-line only.)
     
  5. Mad Echidna

    Mad Echidna

    Gone Oldbie
    5,219
    0
    0
    Good stuff Gerb, I look forward to hearing more about this.
     
  6. Don't know shit about emulators code and what are exactly your needs, but did you consider using SFML 1.6 instead of SDL? Seems to me some features would be really useful for you.
     
  7. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    SFML actually does look kinda interesting, so I might consider it. Ubuntu has SFML, but it seems to be an old version (1.5 in Ubuntu 10.04), so I guess I might include a statically-linked copy if I decide to use it.

    EDIT: It seems that the current version of SFML has some joystick limitations. (Specifically, it only supports two joysticks.) It also looks harder to integrate with the Qt4 UI unless I use Qt code in libgens, which I don't want to do. So I guess I'll stick with SDL for now. (I can always port everything to SFML later on if the need arises.)

    EDIT 2: I can't seem to find a source code download for SFML that isn't SVN. All I see are "SDK" downloads, so I'm guessing SFML was primarily developed for Windows systems, and Linux support was added as an afterthought.
     
  8. (?) The full SDK has the source codes; well, I guess so because when I downloaded the 1.5 SDK it had the sources.

    Also, keep in mind that SFML is flexible, I mean you can choose one of the small packages like for instance the System one for threads.
     
  9. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    I now have an initial Qt4-based UI. I'm currently using the QX11EmbedWidget for embedding SDL, since other widgets had issues with BadWindow errors, but I'll get it working with a standard widget for other platforms.

    In the meantime, Gens/GS II is currently only buildable on Linux. Source code is available at <a href="http://gs_server.gerbilsoft.ddns.info/cgi-bin/gitweb.cgi?p=gens-gs-ii.git;a=summary" target="_blank">http://gs_server.gerbilsoft.ddns.info/cgi-...I.git;a=summary</a> .
     
  10. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    I'm just going to say that if this is going to be a raw rewrite then then 32X emulation code in the old Gens is a joke and we both agreed it needs to be replaced. I'll start writing a new one once Gens/GS II can do MD emulation. I have been thinking ahead and I don't think the G BIOS would be needed unless it does something that I don't know about, but that's just what I can tell. After all, we already have everything set up on the emulator side =P
     
  11. Sappharad

    Sappharad

    Oldbie
    1,413
    70
    28
    With these changes, will it be possible to easily compile Gens without a UI?
    It sounds like it, but I just wanted to confirm. (Since your current repository has SDL and Win32 stuff still mixed in with libgens)
     
  12. Mad Echidna

    Mad Echidna

    Gone Oldbie
    5,219
    0
    0
    Hey Gerbilsoft, how seriously do you take the Haiku port? If it reaches your quality standards will it be an "official" port at some point? How do you view this?
     
  13. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    It would still need a "UI", but that UI could easily be a command line interface.

    Considering that very few people use Haiku, I don't know. The initial Haiku port will be Qt4, but a Haiku-native UI could be written later on.
     
  14. Mad Echidna

    Mad Echidna

    Gone Oldbie
    5,219
    0
    0

    That's true, very few people do use Haiku, an OS that's still in alpha

    :P
     
  15. Conan Kudo

    Conan Kudo

    「真実はいつも一つ!」工藤新一 Member
    478
    1
    18
    I'm surprised nobody's brought up AROS yet...

    Also, I thought Starscream was supposed to be replaced, since it isn't GPL compatible?

    I'm no expert on m68k, but I found some GPLv2+ code that emulated an m68k CPU. I don't know how good it is or whatever, but here it is.
     
  16. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,218
    965
    93
    Long-term happiness
    I believe the long-term goal is to ditch Starscream, yes, but a point has to be reached first where there's no other more pressing issues first, like stripping out all the remaining ASM.
     
  17. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    The latest git code now has a port of the VDP code from Gens/GS and an initial ZOMG loader. (The format isn't finalized yet.) I also included a sample ZOMG file that has VDP registers, VRam, CRam, and VSRAM for the Sonic 3 title screen named test.zomg. Place test.zomg in the same directory as gens-qt4, run gens-qt4, and select File, Blit!. The Sonic 3 title screen should appear.

    The next step is to port over the M68K emulator and the main emulation loop.
     
  18. Conan Kudo

    Conan Kudo

    「真実はいつも一つ!」工藤新一 Member
    478
    1
    18
    I found another open source emulator code, called Syn68k. It was opensourced under an MIT-style license by the defunct ARDI company in 2008. It was used to run Mac OS m68k software on non Mac systems. I have no idea how complete it is or whatnot, but it is another option for when the time to ditch Starscream arrives...

    An old whitepaper about Syn68k is available here.
     
  19. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    Current list of goals for this weekend:
    • Make sure the separate menu bar and SDL window works properly on OS X.
    • Initial implementation of the M68K C++ wrapper around the star_m68k asm library.
     
  20. Conan Kudo

    Conan Kudo

    「真実はいつも一つ!」工藤新一 Member
    478
    1
    18
    Well.. It's July. Have you accomplished any of those goals?