Skip navigation
Holy SHIT!!! So I finally stopped hyper-analyzing and obsessing over micro-inefficiencies I was…
0:00 / 0:32

Holy SHIT!!! So I finally stopped hyper-analyzing and obsessing over micro-inefficiencies I was…

Falco Girgis

@falco_girgis14K followers

Visit on X
936 likesDownloadOriginal post

49,384 views

Holy SHIT!!! So I finally stopped hyper-analyzing and obsessing over micro-inefficiencies I was seeing in the SH4 assembly routines within Reshaped's Sonic Adventure 1 Remaster codebase for the Sega Dreamcast... and I just decided to build the goddamn thing and play it already. ...and oh. my. GOD!!! Sonic Adventure 1 is now running mostly at 60FPS (still some dips here and there, though), WITH FREAKING WIDESCREEN SUPPORT? Check out this direct hardware capture! I never thought I'd see my SH4ZAM fast math library for the SH4 contribute to bringing GAINZ to a AAA Sega release like this that I grew up playing, but... here we are. Absolutely incredible. Please support Reshaped's work by following on GitHub and starring the repo! He has done a fantastic job! EDIT: Yes, this is a repost. My original was uploaded at 30FPS, because... I'm an idiot. MY BAD! 🤣

45 Comments

Comments from the original post on X (Twitter)

  • John Linneman's profile picture

    @dark1x

    That's so cool! Do you have an idea of what is causing those dips? I'm also wondering, while digging into this game, if you have any insight into why the time trial mode always ran so much worse than the adventure mode? Like, horrible frame-rates in trial mode exclusively.

    22 likes

  • Falco Girgis's profile picture

    @falco_girgis

    NOT YET. Just BARELY got in here and am hoping to god it's just some stupid CPU-heavy gameplay event or random heavy spike for collision or animation. Or even some TnL load crap that is from not using all of my SH4 transforms effectively (AI skipped out on my rotation ones, which are some of the biggest GAINZ, lol). What I pray it is NOT is a frame dip from the PVR randomly needing 10x longer to render the frame, while the SH4 sits on its ass... As amazing a the PVR is, I know you know it has some very strange, obscure weaknesses with its architecture, much of which involves large swathes of overlapping transparencies close to the camera that have to get auto sorted into MANY different TA's buckets/bins that it overlaps in screen-space. We have freak incidents like that all the time with some of our ports, including from N64, where we're fullspeed, but some fog or smoke particles or other TR sprites get too close to the camera and overlap too much and DESTROY frame time for a few frames... That kind of crap is much harder to gain on (at last for me), cuz I can't just SH4 optimize my way out of it. Haha.

    4 likes

  • Falco Girgis's profile picture

    @falco_girgis

    If the capture sucks, here it is on YouTube: Here it is on BlueSky (best looking):

    17 likes

  • Fox FRL's profile picture

    @ferrlorenz

    looks great! Sega Rally 2 is one that also deserves an optimization.

    7 likes

  • Kurasshu Mashu's profile picture

    @KurasshuMashu

    Esto es un port a PC tomando las versiones originales de Dreamcast?

    5 likes

  • Falco Girgis's profile picture

    @falco_girgis

    No, this is the Dreamcast port, decompiled, then optimized with my math libraries plus a bunch of extras like widescreen support added back, then compiled back for and running natively on an actual Sega Dreamcast hardware.

    4 likes

  • sh4's profile picture

    @sh4forever

    What were the perf limitations in SA1? like, what bad things were they doing? Especially curious because, yes it was a launch title, but Sonic Team ostensibly would have had access to the most informed engineers I would have assumed. Cool stuff!

    4 likes

  • Falco Girgis's profile picture

    @falco_girgis

    I dunno really exhaustively, brand new dude to the codebase who is just looking at the math, but the dumbest shit ever that Ninja did was write these decent little ASM routines, then call them OUT-OF-LINE and pay a full-ass function call with C ABI stack frame and register management overhead just to do like FIPR or a couple math instructions whose GAINZ will barely make up for the inefficiences of preserving regs that never get fucked with in the XMTRX routines. That shit SHOULD'VE been inline ASM, to give the compiler information on the clobbered registers and more context to make micro gainz around the call-site, but perhaps the POS they were building with back then didn't have support inline ASM. lol. Then, the ASM is definitely not optimal, but hey, nobody's is. It looks fine. The other big thing is... LOTS of free GAINZ for us thanks to @EndoOleg and the other contributors to the SH GCC back-end... This is built with the latest GCC17 development branch (with an experimental souped up toolchain) with shit built at -O3 with -flto (but -ffast-math disabled, cuz for whatever reason the AI decomping this insisted it was unmatching to the original, so it's all falling back to SH4ZAM emitting inline ASM for shit the compiler can emit from C). Anyway, this souped up GCC-17 dev experimetnal fucker can vectorize dot products and has comiler-scheduled builtins for all of the FPU shit, meanwhile the POS compilers back then couldn't even emit FMAC automatically... 🤣

    3 likes

  • sh4's profile picture

    @sh4forever

    Similar to the C function wrappers, LTO sounds like a big deal, especially if ninja was doing that as a linked library. No ability to inline into the end program is pretty bad. I'm sure the scheduler of modern compilers is a huge piece too. Thanks again for the thoughful reply!

    1 like

  • Falco Girgis's profile picture

    @falco_girgis

    Dude, -flto is the biggest free GAINZ there ever was. Before I even do a goddamn thing to gain a cycle, I make goddamn sure I am building with LTO enabled. A wise man takes every gain he can get, and the free ones that take no intrusive code changes should be the first ones you reach for.

    2 likes

  • thethiny 🐰🍉's profile picture

    @thethiny

    Gonna love this, aren't I?

    3 likes

  • @undiadefuria's profile picture

    @JuanMan54064335

    Venga, más mágia negra imposible. ¿A qué ente del averno habéis vendido vuestras almas para conseguir semejantes burradas?😆

    2 likes

  • PlusJamais's profile picture

    @PlusJamais49053

    J'ai toujours su que vos travaux mathématiques seraient bénéfiques aux jeux existants. Maintenant que l'on peut les decompiler on va pouvoir se refaire la ludothèque dreamcast ultime à 60 fps en wide-screen VGA. Il manquera le support audio 5.1 malheuresement.

    2 likes

  • Winged H.'s profile picture

    @rodrigo_tr68356

    this is so magical

    2 likes

  • Ruanes Miranda Sabino Jr's profile picture

    @maria_eva36078

    impressionante o sonic adventure 1 está rodando 60fps no Dreamcast. Sh4zam é poderoso.

    2 likes

  • Dark Redshift's profile picture

    @DarkRedshift

    Is this a recomp of the two Dreamcast versions or a remaster on Dreamcast hardware and/or emulators only? If the former, I look forward to the SA2 one most! There’s still some effects from PC version mods that are missing, like the pulse alarm screen effect with the shockwaves.

    2 likes

  • Falco Girgis's profile picture

    @falco_girgis

    Former... and.... well, lets just say you definitely should be looking forward to what you're looking forward to. 😉

    4 likes

  • Douglas Miller's profile picture

    @re4thewin

    so excited he goofed 😅

    1 like

  • Falco Girgis's profile picture

    @falco_girgis

    So excited my dumb ass records it at 30FPS over here. LMFAO.

    3 likes

  • Raymond Rivera's profile picture

    @DTRAS_Band

    Sonic looks great! Thanks for all your effort and the effort of the Dreamcast home brew scene.

    1 like