⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosboxxds510patch

📁 软件模拟ti公司的dsp硬件仿真器dos版
💻
📖 第 1 页 / 共 3 页
字号:
+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) {
+}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -