Some fixes to the modem and a small effiency update by hal
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2366
This commit is contained in:
parent
38c75c55a8
commit
8d663041b0
5 changed files with 41 additions and 42 deletions
|
@ -16,13 +16,13 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: serialport.h,v 1.9 2005-07-30 14:41:30 qbix79 Exp $ */
|
||||
/* $Id: serialport.h,v 1.10 2005-11-04 08:53:06 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSBOX_SERIALPORT_H
|
||||
#define DOSBOX_SERIALPORT_H
|
||||
|
||||
// Uncomment this for a lot of debug messages:
|
||||
//#define SERIALPORT_DEBUGMSG
|
||||
// #define SERIALPORT_DEBUGMSG
|
||||
|
||||
#ifndef DOSBOX_DOSBOX_H
|
||||
#include "dosbox.h"
|
||||
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
TIMER_TickHandler TimerHnd;
|
||||
virtual ~CSerial();
|
||||
void InstallTimerHandler(TIMER_TickHandler);
|
||||
|
||||
IO_ReadHandleObject ReadHandler[8];
|
||||
IO_WriteHandleObject WriteHandler[8];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: directserial_win32.cpp,v 1.1 2005-07-30 14:41:31 qbix79 Exp $ */
|
||||
/* $Id: directserial_win32.cpp,v 1.2 2005-11-04 08:53:07 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
|
||||
|
@ -41,6 +41,7 @@ CDirectSerial::CDirectSerial (IO_ReadHandler * rh, IO_WriteHandler * wh,
|
|||
:CSerial (rh, wh, th,baseAddr,initIrq, initBps,
|
||||
bytesize, parity,stopbits) {
|
||||
InstallationSuccessful = false;
|
||||
InstallTimerHandler(th);
|
||||
lastChance = 0;
|
||||
LOG_MSG ("Serial port at %x: Opening %s", base, realPort);
|
||||
hCom = CreateFile (realPort, GENERIC_READ | GENERIC_WRITE, 0, // must be opened with exclusive-access
|
||||
|
@ -221,7 +222,7 @@ void CDirectSerial::updateMSR () {
|
|||
|
||||
if (!GetCommModemStatus (hCom, &dptr)) {
|
||||
#ifdef SERIALPORT_DEBUGMSG
|
||||
LOG_MSG ("Serial port at %x: GetCommModemStatus failed!", base);
|
||||
// LOG_MSG ("Serial port at %x: GetCommModemStatus failed!", base);
|
||||
#endif
|
||||
//return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: serialport.cpp,v 1.1 2005-07-30 14:41:31 qbix79 Exp $ */
|
||||
/* $Id: serialport.cpp,v 1.2 2005-11-04 08:53:07 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -802,13 +802,14 @@ void CSerial::Init_Registers (Bit32u initbps, Bit8u bytesize,
|
|||
Write_LCR (lcrresult);
|
||||
}
|
||||
|
||||
CSerial::CSerial(IO_ReadHandler * rh, IO_WriteHandler * wh, TIMER_TickHandler th,
|
||||
CSerial::CSerial(IO_ReadHandler * rh, IO_WriteHandler * wh, TIMER_TickHandler,
|
||||
Bit16u initbase, Bit8u initirq, Bit32u initbps, Bit8u bytesize,
|
||||
const char *parity, Bit8u stopbits) {
|
||||
base = initbase;
|
||||
irq = initirq;
|
||||
TimerHnd = th; // for destructor
|
||||
TIMER_AddTickHandler(TimerHnd);
|
||||
TimerHnd = NULL;
|
||||
//TimerHnd = th; // for destructor
|
||||
//TIMER_AddTickHandler(TimerHnd);
|
||||
|
||||
for (Bitu i = 0; i <= 7; i++) {
|
||||
WriteHandler[i].Install (i + base, wh, IO_MB);
|
||||
|
@ -817,9 +818,18 @@ CSerial::CSerial(IO_ReadHandler * rh, IO_WriteHandler * wh, TIMER_TickHandler th
|
|||
};
|
||||
|
||||
CSerial::~CSerial(void) {
|
||||
TIMER_DelTickHandler(TimerHnd);
|
||||
|
||||
if(TimerHnd) TIMER_DelTickHandler(TimerHnd);
|
||||
};
|
||||
|
||||
void CSerial::InstallTimerHandler(TIMER_TickHandler th)
|
||||
{
|
||||
if(TimerHnd==NULL) {
|
||||
TimerHnd=th;
|
||||
TIMER_AddTickHandler(th);
|
||||
}
|
||||
}
|
||||
|
||||
bool getParameter(char *input, char *buffer, const char *parametername,
|
||||
Bitu buffersize) {
|
||||
Bitu outputPos = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: softmodem.cpp,v 1.1 2005-07-30 14:41:31 qbix79 Exp $ */
|
||||
/* $Id: softmodem.cpp,v 1.2 2005-11-04 08:53:07 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
|
||||
|
@ -52,6 +52,7 @@ CSerialModem::CSerialModem(
|
|||
baseAddr, initIrq, initBps, bytesize, parity, stopbits) {
|
||||
socket=0;
|
||||
incomingsocket=0;
|
||||
InstallTimerHandler(th);
|
||||
|
||||
if(!SDLNetInited) {
|
||||
if(SDLNet_Init()==-1) {
|
||||
|
@ -145,7 +146,7 @@ void CSerialModem::SendNumber(Bitu val) {
|
|||
}
|
||||
|
||||
void CSerialModem::SendRes(ResTypes response) {
|
||||
char * string;Bitu /*char **/ code;
|
||||
char * string;Bitu code;
|
||||
switch (response)
|
||||
{
|
||||
case ResNONE: return;
|
||||
|
@ -160,19 +161,9 @@ void CSerialModem::SendRes(ResTypes response) {
|
|||
if(doresponse!=1) {
|
||||
if(doresponse==2 && (response==ResRING ||
|
||||
response == ResCONNECT || response==ResNOCARRIER)) return;
|
||||
if(numericresponse)
|
||||
//{
|
||||
SendNumber(code);
|
||||
// rqueue->addb(*code+'0');
|
||||
// rqueue->addb(0xd);rqueue->addb(0xa);
|
||||
//}
|
||||
else
|
||||
//{
|
||||
SendLine(string);
|
||||
//rqueue->addb(0xd);rqueue->addb(0xa);
|
||||
//rqueue->adds((Bit8u *)string,strlen(string));
|
||||
//rqueue->addb(0xd);rqueue->addb(0xa);
|
||||
//}
|
||||
if(numericresponse) SendNumber(code);
|
||||
else SendLine(string);
|
||||
|
||||
//if(CSerial::CanReceiveByte()) // very fast response
|
||||
// if(rqueue->inuse() && CSerial::getRTS())
|
||||
// { Bit8u rbyte =rqueue->getb();
|
||||
|
@ -191,21 +182,9 @@ void CSerialModem::openConnection(void) {
|
|||
SDLNet_TCP_Close(socket);
|
||||
}
|
||||
socket = SDLNet_TCP_Open(&openip);
|
||||
//if (!socket)
|
||||
|
||||
}
|
||||
|
||||
bool CSerialModem::Dial(char * host) {
|
||||
char* helper;
|
||||
// scan for and remove spaces; weird bug: with leading spaces in the string,
|
||||
// SDLNet_ResolveHost will return no error but not work anyway (win)
|
||||
while(host[0]==' ') host++;
|
||||
helper=host;
|
||||
helper+=strlen(host);
|
||||
while(helper[0]==' ') {
|
||||
helper[0]=0;
|
||||
helper--;
|
||||
}
|
||||
|
||||
/* Scan host for port */
|
||||
Bit16u port;
|
||||
|
@ -257,7 +236,6 @@ void CSerialModem::Reset(){
|
|||
|
||||
plusinc = 0;
|
||||
incomingsocket = 0;
|
||||
//answermode = false; // no autoanswer
|
||||
memset(®,0,sizeof(reg));
|
||||
reg[MREG_AUTOANSWER_COUNT]=0; // no autoanswer
|
||||
reg[MREG_RING_COUNT] = 1;
|
||||
|
@ -326,8 +304,7 @@ void CSerialModem::DoCommand() {
|
|||
/* Check for empty line, stops dialing and autoanswer */
|
||||
if (!cmdbuf[0]) {
|
||||
reg[0]=0; // autoanswer off
|
||||
//answermode = false;
|
||||
return;//goto ret_none;
|
||||
return;
|
||||
// }
|
||||
//else {
|
||||
//MIXER_Enable(mhd.chan,false);
|
||||
|
@ -363,6 +340,17 @@ void CSerialModem::DoCommand() {
|
|||
SendRes(ResERROR);//goto ret_error;
|
||||
return;
|
||||
}
|
||||
char* helper;
|
||||
// scan for and remove spaces; weird bug: with leading spaces in the string,
|
||||
// SDLNet_ResolveHost will return no error but not work anyway (win)
|
||||
while(foundstr[0]==' ') foundstr++;
|
||||
helper=foundstr;
|
||||
helper+=strlen(foundstr);
|
||||
while(helper[0]==' ') {
|
||||
helper[0]=0;
|
||||
helper--;
|
||||
}
|
||||
|
||||
if (strlen(foundstr) >= 12) {
|
||||
// Check if supplied parameter only consists of digits
|
||||
bool isNum = true;
|
||||
|
@ -388,7 +376,7 @@ void CSerialModem::DoCommand() {
|
|||
}
|
||||
}
|
||||
Dial(foundstr);
|
||||
return;//goto ret_none;
|
||||
return;
|
||||
}
|
||||
char * scanbuf;
|
||||
scanbuf=&cmdbuf[2];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: softmodem.h,v 1.2 2005-07-31 12:08:58 qbix79 Exp $ */
|
||||
/* $Id: softmodem.h,v 1.3 2005-11-04 08:53:07 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSBOX_SERIALMODEM_H
|
||||
#define DOSBOX_SERIALMODEM_H
|
||||
|
@ -187,7 +187,6 @@ public:
|
|||
protected:
|
||||
char cmdbuf[255];
|
||||
bool commandmode; // true: interpret input as commands
|
||||
//bool answermode;
|
||||
bool echo; // local echo on or off
|
||||
|
||||
bool oldDTRstate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue