Improvements to PC speaker - fixes sound on Beyond Castle Wolfenstein and probably other games as well.
This commit is contained in:
parent
967feffbc0
commit
67cb9e3781
8 changed files with 35 additions and 22 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
#include "pic.h"
|
#include "pic.h"
|
||||||
#include "pit.h"
|
#include "pit.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "sound_speaker.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
@ -75,9 +76,10 @@ void keyboard_amstrad_write(uint16_t port, uint8_t val, void *priv)
|
||||||
keyboard_amstrad.pb = val;
|
keyboard_amstrad.pb = val;
|
||||||
ppi.pb = val;
|
ppi.pb = val;
|
||||||
|
|
||||||
gated = ((val & 3) == 3);
|
speaker_gated = val & 1;
|
||||||
if (gated)
|
speaker_enable = val & 2;
|
||||||
wasgated = 1;
|
if (speaker_enable)
|
||||||
|
was_speaker_enable = 1;
|
||||||
pit_set_gate(2, val & 1);
|
pit_set_gate(2, val & 1);
|
||||||
|
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "pic.h"
|
#include "pic.h"
|
||||||
#include "pit.h"
|
#include "pit.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "sound_speaker.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
@ -271,9 +272,10 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv)
|
||||||
|
|
||||||
case 0x61:
|
case 0x61:
|
||||||
ppi.pb = val;
|
ppi.pb = val;
|
||||||
gated = ((val & 3) == 3);
|
speaker_gated = val & 1;
|
||||||
if (gated)
|
speaker_enable = val & 2;
|
||||||
wasgated = 1;
|
if (speaker_enable)
|
||||||
|
was_speaker_enable = 1;
|
||||||
pit_set_gate(2, val & 1);
|
pit_set_gate(2, val & 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "pic.h"
|
#include "pic.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "sound_speaker.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
@ -143,9 +144,10 @@ void keyboard_olim24_write(uint16_t port, uint8_t val, void *priv)
|
||||||
case 0x61:
|
case 0x61:
|
||||||
ppi.pb = val;
|
ppi.pb = val;
|
||||||
|
|
||||||
gated = ((val & 3) == 3);
|
speaker_gated = val & 1;
|
||||||
if (gated)
|
speaker_enable = val & 2;
|
||||||
wasgated = 1;
|
if (speaker_enable)
|
||||||
|
was_speaker_enable = 1;
|
||||||
pit_set_gate(2, val & 1);
|
pit_set_gate(2, val & 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,10 @@ void keyboard_pcjr_write(uint16_t port, uint8_t val, void *priv)
|
||||||
|
|
||||||
case 0x61:
|
case 0x61:
|
||||||
keyboard_pcjr.pb = val;
|
keyboard_pcjr.pb = val;
|
||||||
gated = ((val & 3) == 3);
|
speaker_gated = val & 1;
|
||||||
if (gated)
|
speaker_enable = val & 2;
|
||||||
wasgated = 1;
|
if (speaker_enable)
|
||||||
|
was_speaker_enable = 1;
|
||||||
pit_set_gate(2, val & 1);
|
pit_set_gate(2, val & 1);
|
||||||
sn76489_mute = speaker_mute = 1;
|
sn76489_mute = speaker_mute = 1;
|
||||||
switch (val & 0x60)
|
switch (val & 0x60)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "pic.h"
|
#include "pic.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "sound_speaker.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
@ -75,9 +76,10 @@ void keyboard_xt_write(uint16_t port, uint8_t val, void *priv)
|
||||||
keyboard_xt.pb = val;
|
keyboard_xt.pb = val;
|
||||||
ppi.pb = val;
|
ppi.pb = val;
|
||||||
|
|
||||||
gated = ((val & 3) == 3);
|
speaker_gated = val & 1;
|
||||||
if (gated)
|
speaker_enable = val & 2;
|
||||||
wasgated = 1;
|
if (speaker_enable)
|
||||||
|
was_speaker_enable = 1;
|
||||||
pit_set_gate(2, val & 1);
|
pit_set_gate(2, val & 1);
|
||||||
|
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
void sound_add_handler(void (*poll)(void *p), void (*get_buffer)(int16_t *buffer, int len, void *p), void *p);
|
void sound_add_handler(void (*poll)(void *p), void (*get_buffer)(int16_t *buffer, int len, void *p), void *p);
|
||||||
|
|
||||||
extern int wasgated;
|
|
||||||
extern int sbtype;
|
extern int sbtype;
|
||||||
|
|
||||||
extern int sound_card_current;
|
extern int sound_card_current;
|
||||||
|
|
|
||||||
|
|
@ -8,24 +8,26 @@ static int16_t speaker_buffer[SOUNDBUFLEN];
|
||||||
|
|
||||||
static int speaker_pos = 0;
|
static int speaker_pos = 0;
|
||||||
|
|
||||||
int wasgated = 0;
|
int speaker_gated = 0;
|
||||||
|
int speaker_enable = 0, was_speaker_enable = 0;
|
||||||
|
|
||||||
static void speaker_poll(void *p)
|
static void speaker_poll(void *p)
|
||||||
{
|
{
|
||||||
if (speaker_pos >= SOUNDBUFLEN) return;
|
if (speaker_pos >= SOUNDBUFLEN) return;
|
||||||
|
|
||||||
// printf("SPeaker - %i %i %i %02X\n",speakval,gated,speakon,pit.m[2]);
|
// printf("SPeaker - %i %i %i %02X\n",speakval,gated,speakon,pit.m[2]);
|
||||||
if (gated)
|
if (speaker_gated && was_speaker_enable)
|
||||||
{
|
{
|
||||||
if (!pit.m[2] || pit.m[2]==4)
|
if (!pit.m[2] || pit.m[2]==4)
|
||||||
speaker_buffer[speaker_pos] = speakval;
|
speaker_buffer[speaker_pos] = speakval;
|
||||||
else
|
else
|
||||||
speaker_buffer[speaker_pos] = speakon ? 0x1400 : 0;
|
speaker_buffer[speaker_pos] = speakon ? 0x1400 : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
speaker_buffer[speaker_pos] = wasgated ? 0x1400 : 0;
|
speaker_buffer[speaker_pos] = was_speaker_enable ? 0x1400 : 0;
|
||||||
speaker_pos++;
|
speaker_pos++;
|
||||||
wasgated = 0;
|
if (!speaker_enable)
|
||||||
|
was_speaker_enable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void speaker_get_buffer(int16_t *buffer, int len, void *p)
|
static void speaker_get_buffer(int16_t *buffer, int len, void *p)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
void speaker_init();
|
void speaker_init();
|
||||||
|
|
||||||
extern int speaker_mute;
|
extern int speaker_mute;
|
||||||
|
|
||||||
|
extern int speaker_gated;
|
||||||
|
extern int speaker_enable, was_speaker_enable;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue