270 static const enum clock_speeds clockSpeed[] = { DEFAULT, PAL, NTSC, DREAN, NTSC2 };
271 static const enum refresh_rates refreshRate[] = { HZ_DEFAULT, HZ_EU, HZ_US, HZ_US, HZ_US };
272 static const enum raster_rates rasterRate[] = { R_DEFAULT, R_EU, R_US, R_US, R_US };
302 static bool us_Initialised;
303 static bool us_Available;
304 static bool us_PortIsOpen;
308 static double us_CPUcycleDuration;
309 static double us_InvCPUcycleDurationNanoSeconds;
310 static timestamp_t m_StartTime;
311 static timestamp_t m_LastTime;
314 static int diff_size;
315 static int ring_size;
318 int LIBUSB_Setup(
bool start_threaded,
bool with_cycles);
319 int LIBUSB_Exit(
void);
320 int LIBUSB_Available(uint16_t vendor_id, uint16_t product_id);
321 void LIBUSB_StopTransfers(
void);
322 int LIBUSB_OpenDevice(
void);
323 void LIBUSB_CloseDevice(
void);
324 int LIBUSB_DetachKernelDriver(
void);
325 int LIBUSB_ConfigureDevice(
void);
326 void LIBUSB_InitOutBuffer(
void);
327 void LIBUSB_FreeOutBuffer(
void);
328 void LIBUSB_InitInBuffer(
void);
329 void LIBUSB_FreeInBuffer(
void);
330 static void LIBUSB_CALL usb_out(
struct libusb_transfer *transfer);
331 static void LIBUSB_CALL usb_in(
struct libusb_transfer *transfer);
334 unsigned char encoding[7] = { 0x40, 0x54, 0x89, 0x00, 0x00, 0x00, 0x08 };
337 void* USBSID_Thread(
void);
338 int USBSID_InitThread(
void);
339 void USBSID_StopThread(
void);
340 int USBSID_IsRunning(
void);
344 void USBSID_ResetRingBuffer(
void);
345 void USBSID_InitRingBuffer(
int buffer_size,
int differ_size);
346 void USBSID_InitRingBuffer(
void);
347 void USBSID_DeInitRingBuffer(
void);
348 bool USBSID_IsHigher(
void);
349 int USBSID_RingDiff(
void);
350 void USBSID_RingPut(uint8_t item);
351 uint8_t USBSID_RingGet(
void);
352 void USBSID_FlushBuffer(
void);
355 void USBSID_RingPopCycled(
void);
356 void USBSID_RingPop(
void);
364 int USBSID_Init(
bool start_threaded,
bool with_cycles);
365 int USBSID_Close(
void);
366 int USBSID_GetInstanceID(
void){
return us_InstanceID; };
367 bool USBSID_isInitialised(
void){
return us_Initialised; };
368 bool USBSID_isAvailable(
void){
return us_Available; };
369 bool USBSID_isOpen(
void){
return us_PortIsOpen; };
372 void USBSID_Pause(
void);
373 void USBSID_Reset(
void);
374 void USBSID_ResetAllRegisters(
void);
375 void USBSID_Mute(
void);
376 void USBSID_UnMute(
void);
377 void USBSID_DisableSID(
void);
378 void USBSID_EnableSID(
void);
379 void USBSID_ClearBus(
void);
380 void USBSID_SetClockRate(
long clockrate_cycles,
382 long USBSID_GetClockRate(
void);
383 long USBSID_GetRefreshRate(
void);
384 long USBSID_GetRasterRate(
void);
385 uint8_t* USBSID_GetSocketConfig(uint8_t socket_config[]);
386 int USBSID_GetSocketNumSIDS(
int socket, uint8_t socket_config[]);
387 int USBSID_GetSocketChipType(
int socket, uint8_t socket_config[]);
388 int USBSID_GetSocketSIDType1(
int socket, uint8_t socket_config[]);
389 int USBSID_GetSocketSIDType2(
int socket, uint8_t socket_config[]);
390 int USBSID_GetNumSIDs(
void);
391 int USBSID_GetFMOplSID(
void);
392 int USBSID_GetPCBVersion(
void);
393 void USBSID_SetStereo(
int state);
394 void USBSID_ToggleStereo(
void);
397 void USBSID_SingleWrite(
unsigned char *buff,
int len);
398 unsigned char USBSID_SingleRead(uint8_t reg);
399 unsigned char USBSID_SingleReadConfig(
unsigned char *buff,
int len);
402 void USBSID_Write(
unsigned char *buff,
size_t len);
403 void USBSID_Write(uint8_t reg, uint8_t val);
404 void USBSID_Write(
unsigned char *buff,
size_t len, uint16_t cycles);
405 void USBSID_Write(uint8_t reg, uint8_t val, uint16_t cycles);
406 void USBSID_WriteCycled(uint8_t reg, uint8_t val, uint16_t cycles);
407 unsigned char USBSID_Read(uint8_t reg);
408 unsigned char USBSID_Read(
unsigned char *writebuff);
409 unsigned char USBSID_Read(
unsigned char *writebuff, uint16_t cycles);
412 void USBSID_WriteRing(uint8_t reg, uint8_t val);
413 void USBSID_WriteRingCycled(uint8_t reg, uint8_t val, uint16_t cycles);
416 void USBSID_EnableThread(
void);
417 void USBSID_DisableThread(
void);
420 void USBSID_SetFlush(
void);
421 void USBSID_Flush(
void);
422 void USBSID_SetBufferSize(
int size);
423 void USBSID_SetDiffSize(
int size);
424 void USBSID_RestartRingBuffer(
void);
427 void USBSID_RestartThread(
bool with_cycles);
428 static void *_USBSID_Thread(
void *context)
430 return ((USBSID_Class *)context)->USBSID_Thread();
434 uint_fast64_t USBSID_WaitForCycle(uint_fast16_t cycles);
435 uint_fast64_t USBSID_WaitForCycle_(uint_fast16_t cycles);
436 void USBSID_SyncTime(
void);
440 uint8_t USBSID_Address(uint16_t addr);