Skip to content

Commit

Permalink
Merge remote-tracking branch 'rakslice/emaculation_windows_fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatz-drizly committed Oct 16, 2020
2 parents e82b218 + 151a452 commit 6a0b9b5
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 70 deletions.
4 changes: 2 additions & 2 deletions BasiliskII/src/Windows/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $(APP): $(XPLATSRCS) $(OBJ_DIR) $(OBJS)
$(CXX) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) $(SDL_LIBS)

$(UI_APP): $(XPLATSRCS) $(OBJ_DIR) $(UI_OBJS)
$(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) $(GTK_LIBS) -mwindows -mno-cygwin
$(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) -Wl,-Bdynamic $(GTK_LIBS) -Wl,-Bstatic -mwindows -static-libgcc

mostlyclean:
rm -f $(APP) $(UI_APP) $(OBJ_DIR)/* core* *.core *~ *.bak
Expand Down Expand Up @@ -149,7 +149,7 @@ $(OBJ_DIR)/%.o : %.cpp
$(OBJ_DIR)/%.o : %.s
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/prefs_editor_gtk.o: prefs_editor_gtk.cpp
$(CXX) -O2 -mno-cygwin -mms-bitfields $(CPPFLAGS) $(DEFS) $(GTK_CFLAGS) -c $< -o $@
$(CXX) -O2 -mms-bitfields $(CPPFLAGS) $(DEFS) $(GTK_CFLAGS) -c $< -o $@

# Windows resources
$(OBJ_DIR)/%.o: %.rc
Expand Down
5 changes: 4 additions & 1 deletion BasiliskII/src/Windows/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,13 @@ if [[ "x$HAVE_GCC30" = "xyes" ]]; then
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
ac_cv_gcc_no_strict_aliasing, [
AC_TRY_COMPILE([],[],
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
[ac_cv_gcc_no_strict_aliasing=yes],
[ac_cv_gcc_no_strict_aliasing=no])
])
CFLAGS="$SAVED_CFLAGS"
if test "x$ac_cv_gcc_no_strict_aliasing" = xyes; then
AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")
fi
fi

dnl Select appropriate CPU source and REGPARAM define.
Expand Down
4 changes: 2 additions & 2 deletions BasiliskII/src/Windows/main_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ int main(int argc, char **argv)
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));

// Get rom file path from preferences
auto rom_path = tstr(PrefsFindString("rom"));
const char * rom_path = PrefsFindString("rom");

// Load Mac ROM
HANDLE rom_fh = CreateFile(rom_path ? rom_path.get() : ROM_FILE_NAME,
HANDLE rom_fh = CreateFile(rom_path ? rom_path : ROM_FILE_NAME,
GENERIC_READ,
FILE_SHARE_READ, NULL,
OPEN_EXISTING,
Expand Down
11 changes: 10 additions & 1 deletion BasiliskII/src/Windows/posix_emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,23 @@ void init_posix_emu(void)
int fd = my_creat( custom_icon_name, 0 );
if(fd >= 0) {
my_close(fd);
struct my_stat custom_icon_stat;
int stat_result = my_stat( custom_icon_name, &custom_icon_stat );
fd = open_rfork( custom_icon_name, O_RDWR|O_CREAT );
if(fd >= 0) {
my_write( fd, my_comp_icon, sizeof(my_comp_icon) );
my_close(fd);
static uint8 host_finfo[SIZEOF_FInfo];
// need room for the things from around the finfo that set_finfo reads
static uint8 custom_icon_hfile[ioFlXFndrInfo + SIZEOF_FXInfo];
memset(custom_icon_hfile, 0, ioFlXFndrInfo + SIZEOF_FXInfo);
static uint8 * host_finfo = custom_icon_hfile + ioFlFndrInfo;
uint32 finfo = Host2MacAddr(host_finfo);
get_finfo(custom_icon_name, finfo, 0, false);
WriteMacInt16(finfo + fdFlags, kIsInvisible);
if (stat_result == 0) {
WriteMacInt32(finfo - ioFlFndrInfo + ioFlCrDat, TimeToMacTime(custom_icon_stat.st_ctime));
WriteMacInt32(finfo - ioFlFndrInfo + ioFlMdDat, TimeToMacTime(custom_icon_stat.st_mtime));
}
set_finfo(custom_icon_name, finfo, 0, false);
get_finfo(my_computer, finfo, 0, true);
WriteMacInt16(finfo + fdFlags, ReadMacInt16(finfo + fdFlags) | kHasCustomIcon);
Expand Down
2 changes: 1 addition & 1 deletion BasiliskII/src/Windows/posix_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ struct my_utimbuf
};

// Your compiler may have different "struct stat" -> edit "struct my_stat"
#define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct stat) )
#define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct _stat) )

#define st_crtime st_ctime
139 changes: 105 additions & 34 deletions BasiliskII/src/Windows/prefs_editor_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <sys/stat.h>
#include <gtk/gtk.h>

#include <shellapi.h>

#include "user_strings.h"
#include "version.h"
#include "cdrom.h"
Expand Down Expand Up @@ -76,6 +78,27 @@ enum {
* Utility functions
*/

