add support for tandy sound when machine is not set to tandy
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2373
This commit is contained in:
parent
dc4aaeaed0
commit
7529d70fbe
3 changed files with 55 additions and 46 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dosbox.cpp,v 1.88 2005-10-09 15:50:09 qbix79 Exp $ */
|
||||
/* $Id: dosbox.cpp,v 1.89 2005-11-10 18:05:10 c2woody Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -288,6 +288,7 @@ void DOSBOX_Init(void) {
|
|||
#if C_DEBUG
|
||||
secprop=control->AddSection_prop("debug",&DEBUG_Init);
|
||||
#endif
|
||||
|
||||
secprop=control->AddSection_prop("sblaster",&SBLASTER_Init,true);//done
|
||||
secprop->Add_string("type","sb16");
|
||||
secprop->Add_hex("base",0x220);
|
||||
|
@ -332,6 +333,7 @@ void DOSBOX_Init(void) {
|
|||
secprop->Add_bool("pcspeaker",true);
|
||||
secprop->Add_int("pcrate",22050);
|
||||
secprop->AddInitFunction(&TANDYSOUND_Init,true);//done
|
||||
secprop->Add_string("tandy","auto");
|
||||
secprop->Add_int("tandyrate",22050);
|
||||
secprop->AddInitFunction(&DISNEY_Init,true);//done
|
||||
secprop->Add_bool("disney",true);
|
||||
|
@ -339,10 +341,12 @@ void DOSBOX_Init(void) {
|
|||
MSG_Add("SPEAKER_CONFIGFILE_HELP",
|
||||
"pcspeaker -- Enable PC-Speaker emulation.\n"
|
||||
"pcrate -- Sample rate of the PC-Speaker sound generation.\n"
|
||||
"tandy -- Enable Tandy Sound System emulation (false,true,auto).\n"
|
||||
" For auto Tandysound emulation is present only if machine is set to tandy.\n"
|
||||
"tandyrate -- Sample rate of the Tandy 3-Voice generation.\n"
|
||||
" Tandysound emulation is present if machine is set to tandy.\n"
|
||||
"disney -- Enable Disney Sound Source emulation.\n"
|
||||
);
|
||||
|
||||
secprop=control->AddSection_prop("bios",&BIOS_Init,false);//done
|
||||
MSG_Add("BIOS_CONFIGFILE_HELP",
|
||||
"joysticktype -- Type of joystick to emulate: none, 2axis, 4axis,\n"
|
||||
|
|
|
@ -312,17 +312,29 @@ private:
|
|||
MixerObject MixerChan;
|
||||
public:
|
||||
TANDYSOUND(Section* configuration):Module_base(configuration){
|
||||
if (machine!=MCH_TANDY) return;
|
||||
Section_prop * section=static_cast<Section_prop *>(configuration);
|
||||
|
||||
real_writeb(0x40,0xd4,0x00);
|
||||
if (machine==MCH_TANDY) {
|
||||
/* enable tandy sound if tandy=true/auto */
|
||||
if ((strcmp(section->Get_string("tandy"),"true")!=0) &&
|
||||
(strcmp(section->Get_string("tandy"),"auto")!=0)) return;
|
||||
} else {
|
||||
/* only enable tandy sound if tandy=true */
|
||||
if (strcmp(section->Get_string("tandy"),"true")!=0) return;
|
||||
}
|
||||
|
||||
WriteHandler[0].Install(0xc0,SN76496Write,IO_MB,2);
|
||||
WriteHandler[1].Install(0xc4,TandyDACWrite,IO_MB,4);
|
||||
if (machine==MCH_TANDY) {
|
||||
WriteHandler[0].Install(0xc0,SN76496Write,IO_MB,2);
|
||||
WriteHandler[1].Install(0xc4,TandyDACWrite,IO_MB,4);
|
||||
} else WriteHandler[0].Install(0x1e0,SN76496Write,IO_MB,2);
|
||||
|
||||
|
||||
Bit32u sample_rate = section->Get_int("tandyrate");
|
||||
tandy.chan=MixerChan.Install(&SN76496Update,sample_rate,"TANDY");
|
||||
|
||||
tandy.enabled=false;
|
||||
real_writeb(0x40,0xd4,0xff); /* tandy DAC initialization value */
|
||||
|
||||
Bitu i;
|
||||
struct SN76496 *R = &sn;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: bios.cpp,v 1.48 2005-11-06 15:26:06 c2woody Exp $ */
|
||||
/* $Id: bios.cpp,v 1.49 2005-11-10 18:05:12 c2woody Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
#include "mem.h"
|
||||
|
@ -115,11 +115,12 @@ static bool Tandy_InitializeSB() {
|
|||
|
||||
/* check if Tandy DAC is still playing */
|
||||
static bool Tandy_TransferInProgress(void) {
|
||||
if (real_readw(0x40,0xd0)) return true; /* not yet done */
|
||||
if (real_readb(0x40,0xd4)) return false; /* still in init-state */
|
||||
if (real_readw(0x40,0xd0)) return true; /* not yet done */
|
||||
if (real_readb(0x40,0xd4)==0xff) return false; /* still in init-state */
|
||||
|
||||
IO_Write(0x0c,0x00);
|
||||
if (IO_ReadW(tandy_sb.dma*2+1)==0xffff) return false; /* no DMA transfer */
|
||||
Bit16u datalen=IO_ReadB(tandy_sb.dma*2+1)|(IO_ReadB(tandy_sb.dma*2+1)<<8);
|
||||
if (datalen==0xffff) return false; /* no DMA transfer */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -220,20 +221,14 @@ static Bitu IRQ_TandyDAC(void) {
|
|||
}
|
||||
|
||||
static void TandyDAC_Handler(Bit8u tfunction) {
|
||||
if (machine!=MCH_TANDY) return;
|
||||
if (!tandy_sb.port) return;
|
||||
switch (tfunction) {
|
||||
case 0x81: /* Tandy sound system check */
|
||||
if (tandy_sb.port) {
|
||||
reg_ax=0xc4;
|
||||
CALLBACK_SCF(Tandy_TransferInProgress());
|
||||
}
|
||||
reg_ax=0xc4;
|
||||
CALLBACK_SCF(Tandy_TransferInProgress());
|
||||
break;
|
||||
case 0x82: /* Tandy sound system start recording */
|
||||
case 0x83: /* Tandy sound system start playback */
|
||||
if (!tandy_sb.port) {
|
||||
CALLBACK_SCF(true);
|
||||
break;
|
||||
}
|
||||
if (Tandy_TransferInProgress()) {
|
||||
/* cannot play yet as the last transfer isn't finished yet */
|
||||
reg_ah=0x00;
|
||||
|
@ -249,16 +244,12 @@ static void TandyDAC_Handler(Bit8u tfunction) {
|
|||
CALLBACK_SCF(false);
|
||||
break;
|
||||
case 0x84: /* Tandy sound system stop playing */
|
||||
if (!tandy_sb.port) {
|
||||
CALLBACK_SCF(true);
|
||||
break;
|
||||
}
|
||||
reg_ah=0x00;
|
||||
|
||||
/* setup for a small buffer with zeros (silence) */
|
||||
/* setup for a small buffer with silence */
|
||||
real_writew(0x40,0xd0,0x0a);
|
||||
real_writew(0x40,0xd2,0x1c);
|
||||
Tandy_SetupTransfer(PhysMake(0xf000,0xa084),false);
|
||||
Tandy_SetupTransfer(PhysMake(0xf000,0xa084),true);
|
||||
CALLBACK_SCF(false);
|
||||
break;
|
||||
case 0x85: /* Tandy sound system reset */
|
||||
|
@ -802,6 +793,8 @@ private:
|
|||
CALLBACK_HandlerObject callback[9];
|
||||
public:
|
||||
BIOS(Section* configuration):Module_base(configuration){
|
||||
/* tandy DAC can be requested in tandy_sound.cpp by initializing this field */
|
||||
bool use_tandyDAC=(real_readb(0x40,0xd4)==0xff);
|
||||
/* Clear the Bios Data Area (0x400-0x5ff, 0x600- is accounted to DOS) */
|
||||
for (Bit16u i=0;i<0x200;i++) real_writeb(0x40,i,0);
|
||||
/* Setup all the interrupt handlers the bios controls */
|
||||
|
@ -863,22 +856,23 @@ public:
|
|||
callback[8].Install(&INT70_Handler,CB_IRET,"Int 70 RTC");
|
||||
callback[8].Set_RealVec(0x70);
|
||||
|
||||
if (machine==MCH_TANDY) {
|
||||
phys_writeb(0xffffe,0xfc); /* Tandy model */
|
||||
phys_writeb(0xfc000,0x21); /* Tandy bios identificator */
|
||||
if (machine==MCH_TANDY) phys_writeb(0xffffe,0xff); /* Tandy model */
|
||||
else phys_writeb(0xffffe,0xfc); /* PC */
|
||||
|
||||
if (use_tandyDAC) {
|
||||
/* tandy DAC sound requested, see if soundblaster device is available */
|
||||
if (Tandy_InitializeSB()) {
|
||||
real_writew(0x40,0xd0,0x0000);
|
||||
real_writew(0x40,0xd2,0x0000);
|
||||
real_writeb(0x40,0xd4,0xff); /* initial value */
|
||||
real_writeb(0x40,0xd4,0xff); /* tandy DAC init value */
|
||||
real_writed(0x40,0xd6,0x00000000);
|
||||
/* install the DAC callback handler */
|
||||
tandy_DAC_callback=new CALLBACK_HandlerObject();
|
||||
tandy_DAC_callback->Install(&IRQ_TandyDAC,CB_IRET,"Tandy DAC IRQ");
|
||||
RealPt current_irq=RealGetVec(tandy_sb.irq+8);
|
||||
real_writed(0x40,0xd6,current_irq);
|
||||
}
|
||||
} else {
|
||||
phys_writeb(0xffffe,0xfc); /* PC */
|
||||
for (Bitu i=0; i<0x10; i++) phys_writeb(PhysMake(0xf000,0xa084+i),0x80);
|
||||
} else real_writeb(0x40,0xd4,0x00);
|
||||
}
|
||||
|
||||
/* Setup some stuff in 0x40 bios segment */
|
||||
|
@ -968,22 +962,21 @@ public:
|
|||
size_extended|=(IO_Read(0x71) << 8);
|
||||
}
|
||||
~BIOS(){
|
||||
if (machine==MCH_TANDY) {
|
||||
/* abort DAC playing */
|
||||
if (tandy_sb.port) {
|
||||
IO_Write(tandy_sb.port+0xc,0xd3);
|
||||
IO_Write(tandy_sb.port+0xc,0xd0);
|
||||
}
|
||||
if (tandy_DAC_callback) {
|
||||
Bit32u orig_vector=real_readd(0x40,0xd6);
|
||||
if (orig_vector==tandy_DAC_callback->Get_RealPointer()) {
|
||||
/* set IRQ vector to old value */
|
||||
RealSetVec(tandy_sb.irq+8,real_readd(0x40,0xd6));
|
||||
real_writed(0x40,0xd6,0x00000000);
|
||||
}
|
||||
delete tandy_DAC_callback;
|
||||
tandy_DAC_callback=NULL;
|
||||
/* abort DAC playing */
|
||||
if (tandy_sb.port) {
|
||||
IO_Write(tandy_sb.port+0xc,0xd3);
|
||||
IO_Write(tandy_sb.port+0xc,0xd0);
|
||||
}
|
||||
real_writeb(0x40,0xd4,0x00);
|
||||
if (tandy_DAC_callback) {
|
||||
Bit32u orig_vector=real_readd(0x40,0xd6);
|
||||
if (orig_vector==tandy_DAC_callback->Get_RealPointer()) {
|
||||
/* set IRQ vector to old value */
|
||||
RealSetVec(tandy_sb.irq+8,real_readd(0x40,0xd6));
|
||||
real_writed(0x40,0xd6,0x00000000);
|
||||
}
|
||||
delete tandy_DAC_callback;
|
||||
tandy_DAC_callback=NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue