-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIOlib.c
89 lines (81 loc) · 1.85 KB
/
IOlib.c
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
78
79
80
81
82
83
84
85
86
87
88
89
#include "IOlib.h"
#define IO_STOPPED 0
#define IO_PLAYING 1
unsigned char IOStatus;
unsigned char *IOStart;
unsigned char *IOPointer;
unsigned int IOSize;
void IOPlay(unsigned char *IOData, unsigned int size)
{
G2G_NMIPort = 0x80;
G2G_IOPinPort = 0x00;
IOStart = IOData;
IOPointer = IOData;
IOSize = size;
IOStatus=IO_PLAYING;
}
void IOStop(void)
{
G2G_NMIPort = 0x80;
G2G_IOPinPort = 0x00;
unsigned int byte;
for(int i=7;i>=0;i--)
{
byte = 0;
G2G_IOPinPort = byte;
byte |= 1;
G2G_IOPinPort = byte;
byte &= 0xFE;
G2G_IOPinPort = byte;
}
byte |= 1 << 1;
G2G_IOPinPort = byte;
byte = 0;
G2G_IOPinPort = byte;
IOStatus = IO_STOPPED;
}
// every 3 frames for 50ms timing
void IOFrame(void)
{
static int count = 0;
static int frame = 0;
if(IOStatus == IO_PLAYING)
{
if(frame == 0)
{
unsigned int byte;
for(int i=7;i>=0;i--)
{
byte = 0;
byte |= (((*IOPointer)>>i) & 1)<<2;
IOPointer++;
byte |= (((*IOPointer)>>i) & 1)<<3;
IOPointer--;
G2G_IOPinPort = byte;
byte |= 1;
G2G_IOPinPort = byte;
byte &= 0xFE;
G2G_IOPinPort = byte;
}
byte |= 1 << 1;
G2G_IOPinPort = byte;
byte = 0;
G2G_IOPinPort = byte;
//G2G_IOPinPort = *IOPointer;
IOPointer+=2;
count+=2;
if(count >= IOSize)
{
IOStatus = IO_STOPPED;
count = 0;
}
frame++;
}
else
{
frame++;
if(frame >= 3)
frame = 0;
}
}
}