1 #include <ctype.h>
2 #ifdef _MSC_EXTENSIONS
3 #include <excpt.h>
4 #endif
5 #include <math.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 
10 #include "sapGlobals.h"
11 
12 extern void pokeyInit0( void );
13 extern void pokeyInit1( void );
14 extern void pokeyReset0( void );
15 extern void pokeyReset1( void );
16 extern void pokeyUpdateSound0( int n );
17 extern void pokeyUpdateSound1( int n );
18 extern void pokeyUpdateSoundCounters0( void );
19 extern void pokeyUpdateSoundCounters1( void );
20 
21 void pokeyInit( void )
22 {
23 	pokeyInit0();
24 	pokeyInit1();
25 }
26 void pokeyReset( void )
27 {
28 	pokeyReset0();
29 	pokeyReset1();
30 }
31 void pokeyUpdateSound( int n )
32 {
33 int oldBufPtr = sndBufPtr;
34 	pokeyUpdateSound0( n );
35 	if( isStereo )
36 	{
37 		sndBufPtr = (oldBufPtr+1)&16383;
38 		pokeyUpdateSound1( n );
39 		sndBufPtr = (sndBufPtr-1)&16383;
40 	}
41 }
42 void pokeyUpdateSoundCounters( void )
43 {
44 	pokeyUpdateSoundCounters0();
45 	pokeyUpdateSoundCounters1();
46 }
47 
48 BYTE pokeyReadByte( short unsigned int address)
49 {
50 BYTE retVal;
51 
52 	switch( address&0x0F )
53 	{
54 		case 0x09:
55 			return 0xFF;
56 		case 0x0A:
57 			retVal = (BYTE)((255*rand())/RAND_MAX);
58 			return retVal;
59 		case 0x0E:
60 			return 0xFF;
61 		case 0x0F:
62 			return 0xFF;
63 	}
64 	return 0xFF;
65 }
66