added support for a config class/file. System not initialized perfect yet!
(env is not fixed) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@289
This commit is contained in:
parent
f02d440dc9
commit
d0fc1da99b
31 changed files with 502 additions and 120 deletions
|
@ -1,3 +1,7 @@
|
|||
0.60
|
||||
- added support for a configclass/configfile
|
||||
|
||||
0.55
|
||||
- fixed the errors/warnings in prefix_66.h and prefix_66_of.h (decimal too large becomming unsigned).
|
||||
- fixed compilation error on FreeBSD when #disable_joystick was defined
|
||||
- int10_writechar has been updated to move the cursor position.
|
||||
|
|
|
@ -47,6 +47,9 @@ typedef signed int Bits;
|
|||
#include "config.h"
|
||||
#include "../settings.h"
|
||||
|
||||
class Section;
|
||||
|
||||
|
||||
typedef Bitu (LoopHandler)(void);
|
||||
|
||||
void DOSBOX_RunMachine();
|
||||
|
@ -56,6 +59,8 @@ void DOSBOX_SetNormalLoop();
|
|||
void DOSBOX_Init(int argc, char* argv[]);
|
||||
void DOSBOX_StartUp(void);
|
||||
|
||||
class Config;
|
||||
extern Config * control;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
124
include/setup.h
124
include/setup.h
|
@ -20,6 +20,127 @@
|
|||
#define _SETUP_H_
|
||||
|
||||
#include <cross.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
union Value{
|
||||
int _hex;
|
||||
bool _bool;
|
||||
int _int;
|
||||
std::string* _string;
|
||||
};
|
||||
|
||||
class Property {
|
||||
public:
|
||||
Property(const char* _propname):propname(_propname) { }
|
||||
virtual void SetValue(char* input)=0;
|
||||
Value GetValue() { return __value; }
|
||||
std::string propname;
|
||||
Value __value;
|
||||
virtual ~Property(){ }
|
||||
};
|
||||
|
||||
class Prop_int:public Property {
|
||||
public:
|
||||
Prop_int(const char* _propname, int _value):Property(_propname) {
|
||||
__value._int=_value;
|
||||
}
|
||||
void SetValue(char* input);
|
||||
~Prop_int(){ }
|
||||
};
|
||||
|
||||
class Prop_bool:public Property {
|
||||
public:
|
||||
Prop_bool(const char* _propname, bool _value):Property(_propname) {
|
||||
__value._bool=_value;
|
||||
}
|
||||
void SetValue(char* input);
|
||||
~Prop_bool(){ }
|
||||
};
|
||||
|
||||
class Prop_string:public Property{
|
||||
public:
|
||||
Prop_string(const char* _propname, char* _value):Property(_propname) {
|
||||
__value._string=new std::string(_value);
|
||||
}
|
||||
~Prop_string(){
|
||||
delete __value._string;
|
||||
}
|
||||
void SetValue(char* input);
|
||||
};
|
||||
class Prop_hex:public Property {
|
||||
public:
|
||||
Prop_hex(const char* _propname, int _value):Property(_propname) {
|
||||
__value._hex=_value;
|
||||
}
|
||||
void SetValue(char* input);
|
||||
~Prop_hex(){ }
|
||||
};
|
||||
|
||||
class Section {
|
||||
public:
|
||||
Section(const char* _sectionname,void (*_initfunction)(Section*) ):sectionname(_sectionname){ initfunction=_initfunction;}
|
||||
~Section(){ }
|
||||
|
||||
void (*initfunction)(Section*);
|
||||
void ExecuteInit() { initfunction(this);}
|
||||
|
||||
virtual void HandleInputline(char *gegevens){}
|
||||
|
||||
std::string sectionname;
|
||||
};
|
||||
|
||||
|
||||
class Section_prop:public Section {
|
||||
public:
|
||||
Section_prop(const char* _sectionname,void (*_initfunction)(Section*)):Section(_sectionname,_initfunction){ }
|
||||
~Section_prop(){}
|
||||
|
||||
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);
|
||||
void Add_hex(const char* _propname, int _value=0);
|
||||
|
||||
int Get_int(const char* _propname);
|
||||
const char* Get_string(const char* _propname);
|
||||
bool Get_bool(const char* _propname);
|
||||
int Get_hex(const char* _propname);
|
||||
void HandleInputline(char *gegevens);
|
||||
|
||||
std::list<Property*> properties;
|
||||
typedef std::list<Property*>::iterator it;
|
||||
};
|
||||
|
||||
class Section_line: public Section{
|
||||
public:
|
||||
Section_line(const char* _sectionname,void (*_initfunction)(Section*)):Section(_sectionname,_initfunction){}
|
||||
void HandleInputline(char* gegevens);
|
||||
|
||||
std::string data;
|
||||
};
|
||||
|
||||
class Config{
|
||||
public:
|
||||
Config(){};
|
||||
|
||||
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* GetSection(const char* _sectionname);
|
||||
|
||||
void Init();
|
||||
void ParseConfigFile(const char* configfilename);
|
||||
|
||||
std::list<Section*> sectionlist;
|
||||
typedef std::list<Section*>::iterator it;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum { S_STRING,S_HEX,S_INT,S_BOOL};
|
||||
|
||||
typedef char *(String_Handler)(char * input);
|
||||
|
@ -38,6 +159,7 @@ private:
|
|||
|
||||
|
||||
|
||||
extern char dosbox_basedir[CROSS_LEN];
|
||||
extern char dosbox_basedir[CROSS_LEN];
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -135,7 +135,7 @@ bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void CALLBACK_Init(void) {
|
||||
void CALLBACK_Init(Section* sec) {
|
||||
Bitu i;
|
||||
for (i=0;i<CB_MAX;i++) {
|
||||
CallBack_Handlers[i]=&illegal_handler;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "memory.h"
|
||||
#include "debug.h"
|
||||
#include "keyboard.h"
|
||||
#include "setup.h"
|
||||
|
||||
//Regs regs;
|
||||
|
||||
|
@ -137,7 +138,8 @@ void SetCPU16bit()
|
|||
}
|
||||
|
||||
|
||||
void CPU_Init(void) {
|
||||
void CPU_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
reg_eax=0;
|
||||
reg_ebx=0;
|
||||
reg_ecx=0;
|
||||
|
@ -166,7 +168,7 @@ void CPU_Init(void) {
|
|||
flags.io=0;
|
||||
|
||||
SetCPU16bit();
|
||||
cpu_cycles=2000;
|
||||
cpu_cycles=section->Get_int("CYCLES");
|
||||
KEYBOARD_AddEvent(KBD_f11,CTRL_PRESSED,CPU_CycleDecrease);
|
||||
KEYBOARD_AddEvent(KBD_f12,CTRL_PRESSED,CPU_CycleIncrease);
|
||||
|
||||
|
|
|
@ -702,7 +702,7 @@ static void DEBUG_RaiseTimerIrq(void) {
|
|||
PIC_ActivateIRQ(0);
|
||||
}
|
||||
|
||||
void DEBUG_Init(void) {
|
||||
void DEBUG_Init(Section* sec) {
|
||||
#ifdef WIN32
|
||||
WIN32_Console();
|
||||
#endif
|
||||
|
|
|
@ -850,7 +850,7 @@ static Bitu DOS_20Handler(void) {
|
|||
}
|
||||
|
||||
|
||||
void DOS_Init(void) {
|
||||
void DOS_Init(Section* sec) {
|
||||
call_20=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_20,DOS_20Handler,CB_IRET);
|
||||
RealSetVec(0x20,CALLBACK_RealPointer(call_20));
|
||||
|
|
228
src/dosbox.cpp
228
src/dosbox.cpp
|
@ -35,57 +35,57 @@
|
|||
#include "setup.h"
|
||||
#include "cross.h"
|
||||
#include "programs.h"
|
||||
#include "support.h"
|
||||
|
||||
/* NEEDS A CLEANUP */
|
||||
char dosbox_basedir[CROSS_LEN];
|
||||
Config * control;
|
||||
|
||||
//The whole load of startups for all the subfunctions
|
||||
void MSG_Init(void);
|
||||
void MEM_Init(void);
|
||||
void VGA_Init(void);
|
||||
void CALLBACK_Init();
|
||||
void DOS_Init();
|
||||
void RENDER_Init(void);
|
||||
|
||||
void CPU_Init();
|
||||
void MSG_Init(Section_prop *);
|
||||
void MEM_Init(Section *);
|
||||
void IO_Init(Section * );
|
||||
void CALLBACK_Init(Section*);
|
||||
void PROGRAMS_Init(Section*);
|
||||
|
||||
|
||||
void VGA_Init(Section*);
|
||||
|
||||
void DOS_Init(Section*);
|
||||
|
||||
|
||||
void CPU_Init(Section*);
|
||||
//void FPU_Init();
|
||||
void IO_Init(void);
|
||||
void DMA_Init(void);
|
||||
void MIXER_Init(void);
|
||||
void HARDWARE_Init(void);
|
||||
void DMA_Init(Section*);
|
||||
void MIXER_Init(Section*);
|
||||
void HARDWARE_Init(Section*);
|
||||
|
||||
|
||||
void KEYBOARD_Init(void); //TODO This should setup INT 16 too but ok ;)
|
||||
void JOYSTICK_Init(void);
|
||||
void MOUSE_Init(void);
|
||||
void SBLASTER_Init(void);
|
||||
void ADLIB_Init(void);
|
||||
void PCSPEAKER_Init(void);
|
||||
void TANDY_Init(void);
|
||||
void CMS_Init(void);
|
||||
void KEYBOARD_Init(Section*); //TODO This should setup INT 16 too but ok ;)
|
||||
void JOYSTICK_Init(Section*);
|
||||
void MOUSE_Init(Section*);
|
||||
void SBLASTER_Init(Section*);
|
||||
void ADLIB_Init(Section*);
|
||||
void PCSPEAKER_Init(Section*);
|
||||
void TANDYSOUND_Init(Section*);
|
||||
void CMS_Init(Section*);
|
||||
|
||||
void PIC_Init(Section*);
|
||||
void TIMER_Init(Section*);
|
||||
void BIOS_Init(Section*);
|
||||
void DEBUG_Init(Section*);
|
||||
|
||||
void PIC_Init(void);
|
||||
void TIMER_Init(void);
|
||||
void BIOS_Init(void);
|
||||
void DEBUG_Init(void);
|
||||
|
||||
|
||||
void PLUGIN_Init(void);
|
||||
|
||||
/* Dos Internal mostly */
|
||||
void EMS_Init(void);
|
||||
void XMS_Init(void);
|
||||
void PROGRAMS_Init(void);
|
||||
void EMS_Init(Section*);
|
||||
void XMS_Init(Section*);
|
||||
|
||||
void SHELL_Init(void);
|
||||
|
||||
|
||||
void CALLBACK_ShutDown(void);
|
||||
void PIC_ShutDown(void);
|
||||
void KEYBOARD_ShutDown(void);
|
||||
void CPU_ShutDown(void);
|
||||
void VGA_ShutDown(void);
|
||||
void BIOS_ShutDown(void);
|
||||
void MEMORY_ShutDown(void);
|
||||
|
||||
void INT10_Init(Section*);
|
||||
|
||||
|
||||
|
||||
|
@ -129,50 +129,124 @@ void DOSBOX_RunMachine(void){
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void InitSystems(void) {
|
||||
MSG_Init();
|
||||
MEM_Init();
|
||||
IO_Init();
|
||||
CALLBACK_Init();
|
||||
PROGRAMS_Init();
|
||||
HARDWARE_Init();
|
||||
TIMER_Init();
|
||||
CPU_Init();
|
||||
#if C_FPU
|
||||
FPU_Init();
|
||||
#endif
|
||||
MIXER_Init();
|
||||
#if C_DEBUG
|
||||
DEBUG_Init();
|
||||
#endif
|
||||
|
||||
LastTicks=GetTicks();
|
||||
DOSBOX_SetLoop(&Normal_Loop);
|
||||
|
||||
//Start up individual hardware
|
||||
DMA_Init();
|
||||
PIC_Init();
|
||||
VGA_Init();
|
||||
KEYBOARD_Init();
|
||||
MOUSE_Init();
|
||||
JOYSTICK_Init();
|
||||
SBLASTER_Init();
|
||||
// TANDY_Init();
|
||||
PCSPEAKER_Init();
|
||||
ADLIB_Init();
|
||||
CMS_Init();
|
||||
|
||||
PLUGIN_Init();
|
||||
/* Most of the interrupt handlers */
|
||||
BIOS_Init();
|
||||
DOS_Init();
|
||||
EMS_Init(); //Needs dos first
|
||||
XMS_Init(); //Needs dos first
|
||||
static void DOSBOX_RealInit(Section * sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
MSG_Init(section);
|
||||
}
|
||||
|
||||
|
||||
void DOSBOX_Init(int argc, char* argv[]) {
|
||||
/* ADD A GOOD AND CLEAN ENV (see DOSBOX_Init2) */
|
||||
|
||||
|
||||
char base_dir[CROSS_LEN];
|
||||
char file_name[CROSS_LEN];
|
||||
control=new Config;
|
||||
|
||||
strcpy(base_dir,argv[0]);
|
||||
char * last=strrchr(base_dir,CROSS_FILESPLIT); //if windowsversion fails:
|
||||
if (!last) {
|
||||
getcwd(base_dir,CROSS_LEN);
|
||||
char a[2];
|
||||
a[0]=CROSS_FILESPLIT;
|
||||
a[1]='\0';
|
||||
strcat(base_dir,a);
|
||||
} else {
|
||||
*++last=0;
|
||||
}
|
||||
|
||||
|
||||
// Section * sec;
|
||||
Section_prop * secprop;
|
||||
// Section_line * secline;
|
||||
|
||||
secprop=control->AddSection_prop("DOSBOX",&DOSBOX_RealInit);
|
||||
strcpy(file_name,base_dir);
|
||||
strcat(file_name,"dosbox.lang");
|
||||
secprop->Add_string("LANGUAGE",file_name);
|
||||
secprop->Add_int("WARNINGS",0);
|
||||
|
||||
control->AddSection ("MEMORY",&MEM_Init);
|
||||
control->AddSection ("IO",&IO_Init);
|
||||
control->AddSection ("CALLBACK",&CALLBACK_Init);
|
||||
control->AddSection ("PIC",&PIC_Init);
|
||||
control->AddSection ("PROGRAMS",&PROGRAMS_Init);
|
||||
control->AddSection_prop("TIMER",&TIMER_Init);
|
||||
secprop=control->AddSection_prop("CPU",&CPU_Init);
|
||||
secprop->Add_int("CYCLES",3000);
|
||||
secprop=control->AddSection_prop("MIXER",&MIXER_Init);
|
||||
#if C_DEBUG
|
||||
secprop=control->AddSection_prop("'DEBUG",&DEBUG_Init);
|
||||
#endif
|
||||
control->AddSection ("DMA",&DMA_Init);
|
||||
control->AddSection ("VGA",&VGA_Init);
|
||||
control->AddSection ("KEYBOARD",&KEYBOARD_Init);
|
||||
secprop=control->AddSection_prop("MOUSE",&MOUSE_Init);
|
||||
control->AddSection ("JOYSTICK",&JOYSTICK_Init);
|
||||
|
||||
secprop=control->AddSection_prop("SBLASTER",&SBLASTER_Init);
|
||||
secprop->Add_hex("BASE",0x220);
|
||||
secprop->Add_int("IRQ",5);
|
||||
secprop->Add_int("DMA",1);
|
||||
secprop->Add_bool("STATUS",true);
|
||||
|
||||
secprop=control->AddSection_prop("TANDYSOUND",&TANDYSOUND_Init);
|
||||
secprop->Add_bool("STATUS",false);
|
||||
|
||||
secprop=control->AddSection_prop("PCSPEAKER",&PCSPEAKER_Init);
|
||||
|
||||
secprop=control->AddSection_prop("ADLIB",&ADLIB_Init);
|
||||
secprop->Add_bool("STATUS",true);
|
||||
|
||||
secprop=control->AddSection_prop("CMS",&CMS_Init);
|
||||
secprop->Add_bool("STATUS",false);
|
||||
|
||||
secprop=control->AddSection_prop("BIOS",&BIOS_Init);
|
||||
secprop=control->AddSection_prop("VIDBIOS",&INT10_Init);
|
||||
secprop=control->AddSection_prop("DOS",&DOS_Init);
|
||||
secprop=control->AddSection_prop("EMS",&EMS_Init);
|
||||
secprop->Add_bool("STATUS",true);
|
||||
secprop->Add_int("SIZE",4);
|
||||
secprop=control->AddSection_prop("XMS",&XMS_Init);
|
||||
secprop->Add_bool("STATUS",true);
|
||||
secprop->Add_int("SIZE",8);
|
||||
|
||||
|
||||
strcpy(file_name,base_dir);
|
||||
strcat(file_name,"dosbox.conf");
|
||||
/* Parse the command line to find config file name */
|
||||
int i;
|
||||
i=1;
|
||||
while (i<argc) {
|
||||
if ((strcasecmp(argv[i],"-conf")==0) && i<(argc-1)) {
|
||||
strcpy(file_name,argv[i+1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
control->ParseConfigFile(file_name);
|
||||
/* Parse the command line to find all other options */
|
||||
|
||||
/*Init all the systems with the acquired settings */
|
||||
control->Init();
|
||||
|
||||
// HARDWARE_Init();
|
||||
#if C_FPU
|
||||
FPU_Init();
|
||||
#endif
|
||||
|
||||
|
||||
//Start up individual hardware
|
||||
|
||||
/* Most of the interrupt handlers */
|
||||
|
||||
LastTicks=GetTicks();
|
||||
DOSBOX_SetLoop(&Normal_Loop);
|
||||
}
|
||||
|
||||
|
||||
void DOSBOX2_Init(int argc, char* argv[]) {
|
||||
|
||||
|
||||
/* Find the base directory */
|
||||
SHELL_AddAutoexec("SET PATH=Z:\\");
|
||||
SHELL_AddAutoexec("SET COMSPEC=Z:\\COMMAND.COM");
|
||||
|
@ -233,7 +307,7 @@ void DOSBOX_Init(int argc, char* argv[]) {
|
|||
}
|
||||
argl++;
|
||||
}
|
||||
InitSystems();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ Illegal Path
|
|||
:SHELL_STARTUP
|
||||
DOSBox Shell v0.35
|
||||
For Help and supported commands type: HELP
|
||||
For information about the hardware setup manager type: HWSET /?
|
||||
|
||||
HAVE FUN!
|
||||
The DOSBox Team
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "mixer.h"
|
||||
#include "timer.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#include "setup.h"
|
||||
/*
|
||||
Thanks to vdmsound for nice simple way to implement this
|
||||
*/
|
||||
|
@ -192,8 +192,9 @@ static void ADLIB_OutputHandler (char * towrite) {
|
|||
|
||||
|
||||
|
||||
void ADLIB_Init(void) {
|
||||
|
||||
void ADLIB_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
timer1.isMasked=true;
|
||||
timer1.base=0;
|
||||
timer1.count=0;
|
||||
|
|
|
@ -203,7 +203,7 @@ Bit16u DMA_16_Write(Bit32u dmachan,Bit8u * buffer,Bit16u count) {
|
|||
|
||||
|
||||
|
||||
void DMA_Init(void) {
|
||||
void DMA_Init(Section* sec) {
|
||||
for (Bit32u i=0;i<0x10;i++) {
|
||||
IO_RegisterWriteHandler(i,write_dma,"DMA1");
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "mixer.h"
|
||||
#include "mem.h"
|
||||
#include "hardware.h"
|
||||
#include "setup.h"
|
||||
|
||||
#define CMS_RATE 22050
|
||||
#define CMS_VOLUME 6000
|
||||
|
||||
|
||||
#define FREQ_SHIFT 16
|
||||
|
||||
#define SIN_ENT 1024
|
||||
|
@ -213,7 +213,11 @@ static void CMS_OutputHandler (char * towrite) {
|
|||
};
|
||||
|
||||
|
||||
void CMS_Init(void) {
|
||||
|
||||
|
||||
void CMS_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
Bits i;
|
||||
/* Register the Mixer CallBack */
|
||||
cms_chan=MIXER_AddChannel(CMS_CallBack,CMS_RATE,"CMS");
|
||||
|
|
|
@ -80,7 +80,7 @@ void IO_FreeWriteHandler(Bit32u port) {
|
|||
}
|
||||
|
||||
|
||||
void IO_Init(void) {
|
||||
void IO_Init(Section * sect) {
|
||||
for (Bitu i=0;i<IO_MAX;i++) {
|
||||
IO_RegisterReadHandler(i,&IO_ReadDefault,"Default Read");
|
||||
IO_RegisterWriteHandler(i,&IO_WriteDefault,"Default Write");
|
||||
|
|
|
@ -91,7 +91,7 @@ void JOYSTICK_Move_Y(Bitu which,float y) {
|
|||
}
|
||||
|
||||
|
||||
void JOYSTICK_Init(void) {
|
||||
void JOYSTICK_Init(Section* sec) {
|
||||
IO_RegisterReadHandler(0x201,read_p201,"JOYSTICK");
|
||||
IO_RegisterWriteHandler(0x201,write_p201,"JOYSTICK");
|
||||
stick[0].enabled=false;
|
||||
|
|
|
@ -321,7 +321,7 @@ void KEYBOARD_AddKey(Bitu keytype,bool pressed) {
|
|||
KEYBOARD_AddCode(ret);
|
||||
};
|
||||
|
||||
void KEYBOARD_Init(void) {
|
||||
void KEYBOARD_Init(Section* sec) {
|
||||
IO_RegisterWriteHandler(0x60,write_p60,"Keyboard");
|
||||
IO_RegisterReadHandler(0x60,read_p60,"Keyboard");
|
||||
IO_RegisterWriteHandler(0x61,write_p61,"Keyboard");
|
||||
|
|
|
@ -222,7 +222,7 @@ Bit32u mem_readd(PhysPt pt){
|
|||
|
||||
|
||||
|
||||
void MEM_Init(void) {
|
||||
void MEM_Init(Section * sect) {
|
||||
/* Init all tables */
|
||||
Bitu i;
|
||||
i=MAX_PAGES;
|
||||
|
@ -235,7 +235,7 @@ void MEM_Init(void) {
|
|||
/* Allocate the first mb of memory */
|
||||
memory=(Bit8u *)malloc(1024*1024);
|
||||
if (!memory) {
|
||||
E_Exit("Can't allocate memory for memory");
|
||||
throw("Can't allocate memory for memory");
|
||||
}
|
||||
/* Setup tables for first mb */
|
||||
MEM_SetupMapping(0,PAGE_COUNT(1024*1024),memory);
|
||||
|
|
|
@ -217,7 +217,7 @@ static void MIXER_CallBack(void * userdata, Uint8 *stream, int len) {
|
|||
|
||||
|
||||
|
||||
void MIXER_Init(void) {
|
||||
void MIXER_Init(Section* sec) {
|
||||
/* Initialize the internal stuff */
|
||||
first_channel=0;
|
||||
mix_ticks=GetTicks();
|
||||
|
|
|
@ -95,7 +95,7 @@ static void PCSPEAKER_CallBack(Bit8u * stream,Bit32u len) {
|
|||
}
|
||||
}
|
||||
|
||||
void PCSPEAKER_Init(void) {
|
||||
void PCSPEAKER_Init(Section* sec) {
|
||||
spkr.chan=MIXER_AddChannel(&PCSPEAKER_CallBack,SPKR_RATE,"PC-SPEAKER");
|
||||
MIXER_Enable(spkr.chan,false);
|
||||
MIXER_SetMode(spkr.chan,MIXER_16MONO);
|
||||
|
|
|
@ -312,7 +312,7 @@ void PIC_runIRQs(void) {
|
|||
}
|
||||
|
||||
|
||||
void PIC_Init(void) {
|
||||
void PIC_Init(Section* sec) {
|
||||
/* Setup pic0 and pic1 with initial values like DOS has normally */
|
||||
PIC_IRQCheck=0;
|
||||
PIC_IRQActive=PIC_NOIRQ;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "dma.h"
|
||||
#include "pic.h"
|
||||
#include "hardware.h"
|
||||
#include "setup.h"
|
||||
|
||||
#define SB_BASE 0x220
|
||||
#define SB_IRQ 5
|
||||
|
@ -603,14 +604,16 @@ static void SB_OutputHandler (char * towrite) {
|
|||
|
||||
|
||||
|
||||
void SBLASTER_Init(void) {
|
||||
void SBLASTER_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
sb.chan=MIXER_AddChannel(&SBLASTER_CallBack,22050,"SBLASTER");
|
||||
MIXER_Enable(sb.chan,false);
|
||||
sb.state=DSP_S_NORMAL;
|
||||
/* Setup the hardware handler part */
|
||||
sb.base=SB_BASE;
|
||||
sb.irq=SB_IRQ;
|
||||
sb.dma=SB_DMA;
|
||||
sb.base=section->Get_hex("BASE");
|
||||
sb.irq=section->Get_int("IRQ");
|
||||
sb.dma=section->Get_int("DMA");
|
||||
SB_Enable(true);
|
||||
|
||||
sb.hwblock.dev_name="SB";
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "inout.h"
|
||||
#include "mixer.h"
|
||||
#include "mem.h"
|
||||
#include "setup.h"
|
||||
|
||||
#define TANDY_DIV 111860
|
||||
#define TANDY_RATE 22050
|
||||
|
@ -125,7 +126,9 @@ static void TANDYSOUND_CallBack(Bit8u * stream,Bit32u len) {
|
|||
}
|
||||
};
|
||||
|
||||
void TANDY_Init(void) {
|
||||
void TANDYSOUND_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
IO_RegisterWriteHandler(0xc0,write_pc0,"Tandy Sound");
|
||||
tandy_chan=MIXER_AddChannel(&TANDYSOUND_CallBack,TANDY_RATE,"TANDY");
|
||||
MIXER_Enable(tandy_chan,false);
|
||||
|
|
|
@ -297,7 +297,7 @@ void TIMER_CheckPIT(void) {
|
|||
}
|
||||
|
||||
|
||||
void TIMER_Init(void) {
|
||||
void TIMER_Init(Section* sect) {
|
||||
Bitu i;
|
||||
IO_RegisterWriteHandler(0x40,write_latch,"PIT Timer 0");
|
||||
IO_RegisterWriteHandler(0x42,write_latch,"PIT Timer 2");
|
||||
|
|
|
@ -146,7 +146,7 @@ void VGA_StartResize(void) {
|
|||
}
|
||||
|
||||
|
||||
void VGA_Init() {
|
||||
void VGA_Init(Section* sec) {
|
||||
vga.draw.resizing=false;
|
||||
VGA_SetupMemory();
|
||||
VGA_SetupMisc();
|
||||
|
|
|
@ -193,7 +193,7 @@ static void INT15_StartUp(void) {
|
|||
void BIOS_SetupKeyboard(void);
|
||||
void BIOS_SetupDisks(void);
|
||||
|
||||
void BIOS_Init(void) {
|
||||
void BIOS_Init(Section* sec) {
|
||||
/* Clear the Bios Data Area */
|
||||
for (Bit16u i=0;i<1024;i++) real_writeb(0x40,i,0);
|
||||
/* Setup all the interrupt handlers the bios controls */
|
||||
|
@ -205,7 +205,7 @@ void BIOS_Init(void) {
|
|||
mem_writed(BIOS_TIMER,0); //Calculate the correct time
|
||||
RealSetVec(0x8,CALLBACK_RealPointer(call_int8));
|
||||
/* INT10 Video Bios */
|
||||
INT10_StartUp();
|
||||
|
||||
/* INT 11 Get equipment list */
|
||||
call_int11=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_int11,&INT11_Handler,CB_IRET);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "regs.h"
|
||||
#include "inout.h"
|
||||
#include "dos_inc.h"
|
||||
#include "setup.h"
|
||||
|
||||
#define EMM_USEHANDLER 1
|
||||
|
||||
|
@ -454,7 +455,9 @@ static Bitu INT67_Handler(void) {
|
|||
|
||||
|
||||
|
||||
void EMS_Init(void) {
|
||||
void EMS_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
call_int67=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_int67,&INT67_Handler,CB_IRET);
|
||||
/* Register the ems device */
|
||||
|
|
|
@ -259,7 +259,7 @@ static void INT10_InitVGA(void) {
|
|||
IO_Write(0x3c5,0x02);
|
||||
};
|
||||
|
||||
void INT10_StartUp(void) {
|
||||
void INT10_Init(Section* sec) {
|
||||
INT10_InitVGA();
|
||||
/* Setup the INT 10 vector */
|
||||
call_10=CALLBACK_Allocate();
|
||||
|
|
|
@ -310,7 +310,7 @@ static Bitu INT74_Handler(void) {
|
|||
};
|
||||
|
||||
|
||||
void MOUSE_Init(void) {
|
||||
void MOUSE_Init(Section* sec) {
|
||||
call_int33=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_int33,&INT33_Handler,CB_IRET);
|
||||
real_writed(0,(0x33<<2),CALLBACK_RealPointer(call_int33));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mem.h"
|
||||
#include "regs.h"
|
||||
#include "dos_system.h"
|
||||
#include "setup.h"
|
||||
|
||||
|
||||
#define XMS_HANDLES 50 /* 50 XMS Memory Blocks */
|
||||
|
@ -324,7 +325,9 @@ foundnew:
|
|||
|
||||
|
||||
|
||||
void XMS_Init(void) {
|
||||
void XMS_Init(Section* sec) {
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
if(!section->Get_bool("STATUS")) return;
|
||||
DOS_AddMultiplexHandler(multiplex_xms);
|
||||
call_xms=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_xms,&XMS_Handler,CB_RETF);
|
||||
|
|
|
@ -38,7 +38,7 @@ struct MessageBlock
|
|||
static MessageBlock * first_message;
|
||||
|
||||
|
||||
static void LoadMessageFile(char * fname) {
|
||||
static void LoadMessageFile(const char * fname) {
|
||||
FILE * mfile=fopen(fname,"rb");
|
||||
/* This should never happen and since other modules depend on this use a normal printf */
|
||||
if (!mfile) {
|
||||
|
@ -97,11 +97,8 @@ char * MSG_Get(char * msg) {
|
|||
|
||||
|
||||
|
||||
void MSG_Init(void) {
|
||||
void MSG_Init(Section_prop * section) {
|
||||
/* Load the messages from "dosbox.lang file" */
|
||||
first_message=0;
|
||||
char filein[CROSS_LEN];
|
||||
strcpy(filein,dosbox_basedir);
|
||||
strcat(filein,"dosbox.lang");
|
||||
LoadMessageFile(filein);
|
||||
LoadMessageFile(section->Get_string("LANGUAGE"));
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ bool Program::SetEnv(char * env_entry,char * new_string) {
|
|||
//TODO Hash table :)
|
||||
|
||||
|
||||
void PROGRAMS_Init(void) {
|
||||
void PROGRAMS_Init(Section* sec) {
|
||||
/* Setup a special callback to start virtual programs */
|
||||
call_program=CALLBACK_Allocate();
|
||||
CALLBACK_Setup(call_program,&PROGRAMS_Handler,CB_RETF);
|
||||
|
|
|
@ -19,11 +19,173 @@
|
|||
#include "dosbox.h"
|
||||
#include "cross.h"
|
||||
#include "setup.h"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <stdlib.h>
|
||||
#include "support.h"
|
||||
|
||||
void SETUP_AddBoolHandler() {
|
||||
using namespace std;
|
||||
|
||||
|
||||
};
|
||||
void Prop_int::SetValue(char* input){
|
||||
input=trim(input);
|
||||
__value._int= atoi(input);
|
||||
}
|
||||
|
||||
void Prop_string::SetValue(char* input){
|
||||
input=trim(input);
|
||||
__value._string->assign(input);
|
||||
}
|
||||
|
||||
void Prop_bool::SetValue(char* input){
|
||||
input=trim(input);
|
||||
if((input[0]=='0') ||(input[0]=='D')||( (input[0]=='O') && (input[0]=='F'))){
|
||||
__value._bool=false;
|
||||
}else{
|
||||
__value._bool=true;
|
||||
}
|
||||
}
|
||||
void Prop_hex::SetValue(char* input){
|
||||
input=trim(input);
|
||||
if(!sscanf(input,"%X",&(__value._hex))) __value._hex=0;
|
||||
}
|
||||
|
||||
void Section_prop::Add_int(const char* _propname, int _value) {
|
||||
Property* test=new Prop_int(_propname,_value);
|
||||
properties.push_back(test);
|
||||
}
|
||||
|
||||
void Section_prop::Add_string(const char* _propname, char* _value) {
|
||||
Property* test=new Prop_string(_propname,_value);
|
||||
properties.push_back(test);
|
||||
}
|
||||
|
||||
void Section_prop::Add_bool(const char* _propname, bool _value) {
|
||||
Property* test=new Prop_bool(_propname,_value);
|
||||
properties.push_back(test);
|
||||
}
|
||||
void Section_prop::Add_hex(const char* _propname, int _value) {
|
||||
Property* test=new Prop_hex(_propname,_value);
|
||||
properties.push_back(test);
|
||||
}
|
||||
int Section_prop::Get_int(const char* _propname){
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==_propname){
|
||||
return ((*tel)->GetValue())._int;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Section_prop::Get_bool(const char* _propname){
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==_propname){
|
||||
return ((*tel)->GetValue())._bool;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const char* Section_prop::Get_string(const char* _propname){
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==_propname){
|
||||
return ((*tel)->GetValue())._string->c_str();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
int Section_prop::Get_hex(const char* _propname){
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==_propname){
|
||||
return ((*tel)->GetValue())._hex;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Section_prop::HandleInputline(char *gegevens){
|
||||
char * rest=strrchr(gegevens,'=');
|
||||
*rest=0;
|
||||
gegevens=trim(gegevens);
|
||||
for(it tel=properties.begin();tel!=properties.end();tel++){
|
||||
if((*tel)->propname==gegevens){
|
||||
(*tel)->SetValue(rest+1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Section_line::HandleInputline(char* gegevens){
|
||||
data+=gegevens;
|
||||
data+="\n";
|
||||
}
|
||||
|
||||
Section* Config::AddSection(const char* _name,void (*_initfunction)(Section*)){
|
||||
Section* blah = new Section(_name,_initfunction);
|
||||
sectionlist.push_back(blah);
|
||||
return blah;
|
||||
}
|
||||
|
||||
Section_prop* Config::AddSection_prop(const char* _name,void (*_initfunction)(Section*)){
|
||||
Section_prop* blah = new Section_prop(_name,_initfunction);
|
||||
sectionlist.push_back(blah);
|
||||
return blah;
|
||||
}
|
||||
|
||||
Section_line* Config::AddSection_line(const char* _name,void (*_initfunction)(Section*)){
|
||||
Section_line* blah = new Section_line(_name,_initfunction);
|
||||
sectionlist.push_back(blah);
|
||||
return blah;
|
||||
}
|
||||
|
||||
|
||||
void Config::Init(){
|
||||
for (it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){
|
||||
(*tel)->ExecuteInit();
|
||||
}
|
||||
}
|
||||
|
||||
Section* Config::GetSection(const char* _sectionname){
|
||||
for (it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){
|
||||
if ( (*tel)->sectionname==_sectionname) return (*tel);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Config::ParseConfigFile(const char* configfilename){
|
||||
ifstream in(configfilename);
|
||||
if (!in) LOG_MSG("CONFIG:Can't find config file %s, using default settings",configfilename);
|
||||
char gegevens[150];
|
||||
Section* currentsection;
|
||||
while (in) {
|
||||
in.getline(gegevens,150);
|
||||
char* temp;
|
||||
switch(gegevens[0]){
|
||||
case '%':
|
||||
case '\0':
|
||||
case '\n':
|
||||
case ' ':
|
||||
continue;
|
||||
break;
|
||||
case '[':
|
||||
temp = strrchr(gegevens,']');
|
||||
*temp=0;
|
||||
currentsection=GetSection(&gegevens[1]);
|
||||
break;
|
||||
default:
|
||||
try{
|
||||
currentsection->HandleInputline(gegevens);
|
||||
}catch(const char* message){
|
||||
message=0;
|
||||
//EXIT with message
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue