DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/parport/filelpt.h
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 // include guard
00020 #ifndef DOSBOX_FILELPT_H
00021 #define DOSBOX_FILELPT_H
00022 
00023 #include "dosbox.h"
00024 #include "parport.h"
00025 
00026 typedef enum { FILE_DEV, FILE_CAPTURE, FILE_APPEND } DFTYPE;
00027 
00028 class CFileLPT : public CParallel {
00029 public:
00030         CFileLPT (Bitu nr, Bit8u initIrq, CommandLine* cmd);
00031 
00032         ~CFileLPT();
00033         
00034         bool InstallationSuccessful;    // check after constructing. If
00035                                                                         // something was wrong, delete it right away.
00036         
00037         bool fileOpen;
00038         DFTYPE filetype = (DFTYPE)0;                    // which mode to operate in (capture,fileappend,device)
00039         FILE* file = NULL;
00040         std::string name;                       // name of the thing to open
00041         bool addFF;                                     // add a formfeed character before closing the file/device
00042         bool addLF;                                     // if set, add line feed after carriage return if not used by app
00043 
00044         Bit8u lastChar = 0;                             // used to save the previous character to decide wether to add LF
00045         const Bit16u* codepage_ptr; // pointer to the translation codepage if not null
00046 
00047         bool OpenFile();
00048         
00049         bool ack_polarity = false;
00050 
00051         Bitu Read_PR();
00052         Bitu Read_COM();
00053         Bitu Read_SR();
00054 
00055         Bit8u datareg = 0;
00056         Bit8u controlreg;
00057 
00058         void Write_PR(Bitu);
00059         void Write_CON(Bitu);
00060         void Write_IOSEL(Bitu);
00061         bool Putchar(Bit8u);
00062 
00063         bool autofeed = false;
00064         bool ack;
00065         unsigned int timeout = 0;
00066         Bitu lastUsedTick = 0;
00067         virtual void handleUpperEvent(Bit16u type);
00068 };
00069 
00070 #endif  // include guard