forked from iPodLinux-Community/iDarcNES
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcop.c
More file actions
72 lines (65 loc) · 1.69 KB
/
cop.c
File metadata and controls
72 lines (65 loc) · 1.69 KB
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
#include "cop.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#define outl(a, b) (*(volatile unsigned int *)(b) = (a))
#define inl(a) (*(volatile unsigned int *)(a))
int cop_execute(void (*function)())
{
outl((unsigned int)function, COP_HANDLER);
outl(0x0, 0x60007004);
return 1;
}
extern void video_display_buffer_();
//void (*myfunction)();
void cop_lcd_test()
{
while (inl(COP_STATUS) & COP_RUNNING)
{
while ((inl(COP_STATUS) & COP_LINE_REQ)==0); // wait for 1
//outl(1,0xf000f024);
/* if ((inl(COP_STATUS) & COP_LINE_REQ2)!=0)
{
myfunction();
outl(inl(COP_STATUS) &~ COP_LINE_REQ2, COP_STATUS); // clear frameready
}
else*/
video_display_buffer_();
//while ((inl(COP_STATUS) & COP_LINE_REQ)==1) // wait for 1
outl(inl(COP_STATUS) &~ COP_LINE_REQ, COP_STATUS); // clear frameready
}
}
#define CACHE_CTL (*(volatile unsigned long *)(0x6000c000))
#define CACHE_DISABLE 0
void cop_begin(void (*function)())
{
//CACHE_CTL=0;
// myfunction=function;
outl(inl(COP_STATUS) &~ COP_LINE_REQ2, COP_STATUS); // clear frameready
cop_execute(cop_lcd_test);
outl(COP_RUNNING, COP_STATUS);
}
void cop_set(void (*function)())
{
// myfunction=function;
}
/*
int init_snd()
{
int tmp,result;
sound_fd = open("/dev/dsp", O_WRONLY);
tmp = AFMT_S16_LE;
result = ioctl(sound_fd, SNDCTL_DSP_SETFMT, &tmp);
tmp = 0;
result = ioctl(sound_fd, SNDCTL_DSP_CHANNELS, &tmp);
int sound_rate = 44100;
result = ioctl(sound_fd, SNDCTL_DSP_SPEED, &sound_rate);
}
*/
void cop_end()
{
outl(inl(COP_STATUS) &~ COP_RUNNING, COP_STATUS); // set to 0
outl(inl(COP_STATUS) | COP_LINE_REQ, COP_STATUS);
}