工程中去掉XWJ_VGA_DRIVE>LIB
加入以下VGA.C文件
#include "xwj_vga_drive.h"
#include "xwj_fk.h"
#include "xwj_osd_mini.h"
code unsigned char char_fkdot[]={
0xFF,0x01,0x39,0x55,0x6D,0x55,0x39,0x01,0xFF,0x01,0x39,0x45,0x45,0x45,0x39,
0x01,0xFF,0x07,0x01,0x19,0x25,0x25,0x99,0x81,0xFF,0x07,0x01,0x3D,0x25,0x25,
0xBD,0x81,0x75,0xF0,0x0A,0xED,0xA4,0x2F,0xF5,0x82,0xE4,0x35,0xF0,0xF5,0x83,
0xE5,0x82,0x24,0xD5,0xF5,0x82,0xE5,0x83,0x34,0x01,0xF5,0x83,0xE4,0xF0,0x22};
uchar *Music_prt; //乐谱指针
uchar xdata Dis_Buf[FK_LINES *FK_LEN];
uchar ledloop;
uchar delayloop; //delay16.6()函数计数用
uchar Freq;
uchar syncON;
uchar syncOFF;
unsigned char LineCount;
unsigned char Lines;
uchar OSD_Lines;
uchar fk_Lines;
uchar Mus_Len;
uchar Wave;
bit Mute=1; //Mute=1:静音
bit flag_delay; //一场标志,delay16.6()函数用
bit flag_delay_bak; //一场标志,delay16.6()函数判断用
bit flag_Time0_5s_State; //半秒标志
bit flag_IsShowLine;
bit flag_IsHiddenTimes;
extern unsigned char xdata *SramAdr;
unsigned int PAL_lineVideo = 0 ; // current visible video line number
unsigned int PAL_max_y ; // last video line number
unsigned char PAL_shift_y ; // first video line number (vertical centering)
#define PAL_VSYNC P4^6
#define PAL_HSYNC P4^7
#define PAL_BVID P2^0
void init_io(void){
P0M0=0x00;
P0M1=0x00;
P0=0xFF; //P0 为输入
P1M0=0x00;
P1M1=0x00;
P1=0x0FF;
P2M0=0xFF;
P2M1=0x00;
P2=0x0;
P4SW=0x70; //P4为IO
P4M0=0xff;
P4M1=0x00;
P4=0x0;
P3M0=0xFC;
P3M1=0;
P3=0x03;
P5M0=0xFF;
P5M1=0;
//P55=0;
}
void delay17(uchar x) //延时x个16.6毫秒(60Hz)
{
#pragma asm
C1E24:
MOV A,R7
JZ C1E36
C1E27: MOV C,flag_delay;//(0x20.0)
JNB flag_delay_bak,C1E2D;//(0x20.3),C1E2D
CPL C
C1E2D: JNC C1E27
MOV C,flag_delay//(0x20.0)
MOV flag_delay_bak,C
DEC R7
SJMP C1E24
C1E36: RET
#pragma endasm
}
void Start_music(uchar * prt){
#pragma asm
MOV Freq,#0x01;
MOV Mus_Len,#0x01;
MOV R6,0x02;
MOV R7,0x01;
MOV Music_prt,R6;
MOV 0x17,R7;
CLR Mute;//(0x20.2)
RET;
#pragma endasm
}
void Delay_us(unsigned char time){
unsigned char a,b;
for(b=time;b>0;b--)
for(a=2;a>0;a--);
}
void PAL_init(unsigned char y){
PAL_shift_y =33 ; // compute vertical offset for centering
}
void mus(void ){
#if 1
#pragma asm
///声音//////
C0E2F:
JB Mute,C0E3E;
DJNZ Wave,C0E3C;
CPL Beep;
MOV Wave,Freq;
SJMP C0E46;
C0E3C:
SJMP C0E43;
C0E3E:
SETB Beep
NOP;
NOP;
NOP;
C0E43:
NOP;
NOP;
NOP;
C0E46:
////////////////////
#if 1
JNB flag_IsHiddenTimes,C0F11
//不显示跳转
MOV A,Lines;
XRL A,#45
JZ C0E55
//是否已经45行
LJMP C0F11
#endif
//音乐
C0E55:
JB Mute,C0EA0
DEC Mus_Len
MOV A,Mus_Len
JNZ C0E93
INC 0x17
MOV A,0x17
MOV R6,Music_prt
JNZ C0E68
INC Music_prt;
C0E68:
DEC A
MOV DPL,A
MOV DPH,R6
CLR A
MOVC A,@A+DPTR
MOV Freq,A
INC 0x17
MOV A,0x17
MOV R6,Music_prt
JNZ C0E7B
INC Music_prt
C0E7B:
DEC A
MOV DPL,A
MOV DPH,R6
CLR A
MOVC A,@A+DPTR
MOV Mus_Len,A
SETB C
SUBB A,#0x01
JNC C0E8F
SETB Mute
CLR PWM0
SJMP C0EA0;
C0E8F:
SETB PWM0
SJMP C0EA0;
C0E93:
MOV A,Mus_Len
CLR C
SUBB A,#0x06
JNC C0E9E
CLR PWM0
SJMP C0EA0;
C0E9E:
SETB PWM0;
C0EA0:
CPL flag_delay
DEC ledloop
MOV A,ledloop
JNZ C0F11
clr c;//youbang test
//这里获取不到位fk_run
// MOV C, fk_run
CPL C
JNC C0EB2
MOV ledloop,#30;
SJMP C0EB5;
C0EB2:
MOV ledloop,#15;
C0EB5:
CPL IO_LED;
CPL flag_Time0_5s_State;//(0x20.
C0F11:
ret;
#pragma endasm
#endif
}
#define FOSC 30000000L //系统频率
#define BAUD 600000 //串口波特率
#define NONE_PARITY 0 //无校验
#define ODD_PARITY 1 //奇校验
#define EVEN_PARITY 2 //偶校验
#define MARK_PARITY 3 //标记校验
#define SPACE_PARITY 4 //空白校验
#define PARITYBIT NONE_PARITY //定义校验位
#define S1_S0 0x40 //P_SW1.6
#define S1_S1 0x80 //P_SW1.7
sfr P_SW1 = 0xA2; //0000,0000 外设端口切换寄存器1
void uart(void)
{
ACC = P_SW1;
ACC &= ~(S1_S0 | S1_S1); //S1_S0=0 S1_S1=0
P_SW1 = ACC; //(P3.0/RxD, P3.1/TxD)
#if (PARITYBIT == NONE_PARITY)
SCON = 0x50; //8位可变波特率
#elif (PARITYBIT == ODD_PARITY) || (PARITYBIT == EVEN_PARITY) || (PARITYBIT == MARK_PARITY)
SCON = 0xda; //9位可变波特率,校验位初始为1
#elif (PARITYBIT == SPACE_PARITY)
SCON = 0xd2; //9位可变波特率,校验位初始为0
#endif
AUXR |= 0x40; //定时器1为1T模式
TMOD = 0x00; //定时器1为模式0(16位自动重载)
TL1 = (65536 - (FOSC/4/BAUD)); //设置波特率重装值
TH1 = (65536 - (FOSC/4/BAUD))>>8;
TR1 = 1; //定时器1开始启动
ES = 1; //使能串口中断
EA = 1;
}
void vga_init(void){
AUXR = 0x80;
init_io();
//uart();
PAL_init(180);
ACC = P_SW1;
ACC &= ~(S1_S0 | S1_S1); //S1_S0=0 S1_S1=0
P_SW1 = ACC; //(P3.0/RxD, P3.1/TxD)
#pragma asm
MOV TMOD,#0x22
MOV SCON,#0x0
MOV TH0,#0xb1
MOV TL0,#0xb1
MOV TH1,#0xb1
MOV TL1,#0xb1
MOV TCON,#0x51 //51
MOV IP,#0x08;//08
MOV IPH,#0x0A
MOV IE,#0x8a//8a
MOV syncON,#0x7F
MOV syncOFF,#0xFF
CLR flag_IsShowLine;
SETB flag_IsHiddenTimes;
MOV Lines,#45
MOV LineCount,#85;
CLR A
MOV OSD_Lines,A
MOV fk_Lines,#159
MOV ledloop,#30
CLR IO_LED;
#pragma endasm
}
void time1()interrupt 3
{
unsigned char *ptr ; // temporary pointer
unsigned char *osdp ; // temporary pointer
unsigned int line,osd;
//AL_lineVideo++;
if (PAL_lineVideo>521){
P4=0;
flag_IsHiddenTimes=1;
if (PAL_lineVideo==524){
P4|=0x40;
Lines=45;
LineCount=85;
fk_Lines=159;//159行
PAL_lineVideo=0;
}
Delay_us(3) ; // horizontal sync : low leve
P4|=0x80;
}else{
P4&=0x7F;
// Delay_us(1) ;
osd=((PAL_lineVideo-64)>>1);
osdp=diaplay_buf+(osd*6);
P4|=0xC0;
if(((PAL_lineVideo)>63)&&((PAL_lineVideo)<(230)))
{
//P4|=0xC0;
line=((PAL_lineVideo-64)>>3)+1;
ptr=Dis_Buf+(FK_LINES *FK_LEN-(line*10));
ACC=*ptr;
#pragma asm
MOV P2,#0x0A
MOV R6,#0x05 //OSD 一行五个字
MOV R5,#10 //方块10行
//发送数据10个方块数据
FK:
MOVX A,@DPTR
MOV P2,A
INC DPTR
DJNZ R5,FK
MOV P2,#0x0A;
#if 1
#pragma endasm
ACC=*osdp;
#pragma asm
MOV P2,#0x04;
//发送5个字节
OSD:
MOVX A,@DPTR
#if 0
// CLR TI
// MOV SBUF,A
#else
RRC A;
MOV P2^0,c;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
RRC A;
MOV P2^0,C;
#endif
INC DPL
DJNZ R6,OSD
MOV P2,#0x04
//OSD发送完毕
#endif
MOV P2,#0;
#pragma endasm
Lines--;
}
else{
//Delay_us(3) ;
//P4&=0x7F;
//P4&=0x7F;
//P4|=0xC0;
}
flag_IsHiddenTimes=0;
}
PAL_lineVideo++;
mus();
//P4=0xff;
}
|