📄 test_main.c
字号:
while ((U32)p<0x0c00A800) *p++=0;
}
void Led_Display(int LedStatus)
{
//PC1,PC2,PC3 High available
rPDATC=(rPDATC & 0x1f1) | ((LedStatus & 0x7)<<1);
}
void Pixple(int x, int y)
{
U32 *p =(U32*)0x0c000000+ ((320-x)*256+y-1)/32;
if (y%32)
*p |= (1<<(32-(y%32))); else
*p |= 1;
}
void uPixple(int x, int y)
{
U32 *p =(U32*)0x0c000000+ ((320-x)*256+y-1)/32;
if (y%32)
*p &= ~(1<<(32-(y%32))); else
*p &= ~1;
}
void Intro()
{
U32 *video = (U32*)0x0c000000;
int j=0;
while ((U32)video <0x0c00A800) *video ++=bmpIntro[j++];
}
void ClearIntro()
{
int x,y;
for (x=0;x<160;x++)
{
for (y=0;y<240;y++)
{
uPixple(160-x,y);
uPixple(160+x,y);
}
Delay(50);
}
}
const U8 Mouse[35][2]= {
{0,0},{0,1},{0,2},{0,3},{0,4},{0,5},
{0,6},{0,7},{0,8},{0,9},{0,10},{1,1},
{1,10},{2,2},{2,9},{3,3},{3,8},{3,9},
{3,10},{3,11},{3,12},{3,13},{4,4},{4,14},
{5,5},{5,7},{5,8},{5,9},{5,10},{5,11},
{5,12},{5,13},{6,6},{6,7},{7,7}
};
int mPosX, mPosY;
int moPosX, moPosY;
void DrawMousePointer(int x,int y)
{
int i;
for (i=0;i<35;i++)
uPixple(Mouse[i][0]+moPosX, Mouse[i][1]+moPosY);
moPosX = x;
moPosY = y;
for (i=0;i<35;i++)
Pixple(Mouse[i][0]+x, Mouse[i][1]+y);
}
void Uart_Init(int baud)
{
rUFCON0=0x0; //FIFO disable
rUFCON1=0x0;
rUMCON0=0x0;
rUMCON1=0x0;
rULCON0=0x3; //Normal,No parity,1 stop,8 bit
rUCON0=0x245; //rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling
rUBRDIV0=( (int)(MCLK/16./baud + 0.5) -1 );
}
int Uart_Getch()
{
while(!(rUTRSTAT0 & 0x1)); //Receive data read
return RdURXH0();
}
void Uart_SendByte(int data)
{
while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
Delay(10);
WrUTXH0(data);
}
void Uart_SendString(char *pt)
{
while(*pt)
Uart_SendByte(*pt++);
}
void Uart_Printf(char *fmt,...)
{
va_list ap;
char string[256];
va_start(ap,fmt);
vsprintf(string,fmt,ap);
Uart_SendString(string);
va_end(ap);
}
void WaitForSCK(unsigned char value)
{
int i=0;
while (((rPDATG>>6) & 0x01) != value && i++<3000);
}
int readbit()
{
int i;
WaitForSCK(0);
i= (rPDATG>>5) & 0x01;
WaitForSCK(1);
return i;
}
int ReadMouse()
{
int i, mb,p=0,v;
rPCONG = 0xD7FF;// 01 01
rPDATG |= 0x60;
rPCONG = 0xC3FF; // 00 00
mb = readbit();
if (mb != 0) return;
mb = 0;
for (i=0;i<8;i++)
{
v = readbit();
mb = mb | ( v << i);
p = p + v;
}
v = readbit();
p = p + v;
if ((p&0x01)==0)
{
rPCONG = 0xD7FF;// 01 01
rPDATG |= 0x60;
return;
}
readbit();
return mb;
}
void writebit(int b)
{
WaitForSCK(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -