From 224ef1a68b624dd96d46cb5e4e3d364faa64c8fa Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 24 Mar 2005 21:11:05 +0000 Subject: [PATCH] new include system + lot's of classes maintaining certain aspects of dosbox Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2140 --- include/inout.h | 31 +++++++++++++++++++++++++------ include/mixer.h | 24 +++++++++++++++++++++++- include/support.h | 8 ++++---- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/include/inout.h b/include/inout.h index 1de2b064..01ccfdcc 100644 --- a/include/inout.h +++ b/include/inout.h @@ -16,10 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: inout.h,v 1.7 2005-02-10 10:20:47 qbix79 Exp $ */ +/* $Id: inout.h,v 1.8 2005-03-24 21:11:05 qbix79 Exp $ */ -#ifndef __INOUT_H -#define __INOUT_H +#ifndef DOSBOX_INOUT_H +#define DOSBOX_INOUT_H #define IO_MAX (64*1024+3) @@ -37,8 +37,8 @@ extern IO_ReadHandler * io_readhandlers[3][IO_MAX]; void IO_RegisterReadHandler(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); void IO_RegisterWriteHandler(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); -void IO_FreeReadHandler(Bitu port,Bitu mask,Bitu range=0); -void IO_FreeWriteHandler(Bitu port,Bitu mask,Bitu range=0); +void IO_FreeReadHandler(Bitu port,Bitu mask,Bitu range=1); +void IO_FreeWriteHandler(Bitu port,Bitu mask,Bitu range=1); void IO_WriteB(Bitu port,Bitu val); void IO_WriteW(Bitu port,Bitu val); @@ -48,6 +48,26 @@ Bitu IO_ReadB(Bitu port); Bitu IO_ReadW(Bitu port); Bitu IO_ReadD(Bitu port); +/* Classes to manage the IO objects created by the various devices. + * The io objects will remove itself on destruction.*/ +class IO_Base{ +protected: + bool installed; + Bitu m_port, m_mask,m_range; +public: + IO_Base():installed(false){}; +}; +class IO_ReadHandleObject: private IO_Base{ +public: + void Install(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); + ~IO_ReadHandleObject(); +}; +class IO_WriteHandleObject: private IO_Base{ +public: + void Install(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); + ~IO_WriteHandleObject(); +}; + INLINE void IO_Write(Bitu port,Bit8u val) { IO_WriteB(port,val); } @@ -56,4 +76,3 @@ INLINE Bit8u IO_Read(Bitu port){ } #endif - diff --git a/include/mixer.h b/include/mixer.h index b23366d9..1faa5b02 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -16,6 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef DOSBOX_MIXER_H +#define DOSBOX_MIXER_H + +#ifndef DOSBOX_DOSBOX_H +#include "dosbox.h" +#endif + typedef void (*MIXER_MixHandler)(Bit8u * sampdate,Bit32u len); typedef void (*MIXER_Handler)(Bitu len); @@ -65,9 +72,24 @@ public: MixerChannel * MIXER_AddChannel(MIXER_Handler handler,Bitu freq,char * name); MixerChannel * MIXER_FindChannel(const char * name); +/* Find the device you want to delete with findchannel "delchan gets deleted" */ +void MIXER_DelChannel(MixerChannel* delchan); + +/* Object to maintain a mixerchannel; As all objects it registers itself with create + * and removes itself when destroyed. */ +class MixerObject{ +private: + bool installed; + char m_name[32]; +public: + MixerObject():installed(false){}; + MixerChannel* Install(MIXER_Handler handler,Bitu freq,char * name); + ~MixerObject(); +}; + /* PC Speakers functions, tightly related to the timer functions */ - void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode); void PCSPEAKER_SetType(Bitu mode); +#endif diff --git a/include/support.h b/include/support.h index b9f578ed..87d910df 100644 --- a/include/support.h +++ b/include/support.h @@ -16,13 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if !defined __SUPPORT_H -#define __SUPPORT_H +#ifndef DOSBOX_SUPPORT_H +#define DOSBOX_SUPPORT_H #include #include - +#ifndef DOSBOX_DOSBOX_H #include "dosbox.h" +#endif #if defined (_MSC_VER) /* MS Visual C++ */ #define strcasecmp(a,b) stricmp(a,b) @@ -62,4 +63,3 @@ INLINE char * lowcase(char * str) { #endif -