DOSBox-X
|
00001 /* 00002 * Copyright (C) 2002-2020 The DOSBox Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef DOSBOX_PARPORT_H 00020 #define DOSBOX_PARPORT_H 00021 00022 // set to 1 for debug messages and debugging log: 00023 #define PARALLEL_DEBUG 0 00024 00025 #ifndef DOSBOX_DOSBOX_H 00026 #include "dosbox.h" 00027 #endif 00028 #ifndef DOSBOX_INOUT_H 00029 #include "inout.h" 00030 #endif 00031 00032 #include "control.h" 00033 #include "dos_inc.h" 00034 00035 class device_LPT : public DOS_Device { 00036 public: 00037 // Creates a LPT device that communicates with the num-th parallel port, i.e. is LPTnum 00038 device_LPT(Bit8u num, class CParallel* pp); 00039 virtual ~device_LPT(); 00040 bool Read(Bit8u * data,Bit16u * size); 00041 bool Write(const Bit8u * data,Bit16u * size); 00042 bool Seek(Bit32u * pos,Bit32u type); 00043 bool Close(); 00044 Bit16u GetInformation(void); 00045 private: 00046 CParallel* pportclass; 00047 Bit8u num; // This device is LPTnum 00048 }; 00049 00050 00051 class CParallel { 00052 public: 00053 #if PARALLEL_DEBUG 00054 FILE * debugfp; 00055 bool dbg_data; 00056 bool dbg_putchar; 00057 bool dbg_cregs; 00058 bool dbg_plainputchar; 00059 bool dbg_plaindr; 00060 void log_par(bool active, char const* format,...); 00061 #endif 00062 00063 // Constructor 00064 CParallel(CommandLine* cmd, Bitu portnr, Bit8u initirq); 00065 00066 virtual ~CParallel(); 00067 00068 IO_ReadHandleObject ReadHandler[3]; 00069 IO_WriteHandleObject WriteHandler[3]; 00070 00071 void setEvent(Bit16u type, float duration); 00072 void removeEvent(Bit16u type); 00073 void handleEvent(Bit16u type); 00074 virtual void handleUpperEvent(Bit16u type)=0; 00075 00076 void registerDOSDevice(); 00077 void unregisterDOSDevice(); 00078 00079 Bitu port_nr; 00080 Bitu base; 00081 Bitu irq; 00082 00083 // read data line register 00084 virtual Bitu Read_PR()=0; 00085 virtual Bitu Read_COM()=0; 00086 virtual Bitu Read_SR()=0; 00087 00088 virtual void Write_PR(Bitu)=0; 00089 virtual void Write_CON(Bitu)=0; 00090 virtual void Write_IOSEL(Bitu)=0; 00091 00092 virtual bool Putchar(Bit8u)=0; 00093 Bit8u getPrinterStatus(); 00094 void initialize(); 00095 00096 DOS_Device* mydosdevice; 00097 }; 00098 00099 extern CParallel* parallelPortObjects[]; 00100 00101 const Bit16u parallel_baseaddr[3] = {0x378,0x278,0x3bc}; 00102 00103 #endif 00104