libretro / snes9x2005

Snes9x 2005. Port of SNES9x 1.43 for libretro (was previously called CAT SFC).
Other
15 stars 34 forks source link

Cleanups v2 #26

Closed jamsilva closed 7 years ago

jamsilva commented 7 years ago

This time I just removed unused code and fixed a few clang warnings.

Alcaro commented 7 years ago

- 4100, 2600, 1500, 1000, 640, 380, 260, 160, + 4100u, 2600u, 1500u, 1000u, 640u, 380u, 260u, 160u,

Why are compilers so whiny about integer constants

- uint8_t RAM; + uint8_t RAM;

+1, asterisk-right is common in C and C++ but asterisk-left is the standard in Snes9x

-#undef MIN -#undef MAX -#define MIN(A,B) ((A) < (B) ? (A) : (B)) -#define MAX(A,B) ((A) > (B) ? (A) : (B))

Good call moving that to the header. MIN/MAX are defined in windows.h, but a libretro core has few if any reasons to include that anyways.

- S9xSyncSpeed(); - if (Settings.SoundSync) - S9xGenerateSound(); - S9xProcessSound(0);

You sure we don't need these?

define PushWE(w)

define PushWENew(w)

That's a fairly tricky diff, but seems correct...

-#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - if (max(swappedlorom, swappedhirom) >= max(loromscore, hiromscore)) + if (MAX(swappedlorom, swappedhirom) >= MAX(loromscore, hiromscore))

+1, we definitely don't need both max and MAX

- if ((((Memory.Map[8] + 0xFFDE)) == ((Memory.Map[0x808] + 0xFFDE)))) + if ((Memory.Map[8] + 0xFFDE) == (Memory.Map[0x808] + 0xFFDE))

Can we use Memory.Map[8][0xFFDE] instead

-#ifdef __W32_HEAP - if (_HEAPOK != _heapchk()) - MessageBox(GUI.hWnd, "ApplyROMFixes", "Heap Corrupt", MB_OK); -#endif

Yeah, there's no overflow debugging left to do on this core... and that stuff belongs in frontend, anyways.

- strncpy(Memory.ROMName, "THIS SCRIPT WAS STOLEN", 22);

what the fuck

kill it with fire

Everything except the S9xSound function skips (and the memmap pointer shenanigans, but that's a broken->broken transition, they're acceptable) looks good to me, and I can be convinced about that one too. For example if they immediately return if Settings.SoundSync is false, that one sounds like a constant under libretro.

jamsilva commented 7 years ago

The S9xSyncSpeed at gfx.h and S9xGenerateSound and S9xProcessSound at libretro.c were empty.

Alcaro commented 7 years ago

That's convincing enough for me.

It's better to remove them completely, but partial fix is an improvement.