Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
This is a fork of the official source code repository for the Snes9x project, cleaned up for 2024 and building as C++ 20 in VS 2022. Importantly, a new feature has been implemented that adds a socket server on a dedicated thread that surfaces the entire state RAM of the emulated SNES. This behaves like a standard WWW Rest API on the localhost:9000/
Table-of-Contents
Files: memmap.h , memmap.c
| Name | Type | Description |
|---|---|---|
| RAM | uint8 | The working / state memory of the Super Nintendo itself |
| ROMStorage | std::vector<uint8_t> | This is the Byte Array that contains the ROM file of the Super Nintendo cartridge (game) |
| ROM | uint8 * | This is the pointer to the above, as the size will be dynamic |
| SRAMStorage | std::vector<uint8_t> | This is the Byte Array that contains the Save State / Battery backed-up storage |
| SRAM | uint8 * | This is t he pointer to the above, as the size will be dynamic |
| SRAM_SIZE | const size_t | Default: 0x80000 but set to the exact size of the SRAM per game |
| VRAM | uint8 | Default: 0x10000. This is the Video / PPU RAM of the Super Nintendo |
| ROMFilename | std::string | The name of the Super Nintendo ROM file (game name) as it is on the user's hard drive |
| ROMName | char | Length set to a define ROM_NAME_LEN - game name as it is in the ROM file |
| ROMId | char | Length set to 5 |
| CompanyId | int32 | |
| ROMRegion | uint8 | |
| ROMSpeed | uint8 | |
| ROMType | uint8 | |
| ROMSize | uint8 | |
| ROMChecksum | uint32 | |
| ROMComplementChecksum | uint32 | |
| ROMCRC32 | uint32 | |
| ROMSHA256 | unsigned char | 32 |
| ROMFramesPerSecond | int32 | |
| HiROM | bool8 | |
| LoROM | bool8 | |
| SRAMSize | uint8 | |
| SRAMMask | uint32 | |
| CalculatedSize | uint32 | |
| CalculatedChecksum | uint32 |
- Add-in the Nathaniel Lomann JSON header-only implementation
- Entrypoint for Socket Server is in
wsnes9x.cppon Line3917(maybe)
- Added
bool8 MemoryServe;andint MemServePort;to theSSettingsstruct definition insnes9x.h - Added the following code to
wconfig.cppto add support for our new feature intosnes9x.conf:
#define CATEGORY "MemoryServe"
AddBool("Enabled", Settings.MemoryServe, false);
AddInt("Port", Settings.MemServePort, 9000);
#undef CATEGORY- Emulation menu (
wsnes9x.cpp):
mii.fState = Settings.MemoryServe ? MFS_CHECKED : MFS_UNCHECKED;
SetMenuItemInfo(GUI.hMenu, ID_EMULATION_MEMSERVE, FALSE, &mii);
WM_COMMAND:
case ID_EMULATION_MEMSERVE:
MessageBox(hWnd, TEXT("All your base are belong to us."), TEXT("Notice"), MB_OK);
break;Efforts in v0.1 were related to getting the project to compile in VS 2022, targeting C++ 20 and the Windows 10 SDK, as well as removing deprecated features, and updating libraries.
- Windows SDK Version changed from
8.1to10.0 Latest - Platform Toolset changed from
VS 2017 v141_xptoVS 2022 v143 - C++ Language Standard changed from
C++ 17toC++ 20
Review my updated compiling instructions, no DirectX Run-times/SDK downloads are required any longer. Here's what's actually changed:
- Deleted
dxerr.handdxerr.cpp - Removed all instances of
#include "dxerr.hthrough the entire code-base - Updated Direct3D initialization and rendering logic to be compatible with the Windows 10 SDK
- To avoid overhauling from D3D9 to a newer version, we are now just linking against
d3d9.lib
x
Completely removed DirectDraw from the code base. Here's exactly what changed:
- Deleted
ddrawfolder. - Deleted
CDirectDraw.handCDirectDraw.cpp - Removed
TEXT("DirectDraw")from theconst TCHAR* driverNames[]inwin32_display.cpp - Removed the pragma command to link with
ddraw*.lib - Removed
DIRECTDRAW = 0,from theOutputMethodenum inwsnes9x.hand setDIRECT3Dto0 - Removed checks like this:
GUI.outputMethod!=DIRECTDRAW
warning C4996: 'stdext::checked_array_iterator<T *>::value_type': warning STL4043: stdext::checked_array_iterator, stdext::unchecked_array_iterator, and related factory functions are non-Standard extensions and will be removed in the future. std::span (since C++20) and gsl::span can be used instead. You can define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING or _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS to suppress this warning.
- These warnings were solved by overwriting the
srcandincludefolders in this repository with thesrcandincludefolders from the latest version offmt
| Files Modified |
|---|
| wsnes9x.cpp |
Several instances across the project of errors C2440 and C2664, including variable declarations and function arguments, were updated to conform to the C++ 20 requirement /Zc:strictStrings. Compilation errors arose when non-const pointers were initialized with string literals. This was primarily observed in wsnes9x.cpp and other files where TCHAR* variables were assigned string literals directly. This practice is deemed unsafe in C++ 20 as it allows modification of string literals, which are stored in read-only memory sections of an application.
x
| Files Modified |
|---|
| snes9x_imgui.cpp |
| COpenGL.cpp |
| vulkan_shader_chain.cpp |
Minor formatting tweak to the CMemory struct definition.
Implements an HTTP server that streams SNES RAM as binary data.
Header for the MemServe feature.
Web page that fetches RAM from localhost:9000 and draws it on a canvas.
Added MemoryServe and MemServePort to the SSettings struct.
Removed a DIRECTDRAW check to always clear the change log.
Introduces ID_EMULATION_MEMSERVE for the new menu item.
Adds the "SNES Memory REST API" entry under the Emulation menu.
Links against ws2_32.lib and includes the MemServe source files.
Places MemServe files under a "FastLink" filter for organization.
Registers MemServe configuration options in snes9x.conf.
Removed the DirectDraw driver name from the output method list.
Spawns and joins the MemServe thread and handles the menu toggle.
Adjusted OutputMethod enum to drop DIRECTDRAW.
Updated the window title and disclaimer text for "Snes9x-FastLink".