2009-05-02 23:03:37 +02:00
|
|
|
/*
|
2009-05-02 23:35:44 +02:00
|
|
|
* Copyright (C) 2002-2003 The DOSBox Team
|
2009-05-02 23:03:37 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-05-02 23:12:18 +02:00
|
|
|
#include <unistd.h>
|
2009-05-02 23:03:37 +02:00
|
|
|
#include "dosbox.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "video.h"
|
|
|
|
#include "pic.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "callback.h"
|
|
|
|
#include "inout.h"
|
|
|
|
#include "mixer.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "dos_inc.h"
|
|
|
|
#include "setup.h"
|
|
|
|
#include "cross.h"
|
|
|
|
#include "programs.h"
|
2009-05-02 23:20:05 +02:00
|
|
|
#include "support.h"
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
Config * control;
|
|
|
|
Bitu errorlevel=1;
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
/* The whole load of startups for all the subfunctions */
|
|
|
|
void MSG_Init(Section_prop *);
|
2009-05-02 23:35:44 +02:00
|
|
|
void LOG_StartUp(void);
|
2009-05-02 23:20:05 +02:00
|
|
|
void MEM_Init(Section *);
|
|
|
|
void IO_Init(Section * );
|
|
|
|
void CALLBACK_Init(Section*);
|
|
|
|
void PROGRAMS_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void RENDER_Init(Section*);
|
|
|
|
void VGA_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void DOS_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void CPU_Init(Section*);
|
2009-05-02 23:12:18 +02:00
|
|
|
//void FPU_Init();
|
2009-05-02 23:20:05 +02:00
|
|
|
void DMA_Init(Section*);
|
|
|
|
void MIXER_Init(Section*);
|
2009-05-02 23:35:44 +02:00
|
|
|
void MIDI_Init(Section*);
|
2009-05-02 23:20:05 +02:00
|
|
|
void HARDWARE_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
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*);
|
2009-05-02 23:27:47 +02:00
|
|
|
void GUS_Init(Section*);
|
2009-05-02 23:35:44 +02:00
|
|
|
void MPU401_Init(Section*);
|
2009-05-02 23:20:05 +02:00
|
|
|
void ADLIB_Init(Section*);
|
|
|
|
void PCSPEAKER_Init(Section*);
|
|
|
|
void TANDYSOUND_Init(Section*);
|
|
|
|
void CMS_Init(Section*);
|
2009-05-02 23:27:47 +02:00
|
|
|
void DISNEY_Init(Section*);
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void PIC_Init(Section*);
|
|
|
|
void TIMER_Init(Section*);
|
|
|
|
void BIOS_Init(Section*);
|
|
|
|
void DEBUG_Init(Section*);
|
2009-05-02 23:27:47 +02:00
|
|
|
void CMOS_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:35:44 +02:00
|
|
|
void MSCDEX_Init(Section*);
|
|
|
|
|
2009-05-02 23:03:37 +02:00
|
|
|
/* Dos Internal mostly */
|
2009-05-02 23:20:05 +02:00
|
|
|
void EMS_Init(Section*);
|
|
|
|
void XMS_Init(Section*);
|
|
|
|
void AUTOEXEC_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
void SHELL_Init(void);
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void INT10_Init(Section*);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
|
|
|
static LoopHandler * loop;
|
|
|
|
|
2009-05-02 23:27:47 +02:00
|
|
|
Bitu RemainTicks;;
|
|
|
|
Bitu LastTicks;
|
|
|
|
|
2009-05-02 23:03:37 +02:00
|
|
|
static Bitu Normal_Loop(void) {
|
2009-05-02 23:27:47 +02:00
|
|
|
Bitu ret,NewTicks;
|
|
|
|
while (RemainTicks) {
|
|
|
|
ret=PIC_RunQueue();
|
|
|
|
#if C_DEBUG
|
|
|
|
if (DEBUG_ExitLoop()) return 0;
|
|
|
|
#endif
|
|
|
|
if (ret) return ret;
|
|
|
|
RemainTicks--;
|
|
|
|
TIMER_AddTick();
|
|
|
|
GFX_Events();
|
2009-05-02 23:03:37 +02:00
|
|
|
}
|
2009-05-02 23:27:47 +02:00
|
|
|
NewTicks=GetTicks();
|
|
|
|
if (NewTicks>LastTicks) {
|
|
|
|
RemainTicks+=NewTicks-LastTicks;
|
|
|
|
if (RemainTicks>20) {
|
|
|
|
// LOG_DEBUG("Ticks to handle overflow %d",RemainTicks);
|
|
|
|
RemainTicks=20;
|
|
|
|
}
|
|
|
|
LastTicks=NewTicks;
|
|
|
|
}
|
|
|
|
//TODO Make this selectable in the config file, since it gives some lag */
|
|
|
|
if (!RemainTicks) {
|
|
|
|
SDL_Delay(1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
2009-05-02 23:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DOSBOX_SetLoop(LoopHandler * handler) {
|
|
|
|
loop=handler;
|
|
|
|
}
|
|
|
|
|
2009-05-02 23:12:18 +02:00
|
|
|
void DOSBOX_SetNormalLoop() {
|
|
|
|
loop=Normal_Loop;
|
|
|
|
}
|
2009-05-02 23:03:37 +02:00
|
|
|
|
|
|
|
void DOSBOX_RunMachine(void){
|
|
|
|
Bitu ret;
|
|
|
|
do {
|
|
|
|
ret=(*loop)();
|
|
|
|
} while (!ret);
|
|
|
|
}
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
static void DOSBOX_RealInit(Section * sec) {
|
|
|
|
Section_prop * section=static_cast<Section_prop *>(sec);
|
|
|
|
/* Initialize some dosbox internals */
|
|
|
|
errorlevel=section->Get_int("warnings");
|
|
|
|
MSG_Add("DOSBOX_CONFIGFILE_HELP","General Dosbox settings\n");
|
2009-05-02 23:27:47 +02:00
|
|
|
RemainTicks=0;LastTicks=GetTicks();
|
2009-05-02 23:03:37 +02:00
|
|
|
DOSBOX_SetLoop(&Normal_Loop);
|
2009-05-02 23:20:05 +02:00
|
|
|
MSG_Init(section);
|
2009-05-02 23:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
void DOSBOX_Init(void) {
|
|
|
|
// Section * sec;
|
|
|
|
Section_prop * secprop;
|
|
|
|
Section_line * secline;
|
|
|
|
|
|
|
|
/* Setup all the different modules making up DOSBox */
|
|
|
|
|
|
|
|
secprop=control->AddSection_prop("dosbox",&DOSBOX_RealInit);
|
|
|
|
secprop->Add_string("language","");
|
|
|
|
#if C_DEBUG
|
|
|
|
secprop->Add_int("warnings",4);
|
2009-05-02 23:35:44 +02:00
|
|
|
LOG_StartUp();
|
2009-05-02 23:20:05 +02:00
|
|
|
#else
|
|
|
|
secprop->Add_int("warnings",0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
secprop->AddInitFunction(&MEM_Init);
|
|
|
|
secprop->AddInitFunction(&IO_Init);
|
|
|
|
secprop->AddInitFunction(&CALLBACK_Init);
|
|
|
|
secprop->AddInitFunction(&PIC_Init);
|
|
|
|
secprop->AddInitFunction(&PROGRAMS_Init);
|
|
|
|
secprop->AddInitFunction(&TIMER_Init);
|
2009-05-02 23:27:47 +02:00
|
|
|
secprop->AddInitFunction(&CMOS_Init);
|
|
|
|
secprop=control->AddSection_prop("render",&RENDER_Init);
|
|
|
|
secprop->Add_int("frameskip",0);
|
|
|
|
secprop->Add_bool("keepsmall",false);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_string("snapshots","snaps");
|
|
|
|
secprop->Add_string("scaler","none");
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop=control->AddSection_prop("cpu",&CPU_Init);
|
2009-05-02 23:27:47 +02:00
|
|
|
secprop->Add_int("cycles",1800);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop->AddInitFunction(&DMA_Init);
|
|
|
|
secprop->AddInitFunction(&VGA_Init);
|
|
|
|
secprop->AddInitFunction(&KEYBOARD_Init);
|
|
|
|
secprop->AddInitFunction(&MOUSE_Init);
|
|
|
|
secprop->AddInitFunction(&JOYSTICK_Init);
|
2009-05-02 23:03:37 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop=control->AddSection_prop("mixer",&MIXER_Init);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_bool("nosound",false);
|
|
|
|
secprop->Add_int("freq",22050);
|
|
|
|
secprop->Add_int("blocksize",2048);
|
|
|
|
secprop->Add_string("wavedir","waves");
|
|
|
|
|
|
|
|
secprop=control->AddSection_prop("midi",&MIDI_Init);
|
|
|
|
secprop->AddInitFunction(&MPU401_Init);
|
|
|
|
secprop->Add_bool("mpu401",true);
|
|
|
|
secprop->Add_string("device","default");
|
|
|
|
secprop->Add_string("config","");
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
#if C_DEBUG
|
|
|
|
secprop=control->AddSection_prop("debug",&DEBUG_Init);
|
|
|
|
#endif
|
|
|
|
secprop=control->AddSection_prop("sblaster",&SBLASTER_Init);
|
|
|
|
secprop->Add_hex("base",0x220);
|
|
|
|
secprop->Add_int("irq",7);
|
|
|
|
secprop->Add_int("dma",1);
|
|
|
|
secprop->Add_int("hdma",5);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_int("sbrate",22050);
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop->Add_bool("enabled",true);
|
|
|
|
|
|
|
|
secprop->AddInitFunction(&ADLIB_Init);
|
|
|
|
secprop->Add_bool("adlib",true);
|
|
|
|
secprop->AddInitFunction(&CMS_Init);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_bool("cms",false);
|
|
|
|
secprop->Add_int("cmsrate",22050);
|
2009-05-02 23:27:47 +02:00
|
|
|
|
|
|
|
// secprop=control->AddSection_prop("gus",&GUS_Init);
|
2009-05-02 23:35:44 +02:00
|
|
|
|
2009-05-02 23:27:47 +02:00
|
|
|
secprop=control->AddSection_prop("disney",&DISNEY_Init);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_bool("enabled",true);
|
2009-05-02 23:27:47 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop=control->AddSection_prop("speaker",&PCSPEAKER_Init);
|
2009-05-02 23:27:47 +02:00
|
|
|
secprop->Add_bool("enabled",true);
|
2009-05-02 23:35:44 +02:00
|
|
|
secprop->Add_int("pcrate",22050);
|
2009-05-02 23:20:05 +02:00
|
|
|
secprop->AddInitFunction(&TANDYSOUND_Init);
|
|
|
|
secprop->Add_bool("tandy",false);
|
|
|
|
|
|
|
|
secprop=control->AddSection_prop("bios",&BIOS_Init);
|
|
|
|
secprop->AddInitFunction(&INT10_Init);
|
|
|
|
|
|
|
|
/* All the DOS Related stuff, which will eventually start up in the shell */
|
|
|
|
//TODO Maybe combine most of the dos stuff in one section like ems,xms
|
|
|
|
secprop=control->AddSection_prop("dos",&DOS_Init);
|
|
|
|
secprop->AddInitFunction(&EMS_Init);
|
|
|
|
secprop->Add_int("emssize",4);
|
|
|
|
secprop->AddInitFunction(&XMS_Init);
|
|
|
|
secprop->Add_int("xmssize",8);
|
|
|
|
|
2009-05-02 23:35:44 +02:00
|
|
|
// Mscdex
|
|
|
|
secprop->AddInitFunction(&MSCDEX_Init);
|
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
secline=control->AddSection_line("autoexec",&AUTOEXEC_Init);
|
2009-05-02 23:35:44 +02:00
|
|
|
|
2009-05-02 23:20:05 +02:00
|
|
|
control->SetStartUp(&SHELL_Init);
|
|
|
|
|
|
|
|
#if C_FPU
|
|
|
|
FPU_Init();
|
|
|
|
#endif
|
2009-05-02 23:03:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|