diff --git a/include/programs.h b/include/programs.h index 883b0dbd..e4d10330 100644 --- a/include/programs.h +++ b/include/programs.h @@ -16,11 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __PROGRAM_H -#define __PROGRAM_H +#ifndef DOSBOX_PROGRAMS_H +#define DOSBOX_PROGRAMS_H + +#ifndef DOSBOX_DOSBOX_H #include "dosbox.h" +#endif +#ifndef DOSBOX_DOS_INC_H #include "dos_inc.h" +#endif +#ifndef DOSBOX_SETUP_H #include "setup.h" +#endif @@ -48,12 +55,4 @@ public: }; -void SHELL_AddAutoexec(char * line,...); - - - - - - #endif - diff --git a/include/serialport.h b/include/serialport.h index 8f6df34e..1515ebaa 100644 --- a/include/serialport.h +++ b/include/serialport.h @@ -16,12 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if !defined __SERIALPORT_H -#define __SERIALPORT_H +#ifndef DOSBOX_SERIALPORT_H +#define DOSBOX_SERIALPORT_H #include +#ifndef DOSBOX_DOSBOX_H #include "dosbox.h" +#endif +#ifndef DOSBOX_INOUT_H +#include "inout.h" +#endif //If it's too high you overflow terminal clients buffers i think #define QUEUE_SIZE 1024 @@ -142,6 +147,8 @@ private: Bit8u linectrl; Bit8u errors; + IO_ReadHandleObject ReadHandler[9]; + IO_WriteHandleObject WriteHandler[9]; }; #include @@ -152,4 +159,3 @@ typedef std::list::iterator CSerial_it; extern CSerialList seriallist; #endif - diff --git a/include/setup.h b/include/setup.h index 7e0160ad..8f944e43 100644 --- a/include/setup.h +++ b/include/setup.h @@ -16,16 +16,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: setup.h,v 1.17 2005-02-10 10:20:47 qbix79 Exp $ */ +/* $Id: setup.h,v 1.18 2005-03-25 11:43:36 qbix79 Exp $ */ -#ifndef _SETUP_H_ -#define _SETUP_H_ +#ifndef DOSBOX_SETUP_H +#define DOSBOX_SETUP_H #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #endif +#ifndef DOSBOX_CROSS_H #include "cross.h" +#endif #include #include @@ -42,6 +44,7 @@ public: bool FindCommand(unsigned int which,std::string & value); bool FindStringBegin(char * begin,std::string & value, bool remove=false); bool FindStringRemain(char * name,std::string & value); + bool GetStringRemain(std::string & value); unsigned int GetCount(void); private: typedef std::list::iterator cmd_it; @@ -116,31 +119,58 @@ public: } void SetValue(char* input); ~Prop_hex(){ } - void GetValuestring(char* str); + void GetValuestring(char* str); }; +class Section; +class Module_base { + /* Base for all hardware and software "devices" */ +protected: + Section* m_configuration; +public: + Module_base(Section* configuration){m_configuration=configuration;}; +// Module_base(Section* configuration, SaveState* state) {}; + ~Module_base(){/*LOG_MSG("executed")*/;};//Destructors are required + /* Returns true if succesful.*/ + virtual bool Change_Config(Section* newconfig) {return false;} ; +}; + + class Section { public: Section(const char* _sectionname) { sectionname=_sectionname; } - virtual ~Section(){ ExecuteDestroy();} + virtual ~Section(){ExecuteDestroy(true); } typedef void (*SectionFunction)(Section*); - void AddInitFunction(SectionFunction func) {initfunctions.push_back(func);} - void AddDestroyFunction(SectionFunction func) {destroyfunctions.push_front(func);} - void ExecuteInit() { - typedef std::list::iterator func_it; + /* Wrapper class around startup and shutdown functions. the variable + * canchange indicates it can be called on configuration changes */ + struct Function_wrapper { + SectionFunction function; + bool canchange; + Function_wrapper(SectionFunction _fun,bool _ch){ + function=_fun; + canchange=_ch; + } + }; + void AddInitFunction(SectionFunction func,bool canchange=false) {initfunctions.push_back(Function_wrapper(func,canchange));} + void AddDestroyFunction(SectionFunction func,bool canchange=false) {destroyfunctions.push_front(Function_wrapper(func,canchange));} + void ExecuteInit(bool initall=true) { + typedef std::list::iterator func_it; for (func_it tel=initfunctions.begin(); tel!=initfunctions.end(); tel++){ - (*tel)(this); + if(initall || (*tel).canchange) (*tel).function(this); } } - void ExecuteDestroy() { - typedef std::list::iterator func_it; - for (func_it tel=destroyfunctions.begin(); tel!=destroyfunctions.end(); tel++){ - (*tel)(this); + void ExecuteDestroy(bool destroyall=true) { + typedef std::list::iterator func_it; + for (func_it tel=destroyfunctions.begin(); tel!=destroyfunctions.end(); ){ + if(destroyall || (*tel).canchange) { + (*tel).function(this); + tel=destroyfunctions.erase(tel); //Remove destroyfunction once used + } else tel++; } } - std::list initfunctions; - std::list destroyfunctions; + std::list initfunctions; + std::list destroyfunctions; virtual void HandleInputline(char * _line){} virtual void PrintData(FILE* outfile) {} std::string sectionname; @@ -150,7 +180,8 @@ public: class Section_prop:public Section { public: Section_prop(const char* _sectionname):Section(_sectionname){} - + //ExecuteDestroy should be here else the destroy functions use destroyed properties + ~Section_prop(){ExecuteDestroy(true);} void Add_int(const char* _propname, int _value=0); void Add_string(const char* _propname, char* _value=NULL); void Add_bool(const char* _propname, bool _value=false); @@ -172,6 +203,7 @@ class Section_prop:public Section { class Section_line: public Section{ public: Section_line(const char* _sectionname):Section(_sectionname){} + ~Section_line(){ExecuteDestroy(true);} void HandleInputline(char* gegevens); void PrintData(FILE* outfile); std::string data; @@ -185,7 +217,7 @@ public: Section * AddSection(const char * _name,void (*_initfunction)(Section*)); Section_line * AddSection_line(const char * _name,void (*_initfunction)(Section*)); - Section_prop * AddSection_prop(const char * _name,void (*_initfunction)(Section*)); + Section_prop * AddSection_prop(const char * _name,void (*_initfunction)(Section*),bool canchange=false); Section* GetSection(const char* _sectionname);