Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Update to DOSBox r4010
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamlayers committed May 5, 2017
2 parents 6d4194d + 8a33093 commit 4526ed7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
1 change: 1 addition & 0 deletions include/bios.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#define BIOS_VDU_CONTROL 0x465
#define BIOS_VDU_COLOR_REGISTER 0x466
/* 0x467-0x468 is reserved */
#define BIOS_LAST_UNEXPECTED_IRQ 0x46b
#define BIOS_TIMER 0x46c
#define BIOS_24_HOURS_FLAG 0x470
#define BIOS_KEYBOARD_FLAGS 0x471
Expand Down
5 changes: 1 addition & 4 deletions src/cpu/callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
CallBack_Handler CallBack_Handlers[CB_MAX];
char* CallBack_Description[CB_MAX];

static Bitu call_stop,call_idle,call_default,call_default2;
static Bitu call_stop,call_idle,call_default;
Bitu call_priv_io;

static Bitu illegal_handler(void) {
Expand Down Expand Up @@ -575,8 +575,6 @@ void CALLBACK_Init(Section* /*sec*/) {
/* Default handlers for unhandled interrupts that have to be non-null */
call_default=CALLBACK_Allocate();
CALLBACK_Setup(call_default,&default_handler,CB_IRET,"default");
call_default2=CALLBACK_Allocate();
CALLBACK_Setup(call_default2,&default_handler,CB_IRET,"default");

/* Only setup default handler for first part of interrupt table */
for (Bit16u ct=0;ct<0x60;ct++) {
Expand All @@ -597,7 +595,6 @@ void CALLBACK_Init(Section* /*sec*/) {

}
// setup a few interrupt handlers that point to bios IRETs by default
real_writed(0,0x0e*4,CALLBACK_RealPointer(call_default2)); //design your own railroad
real_writed(0,0x66*4,CALLBACK_RealPointer(call_default)); //war2d
real_writed(0,0x67*4,CALLBACK_RealPointer(call_default));
real_writed(0,0x68*4,CALLBACK_RealPointer(call_default));
Expand Down
6 changes: 3 additions & 3 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,9 +1973,9 @@ static void GUI_StartUp(Section * sec) {
glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)SDL_GL_GetProcAddress("glUnmapBufferARB");
const char * gl_ext = (const char *)glGetString (GL_EXTENSIONS);
if(gl_ext && *gl_ext){
sdl.opengl.packed_pixel=(strstr(gl_ext,"EXT_packed_pixels") > 0);
sdl.opengl.paletted_texture=(strstr(gl_ext,"EXT_paletted_texture") > 0);
sdl.opengl.pixel_buffer_object=(strstr(gl_ext,"GL_ARB_pixel_buffer_object") >0 ) &&
sdl.opengl.packed_pixel=(strstr(gl_ext,"EXT_packed_pixels") != NULL);
sdl.opengl.paletted_texture=(strstr(gl_ext,"EXT_paletted_texture") != NULL);
sdl.opengl.pixel_buffer_object=(strstr(gl_ext,"GL_ARB_pixel_buffer_object") != NULL ) &&
glGenBuffersARB && glBindBufferARB && glDeleteBuffersARB && glBufferDataARB &&
glMapBufferARB && glUnmapBufferARB;
} else {
Expand Down
12 changes: 7 additions & 5 deletions src/hardware/gameblaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define RIGHT 0x01
#define CMS_BUFFER_SIZE 128
#define CMS_RATE 22050
/*#define MASTER_CLOCK 14318180/2 */
#define MASTER_CLOCK 7159090


typedef Bit8u UINT8;
Expand Down Expand Up @@ -205,9 +207,9 @@ static void saa1099_update(int chip, INT16 **buffer, int length)
{
switch (saa->noise_params[ch])
{
case 0: saa->noise[ch].freq = 31250.0 * 2; break;
case 1: saa->noise[ch].freq = 15625.0 * 2; break;
case 2: saa->noise[ch].freq = 7812.5 * 2; break;
case 0: saa->noise[ch].freq = MASTER_CLOCK/256 * 2; break;
case 1: saa->noise[ch].freq = MASTER_CLOCK/512 * 2; break;
case 2: saa->noise[ch].freq = MASTER_CLOCK/1024 * 2; break;
case 3: saa->noise[ch].freq = saa->channels[ch * 3].freq; break;
}
}
Expand All @@ -221,15 +223,15 @@ static void saa1099_update(int chip, INT16 **buffer, int length)
for (ch = 0; ch < 6; ch++)
{
if (saa->channels[ch].freq == 0.0)
saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) /
saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) /
(511.0 - (double)saa->channels[ch].frequency);

/* check the actual position in the square wave */
saa->channels[ch].counter -= saa->channels[ch].freq;
while (saa->channels[ch].counter < 0)
{
/* calculate new frequency now after the half wave is updated */
saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) /
saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) /
(511.0 - (double)saa->channels[ch].frequency);

saa->channels[ch].counter += sample_rate;
Expand Down
35 changes: 32 additions & 3 deletions src/ints/bios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,6 @@ static Bitu INT14_Handler(void) {
static Bitu INT15_Handler(void) {
static Bit16u biosConfigSeg=0;
switch (reg_ah) {
case 0x06:
LOG(LOG_BIOS,LOG_NORMAL)("INT15 Unkown Function 6");
break;
case 0xC0: /* Get Configuration*/
{
if (biosConfigSeg==0) biosConfigSeg = DOS_GetMemory(1); //We have 16 bytes
Expand Down Expand Up @@ -966,6 +963,28 @@ static Bitu INT15_Handler(void) {
return CBRET_NONE;
}

static Bitu Default_IRQ_Handler(void) {
IO_WriteB(0x20,0x0b);
Bit8u master_isr=IO_ReadB(0x20);
if (master_isr) {
IO_WriteB(0xa0,0x0b);
Bit8u slave_isr=IO_ReadB(0xa0);
if (slave_isr) {
IO_WriteB(0xa1,IO_ReadB(0xa1)|slave_isr);
IO_WriteB(0xa0,0x20);
} else IO_WriteB(0x21,IO_ReadB(0x21)|(master_isr&~4));
IO_WriteB(0x20,0x20);
#if C_DEBUG
Bit16u irq=0,isr=master_isr;
if (slave_isr) isr=slave_isr<<8;
while (isr>>=1) irq++;
LOG(LOG_BIOS,LOG_WARN)("Unexpected IRQ %u",irq);
#endif
} else master_isr=0xff;
mem_writeb(BIOS_LAST_UNEXPECTED_IRQ,master_isr);
return CBRET_NONE;
}

static Bitu Reboot_Handler(void) {
// switch to text mode, notify user (let's hope INT10 still works)
const char* const text = "\n\n Reboot requested, quitting now.";
Expand Down Expand Up @@ -1102,6 +1121,16 @@ class BIOS:public Module_base{
CALLBACK_Setup(call_irq2,NULL,CB_IRET_EOI_PIC1,Real2Phys(BIOS_DEFAULT_IRQ2_LOCATION),"irq 2 bios");
RealSetVec(0x0a,BIOS_DEFAULT_IRQ2_LOCATION);

/* Default IRQ handler */
Bitu call_irq_default=CALLBACK_Allocate();
CALLBACK_Setup(call_irq_default,&Default_IRQ_Handler,CB_IRET,"irq default");
RealSetVec(0x0b,CALLBACK_RealPointer(call_irq_default)); // IRQ 3
RealSetVec(0x0c,CALLBACK_RealPointer(call_irq_default)); // IRQ 4
RealSetVec(0x0d,CALLBACK_RealPointer(call_irq_default)); // IRQ 5
RealSetVec(0x0f,CALLBACK_RealPointer(call_irq_default)); // IRQ 7
RealSetVec(0x72,CALLBACK_RealPointer(call_irq_default)); // IRQ 10
RealSetVec(0x73,CALLBACK_RealPointer(call_irq_default)); // IRQ 11

// INT 05h: Print Screen
// IRQ1 handler calls it when PrtSc key is pressed; does nothing unless hooked
phys_writeb(Real2Phys(BIOS_DEFAULT_INT5_LOCATION),0xcf);
Expand Down

0 comments on commit 4526ed7

Please sign in to comment.