Permalink
Browse files

Add dosbox.conf option to configure the IRQ used by PC-98 FM board em…

…ulation
  • Loading branch information...
joncampbell123 committed Feb 18, 2018
1 parent 3a78fad commit 4419b59befc5d33b989d3dede7570fe3fb09249d
Showing with 53 additions and 4 deletions.
  1. +1 −0 CHANGELOG
  2. +3 −0 src/dosbox.cpp
  3. +33 −4 src/hardware/pc98_fm.cpp
  4. +16 −0 src/hardware/snd_pc98/sound/fmtimer.c
@@ -1,5 +1,6 @@
(next)
- PC-98 FM board now allows changing the base I/O port
and IRQ (interrupt) line used by the card.
- PC-98 mode now supports joystick emulation. Joystick
input is mapped through the DOSBox mapper to the
PC-98 FM board where DOS games expect to see it.
@@ -1156,6 +1156,9 @@ void DOSBOX_SetupConfigSections(void) {
Pstring->Set_values(pc98fmboards);
Pstring->Set_help("In PC-98 mode, selects the FM music board to emulate.");
Pint = secprop->Add_int("pc-98 fm board irq", Property::Changeable::WhenIdle,0);
Pint->Set_help("If set, helps to determine the IRQ of the FM board. A setting of zero means to auto-determine the IRQ.");
Phex = secprop->Add_hex("pc-98 fm board io port", Property::Changeable::WhenIdle,0);
Phex->Set_help("If set, helps to determine the base I/O port of the FM board. A setting of zero means to auto-determine the port number.");
@@ -212,18 +212,39 @@ static void pc98_mix_CallBack(Bitu len) {
static bool pc98fm_init = false;
extern "C" {
UINT8 fmtimer_irq2index(const UINT8 irq);
UINT8 fmtimer_index2irq(const UINT8 index);
}
UINT8 board86_encodeirqidx(const unsigned char idx) {
/* see board86.c to understand what this is about */
return ((idx & 1) ? 0x08 : 0x00) +
((idx & 2) ? 0x04 : 0x00);
}
UINT8 board26k_encodeirqidx(const unsigned char idx) {
/* see board26k.c to understand what this is about */
return (idx << 6);
}
void PC98_FM_OnEnterPC98(Section *sec) {
Section_prop * section=static_cast<Section_prop *>(control->GetSection("dosbox"));
if (!pc98fm_init) {
unsigned char fmirqidx;
unsigned int baseio;
std::string board;
int irq;
board = section->Get_string("pc-98 fm board");
if (board == "off" || board == "false") return;
irq = section->Get_int("pc-98 fm board irq");
baseio = section->Get_hex("pc-98 fm board io port");
fmirqidx = fmtimer_irq2index(irq);
pc98fm_init = true;
unsigned int rate = 44100;
@@ -264,7 +285,9 @@ void PC98_FM_OnEnterPC98(Section *sec) {
baseio = 0x288;
}
LOG_MSG("PC-98 FM board is PC-9801-86c at baseio=0x%x",baseio);
pccore.snd86opt += board86_encodeirqidx(fmirqidx);
LOG_MSG("PC-98 FM board is PC-9801-86c at baseio=0x%x irq=%d",baseio,fmtimer_index2irq(fmirqidx));
fmboard_reset(&np2cfg, 0x14);
}
else if (board == "board86") {
@@ -276,7 +299,9 @@ void PC98_FM_OnEnterPC98(Section *sec) {
baseio = 0x288;
}
LOG_MSG("PC-98 FM board is PC-9801-86 at baseio=0x%x",baseio);
pccore.snd86opt += board86_encodeirqidx(fmirqidx);
LOG_MSG("PC-98 FM board is PC-9801-86 at baseio=0x%x irq=%d",baseio,fmtimer_index2irq(fmirqidx));
fmboard_reset(&np2cfg, 0x04);
}
else if (board == "board26k") {
@@ -288,7 +313,9 @@ void PC98_FM_OnEnterPC98(Section *sec) {
baseio = 0x088;
}
LOG_MSG("PC-98 FM board is PC-9801-26k at baseio=0x%x",baseio);
pccore.snd26opt += board26k_encodeirqidx(fmirqidx);
LOG_MSG("PC-98 FM board is PC-9801-26k at baseio=0x%x irq=%d",baseio,fmtimer_index2irq(fmirqidx));
fmboard_reset(&np2cfg, 0x02);
}
else {
@@ -300,7 +327,9 @@ void PC98_FM_OnEnterPC98(Section *sec) {
baseio = 0x288;
}
LOG_MSG("PC-98 FM board is PC-9801-86c at baseio=0x%x",baseio);
pccore.snd86opt += board86_encodeirqidx(fmirqidx);
LOG_MSG("PC-98 FM board is PC-9801-86c at baseio=0x%x irq=%d",baseio,fmtimer_index2irq(fmirqidx));
fmboard_reset(&np2cfg, 0x14); // board86c, a good default
}
@@ -42,6 +42,22 @@ static unsigned int nevent_iswork(unsigned int n) {
static const UINT8 irqtable[4] = {0x03, 0x0d, 0x0a, 0x0c};
/* added for DOSBox-X */
UINT8 fmtimer_index2irq(const UINT8 index) {
return irqtable[index & 3];
}
UINT8 fmtimer_irq2index(const UINT8 irq) {
unsigned int i;
for (i=0;i < 4;i++) {
if (irqtable[i] == irq)
return i;
}
return 0x00;
}
/* end */
static void set_fmtimeraevent(BOOL absolute) {

0 comments on commit 4419b59

Please sign in to comment.