aboutsummaryrefslogtreecommitdiff
path: root/pokeytest/pokey.h
blob: ee2c6e3b6871e31fd71aaa0c3e5724fbf0c159b9 (plain)
1
2
3
4
5
6
7
8
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
/*****************************************************************************/
/*                                                                           */
/* Module:  POKEY Chip Simulator Includes, V1.1                              */
/* Purpose: To emulate the sound generation hardware of the Atari POKEY chip.*/
/* Author:  Ron Fries                                                        */
/* Date:    September 22, 1996                                               */
/*                                                                           */
/*****************************************************************************/
/*                                                                           */
/*                 License Information and Copyright Notice                  */
/*                 ========================================                  */
/*                                                                           */
/* PokeySound is Copyright(c) 1996 by Ron Fries                              */
/*                                                                           */
/* This library is free software; you can redistribute it and/or modify it   */
/* under the terms of version 2 of the GNU Library General Public License    */
/* as published by the Free Software Foundation.                             */
/*                                                                           */
/* This library is distributed in the hope that it will be useful, but       */
/* WITHOUT ANY WARRANTY; without even the implied warranty of                */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library */
/* General Public License for more details.                                  */
/* To obtain a copy of the GNU Library General Public License, write to the  */
/* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   */
/*                                                                           */
/* Any permitted reproduction of these routines, in whole or in part, must   */
/* bear this legend.                                                         */
/*                                                                           */
/*****************************************************************************/

#ifndef _POKEYSOUND_H
#define _POKEYSOUND_H

#include <stdint.h>

#define int8  int8_t
#define int16 int16_t
#define int32 int32_t
#define uint8  uint8_t
#define uint16 uint16_t
#define uint32 uint32_t

#define audf1 (0xd200 + 0x00)
#define audc1 (0xd200 + 0x01)
#define audf2 (0xd200 + 0x02)
#define audc2 (0xd200 + 0x03)
#define audf3 (0xd200 + 0x04)
#define audc3 (0xd200 + 0x05)
#define audf4 (0xd200 + 0x06)
#define audc4 (0xd200 + 0x07)
#define audctl (0xd200 + 0x08)

/* CONSTANT DEFINITIONS */

/* As an alternative to using the exact frequencies, selecting a playback
   frequency that is an exact division of the main clock provides a higher
   quality output due to less aliasing.  For best results, a value of 
   1787520 MHz is used for the main clock.  With this value, both the 
   64 kHz and 15 kHz clocks are evenly divisible.  Selecting a playback
   frequency that is also a division of the clock provides the best 
   results.  The best options are FREQ_64 divided by either 2, 3, or 4.
   The best selection is based on a trade off between performance and
   sound quality. 
   
   Of course, using a main clock frequency that is not exact will affect
   the pitch of the output.  With these numbers, the pitch will be low
   by 0.127%.  (More than likely, an actual unit will vary by this much!) */

#define FREQ_17_EXACT     1789790  /* exact 1.79 MHz clock freq */
#define FREQ_17_APPROX    1787520  /* approximate 1.79 MHz clock freq */

void Pokey_sound_init (uint32 freq17, uint16 playback_freq);
void Update_pokey_sound (uint16 addr, uint8 val);
void Pokey_process_2 (register unsigned char *buffer, register uint16 n);
void Pokey_process (register unsigned char *buffer, register uint16 n);

#endif