summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-03-26 21:25:40 -0700
committerMichael Pavone <pavone@retrodev.com>2018-03-26 21:25:40 -0700
commitfef637bdab85fef50d54d985e9c254dbca289d99 (patch)
treefde59ce5e79ddd5b4edbac833840e0438f6ac4f3
parentb79940c0421e79906b4a7af0bb79fdcf39be8c22 (diff)
Get Windows build working again. MegaWiFi code probably needs more work before it will actually work on Windows, but at least it doesn't break the build now
-rw-r--r--Makefile4
-rw-r--r--megawifi.c12
-rw-r--r--net_win.c14
3 files changed, 29 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 94a7d68..95de80f 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ endif
MEM:=mem_win.o
TERMINAL:=terminal_win.o
FONT:=nuklear_ui/font_win.o
+NET:=net_win.o
EXE:=.exe
CC:=i686-w64-mingw32-gcc-win32
CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC
@@ -27,6 +28,7 @@ else
MEM:=mem.o
TERMINAL:=terminal.o
+NET:=net.o
EXE:=
ifeq ($(OS),Darwin)
@@ -146,7 +148,7 @@ RENDEROBJS+= $(LIBZOBJS) png.o
endif
MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \
- realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o net.o serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
+ realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
$(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o
ifdef NONUKLEAR
diff --git a/megawifi.c b/megawifi.c
index 00691f3..e5ba7b7 100644
--- a/megawifi.c
+++ b/megawifi.c
@@ -2,9 +2,15 @@
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
+#ifdef _WIN32
+#define WINVER 0x501
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include "genesis.h"
@@ -125,7 +131,10 @@ static void poll_socket(megawifi *mw, uint8_t channel)
int res = accept(mw->sock_fds[channel], NULL, NULL);
if (res >= 0) {
close(mw->sock_fds[channel]);
+#ifndef _WIN32
+//FIXME: Set nonblocking on Windows too
fcntl(res, F_SETFL, O_NONBLOCK);
+#endif
mw->sock_fds[channel] = res;
mw->channel_state[channel] = 2;
mw->channel_flags |= 1 << (channel + 1);
@@ -284,7 +293,10 @@ static void process_packet(megawifi *mw)
} else {
mw->channel_flags |= 1 << (channel + 1);
mw->channel_state[channel] = 1;
+#ifndef _WIN32
+//FIXME: Set nonblocking on Windows too
fcntl(mw->sock_fds[channel], F_SETFL, O_NONBLOCK);
+#endif
}
end_reply(mw);
break;
diff --git a/net_win.c b/net_win.c
new file mode 100644
index 0000000..2abae16
--- /dev/null
+++ b/net_win.c
@@ -0,0 +1,14 @@
+#include "net.h"
+
+uint8_t get_host_address(iface_info *out)
+{
+ out->ip[0] = 127;
+ out->ip[1] = 0;
+ out->ip[2] = 0;
+ out->ip[3] = 1;
+ out->net_mask[0] = 255;
+ out->net_mask[0] = 255;
+ out->net_mask[0] = 255;
+ out->net_mask[0] = 0;
+ return 1;
+}