gchar * tchar_to_g_utf8(const TCHAR * str) {
gchar * out;
if (str == NULL)
return NULL;
int len = _tcslen(str) + 1;
#ifdef _UNICODE
/* First call just to find what the output size will be */
int size = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
if (size == 0)
return NULL;
out = (gchar *) g_malloc(size);
if (out == NULL)
return NULL;
WideCharToMultiByte(CP_UTF8, 0, str, len, out, size, NULL, NULL);
#else /* _UNICODE */
out = g_locale_to_utf8(str, -1, NULL, NULL, NULL);
#endif /* _UNICODE */
return out;
}


struct opt_desc {
int label_id;
GtkSignalFunc func;
Expand Down Expand Up @@ -672,11 +695,11 @@ static GList *add_cdrom_names(void)
{
GList *glist = NULL;

char rootdir[4] = "X:\\";
for (char letter = 'C'; letter <= 'Z'; letter++) {
TCHAR rootdir[4] = TEXT("X:\\");
for (TCHAR letter = TEXT('C'); letter <= TEXT('Z'); letter++) {
rootdir[0] = letter;
if (GetDriveType(rootdir) == DRIVE_CDROM)
glist = g_list_append(glist, strdup(rootdir));
glist = g_list_append(glist, _tcsdup(rootdir));
}

return glist;
Expand Down Expand Up @@ -887,11 +910,12 @@ static void create_jit_pane(GtkWidget *top)
#endif

set_jit_sensitive();
#endif

#ifdef SHEEPSHAVER
make_checkbox(box, STR_JIT_68K_CTRL, "jit68k", GTK_SIGNAL_FUNC(tb_jit_68k));
#endif

#endif
}

/*
Expand Down Expand Up @@ -1466,51 +1490,53 @@ static int create_ether_menu(GtkWidget *menu)
n_items++;

// Basilisk II Ethernet Adapter
PacketOpenAdapter("", 0);
PacketOpenAdapter(TEXT(""), 0);
{
ULONG sz;
char names[1024];
TCHAR names[1024];
sz = sizeof(names);
if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) {
char *p = names;
TCHAR *p = names;
while (*p) {
const char DEVICE_HEADER[] = "\\Device\\B2ether_";
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
const TCHAR DEVICE_HEADER[] = TEXT("\\Device\\B2ether_");
if (_tcsnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0);
if (fd) {
char guid[256];
sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1);
const char *name = ether_guid_to_name(guid);
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) {
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid));
if (etherguid && strcmp(guid, etherguid) == 0 &&
TCHAR guid[256];
_stprintf(guid, TEXT("%s"), p + sizeof(DEVICE_HEADER) - 1);
const gchar *name = tchar_to_g_utf8(ether_guid_to_name(guid));
if (name) {
std::string str_guid = to_string(guid);
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(str_guid.c_str()));
if (etherguid && to_tstring(guid).compare(to_tstring(etherguid)) == 0 &&
ether && strcmp(ether, "b2ether") == 0)
active = n_items;
n_items++;
}
PacketCloseAdapter(fd);
}
}
p += strlen(p) + 1;
p += _tcslen(p) + 1;
}
}
}
PacketCloseAdapter(NULL);

// TAP-Win32
const char *tap_devices;
const TCHAR *tap_devices;
if ((tap_devices = ether_tap_devices()) != NULL) {
const char *guid = tap_devices;
const TCHAR *guid = tap_devices;
while (*guid) {
const char *name = ether_guid_to_name(guid);
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) {
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_tap, strdup(guid));
if (etherguid && strcmp(guid, etherguid) == 0 &&
const gchar *name = tchar_to_g_utf8(ether_guid_to_name(guid));
if (name) {
std::string str_guid = to_string(guid);
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_tap, strdup(str_guid.c_str()));
if (etherguid && to_tstring(guid).compare(to_tstring(etherguid)) == 0 &&
ether && strcmp(ether, "tap") == 0)
active = n_items;
n_items++;
}
guid += strlen(guid) + 1;
guid += _tcslen(guid) + 1;
}
free((char *)tap_devices);
}
Expand Down Expand Up @@ -1734,21 +1760,66 @@ void SysAddSerialPrefs(void)
* Display alerts
*/

static HWND GetMainWindowHandle() {
return NULL;
}

static void display_alert(int title_id, const char *text, int flags)
{
MessageBox(NULL, text, GetString(title_id), MB_OK | flags);
HWND hMainWnd = GetMainWindowHandle();
MessageBoxA(hMainWnd, text, GetString(title_id), MB_OK | flags);
}
#ifdef _UNICODE
static void display_alert(int title_id, const wchar_t *text, int flags)
{
HWND hMainWnd = GetMainWindowHandle();
MessageBoxW(hMainWnd, text, GetStringW(title_id).get(), MB_OK | flags);
}
#endif


/*
* Display error alert
*/

void ErrorAlert(const char *text)
{
if (PrefsFindBool("nogui"))
return;

display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
}
#ifdef _UNICODE
void ErrorAlert(const wchar_t *text)
{
if (PrefsFindBool("nogui"))
return;

display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
}
#endif


/*
* Display warning alert
*/

void WarningAlert(const char *text)
{
if (PrefsFindBool("nogui"))
return;

display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP);
}
#ifdef _UNICODE
void WarningAlert(const wchar_t *text)
{
if (PrefsFindBool("nogui"))
return;

display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP);
}
#endif

