Name : RetroPlatformIPC.h
Project : RetroPlatform Player
Support : http://www.retroplatform.com
- Legal : Copyright 2007-2021 Cloanto Corporation - All rights reserved. This
+ Legal : Copyright 2007-2022 Cloanto Corporation - All rights reserved. This
: file is multi-licensed under the terms of the Mozilla Public License
: version 2.0 as published by Mozilla Corporation and the GNU General
: Public License, version 2 or later, as published by the Free
: Software Foundation.
Authors : os, m
Created : 2007-08-27 13:55:49
- Updated : 2021-10-17 10:43:32
+ Updated : 2022-12-03 11:27:12
Comment : RetroPlatform Player interprocess communication include file
*****************************************************************************/
#include <windows.h>
-#define RETROPLATFORM_API_VER "10.0"
+#define RETROPLATFORM_API_VER "10.1"
#define RETROPLATFORM_API_VER_MAJOR 10
-#define RETROPLATFORM_API_VER_MINOR 0
+#define RETROPLATFORM_API_VER_MINOR 1
#define RPIPC_HostWndClass "RetroPlatformHost%s"
#define RPIPC_GuestWndClass "RetroPlatformGuest%d"
#define RP_IPC_TO_HOST_TEXT_CURSOR_INFO (WM_APP + 42) // introduced in RetroPlatform API 7.9
#define RP_IPC_TO_HOST_SET_MOUSE_CURSOR (WM_APP + 43) // introduced in RetroPlatform API 7.10
#define RP_IPC_TO_HOST_EXECUTE_RESULT (WM_APP + 44) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_DEVICEOPEN (WM_APP + 45) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_DEVICECLOSE (WM_APP + 46) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_DEVICEREADBYTE (WM_APP + 47) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_DEVICEWRITEBYTE (WM_APP + 48) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_PRIVATE_CANTYPECLIPB (WM_APP + 49) // introduced in RetroPlatform API 10.0
+#define RP_IPC_TO_HOST_DEVICEWRITEBYTES (WM_APP + 50) // introduced in RetroPlatform API 10.1
// ****************************************************************************
// Host-to-Guest Messages
// Device Categories
-#define RP_DEVICECATEGORY_FLOPPY 0 // floppy disk drive
-#define RP_DEVICECATEGORY_HD 1 // hard disk drive
-#define RP_DEVICECATEGORY_CD 2 // CD/DVD drive
-#define RP_DEVICECATEGORY_NET 3 // network card
-#define RP_DEVICECATEGORY_TAPE 4 // cassette tape drive
-#define RP_DEVICECATEGORY_CARTRIDGE 5 // expansion cartridge
-#define RP_DEVICECATEGORY_INPUTPORT 6 // input port (hosts an INPUTDEVICE: mouse, joystick, etc.)
-#define RP_DEVICECATEGORY_KEYBOARD 7 // keyboard
-#define RP_DEVICECATEGORY_MULTITAPPORT 8 // multitap port (e.g. input port on Amiga parallel port joystick adapter)
-#define RP_DEVICECATEGORY_COUNT 9 // total number of device categories
+#define RP_DEVICECATEGORY_FLOPPY 0 // floppy disk drive
+#define RP_DEVICECATEGORY_HD 1 // hard disk drive
+#define RP_DEVICECATEGORY_CD 2 // CD/DVD drive
+#define RP_DEVICECATEGORY_NET 3 // network card
+#define RP_DEVICECATEGORY_TAPE 4 // cassette tape drive
+#define RP_DEVICECATEGORY_CARTRIDGE 5 // expansion cartridge
+#define RP_DEVICECATEGORY_INPUTPORT 6 // input port (hosts an INPUTDEVICE: mouse, joystick, etc.)
+#define RP_DEVICECATEGORY_KEYBOARD 7 // keyboard
+#define RP_DEVICECATEGORY_MULTITAPPORT 8 // multitap port (e.g. input port on Amiga parallel port joystick adapter)
+#define RP_DEVICECATEGORY_MODEM 9 // virtual modem
+#define RP_DEVICECATEGORY_PRINTER 10 // printer
+#define RP_DEVICECATEGORY_COUNT 11 // total number of device categories
#define RP_ALL_DEVICES 32 // constant for the RP_IPC_TO_HOST_DEVICEACTIVITY message (to turn on/off all LEDs for a device category)
} RPEXECUTERESULT;
+// RP_IPC_TO_HOST_DEVICEREADBYTE returned flag
+#define RP_READBYTE_OK 0x80000000 // a byte was read from the specified device
+#define RP_READBYTE_BYTEMASK 0x000000FF // byte mask
+
+
// Legacy Compatibility
#ifndef RP_NO_LEGACY
// Changed in 7.0
#include "uaeipc.h"
#include "xwin.h"
#include "drawing.h"
+#ifdef RETROPLATFORM
+#include "rp.h"
+#endif
#define GSDLLEXPORT __declspec(dllimport)
prt_running--;
}
-static int doflushprinter (void)
+static int doflushprinter(int open)
{
- if (prtopen == 0 && prtbufbytes < MIN_PRTBYTES) {
+ if (open == 0 && prtbufbytes < MIN_PRTBYTES) {
if (prtbufbytes > 0)
write_log (_T("PRINTER: %d bytes received, less than %d bytes, not printing.\n"), prtbufbytes, MIN_PRTBYTES);
prtbufbytes = 0;
if (currprefs.parallel_matrix_emulation >= PARALLEL_MATRIX_EPSON) {
int i;
if (!prtopen) {
- if (!doflushprinter ())
+ if (!doflushprinter(prtopen))
return;
if (epson_init (currprefs.prtname, currprefs.parallel_matrix_emulation))
prtopen = 1;
for (i = 0; i < prtbufbytes; i++)
epson_printchar (prtbuf[i]);
} else {
+#ifdef RETROPLATFORM
+ if (rp_isprinter()) {
+ bool open = rp_isprinteropen();
+ if (!open) {
+ if (!doflushprinter(open))
+ return;
+ }
+ rp_writeprinter(prtbuf, prtbufbytes);
+ prtbufbytes = 0;
+ return;
+ }
+#endif
if (hPrt == INVALID_HANDLE_VALUE) {
- if (!doflushprinter ())
+ if (!doflushprinter(prtopen))
return;
openprinter ();
}
}
}
-int isprinter (void)
+int isprinter(void)
{
+#ifdef RETROPLATFORM
+ if (rp_isprinter()) {
+ return 1;
+ }
+#endif
if (!currprefs.prtname[0])
return 0;
- if (!_tcsncmp (currprefs.prtname, _T("LPT"), 3)) {
- paraport_open (currprefs.prtname);
+ if (!_tcsncmp(currprefs.prtname, _T("LPT"), 3)) {
+ paraport_open(currprefs.prtname);
return -1;
}
return 1;
}
-int isprinteropen (void)
+int isprinteropen(void)
{
if (prtopen || prtbufbytes > 0)
return 1;
}
}
-void flushprinter (void)
+void flushprinter(void)
{
- if (!doflushprinter ())
+#ifdef RETROPLATFORM
+ if (rp_isprinter()) {
+ if (!doflushprinter(rp_isprinteropen())) {
+ return;
+ }
+ flushprtbuf();
+ rp_writeprinter(NULL, 0);
+ closeprinter();
return;
- flushprtbuf ();
- closeprinter ();
+ }
+#endif
+ if (!doflushprinter(prtopen))
+ return;
+ flushprtbuf();
+ closeprinter();
}
void closeprinter (void)
int rp_rpescapeholdtime = 600;
int rp_screenmode = 0;
int rp_inputmode = 0;
+int rp_printer = 0;
int log_rp = 2;
static int rp_revision, rp_version, rp_build;
+static int rp_printeropen = 0;
static int max_horiz_dbl = RES_HIRES;
static int max_vert_dbl = VRES_DOUBLE;
device_add_vsync_pre(rp_vsync);
}
+
+bool rp_isprinter(void)
+{
+ return rp_printer != 0;
+}
+bool rp_isprinteropen(void)
+{
+ return rp_printer != 0 && rp_printeropen != 0;
+}
+void rp_writeprinter(uae_char *b, int len)
+{
+ if (!initialized)
+ return;
+ WPARAM unit = MAKEWORD(RP_DEVICECATEGORY_PRINTER, 0);
+ if (!b) {
+ if (rp_printeropen) {
+ write_log(_T("RP: printer close\n"));
+ RPSendMessagex(RP_IPC_TO_HOST_DEVICECLOSE, unit, 0, NULL, 0, &guestinfo, NULL);
+ }
+ rp_printeropen = 0;
+ return;
+ }
+ if (!rp_printeropen) {
+ write_log(_T("RP: printer open\n"));
+ RPSendMessagex(RP_IPC_TO_HOST_DEVICEOPEN, unit, 0, NULL, 0, &guestinfo, NULL);
+ rp_printeropen = 1;
+ }
+ RPSendMessagex(RP_IPC_TO_HOST_DEVICEWRITEBYTES, unit, 0, b, len, &guestinfo, NULL);
+}
+
void rp_test(void)
{
#if 0
extern bool rp_ismouseevent(void);
extern void rp_reset(void);
extern void rp_test(void);
+extern bool rp_isprinter(void);
+extern bool rp_isprinteropen(void);
+extern void rp_writeprinter(uae_char*, int);
extern TCHAR *rp_param;
extern int rp_rpescapekey;
extern int rp_rpescapeholdtime;
extern int rp_screenmode;
extern int rp_inputmode;
+extern int rp_printer;
extern int log_rp;
extern void rp_input_change (int num);
nocrashdump = 1;
return 1;
}
+ if (!_tcscmp(arg, _T("rpprinter"))) {
+ rp_printer = 1;
+ return 1;
+ }
+
if (!np)
return 0;