diff --git a/Src/Model3/DSB.cpp b/Src/Model3/DSB.cpp index 98d36f0..9238823 100644 --- a/Src/Model3/DSB.cpp +++ b/Src/Model3/DSB.cpp @@ -590,6 +590,11 @@ bool CDSB1::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr) return OKAY; } +CZ80 *CDSB1::GetZ80(void) +{ + return &Z80; +} + CDSB1::CDSB1(void) { progROM = NULL; @@ -1161,6 +1166,11 @@ bool CDSB2::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr) return OKAY; } +M68KCtx *CDSB2::GetM68K(void) +{ + return &M68K; +} + CDSB2::CDSB2(void) { progROM = NULL; diff --git a/Src/Model3/DSB.h b/Src/Model3/DSB.h index 8725172..e846cce 100644 --- a/Src/Model3/DSB.h +++ b/Src/Model3/DSB.h @@ -241,6 +241,9 @@ public: void LoadState(CBlockFile *StateFile); bool Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr); + // Returns a reference to the Z80 CPU + CZ80 *GetZ80(void); + // Constructor and destructor CDSB1(void); ~CDSB1(void); @@ -313,6 +316,9 @@ public: void LoadState(CBlockFile *StateFile); bool Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr); + // Returns a reference to the 68K CPU context + M68KCtx *GetM68K(void); + // Constructor and destructor CDSB2(void); ~CDSB2(void); diff --git a/Src/Model3/DriveBoard.cpp b/Src/Model3/DriveBoard.cpp index 110c7c4..b0ff3bb 100644 --- a/Src/Model3/DriveBoard.cpp +++ b/Src/Model3/DriveBoard.cpp @@ -646,15 +646,12 @@ void CDriveBoard::ProcessEncoderCmd(void) // Disable uncentering SendVibrate(0); } - else if (seqNum == 3) + else if (seqNum == 3 && m_uncenterVal1 > 0) { - if (m_uncenterVal1 > 0) - { - // Uncentering - unsure exactly how values sent map to strength or whether they specify some other attributes of effect - // For now just attempting to map them to a sensible value in range 0x00-0xFF - UINT8 strength = ((m_uncenterVal1>>1) - 7) * 0x50 + ((m_uncenterVal2>>1) - 5) * 0x10 + 0xF; - SendVibrate(strength); - } + // Uncentering - unsure exactly how values sent map to strength or whether they specify some other attributes of effect + // For now just attempting to map them to a sensible value in range 0x00-0xFF + UINT8 strength = ((m_uncenterVal1>>1) - 7) * 0x50 + ((m_uncenterVal2>>1) - 5) * 0x10 + 0xF; + SendVibrate(strength); } } break; diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 127a358..dfff595 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -2197,7 +2197,7 @@ void CModel3::RunSoundBoardThread(void) goto ThreadError; } - // Keep processing frames until audio buffer is half full + // Keep processing frames until audio buffer is full bool repeat = true; // NOTE - performs an unlocked read of pausedThreads here, but this is okay while (!pausedThreads && !SoundBoard.RunFrame()) @@ -2928,6 +2928,16 @@ bool CModel3::Init(void) return OKAY; } +CSoundBoard *CModel3::GetSoundBoard(void) +{ + return &SoundBoard; +} + +CDriveBoard *CModel3::GetDriveBoard(void) +{ + return &DriveBoard; +} + CModel3::CModel3(void) { // Initialize pointers so dtor can know whether to free them diff --git a/Src/Model3/Model3.h b/Src/Model3/Model3.h index cb834a2..6e4073d 100644 --- a/Src/Model3/Model3.h +++ b/Src/Model3/Model3.h @@ -170,8 +170,9 @@ public: * * Loads and resumes execution from a state image. Modifies data that may * be used by multiple threads -- use with caution and ensure threads are - * not accessing data that will be touched. Must never be called while - * emulator is running (inside RunFrame()). + * not accessing data that will be touched, this can be done by calling + * PauseThreads beforehand. Must never be called while emulator is running + * (inside RunFrame()). * * Parameters: * SaveState Block file to load state information from. @@ -278,7 +279,42 @@ public: * occurred. Prints own error messages. */ bool Init(void); - + + /* + * GetSoundBoard(void): + * + * Returns a reference to the sound board. + * + * Returns: + * Pointer to CSoundBoard object. + */ + CSoundBoard *GetSoundBoard(void); + + /* + * GetDriveBoard(void): + * + * Returns a reference to the drive board. + + * Returns: + * Pointer to CDriveBoard object. + */ + CDriveBoard *GetDriveBoard(void); + + /* + * PauseThreads(void): + * + * Flags that any running threads should pause and waits for them to do so. + * Should be used before invoking any method that accesses the internal state, eg LoadState or SaveState. + */ + bool PauseThreads(void); + + /* + * ResumeThreads(void): + * + * Flags that any paused threads should resume running. + */ + void ResumeThreads(void); + /* * CModel3(void): * ~CModel3(void): @@ -291,9 +327,6 @@ public: CModel3(void); ~CModel3(void); - bool PauseThreads(void); - void ResumeThreads(void); - /* * Private Property. * Tresspassers will be shot! ;) diff --git a/Src/Model3/SoundBoard.cpp b/Src/Model3/SoundBoard.cpp index a674cb1..4aa4177 100644 --- a/Src/Model3/SoundBoard.cpp +++ b/Src/Model3/SoundBoard.cpp @@ -515,6 +515,16 @@ bool CSoundBoard::Init(const UINT8 *soundROMPtr, const UINT8 *sampleROMPtr) return OKAY; } +M68KCtx *CSoundBoard::GetM68K(void) +{ + return &M68K; +} + +CDSB *CSoundBoard::GetDSB(void) +{ + return DSB; +} + CSoundBoard::CSoundBoard(void) { DSB = NULL; diff --git a/Src/Model3/SoundBoard.h b/Src/Model3/SoundBoard.h index 2bec2f5..b3ceb5b 100644 --- a/Src/Model3/SoundBoard.h +++ b/Src/Model3/SoundBoard.h @@ -148,6 +148,26 @@ public: */ void AttachDSB(CDSB *DSBPtr); + /* + * GetMS68K(void): + * + * Returns a reference to the 68K CPU of the sound board. + * + * Returns: + * A pointer to the M68K context. + */ + M68KCtx *GetM68K(void); + + /* + * GetDSB(void): + * + * Returns a reference the Digital Sound Board (if attached). + * + * Returns: + * A pointer to the DSB object or NULL if not attached. + */ + CDSB *GetDSB(void); + /* * Init(soundROMPtr, sampleROMPtr): *