From b774eb6b4fd4d83a97d7131e5a69859b08c62ecc Mon Sep 17 00:00:00 2001 From: iridiumR Date: Tue, 7 Jun 2022 23:51:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(MCU=E8=AF=BE=E8=AE=BE):=20=E4=B8=80?= =?UTF-8?q?=E7=B3=BB=E5=88=97=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCU/MCU_REAL_FINAL/IMG/amadeus.png | Bin 0 -> 7755 bytes MCU/MCU_REAL_FINAL/block.c | 48 +-- MCU/MCU_REAL_FINAL/draw.c | 523 ++++------------------------- MCU/MCU_REAL_FINAL/draw.h | 4 +- MCU/MCU_REAL_FINAL/img.h | 42 +-- MCU/MCU_REAL_FINAL/main.c | 32 +- MCU/MCU_REAL_FINAL/main.h | 1 + MCU/MCU_REAL_FINAL/menu.c | 52 ++- 8 files changed, 182 insertions(+), 520 deletions(-) create mode 100644 MCU/MCU_REAL_FINAL/IMG/amadeus.png diff --git a/MCU/MCU_REAL_FINAL/IMG/amadeus.png b/MCU/MCU_REAL_FINAL/IMG/amadeus.png new file mode 100644 index 0000000000000000000000000000000000000000..e3ddfba901bd1abc2a83ff7e0943b7771d2cd616 GIT binary patch literal 7755 zcmX|mbzIZm_diH&O8brFL z^yrk5?~C{6_xSzw+P(MO6VLNJ=bp!72_{Cmbkv;GBqStsdN;LilaP=BBqWzy$;rSS z^^T|%@WX3jXs&a9e!jT42(AVP2j%7EtE;O+LqoZ_x$W)kcXoChXt7izBs|M{+M4D; z6Kik2dQGBO+vDENrzwiS=2nmICWW&!Q4Y^AxkT$cj!i_D$I?%8b5V{@Pc^BKXLFH3 zo}bK?{T@q@?7zvqL$}m?>_o%jU?YDk@~j23cfCbsk@!OG==jFQ%W?CyRv~_c7s4=! zj6!mtWFhFLISJM!>m@l`N&3Eca}Y5s*4V zwzFI&U(m<%6)MGawnbJE4|(ut{e@_C@K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vg6FAv!X4CH_sMSw*$ENq9r<`F~?P=hE0 z;yp+tIuh;uM*5J84?#to!^ZXi(7 zyWc}W>R}RQpkw1qAu6EFuRx2DGZRwUvHNGSArd0I7XbQ$gl=9q{X%-n)j|aBC%ET! z@e#0<+!F$FpeO$>Zomk?Vx^ItnH38^%M6jrHRT z21*tg2uiX$zU?&^fe$m=FMt@x5Nb0TWyc-#Tcq_5p;m8VU z%q}6o1uv2ehU6x)wtKNe;peVhuocP>et~r~@NWa$y@6-VxDew1RG9@XDe>Qt#uq`Y zY=c2T1onc#zyTN~ra-oo2{hQS%1od2cCf>!^CE2s#ugVPP}d7UA;~NYkk;$;0e3|p z*=GMOH9H@Gx8<2-$3dCrK%82kER?_lzrZ<@pPL%)iw_qDdZ2O0&J*Y6(toXkV%)#$ frSHXul9DLzdGmgZlxqY34<^ymG14wW-i!G^mUMq1 literal 0 HcmV?d00001 diff --git a/MCU/MCU_REAL_FINAL/block.c b/MCU/MCU_REAL_FINAL/block.c index a0a45f0..71398c0 100644 --- a/MCU/MCU_REAL_FINAL/block.c +++ b/MCU/MCU_REAL_FINAL/block.c @@ -19,6 +19,31 @@ void blockInit() void blockDestroy() { + //写入排行榜 + if(addBest(score)) + { + IapEraseSector(IAP_ADDRESS); + IapProgramByte(IAP_ADDRESS + 0, bestScore[0] >> 8); + IapProgramByte(IAP_ADDRESS + 1, bestScore[0] % 256); + IapProgramByte(IAP_ADDRESS + 2, bestScore[1] >> 8); + IapProgramByte(IAP_ADDRESS + 3, bestScore[1] % 256); + IapProgramByte(IAP_ADDRESS + 4, bestScore[2] >> 8); + IapProgramByte(IAP_ADDRESS + 5, bestScore[2] % 256); + IapProgramByte(IAP_ADDRESS + 6, bestScore[3] >> 8); + IapProgramByte(IAP_ADDRESS + 7, bestScore[3] % 256); + IapProgramByte(IAP_ADDRESS + 8, bestScore[4] >> 8); + IapProgramByte(IAP_ADDRESS + 9, bestScore[4] % 256); + IapProgramByte(IAP_ADDRESS + 10, bestScore[5] >> 8); + IapProgramByte(IAP_ADDRESS + 11, bestScore[5] % 256); + IapProgramByte(IAP_ADDRESS + 12, bestScore[6] >> 8); + IapProgramByte(IAP_ADDRESS + 13, bestScore[6] % 256); + IapProgramByte(IAP_ADDRESS + 14, bestScore[7] >> 8); + IapProgramByte(IAP_ADDRESS + 15, bestScore[7] % 256); + IapProgramByte(IAP_ADDRESS + 16, bestScore[8] >> 8); + IapProgramByte(IAP_ADDRESS + 17, bestScore[8] % 256); + IapProgramByte(IAP_ADDRESS + 18, bestScore[9] >> 8); + IapProgramByte(IAP_ADDRESS + 19, bestScore[9] % 256); + } memset(base, 0, sizeof(base)); blockGameStatus = over; } @@ -262,7 +287,7 @@ void blockGameOver() //写入排行榜 if(addBest(score)) { - IapEraseSector(IAP_ADDRESS); + IapEraseSector(IAP_ADDRESS); IapProgramByte(IAP_ADDRESS + 0, bestScore[0] >> 8); IapProgramByte(IAP_ADDRESS + 1, bestScore[0] % 256); IapProgramByte(IAP_ADDRESS + 2, bestScore[1] >> 8); @@ -309,24 +334,3 @@ unsigned int addBest(unsigned int s) } return 0; } - -void saveBest() -{ - unsigned int i; - IapEraseSector(IAP_ADDRESS); - delayms(20); - for(i = 0; i++; i < 10) - { - IapProgramByte(IAP_ADDRESS + 2 * i, bestScore[i] >> 8); - IapProgramByte(IAP_ADDRESS + 2 * i + 1, bestScore[i] - (bestScore[i] >> 4) << 8); - } -} - -void readBest() -{ - unsigned int i; - for(i = 0; i++; i < 10) - { - bestScore[i] = (unsigned int)IapReadByte(IAP_ADDRESS + 2 * i) << 8 + (unsigned int)IapReadByte(IAP_ADDRESS + 2 * i + 1); - } -} \ No newline at end of file diff --git a/MCU/MCU_REAL_FINAL/draw.c b/MCU/MCU_REAL_FINAL/draw.c index 40f3057..64d875b 100644 --- a/MCU/MCU_REAL_FINAL/draw.c +++ b/MCU/MCU_REAL_FINAL/draw.c @@ -10,235 +10,113 @@ sbit E = P2 ^ 2; sbit CSA = P2 ^ 4; sbit CSB = P2 ^ 5; - -void drawNUMBER() +void drawFONT(unsigned char x, unsigned char y, unsigned char len, unsigned char re, + unsigned char FONT0[], unsigned char FONT1[]) { unsigned int j; - for(j = 0 ; j < 64; j++) + if(x < 0 || x > 127) + return; + else if(x < 64) { - 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++) + else { - - CSA = 0; CSB = 1; + x = x - 63; + } + + for(j = 0; j < len; j++) + { + RS = 0; RW = 0; - P1 = 0xb8 + 2; + P1 = 0xb8 + y; write(); - P1 = 0X40 + j; - write(); //页2列j屏B + P1 = 0X40 + x + j; + write(); //页y列x+j RS = 1; RW = 0; - P1 = NUMBER_RPAGE0[j]; + if(!re) + P1 = FONT0[j]; + else + P1 = ~FONT0[j]; write(); RS = 0; RW = 0; - P1 = 0xb8 + 3; + P1 = 0xb8 + y + 1; write(); - P1 = 0X40 + j; - write(); //页3列j屏B + P1 = 0X40 + x + j; + write(); //页y+1列x+j + RS = 1; RW = 0; - P1 = NUMBER_RPAGE1[j]; + if(!re) + P1 = FONT1[j]; + else + P1 = ~FONT1[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(); - } + drawFONT(5, 0, 48, 0, NAME_PAGE0, NAME_PAGE1); } + +void drawNUMBER() +{ + drawSUPNUM(0, 2, 2); + drawSUPNUM(8, 2, 0); + drawSUPNUM(16, 2, 2); + drawSUPNUM(24, 2, 0); + drawSUPNUM(32, 2, 1); + drawSUPNUM(40, 2, 1); + drawSUPNUM(48, 2, 4); + drawSUPNUM(56, 2, 4); + drawSUPNUM(64, 2, 9); + drawSUPNUM(72, 2, 0); +} + void drawMAINMENU(unsigned char i) { - unsigned int j; + drawFONT(2, 0, 32, 0, MAINMANU_PAGE0, MAINMANU_PAGE1); + drawFONT(22, 2, 32, i == 1, MAINMANU_PAGE2, MAINMANU_PAGE3); + drawFONT(22, 4, 32, i == 2, MAINMANU_PAGE4, MAINMANU_PAGE5); + drawFONT(22, 6, 32, i == 3, MAINMANU_PAGE6, MAINMANU_PAGE7); +} +void drawBLOCKSCORE() +{ + drawFONT(66, 0, 32, 0, FONT_SCORE0, FONT_SCORE1); +} - for(j = 0; j < 32; j++) - { - CSA = 0; - CSB = 1; +void drawGAME(unsigned char x, unsigned char y) +{ + drawFONT(x, y, 32, 0, FONT_GAME0, FONT_GAME1); +} - RS = 0; - RW = 0; - P1 = 0xb8 + 0; - write(); - P1 = 0X40 + 31 + j; - write(); //页0列31+j屏B +void drawOVER(unsigned char x, unsigned char y) +{ + drawFONT(x, y, 32, 0, FONT_OVER0, FONT_OVER1); +} - 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 drawGOOD(unsigned char x, unsigned char y) +{ + drawFONT(x, y, 40, 0, FONT_GOOD0, FONT_GOOD1); +} +void drawBEST(unsigned char x, unsigned char y) +{ + drawFONT(x, y, 32, 0, FONT_BEST0, FONT_BEST1); +} +void drawVER(unsigned char x, unsigned char y) +{ + drawFONT(x, y, 32, 0, FONT_VER0, FONT_VER1); } void placeIMG_BLOCK(unsigned char x, unsigned char y) { @@ -319,40 +197,6 @@ void drawVerticalDottedLine(char x) } } -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; @@ -380,7 +224,7 @@ void drawSUPNUM(unsigned char x, unsigned char y, unsigned char num) RS = 1; RW = 0; - P1 = SUPER_NUM0[8*num+j]; + P1 = SUPER_NUM0[8 * num + j]; write(); RS = 0; @@ -392,145 +236,14 @@ void drawSUPNUM(unsigned char x, unsigned char y, unsigned char num) RS = 1; RW = 0; - P1 = SUPER_NUM1[8*num+j]; + P1 = SUPER_NUM1[8 * num + j]; write(); } } -void drawGAME(unsigned char x, unsigned char y) +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 < 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) @@ -570,92 +283,4 @@ void drawVOID8(unsigned char x,unsigned char y,unsigned char len) P1 = 0x00; write(); } -} - -void drawBEST(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_BEST0[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_BEST1[j]; - write(); - } -} - -void drawRECORD(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 =MAINMANU_PAGE4[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 = MAINMANU_PAGE5[j]; - write(); - } } \ No newline at end of file diff --git a/MCU/MCU_REAL_FINAL/draw.h b/MCU/MCU_REAL_FINAL/draw.h index 550e2c0..545cc46 100644 --- a/MCU/MCU_REAL_FINAL/draw.h +++ b/MCU/MCU_REAL_FINAL/draw.h @@ -6,6 +6,9 @@ void drawNUMBER(); void drawMAINMENU(unsigned char); void drawSUPNUM(unsigned char x,unsigned char y,unsigned char num); void drawVOID8(unsigned char x,unsigned char y,unsigned char len); +void drawFONT(unsigned char x,unsigned char y,unsigned char len, + unsigned char re,unsigned char FONT0[],unsigned char FONT1[]); +void drawVER(unsigned char x, unsigned char y); ////=================== 方块 ================== void placeIMG_BLOCK(unsigned char x,unsigned char y); @@ -16,7 +19,6 @@ void drawOVER(unsigned char x, unsigned char y); void drawBLOCKSCORE(); ////=================== 记录 ================== -void drawRECORD(unsigned char x, unsigned char y); void drawBEST(unsigned char x, unsigned char y); ////=================== 几何 ================== diff --git a/MCU/MCU_REAL_FINAL/img.h b/MCU/MCU_REAL_FINAL/img.h index e6ecb95..c98a08c 100644 --- a/MCU/MCU_REAL_FINAL/img.h +++ b/MCU/MCU_REAL_FINAL/img.h @@ -14,38 +14,6 @@ code unsigned char NAME_PAGE1[] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x01, 0xFF, 0x01, 0x06, 0x00, 0x00, 0x3F, 0x10, 0x10, 0x10, 0x3F, 0x00, 0x00 }; -//学号 左 -code unsigned char NUMBER_PAGE0[]={ - -0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00, -0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00, -0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00, -0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00, -0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00, -0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00, -0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00, -0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00, -}; -code unsigned char NUMBER_PAGE1[]={ -0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, -0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, -0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, -0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, -0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00, -0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00, -0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24, -0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24, -}; -//学号 右 -code unsigned char NUMBER_RPAGE0[]={ -0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00, -0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00, -}; -code unsigned char NUMBER_RPAGE1[]={ -0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00, -0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, -}; - //=================== 菜单字库 ================== //第一行:菜单 @@ -85,6 +53,16 @@ code unsigned char MAINMANU_PAGE7[]={ 0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00, 0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; + +code unsigned char FONT_VER0[]={ +0x00,0xFE,0x20,0x20,0x3F,0x20,0x00,0xFC,0x24,0xE4,0x24,0x22,0x23,0xE2,0x00,0x00, +0x00,0x10,0x10,0x10,0x10,0xD0,0x30,0xFF,0x30,0xD0,0x10,0x10,0x10,0x10,0x00,0x00, +}; +code unsigned char FONT_VER1[]={ +0x80,0x7F,0x01,0x01,0xFF,0x80,0x60,0x1F,0x80,0x41,0x26,0x18,0x26,0x41,0x80,0x00, +0x10,0x08,0x04,0x02,0x09,0x08,0x08,0xFF,0x08,0x08,0x09,0x02,0x04,0x08,0x10,0x00, +}; + code unsigned char SUPER_NUM0[]={ 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00, 0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00, diff --git a/MCU/MCU_REAL_FINAL/main.c b/MCU/MCU_REAL_FINAL/main.c index 7456cba..58f8b29 100644 --- a/MCU/MCU_REAL_FINAL/main.c +++ b/MCU/MCU_REAL_FINAL/main.c @@ -1,12 +1,15 @@ #include "main.h" #include "eeprom.h" +//#define WIPE_BEST + #define RELOAD (65535-9216) //定时器填充值(1ms) unsigned char TH, TL; extern Menu *NOW; //菜单指针 extern enum OPR opr; //按键状态 extern unsigned int bestScore[]; +extern unsigned int ver; void int0() interrupt 0 //外部中断:检测左右旋钮 { @@ -39,8 +42,12 @@ void time() interrupt 1 // { delayms(15); if(PIN_4 == 0) + { opr = confirm; + delayms(20); + } } + EA = 1; } @@ -67,7 +74,30 @@ int main() displayInit(); //屏幕初始化 clear(); menuInit(); //菜单初始化 - + + //若定义,清除排行榜 + #ifdef WIPE_BEST + IapProgramByte(IAP_ADDRESS + 0, 0); + IapProgramByte(IAP_ADDRESS + 1, 0); + IapProgramByte(IAP_ADDRESS + 2, 0); + IapProgramByte(IAP_ADDRESS + 3, 0); + IapProgramByte(IAP_ADDRESS + 4, 0); + IapProgramByte(IAP_ADDRESS + 5, 0); + IapProgramByte(IAP_ADDRESS + 6, 0); + IapProgramByte(IAP_ADDRESS + 7, 0); + IapProgramByte(IAP_ADDRESS + 8, 0); + IapProgramByte(IAP_ADDRESS + 9, 0); + IapProgramByte(IAP_ADDRESS + 10, 0); + IapProgramByte(IAP_ADDRESS + 11, 0); + IapProgramByte(IAP_ADDRESS + 12, 0); + IapProgramByte(IAP_ADDRESS + 13, 0); + IapProgramByte(IAP_ADDRESS + 14, 0); + IapProgramByte(IAP_ADDRESS + 15, 0); + IapProgramByte(IAP_ADDRESS + 16, 0); + IapProgramByte(IAP_ADDRESS + 17, 0); + IapProgramByte(IAP_ADDRESS + 18, 0); + IapProgramByte(IAP_ADDRESS + 19, 0); + #endif //读取排行榜 bestScore[0] = ((unsigned int)IapReadByte(IAP_ADDRESS + 0)) * 256 + (unsigned int)IapReadByte(IAP_ADDRESS + 1); diff --git a/MCU/MCU_REAL_FINAL/main.h b/MCU/MCU_REAL_FINAL/main.h index 0443b9e..3f7974f 100644 --- a/MCU/MCU_REAL_FINAL/main.h +++ b/MCU/MCU_REAL_FINAL/main.h @@ -10,6 +10,7 @@ #include "button.h" #include "delay.h" +#define VER_ADDRESS 0xaa00 sbit RS = P2 ^ 0; sbit RW = P2 ^ 1; diff --git a/MCU/MCU_REAL_FINAL/menu.c b/MCU/MCU_REAL_FINAL/menu.c index fc53a52..244492c 100644 --- a/MCU/MCU_REAL_FINAL/menu.c +++ b/MCU/MCU_REAL_FINAL/menu.c @@ -5,6 +5,7 @@ #include #include #include "block.h" +#include //便于调试的预编译命令 //#define DEBUG_MODE @@ -21,6 +22,7 @@ Menu M_ABOUT; // Menu* NOW; //当前菜单指针 Menu* LAST = NULL; //上一个状态的菜单 +code unsigned int ver _at_ 0x7ffe; enum OPR opr = idle; static unsigned char local[2] = {0}; unsigned int score; @@ -35,6 +37,20 @@ void m_mainmenu(struct _menu* this) { LAST = &M_MAINMENU; drawMAINMENU(local[0]); + + if(!local[1]) + { + local[1] = 1; + drawVER(90, 4); + drawSUPNUM(80, 6, ver / 10000); //绘制版本 + drawSUPNUM(89, 6, (ver % 10000) / 1000); + drawSUPNUM(98, 6, (ver % 1000) / 100); + drawSUPNUM(107, 6, (ver % 100) / 10); + drawSUPNUM(116, 6, ver % 10); + delayms(1000); + drawVOID8(90, 4, 32); + drawVOID8(80, 6, 46); + } } if(opr == right) @@ -48,7 +64,7 @@ void m_mainmenu(struct _menu* this) } if(opr == left) { - if(local[0] != 0) + if(local[0] > 1) local[0]--; opr = idle; @@ -72,7 +88,6 @@ void m_mainmenu(struct _menu* this) break; } - local[0] = 0; clear(); opr = idle; } @@ -152,6 +167,14 @@ void m_about(struct _menu* this) drawNAME(); //绘制名字 delayms(2000); drawNUMBER(); //绘制学号 + delayms(3000); + + drawVER(5, 4); + drawSUPNUM(2, 6, ver / 10000); //绘制版本 + drawSUPNUM(11, 6, (ver % 10000) / 1000); + drawSUPNUM(20, 6, (ver % 1000) / 100); + drawSUPNUM(29, 6, (ver % 100) / 10); + drawSUPNUM(38, 6, ver % 10); } if(opr == confirm) @@ -176,38 +199,38 @@ void m_best(struct _menu* this) drawSUPNUM(20, 2, (bestScore[0] % 1000) / 100); drawSUPNUM(29, 2, (bestScore[0] % 100) / 10); drawSUPNUM(38, 2, bestScore[0] % 10); - - drawSUPNUM(2, 4, bestScore[1] / 10000); //绘制分数 + + drawSUPNUM(2, 4, bestScore[1] / 10000); //绘制分数 drawSUPNUM(11, 4, (bestScore[1] % 10000) / 1000); drawSUPNUM(20, 4, (bestScore[1] % 1000) / 100); drawSUPNUM(29, 4, (bestScore[1] % 100) / 10); drawSUPNUM(38, 4, bestScore[1] % 10); - - drawSUPNUM(2, 6, bestScore[2] / 10000); //绘制分数 + + drawSUPNUM(2, 6, bestScore[2] / 10000); //绘制分数 drawSUPNUM(11, 6, (bestScore[2] % 10000) / 1000); drawSUPNUM(20, 6, (bestScore[2] % 1000) / 100); drawSUPNUM(29, 6, (bestScore[2] % 100) / 10); drawSUPNUM(38, 6, bestScore[2] % 10); - - drawSUPNUM(72, 0, bestScore[3] / 10000); //绘制分数 + + drawSUPNUM(72, 0, bestScore[3] / 10000); //绘制分数 drawSUPNUM(81, 0, (bestScore[3] % 10000) / 1000); drawSUPNUM(90, 0, (bestScore[3] % 1000) / 100); drawSUPNUM(99, 0, (bestScore[3] % 100) / 10); drawSUPNUM(108, 0, bestScore[3] % 10); - - drawSUPNUM(72, 2, bestScore[4] / 10000); //绘制分数 + + drawSUPNUM(72, 2, bestScore[4] / 10000); //绘制分数 drawSUPNUM(81, 2, (bestScore[4] % 10000) / 1000); drawSUPNUM(90, 2, (bestScore[4] % 1000) / 100); drawSUPNUM(99, 2, (bestScore[4] % 100) / 10); drawSUPNUM(108, 2, bestScore[4] % 10); - - drawSUPNUM(72, 4, bestScore[5] / 10000); //绘制分数 + + drawSUPNUM(72, 4, bestScore[5] / 10000); //绘制分数 drawSUPNUM(81, 4, (bestScore[5] % 10000) / 1000); drawSUPNUM(90, 4, (bestScore[5] % 1000) / 100); drawSUPNUM(99, 4, (bestScore[5] % 100) / 10); drawSUPNUM(108, 4, bestScore[5] % 10); - - drawSUPNUM(72, 6, bestScore[6] / 10000); //绘制分数 + + drawSUPNUM(72, 6, bestScore[6] / 10000); //绘制分数 drawSUPNUM(81, 6, (bestScore[6] % 10000) / 1000); drawSUPNUM(90, 6, (bestScore[6] % 1000) / 100); drawSUPNUM(99, 6, (bestScore[6] % 100) / 10); @@ -224,7 +247,6 @@ void m_best(struct _menu* this) void menuInit() { - M_MAINMENU.f = m_mainmenu; M_BLOCK.f = m_block; M_ABOUT.f = m_about;