aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfinput/guncon.c
diff options
context:
space:
mode:
authornotaz2011-08-09 01:16:59 +0300
committernotaz2011-08-13 00:56:33 +0300
commit4c08b9e7dd350a48fc3e0515913d6ccc8b15e5ae (patch)
tree22f29a06fda180d8269878b3cdb413044a5e351e /plugins/dfinput/guncon.c
parent19e57cbf170d1ce49f00097f3cc3a4ed96d77374 (diff)
downloadpcsx_rearmed-4c08b9e7dd350a48fc3e0515913d6ccc8b15e5ae.tar.gz
pcsx_rearmed-4c08b9e7dd350a48fc3e0515913d6ccc8b15e5ae.tar.bz2
pcsx_rearmed-4c08b9e7dd350a48fc3e0515913d6ccc8b15e5ae.zip
add guncon support
a bit basic but works
Diffstat (limited to 'plugins/dfinput/guncon.c')
-rw-r--r--plugins/dfinput/guncon.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/dfinput/guncon.c b/plugins/dfinput/guncon.c
new file mode 100644
index 0000000..b4f103c
--- /dev/null
+++ b/plugins/dfinput/guncon.c
@@ -0,0 +1,68 @@
+/*
+ * (C) GraÅžvydas "notaz" Ignotas, 2011
+ *
+ * This work is licensed under the terms of any of these licenses
+ * (at your option):
+ * - GNU GPL, version 2 or later.
+ * - GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <string.h>
+#include "main.h"
+
+static unsigned char buf[8];
+
+unsigned char PADpoll_guncon(unsigned char value)
+{
+ if (CurByte == 0) {
+ CurCmd = value;
+ CurByte++;
+ return 0x63; // regardless of cmd
+ }
+
+ if (CurCmd != 0x42 || CurByte >= 8)
+ return 0xff; // verified
+
+ return buf[CurByte++];
+}
+
+unsigned char PADstartPoll_guncon(int pad)
+{
+ int x, xn = 0, y = 0, in = 0, xres = 256;
+ CurByte = 0;
+
+ buf[2] = buf[3] = 0xff;
+ pl_update_gun(&xn, &xres, &y, &in);
+
+ // while y = const + line counter, what is x?
+ // for 256 mode, hw dumped offsets x, y: 0x5a, 0x20
+ //x = 0x5a + (356 * xn >> 10);
+ x = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * xn >> 10);
+ y = 0x20 + y;
+
+ if (in & GUNIN_TRIGGER)
+ buf[3] &= ~0x20;
+ if (in & GUNIN_BTNA)
+ buf[2] &= ~0x08;
+ if (in & GUNIN_BTNB)
+ buf[3] &= ~0x40;
+ if (in & GUNIN_TRIGGER2) {
+ buf[3] &= ~0x20;
+ x = 1;
+ y = 10;
+ }
+ buf[4] = x;
+ buf[5] = x >> 8;
+ buf[6] = y;
+ buf[7] = y >> 8;
+
+ return 0xff;
+}
+
+void guncon_init(void)
+{
+ memset(buf, 0xff, sizeof(buf));
+ buf[1] = 0x5a;
+}
+