/*
* Start standalone GUI
Expand All @@ -1774,23 +1845,23 @@ int main(int argc, char *argv[])

// Transfer control to the executable
if (start) {
char path[_MAX_PATH];
TCHAR path[_MAX_PATH];
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0;
if (ok) {
char b2_path[_MAX_PATH];
char *p = strrchr(path, '\\');
*++p = '\0';
TCHAR b2_path[_MAX_PATH];
TCHAR *p = _tcsrchr(path, TEXT('\\'));
*++p = TEXT('\0');
SetCurrentDirectory(path);
strcpy(b2_path, path);
strcat(b2_path, PROGRAM_NAME);
strcat(b2_path, ".exe");
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open",
b2_path, "", path, SW_SHOWNORMAL);
_tcscpy(b2_path, path);
_tcscat(b2_path, TEXT(PROGRAM_NAME));
_tcscat(b2_path, TEXT(".exe"));
HINSTANCE h = ShellExecute(GetDesktopWindow(), TEXT("open"),
b2_path, TEXT(""), path, SW_SHOWNORMAL);
if ((int)h <= 32)
ok = false;
}
if (!ok) {
ErrorAlert("Coult not start " PROGRAM_NAME " executable");
ErrorAlert(TEXT("Could not start ") TEXT(PROGRAM_NAME) TEXT(" executable"));
return 1;
}
}
Expand Down
4 changes: 0 additions & 4 deletions BasiliskII/src/Windows/sysdeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#ifndef SYSDEPS_H
#define SYSDEPS_H

#ifdef __MINGW32__
#define _UNICODE
#endif

#if !defined _MSC_VER && !defined __STDC__
#error "Your compiler is not ANSI. Get a real one."
#endif
Expand Down
12 changes: 12 additions & 0 deletions BasiliskII/src/slirp/slirp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,32 @@ typedef unsigned long ioctlsockopt_t;
# include <WS2tcpip.h>

#ifdef __MINGW32__
/* Once upon a time MINGW32 didn't have inet_ntop() and inet_pton() in the headers?
In a new mingw32 WS2tcpip.h that has them, the Inet*A defines point to them. */

