SCC.h 3.68 KB
Newer Older
1
2
3
4
5
6
7
/** EMULib Emulation Library *********************************/
/**                                                         **/
/**                           SCC.h                         **/
/**                                                         **/
/** This file contains definitions and declarations for     **/
/** routines in SCC.c.                                      **/
/**                                                         **/
8
/** Copyright (C) Marat Fayzullin 1996-2016                 **/
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**     You are not allowed to distribute this software     **/
/**     commercially. Please, notify me, if you make any    **/
/**     changes to this file.                               **/
/*************************************************************/
#ifndef SCC_H
#define SCC_H

#define SCC_BASE     111861    /* Base frequency for SCC     */
#define SCC_CHANNELS 5         /* 5 melodic channels         */

#define SCC_ASYNC    0         /* Asynchronous emulation     */
#define SCC_SYNC     1         /* Synchronous emulation mode */
#define SCC_FLUSH    2         /* Flush buffers only         */

#ifndef BYTE_TYPE_DEFINED
#define BYTE_TYPE_DEFINED
typedef unsigned char byte;
#endif

/** SCC ******************************************************/
/** This data structure stores SCC state.                   **/
/*************************************************************/
typedef struct
{
  byte R[256];                /* SCC register contents       */
  int Freq[SCC_CHANNELS];     /* Frequencies (0 for off)     */
  int Volume[SCC_CHANNELS];   /* Volumes (0..255)            */
  int First;                  /* First used Sound() channel  */
  byte Changed;               /* Bitmap of changed channels  */
  byte WChanged;              /* Bitmap of changed waveforms */
  byte Sync;                  /* SCC_SYNC/SCC_ASYNC          */
} SCC;

/** ResetSCC() ***********************************************/
/** Reset the sound chip and use sound channels from the    **/
/** one given in First.                                     **/
/*************************************************************/
void ResetSCC(SCC *D,int First);

/** ReadSCC() ************************************************/
/** Call this function to read contents of the generic SCC  **/
/** sound chip registers.                                   **/
/*************************************************************/
byte ReadSCC(SCC *D,byte R);

/** ReadSCCP() ***********************************************/
/** Call this function to read contents of the newer SCC+   **/
/** sound chip registers.                                   **/
/*************************************************************/
byte ReadSCCP(SCC *D,byte R);
           
/** WriteSCC() ***********************************************/
/** Call this function to output a value V into the generic **/
/** SCC sound chip.                                         **/
/*************************************************************/
void WriteSCC(SCC *D,byte R,byte V);

/** WriteSCCP() **********************************************/
/** Call this function to output a value V into the newer   **/
/** SCC+ sound chip.                                        **/
/*************************************************************/
void WriteSCCP( SCC *D,byte R,byte V);

/** SyncSCC() ************************************************/
/** Flush all accumulated changes by issuing Sound() calls  **/
/** and set the synchronization on/off. The second argument **/
/** should be SCC_SYNC/SCC_ASYNC to set/reset sync, or      **/
/** SCC_FLUSH to leave sync mode as it is.                  **/
/*************************************************************/
void SyncSCC(SCC *D,byte Sync);

#endif /* SCC_H */