summaryrefslogtreecommitdiff
path: root/emulators/hercules/files/patch-hc.c
blob: 23359f5ced9362164bd8d1cb261d38f4ab786af2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--- /dev/null	Mon Dec 16 17:18:27 2002
+++ hc.c	Mon Dec 16 17:21:15 2002
@@ -0,0 +1,51 @@
+#include "hercules.h"
+
+#include "opcode.h"
+
+#include "inline.h"
+
+static int hcd;
+
+DEF_INST(hconsole_get_char)
+{
+	char ch;
+
+	E(inst, execflag, regs);
+
+	if (hcd == 0)
+		hcd = open("/home/tzukanov/hercules/hc",
+			   O_RDWR | O_NONBLOCK | O_CREAT, 0);
+	if (read(hcd, &ch, 1) == 1)
+		regs->GR_LHLCL(1) = ch;
+	else
+		regs->GR_L(1) = -1;
+}
+
+DEF_INST(hconsole_put_char)
+{
+	char ch;
+
+	E(inst, execflag, regs);
+
+
+	if (hcd == 0)
+		hcd = open("/home/tzukanov/hercules/hc",
+			   O_RDWR | O_NONBLOCK | O_CREAT, 0);
+	ch = regs->GR_LHLCL(1);
+	write(hcd, &ch, 1);
+}
+
+#if !defined(_GEN_ARCH)
+
+#if defined(_ARCHMODE2)
+ #define  _GEN_ARCH _ARCHMODE2
+ #include "hc.c"
+#endif 
+
+#if defined(_ARCHMODE3)
+ #undef   _GEN_ARCH
+ #define  _GEN_ARCH _ARCHMODE3
+ #include "hc.c"
+#endif 
+
+#endif /*!defined(_GEN_ARCH)*/