apple2ix/src/audio/mockingboard.h

124 lines
3.1 KiB
C
Raw Normal View History

/*
* Apple // emulator for *ix
*
* This software package is subject to the GNU General Public License
* version 3 or later (your choice) as published by the Free Software
* Foundation.
*
* Copyright 2013-2015 Aaron Culliney
*
*/
#ifndef _MOCKINGBOARD_H__
#define _MOCKINGBOARD_H__
#ifdef APPLE2IX
#include "audio/peripherals.h"
extern bool g_bDisableDirectSoundMockingboard;
typedef struct
{
union
{
struct
{
2015-06-07 18:39:01 +00:00
uint8_t l;
uint8_t h;
};
2015-06-07 18:35:45 +00:00
uint16_t w;
};
} IWORD;
typedef struct
{
2015-06-07 18:39:01 +00:00
uint8_t ORB; // $00 - Port B
uint8_t ORA; // $01 - Port A (with handshaking)
uint8_t DDRB; // $02 - Data Direction Register B
uint8_t DDRA; // $03 - Data Direction Register A
//
// $04 - Read counter (L) / Write latch (L)
// $05 - Read / Write & initiate count (H)
// $06 - Read / Write & latch (L)
// $07 - Read / Write & latch (H)
// $08 - Read counter (L) / Write latch (L)
// $09 - Read counter (H) / Write latch (H)
IWORD TIMER1_COUNTER;
IWORD TIMER1_LATCH;
IWORD TIMER2_COUNTER;
IWORD TIMER2_LATCH;
//
2015-06-07 18:39:01 +00:00
uint8_t SERIAL_SHIFT; // $0A
uint8_t ACR; // $0B - Auxiliary Control Register
uint8_t PCR; // $0C - Peripheral Control Register
uint8_t IFR; // $0D - Interrupt Flag Register
uint8_t IER; // $0E - Interrupt Enable Register
uint8_t ORA_NO_HS; // $0F - Port A (without handshaking)
} SY6522;
typedef struct
{
2015-06-07 18:39:01 +00:00
uint8_t DurationPhonome;
uint8_t Inflection; // I10..I3
uint8_t RateInflection;
uint8_t CtrlArtAmp;
uint8_t FilterFreq;
//
2015-06-07 18:39:01 +00:00
uint8_t CurrentMode; // b7:6=Mode; b0=D7 pin (for IRQ)
} SSI263A;
extern SS_CARDTYPE g_Slot4; // Mockingboard, Z80, Mouse in slot4
extern SS_CARDTYPE g_Slot5; // Mockingboard, Z80 in slot5
#define MB_UNITS_PER_CARD 2
typedef struct
{
SY6522 RegsSY6522;
2015-06-07 18:39:01 +00:00
uint8_t RegsAY8910[16];
SSI263A RegsSSI263;
2015-06-07 18:39:01 +00:00
uint8_t nAYCurrentRegister;
bool bTimer1IrqPending;
bool bTimer2IrqPending;
bool bSpeechIrqPending;
} MB_Unit;
typedef struct
{
SS_CARD_HDR Hdr;
MB_Unit Unit[MB_UNITS_PER_CARD];
} SS_CARD_MOCKINGBOARD;
#endif
extern bool g_bMBTimerIrqActive;
#ifdef _DEBUG
2015-06-07 18:00:15 +00:00
extern uint32_t g_uTimer1IrqCount; // DEBUG
#endif
void MB_Initialize();
void MB_Reinitialize();
void MB_Destroy();
void MB_SetEnabled(bool enabled);
2015-07-24 06:46:23 +00:00
bool MB_ISEnabled(void);
void MB_Reset();
2015-06-07 19:11:19 +00:00
void MB_InitializeIO(char *pCxRomPeripheral, unsigned int uSlot4, unsigned int uSlot5);
void MB_Mute();
void MB_Demute();
void MB_StartOfCpuExecute();
void MB_EndOfVideoFrame();
Refactor speaker system to prevent audio glitches and to support CPU automatic speed switching Squashed commit of the following: REFACTOR : fix comments, logging, and rename some variables REFACTOR : fix up some commentary, clean deadc0de REFACTOR : mostly fix all the audio glitches - amplitudes of samples are gradually shifted to zero when speaker has fallen silent - simplifies speaker state machine - fullspeed mode only enqueues quiet samples REFACTOR : fix up a number of other functions and comments REFACTOR : clean up code to submit normal speed wave buffer to OpenAL Move some initializations to the cpu_thread() REFACTOR : properly reset the speaker cycles access counter so we don't underflow and assert REFACTOR : should never get a split buffer from our soundcore implementation Fix warning from gcc ... static array size needs to be computed from integer values REFACTOR : gcc (but not clang) complains about these, so just make them preprocessor defines REFACTOR : use unsigned long long because we don't actually care that this counter is 64bit REFACTOR : remainder_buffer and miscellaneous tweaks - Adds implementation commentary to document remainder_buffer purpose - Also adds sample average for square wave boundary in case where remainder_buffer not used (whole-sample boundary) - Variable renaming and code shuffling REFACTOR : do not dynamically alloc remainder buffer - Never attribute to cache-coherancy bugs what is a simple thread race =P REFACTOR : comments and whitespace REFACTOR : rename public speaker API functions REFACTOR : clean up public speaker API REFACTOR : tabs to spaces REFACTOR : moar deadc0de clean up and renaming REFACTOR : remove deadc0de paths from soundcore REFACTOR : fully excise soundtype stuff now that we only support soundcard output Move a file static to function scope REFACTOR : rename more variables and remove deadc0de REFACTOR : samples_buffer naming and change to explict int16_t REFACTOR : removed deadc0de and shuffled code locations REFACTOR : remainder buffer naming and clarify type REFACTOR : move joystick timing to VM module and remove header visibility REFACTOR : clarify speaker variable name REFACTOR : clarify cycle counting codepaths REFACTOR : VBL/timing interfaces - eliminates passing around a common global REFACTOR : names and comments HACK around volume issue REFACTOR : rename speaker feedback variable REFACTOR : rename global total cycle count REFACTOR : rename a constant Fix test builds REFACTOR: rename to is_fullspeed REFACTOR : local variable naming changes REFACTOR : migrate cycle timing variables to correct location and remove header visibility Allow fullspeed codepath to update speaker REFACTOR : remove deadc0de paths in prep for cleanup REFACTOR : speaker now manages its own VM entry point
2015-01-31 21:57:10 +00:00
void MB_UpdateCycles(void);
SS_CARDTYPE MB_GetSoundcardType();
void MB_SetSoundcardType(SS_CARDTYPE NewSoundcardType);
double MB_GetFramePeriod();
bool MB_IsActive();
2015-06-07 18:47:57 +00:00
unsigned long MB_GetVolume();
void MB_SetVolumeZeroToTen(unsigned long goesToTen);
2015-06-07 18:47:57 +00:00
void MB_SetVolume(unsigned long dwVolume, unsigned long dwVolumeMax);
unsigned long MB_GetSnapshot(SS_CARD_MOCKINGBOARD* pSS, unsigned long dwSlot);
unsigned long MB_SetSnapshot(SS_CARD_MOCKINGBOARD* pSS, unsigned long dwSlot);
#ifdef APPLE2IX
void mb_io_initialize(unsigned int slot4, unsigned int slot5);
#endif
#endif // whole file