This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_REAL _FINAL/draw.c

573 lines
No EOL
8.3 KiB
C

#include "img.h"
#include "display.h"
#include "draw.h"
#include <reg52.h>
#include "block.h"
sbit RS = P2 ^ 0;
sbit RW = P2 ^ 1;
sbit E = P2 ^ 2;
sbit CSA = P2 ^ 4;
sbit CSB = P2 ^ 5;
void drawNUMBER()
{
unsigned int j;
for(j = 0 ; j < 64; j++)
{
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 2;
write();
P1 = 0X40 + j;
write(); //Ò³2ÁÐjÆÁA
RS = 1;
RW = 0;
P1 = NUMBER_PAGE0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 3;
write();
P1 = 0X40 + j;
write(); //Ò³3ÁÐjÆÁA
RS = 1;
RW = 0;
P1 = NUMBER_PAGE1[j];
write();
}
for(j = 0 ; j < 16; j++)
{
CSA = 0;
CSB = 1;
RS = 0;
RW = 0;
P1 = 0xb8 + 2;
write();
P1 = 0X40 + j;
write(); //Ò³2ÁÐjÆÁB
RS = 1;
RW = 0;
P1 = NUMBER_RPAGE0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 3;
write();
P1 = 0X40 + j;
write(); //Ò³3ÁÐjÆÁB
RS = 1;
RW = 0;
P1 = NUMBER_RPAGE1[j];
write();
}
}
void drawNAME()
{
unsigned int j;
for(j = 0; j < 48; j++)
{
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 0;
write();
P1 = 0X40 + j;
write(); //Ò³0ÁÐjÆÁA
RS = 1;
RW = 0;
P1 = NAME_PAGE0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 1;
write();
P1 = 0X40 + j;
write(); //Ò³1ÁÐjÆÁA
RS = 1;
RW = 0;
P1 = NAME_PAGE1[j];
write();
}
}
void drawMAINMENU(unsigned char i)
{
unsigned int j;
for(j = 0; j < 32; j++)
{
CSA = 0;
CSB = 1;
RS = 0;
RW = 0;
P1 = 0xb8 + 0;
write();
P1 = 0X40 + 31 + j;
write(); //Ò³0ÁÐ31+jÆÁB
RS = 1;
RW = 0;
P1 = MAINMANU_PAGE0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 1;
write();
P1 = 0X40 + 31 + j;
write(); //Ò³1ÁÐ31+jÆÁB
RS = 1;
RW = 0;
P1 = MAINMANU_PAGE1[j];
write();
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 2;
write();
P1 = 0X40 + j;
write(); //Ò³2ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 1)
P1 = ~MAINMANU_PAGE2[j];
else
P1 = MAINMANU_PAGE2[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 3;
write();
P1 = 0X40 + j;
write(); //Ò³3ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 1)
P1 = ~MAINMANU_PAGE3[j];
else
P1 = MAINMANU_PAGE3[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 4;
write();
P1 = 0X40 + j;
write(); //Ò³4ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 2)
P1 = ~MAINMANU_PAGE4[j];
else
P1 = MAINMANU_PAGE4[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 5;
write();
P1 = 0X40 + j;
write(); //Ò³5ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 2)
P1 = ~MAINMANU_PAGE5[j];
else
P1 = MAINMANU_PAGE5[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 6;
write();
P1 = 0X40 + j;
write(); //Ò³6ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 3)
P1 = ~MAINMANU_PAGE6[j];
else
P1 = MAINMANU_PAGE6[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 7;
write();
P1 = 0X40 + j;
write(); //Ò³7ÁÐjÆÁA
RS = 1;
RW = 0;
if(i == 3)
P1 = ~MAINMANU_PAGE7[j];
else
P1 = MAINMANU_PAGE7[j];
write();
}
}
void placeIMG_BLOCK(unsigned char x, unsigned char y)
{
char j;
for(j = 0 ; j < 8; j++)
{
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 7 - y;
write();
P1 = 0X40 + x * 8 + j;
write(); //Ò³7-yÁÐx*8+jÆÁA
RS = 1;
RW = 0;
P1 = IMG_BLOCK[j];
write();
}
}
void placeVOID_BLOCK(unsigned char x, unsigned char y)
{
char j;
for(j = 0 ; j < 8; j++)
{
CSA = 1;
CSB = 0;
RS = 0;
RW = 0;
P1 = 0xb8 + 7 - y;
write();
P1 = 0X40 + x * 8 + j;
write(); //Ò³7-yÁÐx*8+jÆÁA
RS = 1;
RW = 0;
P1 = 0x00;
write();
}
}
void drawVerticalDottedLine(char x)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0 ; j < 8; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + j;
write();
P1 = 0X40 + x;
write(); //Ò³jÁÐx
RS = 1;
RW = 0;
P1 = 0x55;
write();
}
}
void drawBLOCKSCORE()
{
unsigned int j;
for(j = 0; j < 32; j++)
{
CSA = 0;
CSB = 1;
RS = 0;
RW = 0;
P1 = 0xb8 + 0;
write();
P1 = 0X40 + 5 + j;
write(); //Ò³0ÁÐ5+jÆÁB
RS = 1;
RW = 0;
P1 = FONT_SCORE0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + 1;
write();
P1 = 0X40 + 5 + j;
write(); //Ò³1ÁÐ5+jÆÁB
RS = 1;
RW = 0;
P1 = FONT_SCORE1[j];
write();
}
}
void drawSUPNUM(unsigned char x, unsigned char y, unsigned char num)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < 8; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = SUPER_NUM0[8*num+j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = SUPER_NUM1[8*num+j];
write();
}
}
void drawGAME(unsigned char x, unsigned char y)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < 32; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_GAME0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_GAME1[j];
write();
}
}
void drawOVER(unsigned char x, unsigned char y)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < 32; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_OVER0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_OVER1[j];
write();
}
}
void drawGOOD(unsigned char x, unsigned char y)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < 40; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_GOOD0[j];
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = FONT_GOOD1[j];
write();
}
}
void drawVOID8(unsigned char x,unsigned char y,unsigned char len)
{
unsigned int j;
if(x < 0 || x > 127)
return;
else if(x < 64)
{
CSA = 1;
CSB = 0;
}
else
{
x = x - 63;
CSA = 0;
CSB = 1;
}
for(j = 0; j < len; j++)
{
RS = 0;
RW = 0;
P1 = 0xb8 + y;
write();
P1 = 0X40 + x + j;
write(); //Ò³yÁÐx+j
RS = 1;
RW = 0;
P1 = 0x00;
write();
RS = 0;
RW = 0;
P1 = 0xb8 + y + 1;
write();
P1 = 0X40 + x + j;
write(); //Ò³y+1ÁÐx+j
RS = 1;
RW = 0;
P1 = 0x00;
write();
}
}