From 2c1d5bd45685ea2e1237d4db7c10493ede306983 Mon Sep 17 00:00:00 2001 From: nightmareci Date: Thu, 21 Aug 2025 10:19:20 -0700 Subject: [PATCH 1/2] Add Windows MSVC and Visual Studio support --- .github/workflows/ci.yml | 13 ++++++++++++- .gitignore | 4 ++++ .gitmodules | 3 +++ CMakeLists.txt | 26 ++++++++++++++++++++++++++ SDL | 1 + smolnes.c | 4 ++-- 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 SDL diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dffa774..e23cc38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: run: brew install sdl2 - name: Build run: make -j$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN) - build-windows: + build-windows-msys2: runs-on: windows-latest env: POWERSHELL_TELEMETRY_OPTOUT: 1 @@ -55,3 +55,14 @@ jobs: - name: Build shell: msys2 {0} run: make -j $NUMBER_OF_PROCESSORS + build-windows-msvc: + runs-on: windows-latest + env: + POWERSHELL_TELEMETRY_OPTOUT: 1 + steps: + - uses: actions/checkout@v3 + - uses: ilammy/msvc-dev-cmd@v1 + - name: Generate project + run: cmake -B build + - name: Build + run: cmake --build build -j (Get-WmiObject Win32_Processor).NumberOfLogicalProcessors diff --git a/.gitignore b/.gitignore index 55d8198..1f02eef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ smolnes deobfuscated *.nes +out +build +.vs +CMakeSettings.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5d2cee1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "SDL"] + path = SDL + url = git@github.com:libsdl-org/SDL.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6100d74 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.16) + +project(smolnes) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out") + +option(SMOLNES_VENDORED "Use vendored dependencies" ${WIN32}) + +if(SMOLNES_VENDORED) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out") + add_subdirectory(SDL EXCLUDE_FROM_ALL) +else() + find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2) + find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main) +endif() + +add_executable(smolnes WIN32 smolnes.c) +add_executable(deobfuscated WIN32 deobfuscated.c) + +if(TARGET SDL2::SDL2main) + target_link_libraries(smolnes PRIVATE SDL2::SDL2main) + target_link_libraries(deobfuscated PRIVATE SDL2::SDL2main) +endif() + +target_link_libraries(smolnes PRIVATE SDL2::SDL2) +target_link_libraries(deobfuscated PRIVATE SDL2::SDL2) diff --git a/SDL b/SDL new file mode 160000 index 0000000..98d1f3a --- /dev/null +++ b/SDL @@ -0,0 +1 @@ +Subproject commit 98d1f3a45aae568ccd6ed5fec179330f47d4d356 diff --git a/smolnes.c b/smolnes.c index cd48412..e93b0ce 100644 --- a/smolnes.c +++ b/smolnes.c @@ -23,8 +23,8 @@ l%2)|l%2 ,M[4+l-t]=S[2+l];K[t=MB/32&2]=S[6];K[1]=S[7];K[2-t]=(K[3]=b[4]*2-1)-1; :*K=v&31 ;W+1:v&128?F=0,mb=5,I|=12:(F=F/2|v<<4&16, !--mb)?t=a>>13,*(t==4?D=F&3,&I:t^5?t^6?&J:&c1:&c0 )=F,mb= 5,*M=c0& ~!(I&16),M[1]=I&16?c1:c0|1,t=I/4%4-2,*K=! t?0:t^1?J&~1:J,K[1]=!t?J:t^1?J|1:b[4]-1:0;}Q+E[(K [h-8>>e -12]&(b[ 4]<<14-e)-1)<>5){W+0:!++l&&++h;N:g(h)g(l)g(P|32)l=m(N=~1-(N&4),~0);h=m(N+1,~0);N=0;c++;W+1:r=R ();g(h) g(l)h=R( );l=r;W+2:P =z&~32;l= z;h=z;W+3:l=z;h=z;!++l&&++h;}c+=4;W+16:R();k(!(P&bm[o>>6])^o/32&1)r=l+(int8_t)v>>8,h+=r,l+=v,c+=r?2:1;W-1 :x(8,24 From 7b9091b0ac2ad357b1de3b489fb8ea543b45f615 Mon Sep 17 00:00:00 2001 From: nightmareci Date: Thu, 21 Aug 2025 10:28:06 -0700 Subject: [PATCH 2/2] Set up submodules for build-windows-msvc --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e23cc38..cbd9f6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,13 @@ jobs: POWERSHELL_TELEMETRY_OPTOUT: 1 steps: - uses: actions/checkout@v3 + with: + submodules: recursive - uses: ilammy/msvc-dev-cmd@v1 + - name: Initialize and update submodules + run: | + git submodule init + git submodule update --recursive - name: Generate project run: cmake -B build - name: Build