192 #include "sid2types.h"
194 #include "sidbuilder.h"
198 #include "c64/c64xsid.h"
199 #include "c64/c64cia.h"
200 #include "c64/c64vic.h"
202 #include "mos6510/mos6510.h"
203 #include "sid6526/sid6526.h"
211 #ifdef PC64_TESTSUITE
215 #define SID2_MAX_SIDS 2
216 #define SID2_MAPPER_SIZE 32
218 SIDPLAY2_NAMESPACE_START
223 static const double CLOCK_FREQ_NTSC;
224 static const double CLOCK_FREQ_PAL;
225 static const double VIC_FREQ_PAL;
226 static const double VIC_FREQ_NTSC;
228 static const char TXT_PAL_VBI[];
229 static const char TXT_PAL_VBI_FIXED[];
230 static const char TXT_PAL_CIA[];
231 static const char TXT_PAL_UNKNOWN[];
232 static const char TXT_NTSC_VBI[];
233 static const char TXT_NTSC_VBI_FIXED[];
234 static const char TXT_NTSC_CIA[];
235 static const char TXT_NTSC_UNKNOWN[];
236 static const char TXT_NA[];
238 static const char ERR_CONF_WHILST_ACTIVE[];
239 static const char ERR_UNSUPPORTED_FREQ[];
240 static const char ERR_UNSUPPORTED_PRECISION[];
241 static const char ERR_MEM_ALLOC[];
242 static const char ERR_UNSUPPORTED_MODE[];
243 static const char *credit[10];
245 static const char ERR_PSIDDRV_NO_SPACE[];
246 static const char ERR_PSIDDRV_RELOC[];
259 sidemu *sid[SID2_MAX_SIDS];
267 uint8_t *m_ram, *m_rom;
271 const char *m_errorString;
272 int m_fastForwardFactor;
273 uint_least32_t m_mileage;
274 int_least32_t m_leftVolume;
275 int_least32_t m_rightVolume;
276 volatile sid2_player_t m_playerState;
277 volatile bool m_running;
279 uint_least32_t m_sid2crc;
280 uint_least32_t m_sid2crcCount;
285 uint_least32_t m_sampleCount;
286 uint_least32_t m_sampleIndex;
287 short *m_sampleBuffer;
304 void evalBankSelect (
const uint8_t data);
308 float64_t clockSpeed (sid2_clock_t clock, sid2_clock_t defaultClock,
310 int environment (sid2_env_t env);
312 int initialise (
void);
314 void mixerReset (
void);
315 void mileageCorrect (
void);
316 int sidCreate (
sidbuilder *builder, sid2_model_t model,
317 sid2_model_t defaultModel);
318 void sidSamples (
const bool enable);
320 uint8_t iomap (
const uint_least16_t addr);
321 sid2_model_t getModel(
const int sidModel,
322 sid2_model_t userModel,
323 sid2_model_t defaultModel);
325 uint8_t readMemByte_plain (
const uint_least16_t addr);
326 uint8_t readMemByte_io (
const uint_least16_t addr);
327 uint8_t readMemByte_sidplaytp (
const uint_least16_t addr);
328 uint8_t readMemByte_sidplaybs (
const uint_least16_t addr);
329 void writeMemByte_plain (
const uint_least16_t addr,
const uint8_t data);
330 void writeMemByte_playsid (
const uint_least16_t addr,
const uint8_t data);
331 void writeMemByte_sidplay (
const uint_least16_t addr,
const uint8_t data);
335 uint8_t (
Player::*m_readMemByte) (
const uint_least16_t);
336 void (
Player::*m_writeMemByte) (
const uint_least16_t,
const uint8_t);
337 uint8_t (
Player::*m_readMemDataByte)(
const uint_least16_t);
339 uint8_t readMemRamByte (
const uint_least16_t addr)
340 {
return m_ram[addr]; }
341 void sid2crc (
const uint8_t data);
344 void envReset (
const bool safe);
345 void envReset (
void) { envReset (
true); }
346 inline uint8_t envReadMemByte (
const uint_least16_t addr);
347 inline void envWriteMemByte (
const uint_least16_t addr,
const uint8_t data);
348 bool envCheckBankJump (
const uint_least16_t addr);
349 inline uint8_t envReadMemDataByte (
const uint_least16_t addr);
350 inline void envSleep (
void);
352 #ifdef PC64_TESTSUITE
353 void envLoadFile (
const char *file)
355 char name[0x100] = PC64_TESTSUITE;
357 strcat (name,
".prg");
365 uint_least32_t (
Player::*output) (
char *buffer);
367 inline void interruptIRQ (
const bool state);
368 inline void interruptNMI (
void);
369 inline void interruptRST (
void);
370 void signalAEC (
const bool state) { cpu.aecSignal (state); }
371 void lightpen () { vic.lightpen (); }
376 void psidRelocAddr (
SidTuneInfo &tuneInfo,
int startp,
int endp);
383 const sid2_info_t &info (
void)
const {
return m_info; }
386 int fastForward (uint percent);
388 uint_least32_t mileage (
void)
const {
return m_mileage + time(); }
389 float64_t cpuFreq (
void)
const {
return m_cpuFreq; }
391 uint_least32_t play (
short *buffer, uint_least32_t samples);
392 sid2_player_t state (
void)
const {
return m_playerState; }
394 uint_least32_t time (
void)
const {
return (uint_least32_t)(context().getTime(EVENT_CLOCK_PHI1) / m_cpuFreq); }
395 void debug (
bool enable, FILE *out)
396 { cpu.debug (enable, out); }
397 void mute (
int voice,
bool enable);
398 const char *error (
void)
const {
return m_errorString; }
402 uint8_t Player::envReadMemByte (
const uint_least16_t addr)
404 return (this->*(m_readMemByte)) (addr);
407 void Player::envWriteMemByte (
const uint_least16_t addr, uint8_t data)
409 (this->*(m_writeMemByte)) (addr, data);
412 uint8_t Player::envReadMemDataByte (
const uint_least16_t addr)
414 return (this->*(m_readMemDataByte)) (addr);
417 void Player::envSleep (
void)
419 if (m_info.environment != sid2_envR)
421 xsid.suppress (
false);
422 xsid.suppress (
true);
426 void Player::interruptIRQ (
const bool state)
430 if (m_info.environment == sid2_envR)
439 void Player::interruptNMI ()
444 void Player::interruptRST ()
449 SIDPLAY2_NAMESPACE_STOP