diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/dosbox.cpp c:\MinGW\projects\dosbox-0.65/src/dosbox.cpp
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/dosbox.cpp	2006-03-28 13:30:52.000000000 +0200
+++ c:\MinGW\projects\dosbox-0.65/src/dosbox.cpp	2006-07-07 16:55:02.435160300 +0200
@@ -82,6 +82,8 @@
 void DISNEY_Init(Section*);
 void SERIAL_Init(Section*); 
 
+void EMULATOR_Init(Section*);
+void XDS510_Init(Section*);
 
 #if C_IPX
 void IPX_Init(Section*);
@@ -391,6 +393,34 @@
 		"disney -- Enable Disney Sound Source emulation.\n"
 	);
 
+	secprop=control->AddSection_prop("emulator",&EMULATOR_Init,true);//done
+	secprop->AddInitFunction(&XDS510_Init,true);//done
+	secprop->Add_bool("xds510",true);
+	secprop->Add_hex("printerport",0x378);
+	secprop->Add_hex("base",0x240);
+	secprop->Add_hex("defaultstate",0x10);
+	secprop->Add_hex("tdi",1);
+	secprop->Add_bool("tdiinverted",false);
+	secprop->Add_hex("tdo",0x10);
+	secprop->Add_bool("tdoinverted",false);
+	secprop->Add_hex("tms",4);
+	secprop->Add_bool("tmsinverted",false);
+	secprop->Add_hex("tck",2);
+	secprop->Add_bool("tckinverted",false);
+	secprop->Add_hex("trst",0);
+	secprop->Add_bool("trstinverted",false);
+	
+	MSG_Add("EMULATOR_CONFIGFILE_HELP",
+		"xds510 -- Enable XDS510 emulator.\n"
+		"base -- XDS510 emulator port.\n"
+		"printerport -- Local printer port.\n"
+		"defaultstate -- default state of outputs (16 bits : 0 to 7 for Data port and 8 to 15 for Control Port).\n"
+		"tdi, tck, tms -- bits to activate on Data port for TDI, TCK and TMS signals (8 bits).\n"
+		"trst -- bits to activate TRST (16 bits : 0 to 7 for Data port and 8 to 15 for Control Port).\n"
+		"tdo -- bits to read on Status port for TDO (8 bits).\n"
+		"tdiinverted, ... -- true or false to invert signal.\n"
+	);
+
 	secprop=control->AddSection_prop("bios",&BIOS_Init,false);//done
 	MSG_Add("BIOS_CONFIGFILE_HELP",
 	        "joysticktype -- Type of joystick to emulate: none, 2axis, 4axis,\n"
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/Makefile.am c:\MinGW\projects\dosbox-0.65/src/hardware/Makefile.am
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/Makefile.am	2006-01-30 11:16:48.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/Makefile.am	2006-07-10 09:40:42.740124900 +0200
@@ -2,7 +2,7 @@
 
 SUBDIRS = serialport
 
-EXTRA_DIST = fmopl.c fmopl.h ymf262.h ymf262.c
+EXTRA_DIST = fmopl.c fmopl.h ymf262.h ymf262.c xds510.c xds510_io.c xds510.h xds510_io.h
 
 noinst_LIBRARIES = libhardware.a
 
@@ -10,6 +10,7 @@
                         memory.cpp mixer.cpp pcspeaker.cpp pic.cpp sblaster.cpp tandy_sound.cpp timer.cpp \
 			vga.cpp vga_attr.cpp vga_crtc.cpp vga_dac.cpp vga_draw.cpp vga_gfx.cpp vga_other.cpp \
 			vga_memory.cpp vga_misc.cpp vga_seq.cpp vga_xga.cpp vga_s3.cpp \
-			cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp
+			cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp \
+			xds510c.cpp
 
 
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/Makefile.in c:\MinGW\projects\dosbox-0.65/src/hardware/Makefile.in
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/Makefile.in	2006-03-29 14:55:32.000000000 +0200
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/Makefile.in	2006-07-10 09:40:56.427537300 +0200
@@ -64,7 +64,8 @@
 	vga_other.$(OBJEXT) vga_memory.$(OBJEXT) vga_misc.$(OBJEXT) \
 	vga_seq.$(OBJEXT) vga_xga.$(OBJEXT) vga_s3.$(OBJEXT) \
 	cmos.$(OBJEXT) disney.$(OBJEXT) gus.$(OBJEXT) mpu401.$(OBJEXT) \
-	ipx.$(OBJEXT) ipxserver.$(OBJEXT)
+	ipx.$(OBJEXT) ipxserver.$(OBJEXT) \
+  xds510c.$(OBJEXT)
 libhardware_a_OBJECTS = $(am_libhardware_a_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -188,13 +189,14 @@
 target_vendor = @target_vendor@
 AM_CPPFLAGS = -I$(top_srcdir)/include
 SUBDIRS = serialport
-EXTRA_DIST = fmopl.c fmopl.h ymf262.h ymf262.c
+EXTRA_DIST = fmopl.c fmopl.h ymf262.h ymf262.c xds510.c xds510_io.c xds510.h xds510_io.h
 noinst_LIBRARIES = libhardware.a
 libhardware_a_SOURCES = adlib.cpp dma.cpp gameblaster.cpp hardware.cpp iohandler.cpp joystick.cpp keyboard.cpp \
                         memory.cpp mixer.cpp pcspeaker.cpp pic.cpp sblaster.cpp tandy_sound.cpp timer.cpp \
 			vga.cpp vga_attr.cpp vga_crtc.cpp vga_dac.cpp vga_draw.cpp vga_gfx.cpp vga_other.cpp \
 			vga_memory.cpp vga_misc.cpp vga_seq.cpp vga_xga.cpp vga_s3.cpp \
-			cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp
+			cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp \
+			xds510c.cpp
 
 all: all-recursive
 
@@ -275,6 +277,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vga_s3.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vga_seq.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vga_xga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xds510c.Po@am__quote@
 
 .cpp.o:
 @am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510.c c:\MinGW\projects\dosbox-0.65/src/hardware/xds510.c
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510.c	1970-01-01 01:00:00.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/xds510.c	2006-07-10 09:59:28.686043800 +0200
@@ -0,0 +1,629 @@
+/*
+ * xds510 simulator for Wine
+ * Copyright (c) 2001 Blaise Gassend (blaise.gassend@m4x.org)
+ * Modified for DOSBox by Guillaume Zin (guillaume.zin@teleca.fr)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. You should have received a
+ * copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ * */
+
+// This code assumes at least 32-bit ints as does wine.
+
+#include <stdio.h>
+
+#include "xds510.h"
+#include "xds510_io.h"
+//#include "debugtools.h"
+
+#define FIXME 
+//DECLARE_DEBUG_CHANNEL(xds510);
+//DEFAULT_DEBUG_CHANNEL(xds510);
+
+#define BTAB "\t\t\t\t"
+ 
+#define INTERFACE_VERSION (6)
+static int interface_interrupt;
+//static int read800;
+static int interface_reset;
+static int counter1;
+static int counter1_update;
+static int counter1_capture;
+static int active_command;
+
+#define NUM_LOW_REGISTERS (0xC)
+#define NUM_STATUS_REGISTERS (4)
+static int low_register_val[NUM_LOW_REGISTERS];
+static int status_register[NUM_STATUS_REGISTERS];
+
+static int fifo_buffer;
+static unsigned int read_buffer;
+static int read_buffer_pos;
+static unsigned int write_buffer;
+static int write_buffer_pos;
+
+#define TAP_TEST_LOGIC_RESET (0)
+#define TAP_RUN_TEST_IDLE (2)
+#define TAP_SHIFT_DR (4)
+#define TAP_SHIFT_IR (5)
+#define TAP_PAUSE_DR (6)
+#define TAP_PAUSE_IR (7)
+
+static int tap_state;
+
+//static FILE *debugf; // ####
+//static int outdata, indata, indatap, outdatap, databitsp;
+
+int get_outbit()
+{
+  int outbit;
+  
+  switch (low_register_val[4] & 0x0300)
+  {
+    default:
+    case 0x0000:
+      outbit = 0;
+      break;
+      
+    case 0x0100:
+      outbit = 1;
+      break;
+      
+    case 0x0200:
+      outbit = fifo_buffer & 1;
+      break;
+
+    case 0x0300:
+      outbit = write_buffer & 1;
+      break;
+  }
+  
+  return outbit;
+}
+
+/*static void tap_log(int tms, int tdo, int tdi)
+{
+  void printbuff(unsigned char *buff, int len)
+  {
+    int i;
+    int bytes = len / 8;
+    int bits = len % 8;
+    int mask = 1 << bits;
+    
+    for (i = 0; i < bytes; i++)
+    {
+      fprintf(debugf, "%02x", (int) buff[i]);
+    }
+
+    if (bits > 0)
+    {
+      buff[bytes] &= mask - 1;
+      fprintf(debugf, "%0*x", (bits + 3) / 4, buff[bytes]);
+    }
+  }
+  
+  static unsigned char inbuff[256];
+  static unsigned char outbuff[256];
+  static int buffp = 0;
+  static int state = 0; // 0 reset, 1 run, then DR top to bot, ir top to bot.
+  static int trans[2][16] = 
+  { { 1, 1, 3, 4, 4, 6, 6, 4, 1, 10, 11, 11, 13, 13, 11, 1 },
+    { 0, 2, 9, 5, 5, 8, 7, 8, 2, 0, 12, 12, 15, 14, 15, 2 } };
+
+  if (state == 4 || state == 11) // Shifting
+  {
+    int byte = buffp / 8;
+    int bit = buffp % 8;
+    int mask = 1 << bit;
+    if (buffp < 2048)
+    {
+      inbuff[byte] = (inbuff[byte] & (mask - 1)) | (tdi ? mask : 0);
+      outbuff[byte] = (outbuff[byte] & (mask - 1)) | (tdo ? mask : 0);
+      buffp++;
+    }
+  }
+  
+  state = trans[tms][state & 0xF];
+
+  switch (state)
+  {
+    case 0: // reset
+      fputs("RESET ", debugf);
+      break;
+
+    case 1: // run
+      fputs("RUN ", debugf);
+      break;
+
+    case 8: // update dr
+      fprintf(debugf, "\n              DRU %i ", buffp);
+      printbuff(outbuff, buffp);
+      fputs(" -> ", debugf);
+      printbuff(inbuff, buffp);
+      fputc(' ', debugf);
+      fflush(debugf);
+      buffp = 0;
+      break;
+       
+    case 15: // update ir
+      fprintf(debugf, "\nIRU %i ", buffp - 16);
+      printbuff(outbuff + 2, buffp - 16);
+      fputs(" -> ", debugf);
+      printbuff(inbuff, buffp - 16);
+      fputc(' ', debugf);
+      fflush(debugf);
+      buffp = 0;
+      break;
+  }
+}
+*/
+static int io_cycle(int tms)
+{
+  int tdo = get_outbit();
+  int tdi = xds510_io_write_cycle(tdo, tms);
+
+//  tap_log(tms, tdo, tdi);
+  
+  return tdi;
+}
+
+static void XDS510_reset()
+{
+  int i;
+  
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510 :XDS510_reset\n");
+
+  counter1 = 0;
+  counter1_update = 0;
+  counter1_capture = 0;
+  interface_interrupt = 0;
+//  read800 = 0;
+  active_command = 0;
+  
+  fifo_buffer = 0xFFFFFFFF;
+  read_buffer = 0;
+  read_buffer_pos = 0;
+  write_buffer = 0;
+  write_buffer_pos = 0;
+
+/*  for (i = 0; i < 6; i++)
+  {
+    io_cycle(1); 
+  }
+  io_cycle(0); */
+  tap_state = TAP_TEST_LOGIC_RESET;
+  
+  for (i = 0; i < NUM_LOW_REGISTERS; i++)
+    low_register_val[i] = 0;    
+  
+  for (i = 0; i < NUM_STATUS_REGISTERS; i++)
+    status_register[i] = 0;    
+
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: returning\n\n");
+}
+
+int state_id(int s)
+{
+  s &= 0x7;
+  if (s < 4) 
+    return s / 2;
+  else 
+    return s - 2;
+}
+  
+static void go_tap_state(int state)
+{
+  // The order is RESET, RUN, S-DR, S-IR, P-DR, P-IR
+  
+  static const char *transitions[6][6] = { // [from][to]
+    { "11111", "0",   "0100",  "01100",  "01010",  "011010"  },
+    { "11111", "0",   "100",   "1100",   "1010",   "11010"   },
+    { "11111", "110", "0",     "111100", "10",     "1111010" },
+    { "11111", "110", "11100", "0",      "111010", "10"      },
+    { "11111", "110", "10",    "111100", "0",      "1111010" },
+    { "11111", "110", "11100", "10",     "111010", "0"    }  };
+  int i;
+
+  const char *trans = transitions[state_id(tap_state)][state_id(state)];
+  
+//  printf("Goto Tap %i From %i\n", state, tap_state);
+  
+  while (*trans)
+  {
+    io_cycle(*trans - '0');
+    trans++;
+  }
+
+  if ((state & 0x6) == 2)
+    for (i = 0; i < 10; i++)
+      io_cycle(0);  
+
+  tap_state = state & 0x7;
+}
+
+static void go_tap_state2(int state)
+{
+  // The order is RESET, RUN, S-DR, S-IR, P-DR, P-IR
+  
+  static const char *transitions[6][6] = { // [from][to]
+    { "11111", "0",   "0100",  "01100",  "01010",  "011010"  },
+    { "11111", "0",   "100",   "1100",   "1010",   "11010"   },
+    { "11111", "110", "0",     "111100", "10",     "1111010" },
+    { "11111", "110", "11100", "0",      "111010", "10"      },
+    { "11111", "110", "10",    "111100", "111010", "1111010" },
+    { "11111", "110", "11100", "10",     "111010", "1111010" }  };
+  int i;
+  
+  const char *trans = transitions[state_id(tap_state)][state_id(state)];
+  
+//  printf("Goto Tap 2 %i From %i\n", state, tap_state);
+  
+  while (*trans)
+  {
+    io_cycle(*trans - '0');
+    trans++;
+  }
+
+  if ((state & 0x6) == 2)
+    for (i = 0; i < 10; i++)
+      io_cycle(0);  
+
+  tap_state = state & 0x7;
+}
+
+static void minor_command(int value)
+{
+  int cmd = (value >> 12) & 0xF;
+
+  switch (cmd)
+  {
+    case 4:
+    case 5:
+      if (value & 0x0080)
+      {
+/*	if (low_register_val[0xB] >> 12 == 3)
+	{
+	  fprintf(debugf, "i %0*x o %0*x\nExecute %04X, count = %i ", 
+	    (databitsp + 3) / 4, indata & ~(-1 << (indatap - 16)), 
+	    (databitsp + 3) / 4, outdata >> 16, 
+	    low_register_val[0xB], counter1 - 15);
+	  fflush(debugf);
+	  outdata = 0;
+	  indata = 0;
+	  indatap = 0;
+	  outdatap = 0;
+	  databitsp = counter1 - 15;
+	}*/
+	active_command = 1;
+	LOG(LOG_MISC,LOG_NORMAL)("XDS510: Just activated a command.\n");
+      }
+      if (value & 0xF7F)
+      {
+	FIXME("XDS510: Unsupported bits in minor command 4\n");
+	
+      }
+      break;
+    
+    case 6:
+      if (value & 0x001)
+      {
+        counter1 = counter1_update;
+	LOG(LOG_MISC,LOG_NORMAL)("XDS510: counter1 loaded with : %08x\n", counter1);
+      }
+      
+      if (value & 0x004) 
+      {
+	counter1_capture = counter1;
+	LOG(LOG_MISC,LOG_NORMAL)("XDS510: counter1 captured with : %08x\n", counter1);
+      }
+	
+      if (value & 0x040) 
+      {
+	status_register[0] = 0xF; // ####
+	status_register[1] = (active_command ? 0x8000 : 0);
+	status_register[2] = tap_state & 0x7;
+	if (read_buffer_pos >= 16) status_register[2] |= 0x1000;
+	if (read_buffer_pos >= 32) status_register[2] |= 0x2000;
+	if (write_buffer_pos > 0) status_register[2] |= 0x0100;
+	if (write_buffer_pos > 16) status_register[2] |= 0x0200;
+	status_register[3] = 0;
+      }
+      
+      if (value & (0x002 | 0x030 | 0xF88))
+      {
+	FIXME("XDS510: Unsupported bits in minor command 6\n");
+      }
+      break;
+
+    case 7:
+      if (value & 0x0001)
+      {
+	XDS510_reset();
+      }
+
+      if (value & 0x0FFE)
+      {
+	FIXME("XDS510: Unsupported bits in minor command 7\n");
+      }
+      
+      break;
+    
+    default:
+      FIXME("XDS510: Unknown minor command %04x\n", value);
+  }
+
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: minor_command(%04x)\n", value);
+}
+
+static int scannable_bits()
+{
+  int rslt = counter1 + 1;
+  if (rslt > 32 - read_buffer_pos && (low_register_val[4] & 0x0400)) 
+  {
+    rslt = 32 - read_buffer_pos;
+  }
+  if (rslt > write_buffer_pos && 
+      (low_register_val[4] & 0x0300) == 0x0300) 
+  {
+    rslt = write_buffer_pos;
+  }
+  return rslt;
+}
+
+static void shift_bit(int tdi0)
+{
+  if (!(low_register_val[4] & 0x0080))
+  {
+    tdi0 = get_outbit();
+  }
+
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: s4 : %04x tdi : %i w : %08x f : %04x r : %08x\n", 
+      low_register_val[4], tdi0, write_buffer, fifo_buffer, read_buffer);
+  
+  if (low_register_val[4] & 0x0400) 
+  {
+    read_buffer = (read_buffer & ~(-1 << read_buffer_pos)) | 
+      ((fifo_buffer & 1) <<  read_buffer_pos);
+    read_buffer_pos++;
+  }
+
+  fifo_buffer >>= 1;
+  {
+    int mask = (low_register_val[4] & 0x0020) ? 0x80000000 : 0x8000;
+    if (tdi0)
+      fifo_buffer |= mask;
+    else
+      fifo_buffer &= ~mask;
+  }
+  
+  if ((low_register_val[4] & 0x0300) == 0x0300)
+  {
+    write_buffer >>= 1;
+    write_buffer_pos--;
+  }
+}
+
+static void scan_bits(int pause_state)
+{
+  int bits = scannable_bits();
+  
+  if (bits > 0)
+  {
+    go_tap_state(pause_state);
+	
+    io_cycle(1); // Switch to scan state
+    io_cycle(0);
+    
+    while (bits > 1)
+    {
+      counter1--;
+      bits--;
+      shift_bit(io_cycle(0));
+    }
+
+    counter1--;
+    shift_bit(io_cycle(1)); // Return to pause state
+    io_cycle(0);  
+  }
+}
+
+static void execute_command()
+{
+  if (active_command)
+  {
+    int fcmd = low_register_val[0xB];
+    int cmd = (fcmd >> 12) & 0xF;
+    
+    switch (cmd)
+    {
+      case 1:
+	LOG(LOG_MISC,LOG_NORMAL)("XDS510: STATE command to TAP state %i.\n", fcmd & 0x7);
+	active_command = 0;
+	go_tap_state2(fcmd & 0x7);
+	if (fcmd & 0x0FF8)
+	{
+	  FIXME("XDS510: Unsupported bits in major command 1.\n");
+	}
+	break;
+	
+      case 3:
+	scan_bits((fcmd & 0x0008) ? TAP_PAUSE_IR : TAP_PAUSE_DR);
+
+	if (fcmd & 0xF80)
+	{
+	  FIXME("XDS510: Unsupported bits in major command 3.\n");
+	}
+	
+	if (counter1 < 0)
+	{
+	  LOG(LOG_MISC,LOG_NORMAL)("XDS510: SCAN command finished.\n");
+	  go_tap_state(fcmd & 0x7);
+	  active_command = 0;
+	  read_buffer_pos = (read_buffer_pos + 15) & 0xFFF0;
+	  write_buffer_pos &= 0xFFF0;
+	}
+	break;
+    
+      default:
+	active_command = 0;
+	FIXME("XDS510: Tried to execute unsupported major command %04x\n", fcmd);
+	break;
+    }
+  }
+}
+
+int XDS510_read(int port)
+{
+  int retval = 0xFFFF;
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: XDS510_read(%03x)\n", port);
+  
+  switch (port)
+  {
+    case 0x18: // counter1 low
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Read counter1 capture low\n");
+      retval = counter1_capture & 0xFFFF;
+      break;	  
+    
+    case 0x1A: // counter1 high
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Read counter1 capture high\n");
+      retval = (counter1_capture >> 16) & 0xFFFF;
+      break;	  
+
+    case 0x40C: // Read buffer
+      retval = read_buffer & 0xFFFF;  
+//      outdata |= retval << outdatap;
+//      outdatap += 16;
+      read_buffer >>= 16;
+      read_buffer_pos -= 16;
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Read %04x from read buffer.\n", retval);
+      if (read_buffer_pos < 0)
+      {
+	FIXME("XDS510: Read buffer underflow.\n");
+	read_buffer_pos = 0;
+      }
+      break;
+      
+    case 0x800: // The interface word
+/*      if (read800)
+      {
+        fprintf(debugf, "\nread800 %i\n", interface_interrupt);
+        interface_interrupt = (interface_interrupt + 1) & 0x1FF;
+      }*/
+      retval = (((-INTERFACE_VERSION) & 0x7) << 5) | 
+	/*(read800 && interface_interrupt == 0) |*/ 0x10 | 
+	(!!interface_reset << 8);
+/*      if (retval & 0x0001)
+        FIXME("XDS510: interrupt flag %i\n", interface_interrupt);
+      read800 = !read800;*/
+      break;
+      
+    default:
+      if (port >= 0 && port < 2 * NUM_LOW_REGISTERS)
+      {
+	retval = low_register_val[port / 2];
+      }
+      else if (port >= 0x400 && port < 0x400 + 2 * NUM_STATUS_REGISTERS)
+      {
+	retval = status_register[(port - 0x400) / 2];
+      }
+      else
+      {
+        FIXME("XDS510: Unhandled port %03x.\n", port);
+      }
+      break;
+  }
+  
+  execute_command();
+  
+/*  if (port != 0x800) 
+    read800 = 0;*/
+  
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: returning %04x\n\n", retval);
+  return retval;
+}
+
+void XDS510_write(int port, int value, int mask)
+{
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: XDS510_write(%03x, %04x)\n", port, value);
+  static int current_minor_command = 0;
+  static int current_control5 = 0;
+
+//  read800 = 0;
+  
+  if (port >= 0 && port < 2 * NUM_LOW_REGISTERS)
+    low_register_val[port / 2] = ((value & mask) | low_register_val[port / 2] & ~mask) & 0xffff;
+    
+  switch (port)
+  {
+    case 0x0A: //Control 5
+      current_control5 = (current_control5 & ~mask) | (value & mask) & 0xffff;
+      FIXME("XDS510: Write of %04x to 00A -> emu = %i\n", current_control5, !!(current_control5 & 0x0004));
+      xds510_io_write_trst(current_control5 & 0x0004);
+      go_tap_state(tap_state);
+      go_tap_state(tap_state);
+      break;
+    
+    case 0x14: // Minor command
+      current_minor_command = (current_minor_command & ~mask) | (value & mask) & 0xffff;
+      minor_command(current_minor_command);
+      break;
+
+    case 0x8:
+    case 0x16: // Major command
+//      major_command(value); // #### Useless
+      break;
+
+    case 0x18: // Counter1 low
+      counter1_update = (counter1_update & ~mask) | (value & mask);
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Write counter1 update low. New value : %08x\n", counter1_update);
+      break;
+
+    case 0x1A: // Counter1 high
+      counter1_update = (counter1_update & ~(mask << 16)) | ((value & mask) << 16);
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Write counter1 update high. New value : %08x\n", counter1_update);	
+      break;
+    
+    case 0x40E: // Write buffer
+      write_buffer = (value << write_buffer_pos) | 
+	(write_buffer & ~(-1 << write_buffer_pos));
+      write_buffer_pos += (mask == 0xffff) ? 16 : 8;
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Wrote %04x to write buffer.\n", value);
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: Total bits in buffer : %i\n", write_buffer_pos);
+      if (write_buffer_pos > 32)
+      {
+      	LOG(LOG_MISC,LOG_WARN)("XDS510: Write buffer overflow.\n");
+	write_buffer_pos = 32;
+      }
+//      indata |= (value & 0xFFFF) << indatap;
+//      indatap += 16;
+      break;
+	  
+    case 0x800: // The interface word
+      if ((mask & 0x100) != 0) {
+        if (!!(value & 0x100) != interface_reset)
+        {
+  	interface_reset = !!(value & 0x100);
+  	LOG(LOG_MISC,LOG_NORMAL)("XDS510: New unknown pin value is %i\n", interface_reset);
+  //	xds510_io_write_trst(!interface_reset);
+        }
+      }
+      break;
+      
+    default:
+      FIXME("XDS510: Unhandled port %03x. (writing %4x)\n", port, value);
+      break;
+  }
+
+  execute_command();
+
+  LOG(LOG_MISC,LOG_NORMAL)("XDS510: returning\n\n");
+}
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510.h c:\MinGW\projects\dosbox-0.65/src/hardware/xds510.h
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510.h	1970-01-01 01:00:00.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/xds510.h	2006-07-07 13:04:09.398820300 +0200
@@ -0,0 +1,29 @@
+/*
+ * xds510 simulator for Wine
+ * Copyright (c) 2001 Blaise Gassend (blaise.gassend@m4x.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. You should have received a
+ * copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ * */
+
+#ifndef __XDS510_H__
+#define __XDS510_H__
+
+#define XDS510_BASE (0x240)
+#define XDS510(x) ((XDS510_BASE) + (x))
+
+void XDS510_init();
+int XDS510_read(int port);
+void XDS510_write(int port, int value, int mask);
+
+#endif
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510_io.c c:\MinGW\projects\dosbox-0.65/src/hardware/xds510_io.c
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510_io.c	1970-01-01 01:00:00.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/xds510_io.c	2006-07-07 17:53:54.975051900 +0200
@@ -0,0 +1,150 @@
+/*
+ * xds510 simulator for Wine
+ * Copyright (c) 2001 Blaise Gassend (blaise.gassend@m4x.org)
+ * Modified for DOSBox by Guillaume Zin (guillaume.zin@teleca.fr)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. You should have received a
+ * copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ * */
+
+#include <stdio.h>
+//#include <sys/io.h>
+#include "xds510_io.h"
+
+static int baseport = -1;
+
+static unsigned short xdefault_state = 0x10; 
+static unsigned char xtdi = 0x1;
+static unsigned char xtck = 0x2; 
+static unsigned char xtms = 0x4; 
+static unsigned short xtrst = 0x0000;
+static unsigned char xtdo = 0x10;
+static unsigned char xinv_tdi = 0; 
+static unsigned char xinv_tck = 0; 
+static unsigned char xinv_tms = 0; 
+static unsigned char xinv_trst = 0;
+static unsigned char xinv_tdo = 0;
+
+int xds510_io_init(int bp, 
+                    unsigned char default_state, 
+                    unsigned char tdi, 
+                    unsigned char inv_tdi, 
+                    unsigned char tck, 
+                    unsigned char inv_tck, 
+                    unsigned char tms, 
+                    unsigned char inv_tms, 
+                    unsigned short trst,
+                    unsigned char inv_trst,
+                    unsigned char tdo,
+                    unsigned char inv_tdo
+                    )
+{
+  int io_error = -1;
+
+  if (!iopl(3))
+  {
+    xdefault_state = default_state; 
+    xtdi = tdi;
+    xtck = tck; 
+    xtms = tms; 
+    xtrst = trst;
+    xtdo = tdo;
+    xinv_tdi = inv_tdi;
+    xinv_tck = inv_tck; 
+    xinv_tms = inv_tms; 
+    xinv_trst = inv_trst;
+    xinv_tdo = inv_tdo;
+    
+    //printf("%x %x %x %x %x %x %x %x %x %x %x", default_state, xtdi, xtck, xtms, xtrst, xtdo, xinv_tdi, xinv_tck, xinv_tms, xinv_trst, xinv_tdo);
+    
+    io_error = 0;
+    baseport = bp;
+    iopl(0);
+  }
+  return io_error;
+}
+
+int xds510_io_write_cycle(int tdi, int tms)
+{
+  int inval = 0;
+  
+  if (!iopl(3)) {
+    if ((xinv_tdi && tdi) || (!xinv_tdi && !tdi)) {
+      xdefault_state &= ~xtdi;
+    }
+    else
+    {
+      xdefault_state |= xtdi;
+    }
+    if ((xinv_tms && tms) || (!xinv_tms && !tms)) {
+      xdefault_state &= ~xtms;
+    }
+    else {
+      xdefault_state |= xtms;
+    }
+    if (xinv_tck) {
+      xdefault_state |= xtck;
+    }
+    else {
+      xdefault_state &= ~xtck;
+    }
+    outb(xdefault_state & 0xff, baseport);
+    
+    if (xinv_tck) {
+      xdefault_state &= ~xtck;
+    }
+    else {
+      xdefault_state |= xtck;
+    }
+    outb(xdefault_state & 0xff, baseport);
+
+    inval = (inb(baseport + 1) & xtdo) != 0;
+    if (xinv_tdo) {
+      inval = !inval;
+    }
+    
+    iopl(0);
+  }
+  return inval;
+}
+
+void xds510_io_write_trst(int trst)
+{
+  if (!iopl(3))
+  {
+    if (trst)
+    {
+      if (xinv_trst) {
+        xdefault_state |= xtck;
+      }
+      else {
+        xdefault_state &= ~xtck;
+      }
+      outb((xdefault_state >> 8) & 0xff, baseport + 2);
+      outb(xdefault_state & 0xff, baseport);
+    }
+    else
+    {
+      if (xinv_trst) {
+        xdefault_state &= ~xtck;
+      }
+      else {
+        xdefault_state |= xtck;
+      }
+      outb((xdefault_state >> 8) & 0xff, baseport + 2);
+      outb(xdefault_state & 0xff, baseport);
+    }
+    iopl(0);
+  }
+}
+
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510_io.h c:\MinGW\projects\dosbox-0.65/src/hardware/xds510_io.h
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510_io.h	1970-01-01 01:00:00.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/xds510_io.h	2001-11-10 21:12:24.000000000 +0100
@@ -0,0 +1,27 @@
+/*
+ * xds510 simulator for Wine
+ * Copyright (c) 2001 Blaise Gassend (blaise.gassend@m4x.org)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. You should have received a
+ * copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ * */
+
+#ifndef __XDS510_IO_H__
+#define __XDS510_IO_H__
+
+int xds510_io_init(int bp);
+int xds510_io_write_cycle(int tdi, int tms);
+void xds510_io_write_trst(int trst);
+void xds510_io_write_emu(int trst);
+
+#endif
diff -urN d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510c.cpp c:\MinGW\projects\dosbox-0.65/src/hardware/xds510c.cpp
--- d:\Devel\BP\DosBoxXDS510\downloads\dosbox-0.65.tar\dosbox-0.65/src/hardware/xds510c.cpp	1970-01-01 01:00:00.000000000 +0100
+++ c:\MinGW\projects\dosbox-0.65/src/hardware/xds510c.cpp	2006-07-10 09:59:53.982756900 +0200
@@ -0,0 +1,243 @@
+/*
+ *  Copyright (C) 2002-2006  The DOSBox Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include "dosbox.h"
+#include "inout.h"
+#include "setup.h"
+
+#ifdef WIN32
+
+#include <conio.h>
+#include <windows.h>
+
+typedef short _stdcall (*inpfuncPtr)(short portaddr);
+typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
+inpfuncPtr inp32;
+oupfuncPtr oup32;
+
+#define   inb(address)          (inp32)(address)
+#define   outb(value, address)  (oup32)(address, value)
+#define   iopl(value)           0
+
+#endif
+
+
+#include "xds510_io.c"
+#include "xds510.c"
+
+Bitu currentXds510Port;
+
+#define XDS510PORT(x) (currentXds510Port + (x))
+
+
+static void xds510c_write(Bitu port,Bitu val,Bitu iolen) {
+  Bitu pport = (port - currentXds510Port) & ~0x01;
+  Bitu shift = (port - currentXds510Port) & 0x01 != 0;
+  
+  if (iolen < 2) {
+    LOG_MSG("XDS510: Unsupported byte write 0x%04x at address 0x@%x\n", val & 0xffff, port);
+    return;
+  }
+  if (iolen > 2) {
+    LOG_MSG("XDS510: Unsupported long write 0x%08x at address 0x@%x\n", val & 0xffffffff, port);
+    return;
+  }
+
+  if ((port >= XDS510PORT(0x00) && port < XDS510PORT(0x20)) ||
+    (port >= XDS510PORT(0x400) && port < XDS510PORT(0x410)) ||
+    port == XDS510PORT(0x800))
+  {
+    if (iolen < 2) {
+      XDS510_write(pport, shift ? ((val & 0xff) << 8) : (val & 0xff), shift ? 0xff << 8 : 0xff);
+    }
+    else {
+      XDS510_write(pport, val & 0xffff, 0xffff);
+    }
+  }
+  else
+  {
+    LOG(LOG_MISC,LOG_WARN)("XDS510: direct I/O write attempted to port %x\n", port );
+  }
+}
+
+static Bitu xds510c_read(Bitu port,Bitu iolen) {
+  Bitu pport = (port - currentXds510Port) & ~0x01;
+  Bitu shift = (port - currentXds510Port) & 0x01 != 0;
+  Bitu val;
+
+  if (iolen < 2) {
+    LOG_MSG("XDS510: Unsupported byte read at address 0x@%x\n", val & 0xffff, port);
+    return 0;
+  }
+  if (iolen > 2) {
+    LOG_MSG("XDS510: Unsupported long read at address 0x@%x\n", val & 0xffffffff, port);
+    return 0;
+  }
+
+  if ((port >= XDS510PORT(0x00) && port < XDS510PORT(0x20)) ||
+    (port >= XDS510PORT(0x400) && port < XDS510PORT(0x410)) ||
+    port == XDS510PORT(0x800))
+  {
+    if (iolen < 2) {
+      val = XDS510_read(pport);
+      return shift ? ((val >> 8) & 0xff) : (val & 0xff);
+    }
+    else {
+      return XDS510_read(pport);
+    }
+  }
+  else
+  {
+    LOG(LOG_MISC,LOG_WARN)("XDS510: Direct I/O read attempted from port %x\n", port);
+  }
+	return 0xff;
+}
+
+class XDS510C: public Module_base {
+private:
+	IO_ReadHandleObject ReadHandler[3];
+	IO_WriteHandleObject WriteHandler[3];
+
+#ifdef WIN32
+  HINSTANCE hLib;  
+#endif
+  
+public:
+	XDS510C(Section* configuration):Module_base(configuration) 
+  {
+  	Bitu currentPrinterPort;
+    unsigned char default_state; 
+    unsigned char tdi;
+    unsigned char inv_tdi; 
+    unsigned char tck;
+    unsigned char inv_tck; 
+    unsigned char tms;
+    unsigned char inv_tms; 
+    unsigned short trst;
+    unsigned char inv_trst;
+    unsigned char tdo;
+    unsigned char inv_tdo;
+    
+    hLib = NULL;
+  	
+		Section_prop * section=static_cast<Section_prop *>(configuration);
+		if(!section->Get_bool("xds510")) return;
+
+#ifdef WIN32    
+     /* Load the library */
+     hLib = LoadLibrary("inpout32.dll");
+
+     if (hLib == NULL) {
+          LOG_MSG("XDS510: LoadLibrary on inpout32.dll failed.\n");
+          return;
+     }
+
+     /* get the address of the function */
+
+     inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
+
+     if (inp32 == NULL) {
+          LOG_MSG("XDS510: GetProcAddress for Inp32 failed.\n");
+          return;
+     }
+     
+     oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
+     
+     if (oup32 == NULL) {
+          LOG_MSG("XDS510: GetProcAddress for Oup32 failed.\n");
+          return;
+     }
+#endif
+
+		currentXds510Port = section->Get_hex("base");
+		currentPrinterPort = section->Get_hex("printerport");
+		default_state = section->Get_hex("defaultstate");
+		tdi = section->Get_hex("tdi");
+		inv_tdi = section->Get_bool("tdiinverted");
+		tdi = section->Get_hex("tdi");
+		inv_tdi = section->Get_bool("tdiinverted");
+		tck = section->Get_hex("tck");
+		inv_tck = section->Get_bool("tckinverted");
+		tms = section->Get_hex("tms");
+		inv_tms = section->Get_bool("tmsinverted");
+		trst = section->Get_hex("trst");
+		inv_trst = section->Get_bool("trstinverted");
+		tdo = section->Get_hex("tdo");
+		inv_tdo = section->Get_bool("tdoinverted");
+		
+		WriteHandler[0].Install(XDS510PORT(0x00), xds510c_write, IO_MW, XDS510PORT(0x20) - XDS510PORT(0x00));
+		WriteHandler[1].Install(XDS510PORT(0x400), xds510c_write, IO_MW, XDS510PORT(0x410) - XDS510PORT(0x400));
+		WriteHandler[2].Install(XDS510PORT(0x800), xds510c_write, IO_MW, 1);
+		
+		ReadHandler[0].Install(XDS510PORT(0x00), xds510c_read, IO_MW, XDS510PORT(0x20) - XDS510PORT(0x00));
+	  ReadHandler[1].Install(XDS510PORT(0x400), xds510c_read, IO_MW, XDS510PORT(0x410) - XDS510PORT(0x400));
+		ReadHandler[2].Install(XDS510PORT(0x800), xds510c_read, IO_MW, 1);
+		
+    if (xds510_io_init(currentPrinterPort,
+      default_state, 
+      tdi, 
+      inv_tdi, 
+      tck, 
+      inv_tck, 
+      tms, 
+      inv_tms, 
+      trst,
+      inv_trst,
+      tdo,
+      inv_tdo
+      )
+    ) {
+      LOG_MSG("XDS510: Root privileges necessary to access XDS510.\n\n");
+    }
+    else
+    {
+      LOG(LOG_MISC,LOG_NORMAL)("XDS510: XDS510 on port 0x%03x.\n\n", currentPrinterPort);
+    }
+
+    xds510_io_write_trst(1);
+    io_cycle(1);
+    xds510_io_write_trst(0);
+    io_cycle(1);
+    
+    XDS510_reset();
+	}
+	
+  ~XDS510C()
+  {    
+#ifdef WIN32    
+    if (hLib != NULL) {
+      FreeLibrary(hLib);
+    }
+#endif
+  }
+};
+
+static XDS510C* xds510c;
+
+static void XDS510_ShutDown(Section* sec){
+	delete xds510c;
+}
+
+void XDS510_Init(Section* sec) {
+	xds510c = new XDS510C(sec);
+	sec->AddDestroyFunction(&XDS510_ShutDown, true);
+}
+
+void EMULATOR_Init(Section* sec) {
+}
