mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-04-10 19:15:14 +00:00
- Changes submitted by krom: cleaned up spacing in Games.cpp, optimized byte swapping functions in Supermodel.h, minor changes to fix compiler errors in gcc.
This commit is contained in:
parent
4c02a8af05
commit
2ca7898f1a
1074
Src/Games.cpp
1074
Src/Games.cpp
File diff suppressed because it is too large
Load diff
|
@ -422,7 +422,7 @@ void CDSB1::Reset(void)
|
||||||
#define DSB1_OFFSET_RAM 0 // 32KB Z80 RAM
|
#define DSB1_OFFSET_RAM 0 // 32KB Z80 RAM
|
||||||
#define DSB1_OFFSET_MPEG_LEFT 0x8000 // 1604 bytes (48 KHz max., 1/60th second, 2 extra = 2*(48000/60+2)) left MPEG buffer
|
#define DSB1_OFFSET_MPEG_LEFT 0x8000 // 1604 bytes (48 KHz max., 1/60th second, 2 extra = 2*(48000/60+2)) left MPEG buffer
|
||||||
#define DSB1_OFFSET_MPEG_RIGHT 0x8644 // 1604 bytes right MPEG buffer
|
#define DSB1_OFFSET_MPEG_RIGHT 0x8644 // 1604 bytes right MPEG buffer
|
||||||
#define DSB1_MEMORY_POOL_SIZE (0x8000+0x644+0x644)
|
#define DSB1_MEMORY_POOL_SIZE (0x8000 + 0x644 + 0x644)
|
||||||
|
|
||||||
BOOL CDSB1::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr)
|
BOOL CDSB1::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr)
|
||||||
{
|
{
|
||||||
|
@ -809,7 +809,7 @@ void CDSB2::Reset(void)
|
||||||
#define DSB2_OFFSET_RAM 0 // 128KB 68K RAM
|
#define DSB2_OFFSET_RAM 0 // 128KB 68K RAM
|
||||||
#define DSB2_OFFSET_MPEG_LEFT 0x20000 // 1604 bytes (48 KHz max., 1/60th second, 2 extra = 2*(48000/60+2)) left MPEG buffer
|
#define DSB2_OFFSET_MPEG_LEFT 0x20000 // 1604 bytes (48 KHz max., 1/60th second, 2 extra = 2*(48000/60+2)) left MPEG buffer
|
||||||
#define DSB2_OFFSET_MPEG_RIGHT 0x20644 // 1604 bytes right MPEG buffer
|
#define DSB2_OFFSET_MPEG_RIGHT 0x20644 // 1604 bytes right MPEG buffer
|
||||||
#define DSB2_MEMORY_POOL_SIZE (0x20000+0x644+0x644)
|
#define DSB2_MEMORY_POOL_SIZE (0x20000 + 0x644 + 0x644)
|
||||||
|
|
||||||
BOOL CDSB2::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr)
|
BOOL CDSB2::Init(const UINT8 *progROMPtr, const UINT8 *mpegROMPtr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
#include "Supermodel.h"
|
#include "Supermodel.h"
|
||||||
|
|
||||||
#ifdef SUPERMODEL_OSX
|
#ifdef SUPERMODEL_OSX
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL/SDL_audio.h>
|
#include <SDL/SDL_audio.h>
|
||||||
#else
|
#else
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_audio.h>
|
#include <SDL_audio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Model3 audio output is 44.1KHz 2-channel sound and frame rate is 60fps
|
// Model3 audio output is 44.1KHz 2-channel sound and frame rate is 60fps
|
||||||
#define SAMPLE_RATE 44100
|
#define SAMPLE_RATE 44100
|
||||||
#define NUM_CHANNELS 2
|
#define NUM_CHANNELS 2
|
||||||
#define SUPERMODEL_FPS 60
|
#define SUPERMODEL_FPS 60
|
||||||
|
|
||||||
#define BYTES_PER_SAMPLE (NUM_CHANNELS * sizeof(INT16))
|
#define BYTES_PER_SAMPLE (NUM_CHANNELS * sizeof(INT16))
|
||||||
#define SAMPLES_PER_FRAME (SAMPLE_RATE / SUPERMODEL_FPS)
|
#define SAMPLES_PER_FRAME (SAMPLE_RATE / SUPERMODEL_FPS)
|
||||||
#define BYTES_PER_FRAME (SAMPLES_PER_FRAME * BYTES_PER_SAMPLE)
|
#define BYTES_PER_FRAME (SAMPLES_PER_FRAME * BYTES_PER_SAMPLE)
|
||||||
|
|
||||||
#define MAX_LATENCY 100
|
#define MAX_LATENCY 100
|
||||||
|
|
||||||
static bool enabled = true; // True if sound output is enabled
|
static bool enabled = true; // True if sound output is enabled
|
||||||
static unsigned latency = 20; // Audio latency to use (ie size of audio buffer) as percentage of max buffer size
|
static unsigned latency = 20; // Audio latency to use (ie size of audio buffer) as percentage of max buffer size
|
||||||
|
@ -178,6 +178,10 @@ void OutputAudio(unsigned numSamples, INT16 *leftBuffer, INT16 *rightBuffer)
|
||||||
{
|
{
|
||||||
//printf("OutputAudio(%u)\n", numSamples);
|
//printf("OutputAudio(%u)\n", numSamples);
|
||||||
|
|
||||||
|
UINT32 bytesRemaining;
|
||||||
|
UINT32 bytesToCopy;
|
||||||
|
INT16 *src;
|
||||||
|
|
||||||
// Number of samples should never be more than max number of samples per frame
|
// Number of samples should never be more than max number of samples per frame
|
||||||
if (numSamples > SAMPLES_PER_FRAME)
|
if (numSamples > SAMPLES_PER_FRAME)
|
||||||
numSamples = SAMPLES_PER_FRAME;
|
numSamples = SAMPLES_PER_FRAME;
|
||||||
|
@ -224,7 +228,7 @@ void OutputAudio(unsigned numSamples, INT16 *leftBuffer, INT16 *rightBuffer)
|
||||||
writeWrapped = true;
|
writeWrapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT16 *src = mixBuffer;
|
src = mixBuffer;
|
||||||
INT8 *dst1;
|
INT8 *dst1;
|
||||||
INT8 *dst2;
|
INT8 *dst2;
|
||||||
UINT32 len1;
|
UINT32 len1;
|
||||||
|
@ -249,8 +253,8 @@ void OutputAudio(unsigned numSamples, INT16 *leftBuffer, INT16 *rightBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy chunk to write position in buffer
|
// Copy chunk to write position in buffer
|
||||||
UINT32 bytesRemaining = numBytes;
|
bytesRemaining = numBytes;
|
||||||
UINT32 bytesToCopy = (bytesRemaining > len1 ? len1 : bytesRemaining);
|
bytesToCopy = (bytesRemaining > len1 ? len1 : bytesRemaining);
|
||||||
memcpy(dst1, src, bytesToCopy);
|
memcpy(dst1, src, bytesToCopy);
|
||||||
|
|
||||||
// Adjust for number of bytes copied
|
// Adjust for number of bytes copied
|
||||||
|
|
|
@ -169,6 +169,7 @@ extern void InfoLog(const char *fmt, ...);
|
||||||
#include "Model3/DSB.h"
|
#include "Model3/DSB.h"
|
||||||
#include "Model3/Model3.h"
|
#include "Model3/Model3.h"
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Helpful Macros and Inlines
|
Helpful Macros and Inlines
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -187,16 +188,12 @@ extern void InfoLog(const char *fmt, ...);
|
||||||
*/
|
*/
|
||||||
static inline UINT16 FLIPENDIAN16(UINT16 d)
|
static inline UINT16 FLIPENDIAN16(UINT16 d)
|
||||||
{
|
{
|
||||||
return(((d >> 8) & 0x00FF) |
|
return ((d>>8) | (d<<8));
|
||||||
((d << 8) & 0xFF00));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline UINT32 FLIPENDIAN32(UINT32 d)
|
static inline UINT32 FLIPENDIAN32(UINT32 d)
|
||||||
{
|
{
|
||||||
return(((d >> 24) & 0x000000FF) |
|
return ((d>>24) | ((d<<8)&0x00FF0000) | ((d>>8)&0x0000FF00) | (d<<24));
|
||||||
((d >> 8) & 0x0000FF00) |
|
|
||||||
((d << 8) & 0x00FF0000) |
|
|
||||||
((d << 24) & 0xFF000000));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INCLUDED_SUPERMODEL_H
|
#endif // INCLUDED_SUPERMODEL_H
|
||||||
|
|
Loading…
Reference in a new issue