From bbfeb19b08c9971b0dc3219c4f92d4cf9efda530 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Tue, 24 Apr 2018 17:06:32 -0500 Subject: [PATCH] Calculate SHA256 checksum for later use. --- gtk/Makefile.am | 3 ++- libretro/Makefile.common | 1 + libretro/libretro.cpp | 2 +- memmap.cpp | 5 +++++ memmap.h | 1 + sha256.c => sha256.cpp | 0 unix/Makefile.in | 2 +- win32/snes9xw.vcxproj | 4 +++- win32/snes9xw.vcxproj.filters | 8 +++++++- 9 files changed, 21 insertions(+), 5 deletions(-) rename sha256.c => sha256.cpp (100%) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 54fb3e59..a3bc4a5f 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -179,7 +179,8 @@ snes9x_gtk_SOURCES += \ ../snapshot.cpp \ ../screenshot.cpp \ ../movie.cpp \ - ../statemanager.cpp + ../statemanager.cpp \ + ../sha256.cpp # ASMCPU Doesn't exist anymore. snes9x_gtk_SOURCES += \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 7b29c937..31ec04f3 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -44,6 +44,7 @@ SOURCES_CXX := $(CORE_DIR)/apu/apu.cpp \ $(CORE_DIR)/seta010.cpp \ $(CORE_DIR)/seta011.cpp \ $(CORE_DIR)/seta018.cpp \ + $(CORE_DIR)/sha256.cpp \ $(CORE_DIR)/snapshot.cpp \ $(CORE_DIR)/snes9x.cpp \ $(CORE_DIR)/spc7110.cpp \ diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 4219f8fc..dd2f91ea 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -550,7 +550,7 @@ bool retro_load_game(const struct retro_game_info *game) if(!environ_cb || !environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { - return false + return false; } S9xGraphicsDeinit(); diff --git a/memmap.cpp b/memmap.cpp index 3c35305a..b6c70e90 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -219,6 +219,7 @@ #include "cheats.h" #include "movie.h" #include "display.h" +#include "sha256.h" #ifndef SET_UI_COLOR #define SET_UI_COLOR(r, g, b) ; @@ -2671,7 +2672,10 @@ void CMemory::InitROM (void) // CRC32 if (!Settings.BS || Settings.BSXItself) // Not BS Dump + { ROMCRC32 = caCRC32(ROM, CalculatedSize); + sha256sum(ROM, CalculatedSize, ROMSHA256); + } else // Convert to correct format before scan { int offset = HiROM ? 0xffc0 : 0x7fc0; @@ -2683,6 +2687,7 @@ void CMemory::InitROM (void) ROM[offset + 23] = 0x00; // Calc ROMCRC32 = caCRC32(ROM, CalculatedSize); + sha256sum(ROM, CalculatedSize, ROMSHA256); // Convert back ROM[offset + 22] = BSMagic0; ROM[offset + 23] = BSMagic1; diff --git a/memmap.h b/memmap.h index d141c190..507a3b4c 100644 --- a/memmap.h +++ b/memmap.h @@ -268,6 +268,7 @@ struct CMemory uint32 ROMChecksum; uint32 ROMComplementChecksum; uint32 ROMCRC32; + unsigned char ROMSHA256[32]; int32 ROMFramesPerSecond; bool8 HiROM; diff --git a/sha256.c b/sha256.cpp similarity index 100% rename from sha256.c rename to sha256.cpp diff --git a/unix/Makefile.in b/unix/Makefile.in index 7d321e83..e4b23cfd 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -8,7 +8,7 @@ OS = `uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` BUILDDIR = . -OBJECTS = ../apu/apu.o ../apu/bapu/dsp/sdsp.o ../apu/bapu/dsp/SPC_DSP.o ../apu/bapu/smp/smp.o ../apu/bapu/smp/smp_state.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../msu1.o ../movie.o ../obc1.o ../ppu.o ../stream.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o ../statemanager.o unix.o x11.o +OBJECTS = ../apu/apu.o ../apu/bapu/dsp/sdsp.o ../apu/bapu/dsp/SPC_DSP.o ../apu/bapu/smp/smp.o ../apu/bapu/smp/smp_state.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../msu1.o ../movie.o ../obc1.o ../ppu.o ../stream.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o ../statemanager.o ../sha256.o unix.o x11.o DEFS = -DMITSHM ifdef S9XDEBUGGER diff --git a/win32/snes9xw.vcxproj b/win32/snes9xw.vcxproj index 916c4c0e..efc7ba58 100644 --- a/win32/snes9xw.vcxproj +++ b/win32/snes9xw.vcxproj @@ -388,6 +388,7 @@ + @@ -517,6 +518,7 @@ true + @@ -686,4 +688,4 @@ - \ No newline at end of file + diff --git a/win32/snes9xw.vcxproj.filters b/win32/snes9xw.vcxproj.filters index 26fae9fa..36ead7cc 100644 --- a/win32/snes9xw.vcxproj.filters +++ b/win32/snes9xw.vcxproj.filters @@ -48,6 +48,9 @@ Emu + + Emu + UnZip @@ -398,6 +401,9 @@ Emu + + Emu + Emu @@ -797,4 +803,4 @@ - \ No newline at end of file +