Network code and pc.c are more platform-independent now.

This commit is contained in:
OBattler
2017-06-15 06:34:08 +02:00
parent 12e1e8dfa7
commit e4c08cf594
6 changed files with 99 additions and 13 deletions

View File

@@ -24,8 +24,7 @@
#include "../device.h"
#include "network.h"
#include "net_ne2000.h"
#include "../WIN/win.h"
#include "../WIN/win_language.h"
#include "../WIN/plat_ui.h"
static netcard_t net_cards[] = {
@@ -112,7 +111,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
case NET_TYPE_PCAP:
ret = network_pcap_setup(mac, rx, dev);
if (ret < 0) {
msgbox_error(ghwnd, IDS_2219);
plat_msgbox_error(IDS_2219);
network_type = NET_TYPE_NONE;
}
break;

26
src/WIN/plat_ui.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef __unix
extern void plat_msgbox_error(int i);
extern wchar_t *plat_get_string_from_id(int i);
#ifndef IDS_2219
#define IDS_2219 2219
#endif
#ifndef IDS_2077
#define IDS_2077 2077
#endif
#ifndef IDS_2078
#define IDS_2078 2078
#endif
#ifndef IDS_2079
#define IDS_2079 2079
#endif
#endif
extern void plat_msgbox_fatal(char *string);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void startblit(void);
extern void endblit(void);

View File

@@ -49,6 +49,7 @@
#include "plat_mouse.h"
#include "plat_midi.h"
#include "plat_thread.h"
#include "plat_ui.h"
#include "win.h"
#include "win_cgapal.h"
@@ -525,12 +526,12 @@ void create_removable_disk_submenu(HMENU m, int id)
AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE_WP | id, win_language_get_string_from_id(2220));
}
void get_executable_name(WCHAR *s, int size)
void get_executable_name(wchar_t *s, int size)
{
GetModuleFileName(hinstance, s, size);
}
void set_window_title(WCHAR *s)
void set_window_title(wchar_t *s)
{
if (video_fullscreen)
return;

View File

@@ -83,8 +83,8 @@ extern void joystickconfig_open(HWND hwnd, int joy_nr, int type);
extern int getfile(HWND hwnd, char *f, char *fn);
extern int getsfile(HWND hwnd, char *f, char *fn);
extern void get_executable_name(WCHAR *s, int size);
extern void set_window_title(WCHAR *s);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void startblit(void);
extern void endblit(void);

View File

@@ -20,6 +20,7 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#undef BITMAP
#include <commdlg.h>
@@ -27,6 +28,7 @@
#include "../ibm.h"
#include "../device.h"
#include "../ide.h"
#include "plat_ui.h"
#include "win.h"
#include "win_language.h"
@@ -82,6 +84,11 @@ LPTSTR win_language_get_string_from_id(int i)
return lpResourceString[i - 2048];
}
wchar_t *plat_get_string_from_id(int i)
{
return (wchar_t *) win_language_get_string_from_id(i);
}
LPTSTR win_language_get_string_from_string(char *str)
{
return lpResourceString[atoi(str) - 2048];
@@ -117,6 +124,11 @@ void msgbox_error(HWND hwndParent, int i)
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[1], MB_OK | MB_ICONWARNING);
}
void plat_msgbox_error(int i)
{
msgbox_error(ghwnd, i);
}
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr)
{
MessageBox(hwndParent, wstr, lpResourceString[1], MB_OK | MB_ICONWARNING);
@@ -139,6 +151,11 @@ void msgbox_fatal(HWND hwndParent, char *string)
free(lptsTemp);
}
void plat_msgbox_fatal(char *string)
{
msgbox_fatal(ghwnd, string);
}
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)
{
OPENFILENAME ofn; /* common dialog box structure */
@@ -207,3 +224,47 @@ int file_dlg_st(HWND hwnd, int i, char *fn, int save)
{
return file_dlg(hwnd, win_language_get_string_from_id(i), fn, save);
}
static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData)
{
if(uMsg == BFFM_INITIALIZED)
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
return 0;
}
WCHAR path[MAX_PATH];
wchar_t *BrowseFolder(wchar_t *saved_path)
{
BROWSEINFO bi = { 0 };
bi.lpszTitle = L"Browse for folder...";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) saved_path;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl != 0)
{
/* Get the name of the folder and put it in path. */
SHGetPathFromIDList(pidl, path);
/* Free memory used. */
#if 0
IMalloc *imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
}
#endif
free(pidl);
return path;
}
return L"";
}

View File

@@ -73,8 +73,7 @@
#include "video/video.h"
#include "video/vid_voodoo.h"
#include "amstrad.h"
#include "win.h"
#include "win_language.h"
#include "../WIN/plat_ui.h"
#ifdef WALTJE
# include "plat_dir.h"
#endif
@@ -187,7 +186,7 @@ void fatal(const char *format, ...)
{
*newline = 0;
}
msgbox_fatal(ghwnd, msg);
plat_msgbox_fatal(msg);
#endif
dumppic();
dumpregs(1);
@@ -577,8 +576,8 @@ int serial_fifo_read, serial_fifo_write;
int emu_fps = 0;
static WCHAR wmodel[2048];
static WCHAR wcpu[2048];
static wchar_t wmodel[2048];
static wchar_t wcpu[2048];
void runpc(void)
{
@@ -659,7 +658,7 @@ void runpc(void)
win_title_update=0;
mbstowcs(wmodel, model_getname(), strlen(model_getname()) + 1);
mbstowcs(wcpu, models[model].cpu[cpu_manufacturer].cpus[cpu].name, strlen(models[model].cpu[cpu_manufacturer].cpus[cpu].name) + 1);
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmodel, wcpu, (!mousecapture) ? win_language_get_string_from_id(2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? win_language_get_string_from_id(2078) : win_language_get_string_from_id(2079)));
_swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmodel, wcpu, (!mousecapture) ? plat_get_string_from_id(IDS_2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079)));
set_window_title(s);
}
done++;