#ifndef InetNtopA

char * WSAAPI inet_ntop(
INT Family,
PVOID pAddr,
PTSTR pStringBuf,
size_t StringBufSize
);

#endif

#ifndef InetPtonA

INT WSAAPI inet_pton(
INT Family,
const char * pszAddrString,
PVOID pAddrBuf
);

#endif

#endif /* __MINGW32__ */

# include <sys/timeb.h>
# include <iphlpapi.h>

Expand Down
2 changes: 1 addition & 1 deletion SheepShaver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ links:
case $$i in *codegen_x86.h) o=kpx_cpu/src/cpu/jit/x86/codegen_x86.h;; esac; \
SUB=`echo $$o | sed 's;[^/]*/;../;g' | sed 's;[^/]*$$;;'` ;\
cur_link=src/$$o ;\
if [ -d "$$cur_link" ]; then rm -rf "$$cur_link"; fi ;\
if [ -e "$$cur_link" ]; then rm -rf "$$cur_link"; fi ;\
ln -sf "$$PREFIX$$SUB$(B2_TOPDIR)/src/$$i" $$cur_link; \
fi; \
done;
5 changes: 3 additions & 2 deletions SheepShaver/src/Windows/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window

UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \
../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \
../dummy/prefs_dummy.cpp \
b2ether/packet32.cpp SheepShaverGUI.rc

UI_APP = SheepShaverGUI.exe
Expand Down Expand Up @@ -128,7 +129,7 @@ $(APP): $(XPLATSRCS) $(OBJ_DIR) $(OBJS)
$(CXX) -o $(APP) $(LDFLAGS) $(OBJS) $(LIBS) $(SDL_LIBS)

$(UI_APP): $(XPLATSRCS) $(OBJ_DIR) $(UI_OBJS)
$(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) $(GTK_LIBS) -mwindows -mno-cygwin
$(CXX) -o $@ $(LDFLAGS) $(UI_OBJS) $(LIBS) -Wl,-Bdynamic $(GTK_LIBS) -Wl,-Bstatic -mwindows -static-libgcc

mostlyclean:
rm -f $(APP) $(UI_APP) $(OBJ_DIR)/* core* *.core *~ *.bak
Expand Down Expand Up @@ -163,7 +164,7 @@ $(OBJ_DIR)/%.o : %.S
$(AS) $(ASFLAGS) -o $@ $*.out.s
rm $*.out.s
$(OBJ_DIR)/prefs_editor_gtk.o: prefs_editor_gtk.cpp
$(CXX) -O2 -mno-cygwin -mms-bitfields $(CPPFLAGS) $(DEFS) $(GTK_CFLAGS) -c $< -o $@
$(CXX) -O2 -mms-bitfields $(CPPFLAGS) $(DEFS) $(GTK_CFLAGS) -c $< -o $@

# Windows resources
$(OBJ_DIR)/%.o: %.rc
Expand Down
Loading

0 comments on commit 6a0b9b5

Please sign in to comment.