2009-7-24 经过半个月的努力,31岁单片机初学者的第一个项目终于完成了,版主还给加个酷,我是有点受宠若惊啊,谢谢大家的鼓励 ;贪吃蛇程序,蛇身初始长度5个点,屏幕尺寸128x64,12MHz晶振,蛇身每个点为8x8点阵 COMMAND EQU 30H ;命令 D_DATA EQU 31H ;数据 SNAKE_L EQU 32H ;蛇身长度 WAY EQU 33H ;蛇头移动路线,上00,下10,左01,右11 F_POSITION EQU 34H ;食物坐标 TEMP1 EQU 35H ;数据暂存 TEMP2 EQU 36H T_POSITION EQU 3EH N_POSITION EQU 3FH ;新蛇头位置 POSITION EQU 40H ;蛇头位置,高4位纵坐标,低4位横坐标 DI EQU P1.0 RW EQU P1.1 E EQU P1.2 CS1 EQU P1.3 CS2 EQU P1.4 ;LCD-MCU UP EQU P2.0 DOWN EQU P2.1 LEFT EQU P2.2 RIGHT EQU P2.3 ;KEYBOARD-MCU ORG 0000H AJMP START ORG 0033H START: MOV SP,#60H MOV TMOD,11H MOV TH0,#00H MOV TL0,#00H SETB TR0 ACALL C_SCREEN ;屏幕初始化子程序 ACALL S_SNAKE ;游戏启动界面 SR_UP: JB UP,SR_DOWN AJMP S_GAME SR_DOWN: JB DOWN,SR_LEFT AJMP S_GAME SR_LEFT: JB LEFT,SR_RIGHT AJMP S_GAME SR_RIGHT: JB RIGHT,SR_UP S_GAME: ACALL C_SCREEN ;屏幕初始化子程序 ACALL R_SNAKE ;蛇身初始化子程序,初始运动方向:右,各点坐标存在40H开始的5个单元 ACALL R_FOOD ;食物初始化子程序 NEXT: ACALL D_FOOD ;食物显示子程序 MOV R2,#10 WAIT: ACALL DELAY DJNZ R2,WAIT ;0.5s延时 ACALL R_KEY ;读键值,确定蛇头新的运动方向 ACALL N_HEAD ;根据蛇头坐标及蛇头运动方向确定下一个蛇头的坐标 ACALL TAIL ;去掉蛇尾 ACALL D_HEAD ;在下一个蛇头的坐标处显示新的蛇头 ACALL R_POSITION ;蛇身各点坐标更新 ACALL GAME_OVER ;蛇死亡判断子程序 JB F0,D_OVER MOV A,POSITION CJNE A,F_POSITION,NEXT ;蛇头未吃到食物,继续移动 ACALL R_FOOD ;蛇头坐标与食物坐标重叠,喂食,当蛇尾离开该食物坐标时,该食物被自动删除 INC SNAKE_L ACALL SL_LONG ;蛇身+1子程序 MOV A,SNAKE_L CJNE A,#30,NEXT ;蛇身长度达到30,游戏结束,显示通关画面 ACALL C_SCREEN ;屏幕初始化子程序 SETB CS1 CLR CS2 MOV R5,#10111000B MOV DPTR,#HUA MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#ZAI MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#ZHEN MOV TEMP1,#16 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#NIU MOV TEMP1,#16 MOV TEMP2,#01110000B ACALL DISPLAY CLR CS1 SETB CS2 MOV R5,#10111000B MOV DPTR,#B1 MOV TEMP1,#8 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#GANTANHAO MOV TEMP1,#8 MOV TEMP2,#01001000B ACALL DISPLAY AJMP $ D_OVER: ACALL C_SCREEN ;屏幕初始化子程序 SETB CS1 CLR CS2 MOV R5,#10111000B MOV DPTR,#AI MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#YA MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#ZHE2 MOV TEMP1,#16 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#HAI MOV TEMP1,#16 MOV TEMP2,#01110000B ACALL DISPLAY CLR CS1 SETB CS2 MOV R5,#10111000B MOV DPTR,#ZI MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#DOUHAO MOV TEMP1,#8 MOV TEMP2,#01010000B ACALL DISPLAY SETB CS1 CLR CS2 MOV R5,#10111010B MOV DPTR,#ZA MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#ZHE2 MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#BEN MOV TEMP1,#16 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#NI MOV TEMP1,#16 MOV TEMP2,#01110000B ACALL DISPLAY CLR CS1 SETB CS2 MOV R5,#10111010B MOV DPTR,#GANTANHAO MOV TEMP1,#8 MOV TEMP2,#01000000B ACALL DISPLAY AJMP $
GAME_OVER: CLR F0 MOV R0,#POSITION MOV A,R0 ADD A,#04H MOV R0,A MOV A,SNAKE_L CLR C SUBB A,#04H MOV R2,A MOV A,POSITION GO_NEXT: MOV TEMP1,@R0 CJNE A,TEMP1,NO_OVER SETB F0 AJMP OVER NO_OVER: INC R0 DJNZ R2,GO_NEXT OVER: RET
SL_LONG: MOV A,T_POSITION ;蛇身+1后,新的蛇尾坐标为T_POSITION单元存储数据,并将新的蛇尾坐标存入蛇身坐标列表末位 SWAP A RLC A JC L_RS SETB CS1 CLR CS2 AJMP SLL L_RS: CLR CS1 SETB CS2 SLL: MOV A,T_POSITION SWAP A ANL A,#00000111B ADD A,#10111000B MOV R2,A MOV A,T_POSITION ANL A,#00000111B MOV B,#8 MUL AB ADD A,#01000000B MOV R3,A MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,R3 ACALL W_COMMAND MOV D_DATA,#0FFH MOV R4,#8 SLL_NEXT: ACALL W_DATA DJNZ R4,SLL_NEXT MOV R0,#POSITION MOV A,R0 ADD A,SNAKE_L DEC A MOV R0,A MOV @R0,T_POSITION RET
R_FOOD: MOV F_POSITION,TL0 ;食物坐标获取子程序,由定时器0产生的随机数作为食物坐标,存F_POSITION单元 ;横坐标低4位,纵坐标高4位,最高位未用,填0 MOV A,F_POSITION ANL A,#7FH MOV F_POSITION,A RET
D_FOOD: MOV A,F_POSITION ;根据食物坐标显示食物,其中第3位决定食物位于左半屏还是右半屏 SWAP A RLC A JC DF_RS SETB CS1 CLR CS2 AJMP DF DF_RS: CLR CS1 SETB CS2 DF: MOV A,F_POSITION SWAP A ANL A,#00000111B ADD A,#10111000B MOV R2,A MOV A,F_POSITION ANL A,#00000111B MOV B,#8 MUL AB ADD A,#01000000B MOV R3,A MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,R3 ACALL W_COMMAND MOV D_DATA,#0FFH MOV R4,#8 DF_NEXT: ACALL W_DATA DJNZ R4,DF_NEXT RET
R_POSITION:MOV R0,#POSITION ;上一个蛇尾坐标存T_POSITION单元,蛇吃到食物以后,蛇身在该位置加长 MOV A,R0 ADD A,SNAKE_L DEC A MOV R0,A MOV T_POSITION,@R0 DEC A MOV R1,A MOV R2,SNAKE_L MOVE: MOV A,@R1 MOV @R0,A DEC R0 DEC R1 DJNZ R2,MOVE RET
TAIL: MOV R0,#POSITION ;根据蛇身长度确定蛇尾坐标,去掉蛇尾 MOV A,R0 ADD A,SNAKE_L DEC A MOV R0,A MOV A,@R0 SWAP A RLC A JC T_RS SETB CS1 CLR CS2 AJMP DT T_RS: CLR CS1 SETB CS2 DT: MOV A,@R0 SWAP A ANL A,#00000111B ADD A,#10111000B MOV R2,A MOV A,@R0 ANL A,#00000111B MOV B,#8 MUL AB ADD A,#01000000B MOV R3,A MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,R3 ACALL W_COMMAND MOV D_DATA,#00H MOV R4,#8 DT_NEXT: ACALL W_DATA DJNZ R4,DT_NEXT RET
D_HEAD: MOV A,N_POSITION SWAP A RLC A JC D_RS SETB CS1 CLR CS2 AJMP DH D_RS: CLR CS1 SETB CS2 DH: MOV A,N_POSITION SWAP A ANL A,#00000111B ADD A,#10111000B MOV R2,A MOV A,N_POSITION ANL A,#00000111B MOV B,#8 MUL AB ADD A,#01000000B MOV R3,A MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,R3 ACALL W_COMMAND MOV D_DATA,#0FFH MOV R4,#8 DH_NEXT: ACALL W_DATA DJNZ R4,DH_NEXT RET N_HEAD: MOV A,WAY ;下一个蛇头位置存N_POSITION单元 ADD A,WAY MOV DPTR,#N_H_SHEET JMP @A+DPTR N_H_SHEET: AJMP H_UP AJMP H_LEFT AJMP H_DOWN AJMP H_RIGHT H_UP: MOV A,POSITION SWAP A ANL A,#00000111B DEC A ANL A,#00000111B SWAP A MOV N_POSITION,POSITION ANL N_POSITION,#00001111B ADD A,N_POSITION MOV N_POSITION,A AJMP N_H_END H_DOWN: MOV A,POSITION SWAP A ANL A,#00000111B INC A ANL A,#00000111B SWAP A MOV N_POSITION,POSITION ANL N_POSITION,#00001111B ADD A,N_POSITION MOV N_POSITION,A AJMP N_H_END H_LEFT: MOV A,POSITION ANL A,#00001111B DEC A ANL A,#00001111B MOV N_POSITION,POSITION ANL N_POSITION,#11110000B ADD A,N_POSITION MOV N_POSITION,A AJMP N_H_END H_RIGHT: MOV A,POSITION ANL A,#00001111B INC A ANL A,#00001111B MOV N_POSITION,POSITION ANL N_POSITION,#11110000B ADD A,N_POSITION MOV N_POSITION,A N_H_END: RET
C_SCREEN: MOV COMMAND,#00111111B ;清屏子程序 ACALL W_COMMAND MOV COMMAND,#11000000B ACALL W_COMMAND SETB CS1 CLR CS2 MOV R2,#10111000B MOV R5,#08H CS_NEXT2: MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,#01000000B ACALL W_COMMAND MOV D_DATA,#00H MOV R4,#64 CS_NEXT1: ACALL W_DATA DJNZ R4,CS_NEXT1 INC R2 DJNZ R5,CS_NEXT2 CLR CS1 SETB CS2 MOV R2,#10111000B MOV R5,#08H CS_NEXT4: MOV COMMAND,R2 ACALL W_COMMAND MOV COMMAND,#01000000B ACALL W_COMMAND MOV D_DATA,#00H MOV R4,#64 CS_NEXT3: ACALL W_DATA DJNZ R4,CS_NEXT3 INC R2 DJNZ R5,CS_NEXT4 RET
R_SNAKE: SETB CS1 ;蛇身初始化子程序,蛇身初始长度5,由蛇尾到蛇头自左至右排列在屏幕的左上角,蛇头初始运动方向:右 ;蛇身5点初始坐标由蛇头开始存储在POSITION开头的5个单元,蛇身长度存SNAKE_L单元 CLR CS2 MOV COMMAND,#10111000B ACALL W_COMMAND MOV COMMAND,#01000000B ACALL W_COMMAND MOV D_DATA,#0FFH MOV R2,#40 RS_NEXT1: ACALL W_DATA DJNZ R2,RS_NEXT1 MOV SNAKE_L,#05H MOV WAY,#03H MOV R0,#POSITION MOV A,#04H MOV R3,#05H RS_NEXT2: MOV @R0,A INC R0 DEC A DJNZ R3,RS_NEXT2 RET R_KEY: MOV A,WAY ;根据蛇头运动方向,读取键位 ;蛇头横向运动,读取上下键,蛇头左右运动,读取左右键,修改蛇头运动方向,存WAY单元 RRC A JC R_K_NEXT2 JB LEFT,R_K_NEXT1 MOV WAY,#01H AJMP R_K_END R_K_NEXT1: JB RIGHT,R_K_END MOV WAY,#03H AJMP R_K_END R_K_NEXT2: JB UP,R_K_NEXT3 MOV WAY,#00H AJMP R_K_END R_K_NEXT3: JB DOWN,R_K_END MOV WAY,#02H R_K_END: RET
S_SNAKE: SETB CS1 CLR CS2 MOV R5,#10111000B MOV DPTR,#TAN MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#CHI MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111000B MOV DPTR,#SHE MOV TEMP1,#16 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#ZUO MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#ZHE1 MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#MAOHAO MOV TEMP1,#8 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#HUA MOV TEMP1,#16 MOV TEMP2,#01110000B ACALL DISPLAY CLR CS1 SETB CS2 MOV R5,#10111010B MOV DPTR,#ZAI MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#ER MOV TEMP1,#8 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#LING MOV TEMP1,#8 MOV TEMP2,#01011000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#LING MOV TEMP1,#8 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111010B MOV DPTR,#QI MOV TEMP1,#8 MOV TEMP2,#01101000B ACALL DISPLAY SETB CS1 CLR CS2 MOV R5,#10111100B MOV DPTR,#AN MOV TEMP1,#16 MOV TEMP2,#01000000B ACALL DISPLAY MOV R5,#10111100B MOV DPTR,#REN1 MOV TEMP1,#16 MOV TEMP2,#01010000B ACALL DISPLAY MOV R5,#10111100B MOV DPTR,#YI MOV TEMP1,#16 MOV TEMP2,#01100000B ACALL DISPLAY MOV R5,#10111100B MOV DPTR,#JIAN MOV TEMP1,#16 MOV TEMP2,#01110000B ACALL DISPLAY RET
DISPLAY: MOV COMMAND,R5 ACALL W_COMMAND MOV R2,#00H MOV R4,TEMP1 MOV R3,TEMP2 D_NEXT1: MOV COMMAND,R3 ACALL W_COMMAND MOV A,R2 MOVC A,@A+DPTR MOV D_DATA,A ACALL W_DATA INC R3 INC R2 DJNZ R4,D_NEXT1 INC R5 MOV COMMAND,R5 ACALL W_COMMAND MOV R2,TEMP1 MOV R4,TEMP1 MOV R3,TEMP2 D_NEXT2: MOV COMMAND,R3 ACALL W_COMMAND MOV A,R2 MOVC A,@A+DPTR MOV D_DATA,A ACALL W_DATA INC R3 INC R2 DJNZ R4,D_NEXT2 RET
BUSY: MOV P0,#0FFH ;点阵型液晶显示模块驱动程序 CLR E SETB RW CLR DI NOP SETB E NOP JB P0.7,BUSY CLR E RET W_COMMAND: ACALL BUSY CLR E CLR RW CLR DI MOV P0,COMMAND SETB E NOP CLR E RET W_DATA: ACALL BUSY CLR E CLR RW SETB DI MOV P0,D_DATA SETB E NOP CLR E RET
DELAY: MOV TMOD,#11H ;延时50ms子程序 MOV TH1,#3CH MOV TL1,#0B0H SETB TR1 D_WAIT: JBC TF1,D_END SJMP D_WAIT D_END: RET
TAN: DB 20H,20H,10H,90H,0A8H,0A4H,0AAH,0B1H,0A2H,0E4H,0A8H,88H,10H,30H,10H,00H DB 00H,00H,80H,9FH,40H,20H,10H,0EH,10H,20H,60H,0DFH,00H,00H,00H,00H CHI: DB 00H,0FCH,04H,04H,0FCH,20H,58H,4FH,4AH,48H,48H,0C8H,08H,08H,08H,00H DB 00H,0FH,02H,02H,07H,00H,30H,48H,44H,42H,41H,40H,40H,40H,70H,00H SHE: DB 00H,0F0H,10H,0FFH,10H,0F0H,20H,18H,0E8H,09H,0EH,0AH,0A8H,18H,08H,00H DB 20H,23H,21H,1FH,11H,3BH,10H,00H,3FH,42H,41H,41H,40H,38H,00H,00H ZUO: DB 80H,40H,20H,0F8H,07H,22H,18H,0CH,0FBH,48H,48H,48H,68H,48H,08H,00H DB 00H,00H,00H,0FFH,00H,00H,00H,00H,0FFH,04H,04H,04H,04H,06H,04H,00H ZHE1: DB 00H,20H,24H,24H,24H,24H,0A4H,0BFH,64H,24H,34H,28H,26H,24H,20H,00H DB 04H,04H,04H,02H,02H,0FFH,49H,49H,49H,49H,49H,49H,0FFH,00H,00H,00H MAOHAO: DB 00H,00H,00H,0C0H,0C0H,00H,00H,00H DB 00H,00H,00H,30H,30H,00H,00H,00H HUA: DB 20H,10H,08H,0FCH,03H,02H,10H,10H,7FH,88H,88H,84H,86H,0E4H,00H,00H DB 00H,04H,04H,05H,04H,04H,04H,0FFH,04H,04H,04H,04H,04H,04H,04H,00H ZAI: DB 80H,40H,30H,0FCH,43H,40H,42H,42H,42H,0E2H,52H,4AH,46H,40H,40H,00H DB 00H,00H,00H,0FFH,00H,00H,00H,40H,80H,7FH,00H,00H,00H,00H,00H,00H ER: DB 00H,70H,08H,08H,08H,88H,70H,00H DB 00H,30H,28H,24H,22H,21H,30H,00H LING: DB 00H,0E0H,10H,08H,08H,10H,0E0H,00H DB 00H,0FH,10H,20H,20H,10H,0FH,00H QI: DB 00H,38H,08H,08H,0C8H,38H,08H,00H DB 00H,00H,00H,3FH,00H,00H,00H,00H AN: DB 10H,10H,10H,0FFH,90H,50H,98H,88H,88H,0E9H,8EH,88H,88H,98H,88H,00H DB 02H,42H,81H,7FH,00H,40H,40H,26H,25H,18H,08H,16H,31H,60H,20H,00H REN1: DB 80H,40H,30H,0FCH,87H,82H,84H,84H,84H,0FCH,82H,82H,82H,82H,80H,00H DB 00H,00H,00H,7FH,00H,20H,20H,20H,20H,3FH,20H,20H,20H,20H,20H,00H YI: DB 10H,10H,12H,0D2H,56H,5AH,0D2H,53H,52H,5AH,56H,0D2H,12H,12H,10H,00H DB 00H,20H,38H,03H,3AH,42H,42H,4BH,52H,42H,42H,63H,08H,30H,00H,00H JIAN: DB 40H,30H,0EFH,28H,28H,44H,64H,0DCH,10H,54H,0FFH,54H,54H,7CH,10H,00H DB 01H,01H,7FH,21H,51H,22H,14H,0FH,14H,25H,3FH,25H,25H,25H,24H,00H ZHEN: DB 00H,04H,04H,04H,0F4H,54H,5CH,57H,54H,54H,54H,0F4H,04H,06H,04H,00H DB 10H,90H,90H,50H,5FH,35H,15H,15H,15H,35H,55H,5FH,90H,90H,10H,00H NIU: DB 00H,40H,30H,0EH,08H,08H,08H,08H,0FFH,08H,08H,08H,08H,08H,00H,00H DB 00H,01H,01H,01H,01H,01H,01H,01H,7FH,01H,01H,01H,01H,01H,01H,00H B1: DB 00H,0F8H,08H,08H,08H,08H,0F0H,00H DB 00H,3FH,21H,21H,21H,21H,1EH,00H GANTANHAO: DB 00H,00H,00H,0F8H,00H,00H,00H,00H DB 00H,00H,00H,33H,30H,00H,00H,00H AI: DB 0FCH,04H,04H,0FCH,00H,80H,68H,5CH,4BH,0C8H,48H,48H,4AH,5CH,08H,00H DB 07H,01H,01H,03H,81H,42H,22H,12H,0AH,07H,0AH,12H,62H,0C2H,42H,00H YA: DB 00H,0FCH,04H,04H,0FCH,00H,42H,7AH,42H,42H,0C2H,0FEH,42H,42H,40H,00H DB 00H,07H,01H,01H,43H,20H,10H,08H,04H,23H,40H,3FH,00H,00H,00H,00H ZHE2: DB 40H,42H,44H,0CCH,00H,08H,28H,48H,89H,0EH,0CAH,38H,08H,08H,00H,00H DB 80H,40H,20H,1FH,20H,40H,50H,48H,44H,43H,44H,48H,50H,40H,40H,00H HAI: DB 02H,02H,02H,0F2H,8AH,06H,44H,64H,54H,4DH,46H,0C4H,64H,04H,04H,00H DB 01H,23H,41H,3FH,00H,48H,48H,24H,24H,12H,09H,0CH,12H,61H,00H,00H ZI: DB 00H,00H,02H,02H,02H,02H,02H,0E2H,12H,0AH,06H,02H,00H,80H,00H,00H DB 01H,01H,01H,01H,01H,41H,81H,7FH,01H,01H,01H,01H,01H,01H,01H,00H DOUHAO: DB 00H,00H,00H,00H,00H,00H,00H,00H DB 80H,0B0H,70H,00H,00H,00H,00H,00H ZA: DB 0FCH,04H,04H,04H,0FCH,20H,10H,08H,0FFH,4AH,48H,48H,48H,48H,08H,00H DB 07H,02H,02H,02H,07H,00H,00H,00H,0FFH,04H,04H,04H,04H,04H,04H,00H BEN: DB 10H,4CH,43H,46H,5AH,0C2H,42H,0F8H,44H,0C3H,42H,46H,5AH,62H,42H,00H DB 20H,10H,08H,04H,0AH,09H,08H,0FFH,08H,08H,0BH,04H,0CH,18H,08H,00H NI: DB 0FEH,02H,02H,02H,0FEH,00H,0FEH,12H,0D2H,12H,12H,12H,92H,3EH,00H,00H DB 07H,01H,01H,81H,43H,30H,0FH,00H,3FH,42H,42H,41H,41H,41H,70H,00H END 2009-7-22 本打算读取定时器计数值再进行线性叠加的方法得到随机数,但由于按键的顺序及时间,随机性非常大,所以只采用计数值作为食物坐标,实验中效果很好 食物放置,蛇吃食长大的程序实验通过 2009-7-20 这几天挺忙的,第一步"柔体传动"就用了差不多一周时间,不过总算完成了,下一步要产生一个随机数,确定食物的位置,蛇吃食,长大,请问如何用汇编语言产生一个随机数,编程思路是什么 以下是柔体传动部分程序:
大家好: 我是一名30岁的单片机初学者,这两天刚把点阵式液晶模块弄明白,想编个贪吃蛇的小游戏,给老婆玩,希 |