Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows version of LaiNES #27

Open
ghost opened this issue Dec 11, 2016 · 3 comments
Open

Windows version of LaiNES #27

ghost opened this issue Dec 11, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2016

Is a Windows build an eventual goal of LaiNES?

@ghost
Copy link
Author

ghost commented Dec 11, 2016

Compiles to binary in MinGW32/gcc46 but not yet working. Have this so far (Makefile has compile hints):

diff -rupN LaiNES-ORIG//src/Makefile LaiNES//src/Makefile
--- LaiNES-ORIG//src/Makefile	1969-12-31 19:00:00 -0500
+++ LaiNES//src/Makefile	2016-12-11 01:51:38 -0500
@@ -0,0 +1,28 @@
+# verify that SDL2 and related library files in /mingw/lib/
+# verify that SDL2 and related header files are "included" 
+# include SimpleIni.h; available here: 
+# https://github.com/brofield/simpleini/blob/master/SimpleIni.h
+# include dirent.h; available from here:
+# https://sourceforge.net/p/mingw/mingw-org-wsl/ci/master/tree/include/dirent.h
+
+CPP  = g++.exe
+CC   = gcc.exe
+
+CPPFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -I/usr/include -I/usr/include/directx -Wno-unused-value -Iinclude -I../lib/include -fpermissive -std=c++0x -DSI_NO_MBCS=1
+OBJ = mappers/mapper1.o mappers/mapper2.o mappers/mapper3.o mappers/mapper4.o apu.o cartridge.o config.o cpu.o gui.o joypad.o main.o mapper.o menu.o ppu.o ../lib/apu_snapshot.o ../lib/Blip_Buffer.o ../lib/Multi_Buffer.o ../lib/Nes_Apu.o ../lib/Nes_Namco.o ../lib/Nes_Oscs.o ../lib/Nes_Vrc6.o ../lib/Nonlinear_Buffer.o ../lib/Sound_Queue.o
+
+
+LIBS = -lstdc++ -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf
+
+LaiNES.exe: $(OBJ) $(DBOBJ) $(SIDOBJ)
+	$(CC) $(OBJ) $(DBOBJ) $(SIDOBJ) -o "LaiNES.exe" $(LIBS)
+
+all : LaiNES.exe
+
+clean :
+	rm *.o
+	rm *.exe
+
+%.o : %.cc
+	$(CPP) $(CPPFLAGS) -c $<
+
diff -rupN LaiNES-ORIG//src/config.cpp LaiNES//src/config.cpp
--- LaiNES-ORIG//src/config.cpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/config.cpp	2016-12-11 00:54:06 -0500
@@ -2,6 +2,7 @@
 #include <SimpleIni.h>
 #include "config.hpp"
 #include "gui.hpp"
+#include <unistd.h>
 
 namespace GUI {
 
@@ -51,7 +52,7 @@ const char* get_config_path(char * buf,
     snprintf(homepath, sizeof(homepath), "%s/.config", home);
 
     /* Then, .config as a folder */
-    int res = mkdir(homepath, CONFIG_DIR_DEFAULT_MODE);
+    int res = mkdir(homepath);
     int err = errno;
 
     if (res == -1 && err != EEXIST)
@@ -60,7 +61,7 @@ const char* get_config_path(char * buf,
     snprintf(path, sizeof(path), "%s/%s", homepath, CONFIG_DIR_NAME);
 
     /* Finally, CONFIG_DIR_NAME as a sub-folder */
-    res = mkdir(path, CONFIG_DIR_DEFAULT_MODE);
+    res = mkdir(path);
     err = errno;
 
     if (res == -1 && err != EEXIST)
diff -rupN LaiNES-ORIG//src/include/common.hpp LaiNES//src/include/common.hpp
--- LaiNES-ORIG//src/include/common.hpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/include/common.hpp	2016-12-11 00:12:55 -0500
@@ -1,5 +1,5 @@
 #pragma once
-#include <cstdint>
+#include <stdint.h>
 
 
 #define NTH_BIT(x, n) (((x) >> (n)) & 1)
diff -rupN LaiNES-ORIG//src/include/mapper.hpp LaiNES//src/include/mapper.hpp
--- LaiNES-ORIG//src/include/mapper.hpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/include/mapper.hpp	2016-12-11 01:05:51 -0500
@@ -6,7 +6,7 @@
 class Mapper
 {
     u8* rom;
-    bool chrRam = false;
+    static bool chrRam;
 
   protected:
     u32 prgMap[4];
diff -rupN LaiNES-ORIG//src/include/menu.hpp LaiNES//src/include/menu.hpp
--- LaiNES-ORIG//src/include/menu.hpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/include/menu.hpp	2016-12-11 01:16:30 -0500
@@ -5,6 +5,22 @@
 #include <vector>
 #include "gui.hpp"
 
+#include<sstream>
+
+template <typename T>
+std::string to_string(T value)
+{
+    //create an output string stream
+    std::ostringstream os ;
+
+    //throw the value into the string stream
+    os << value ;
+
+    //convert the string stream into a string and return
+    return os.str() ;
+}
+
+
 namespace GUI {
 
 
@@ -15,9 +31,9 @@ class Entry
     std::string label;
     std::function<void()> callback;
 
-    bool selected = false;
-    SDL_Texture* whiteTexture = nullptr;
-    SDL_Texture* redTexture   = nullptr;
+    static SDL_Texture* whiteTexture;
+    static SDL_Texture* redTexture;
+    static bool selected;
 
   public:
     Entry(std::string label, std::function<void()> callback = []{}, int x = TEXT_CENTER, int y = 0);
@@ -53,7 +69,7 @@ class ControlEntry : public Entry
 class Menu
 {
     std::vector<Entry*> entries;
-    int cursor = 0;
+    static int cursor;
 
   public:
     void add(Entry* entry);
diff -rupN LaiNES-ORIG//src/mapper.cpp LaiNES//src/mapper.cpp
--- LaiNES-ORIG//src/mapper.cpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/mapper.cpp	2016-12-11 01:06:13 -0500
@@ -1,6 +1,7 @@
 #include "ppu.hpp"
 #include "mapper.hpp"
 
+bool Mapper::chrRam = false;
 
 Mapper::Mapper(u8* rom) : rom(rom)
 {
diff -rupN LaiNES-ORIG//src/menu.cpp LaiNES//src/menu.cpp
--- LaiNES-ORIG//src/menu.cpp	2016-12-04 14:21:14 -0500
+++ LaiNES//src/menu.cpp	2016-12-11 01:38:07 -0500
@@ -3,6 +3,14 @@
 #include "cartridge.hpp"
 #include "menu.hpp"
 
+#include <iostream>
+#include <dirent.h>
+
+SDL_Texture* GUI::Entry::whiteTexture = nullptr;
+SDL_Texture* GUI::Entry::redTexture   = nullptr;
+bool GUI::Entry::selected = false;
+int GUI::Menu::cursor = 0;
+
 namespace GUI {
 
 using namespace std;

@kraln
Copy link
Contributor

kraln commented Dec 24, 2016

I had it nearly working with clang on windows, but strange linker errors and stuff caused issues. I will likely try again.

@AndreaOrru
Copy link
Owner

I don't have a Windows machine to try this out. Happy to merge patches if you manage to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants