home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Emulation / Atari800 / pokey11.h < prev    next >
C/C++ Source or Header  |  1998-01-08  |  5KB  |  135 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /* Module:  POKEY Chip Simulator Includes, V1.1                              */
  4. /* Purpose: To emulate the sound generation hardware of the Atari POKEY chip.*/
  5. /* Author:  Ron Fries                                                        */
  6. /* Date:    September 22, 1996                                               */
  7. /*                                                                           */
  8. /*****************************************************************************/
  9. /*                                                                           */
  10. /*                 License Information and Copyright Notice                  */
  11. /*                 ========================================                  */
  12. /*                                                                           */
  13. /* PokeySound is Copyright(c) 1996 by Ron Fries                              */
  14. /*                                                                           */
  15. /* This library is free software; you can redistribute it and/or modify it   */
  16. /* under the terms of version 2 of the GNU Library General Public License    */
  17. /* as published by the Free Software Foundation.                             */
  18. /*                                                                           */
  19. /* This library is distributed in the hope that it will be useful, but       */
  20. /* WITHOUT ANY WARRANTY; without even the implied warranty of                */
  21. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library */
  22. /* General Public License for more details.                                  */
  23. /* To obtain a copy of the GNU Library General Public License, write to the  */
  24. /* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   */
  25. /*                                                                           */
  26. /* Any permitted reproduction of these routines, in whole or in part, must   */
  27. /* bear this legend.                                                         */
  28. /*                                                                           */
  29. /*****************************************************************************/
  30.  
  31. #ifndef __POKEY__
  32. #define __POKEY__
  33.  
  34. #include "atari.h"
  35.  
  36. /* define some data types to keep it platform independent */
  37. #ifdef COMP16          /* if 16-bit compiler defined */
  38. #define int8  char
  39. #define int16 int
  40. #define int32 long
  41. #else                  /* else default to 32-bit compiler */
  42. #define int8  char
  43. #define int16 short
  44. #define int32 int
  45. #endif
  46.  
  47. #define uint8  unsigned int8 
  48. #define uint16 unsigned int16
  49. #define uint32 unsigned int32
  50.  
  51.  
  52. /* CONSTANT DEFINITIONS */
  53.  
  54. /* As an alternative to using the exact frequencies, selecting a playback
  55.    frequency that is an exact division of the main clock provides a higher
  56.    quality output due to less aliasing.  For best results, a value of 
  57.    1787520 MHz is used for the main clock.  With this value, both the 
  58.    64 kHz and 15 kHz clocks are evenly divisible.  Selecting a playback
  59.    frequency that is also a division of the clock provides the best 
  60.    results.  The best options are FREQ_64 divided by either 2, 3, or 4.
  61.    The best selection is based on a trade off between performance and
  62.    sound quality. 
  63.    
  64.    Of course, using a main clock frequency that is not exact will affect
  65.    the pitch of the output.  With these numbers, the pitch will be low
  66.    by 0.127%.  (More than likely, an actual unit will vary by this much!) */
  67.  
  68. #define FREQ_17_EXACT     1789790  /* exact 1.79 MHz clock freq */
  69. #define FREQ_17_APPROX    1787520  /* approximate 1.79 MHz clock freq */
  70.  
  71. void Pokey_sound_init (ULONG freq17, UWORD playback_freq);
  72. void Pokey_process_2 (register unsigned char *buffer, register UWORD n);
  73. void Pokey_process (register unsigned char *buffer, register UWORD n);
  74. void POKEY_Scanline(void);
  75. void SendKey(UBYTE key);
  76. void SendBRK(void);
  77.  
  78. extern ULONG  Div_n_cnt[4],   /* Divide by n counter. one for each channel */
  79.               Div_n_max[4],   /* Divide by n maximum, one for each channel */
  80.               Div_n_irq[4];   /* Just the same counter, but used for IRQ */
  81.  
  82. extern int DELAYED_SERIN_IRQ;
  83. extern int DELAYED_SEROUT_IRQ;
  84. extern int DELAYED_XMTDONE_IRQ;
  85.  
  86. #define _AUDF1 0x00
  87. #define _AUDC1 0x01
  88. #define _AUDF2 0x02
  89. #define _AUDC2 0x03
  90. #define _AUDF3 0x04
  91. #define _AUDC3 0x05
  92. #define _AUDF4 0x06
  93. #define _AUDC4 0x07
  94. #define _AUDCTL 0x08
  95. #define _STIMER 0x09
  96. #define _SKRES 0x0a
  97. #define _POTGO 0x0b
  98. #define _SEROUT 0x0d
  99. #define _IRQEN 0x0e
  100. #define _SKCTLS 0x0f
  101.  
  102. #define _POT0 0x00
  103. #define _POT1 0x01
  104. #define _POT2 0x02
  105. #define _POT3 0x03
  106. #define _POT4 0x04
  107. #define _POT5 0x05
  108. #define _POT6 0x06
  109. #define _POT7 0x07
  110. #define _ALLPOT 0x08
  111. #define _KBCODE 0x09
  112. #define _RANDOM 0x0a
  113. #define _SERIN 0x0d
  114. #define _IRQST 0x0e
  115. #define _SKSTAT 0x0f
  116.  
  117. extern UBYTE KBCODE;
  118. extern UBYTE IRQST;
  119. extern UBYTE IRQEN;
  120. extern UBYTE SKSTAT;
  121.  
  122. /* channel definitions */
  123. #define CHAN1       0
  124. #define CHAN2       1
  125. #define CHAN3       2
  126. #define CHAN4       3
  127. #define SAMPLE      4
  128.  
  129. UBYTE AUDF[4];    /* AUDFx (D200, D202, D204, D206) */
  130. UBYTE AUDC[4];    /* AUDCx (D201, D203, D205, D207) */
  131. UBYTE AUDCTL;     /* AUDCTL (D208) */      
  132.  
  133. void Init_Pokey (int *argc, char *argv[],int base);
  134. #endif
  135.