久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5281|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

用16x8的LED點(diǎn)陣做的單片機(jī)貪吃蛇,匯編語言寫的,有興趣的可看看

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:202508 發(fā)表于 2017-5-19 12:43 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
網(wǎng)上看到的一個貪吃蛇的文件,用的是16x8的點(diǎn)陣。

實物圖:


電路原理圖如下:


16x8led點(diǎn)陣程序流程圖:


單片機(jī)源程序如下:
  1. ;
  2. ;  C51 Snakes ~~~~~~~~~
  3. ;
  4. ;  Created by Sandeep Sasi
  5. ;  Project Started:   10/09/09, 12:00PM
  6. ;  Project Completed: 30/09/09, 02:10AM

  7. ; File:       C51Snakes.asm
  8. ; Created by: Sandeep Sasi

  9. $TITLE ('C51Snakes')

  10. ; This file defines the Main Block and the entry point of the app.

  11. ; The app. uses polling technique to sequentially montior the state of the
  12. ; keys and then bring about the appropriate response. Since there are no blocking
  13. ; modules and each module will complete executuion within a deterministic time
  14. ; period, polling tech. proves more efficient over others in implementing this logic!!!





  15. ORG 0000H ; System reset sets PC to this addr.
  16.                                 SJMP ResetRecoveryISR ; After a sys. reset, pgm. exe. begins at this inst.
  17. ORG 0003H
  18.                                 SJMP ExternalInterrupt0ISR
  19. ORG 000BH ; Sets PC to this addr. when a Timer 0 overflow signal is raised
  20.                                 AJMP DisplayMuxISR ; Jump to the corresponding ISR's block
  21. ORG 0013H
  22.                                 SJMP ExternalInterrupt1ISR
  23. ORG 0020H ; All the supporting librarires are place in page one of ROM.
  24.           ; The game library (EggHandle.inc, GameBackEnd.inc and GameFrontEnd.inc) and
  25.           ; C51Snakes.asm will be moved to page two of ROM!!!




  26. $INCLUDE (ConstAndDataDefs.inc) ; Program Conts.s, redefinition of SFRs and Variable defs.
  27. $INCLUDE (SystemPower.inc)      ; Functions that handle system power down & program recovery after a system reset
  28. $INCLUDE (DisplayMuxing.inc)    ; Function and ISR for Disp. Muxing.
  29. $INCLUDE (SystemFunctions.inc)  ; Fns. to ctrl. disp., buzzer, scan keypad and delay the execution
  30. $INCLUDE (LowLevelGfx.inc)      ; Fuctions that give pixel level access to the disp.
  31. $INCLUDE (HighLevelGfx.inc)     ; Function to clear screen, print text and draw line
  32. $INCLUDE (WelcomeGfx.inc)       ; Functions to display an animation when the console is switched on
  33. $INCLUDE (DelaySettings.inc)    ; Functions to adjust the speed (prop. delay) of the snake
  34. $INCLUDE (StandByState.inc)     ; Fuctions that are called when the app. enters stand by
  35. $INCLUDE (PauseState.inc)       ; Functions that are called when the game is paused

  36. ORG 0801H ; The core game library functions; Beginning of page two of ROM

  37. $INCLUDE (EggHandle.inc)        ; Functions to handle generation and management of eggs for the snake
  38. $INCLUDE (GameBackEnd.inc)      ; Functions that not directly called from the Main block
  39.                                 ; The core game logic is handled by these functions
  40. $INCLUDE (GameFrontEnd.inc)     ; Functions that are called from Main block to notify various states of the game






  41. ; Beginning of the Main Block

  42. C51Main:
  43. GameStandBy:
  44.                                 LCALL _StandBy ; Enter stand by
  45. GameInit:
  46.                                 ACALL _NotifyGameBegin ; Initiate the operations before game begins
  47.                                 LCALL _WaitForAllActionKeyRelease
  48.                                 MOV PREV_KEY_STATES, #ALL_KEYS_PRESSED ; Force the user to release all keys
  49.                                                                        ; to start processing them in the polling loop
  50.                                 LCALL _ResetSystemIdleTime
  51. GameRun:
  52.                                 MOV CURR_KEY_STATES, KEYPAD_ACCESS_PORT ; Sample the state of all keys
  53. TestForAnyKeyPress:
  54.                                 MOV A, #ANY_KEY_MASK
  55.                                 LCALL ADetectedDepressedStateOfKeyMaskInA
  56.                                 JNZ BeginKeyScan ; If a key press is detected, start scanning the keys sequentially
  57.                                 LCALL AStepSystemIdleTimeAndNotifyOnExpiry ; If not, advance that system idle time
  58.                                 JZ EndOfKeyScan         ; If system idle period expires,
  59.                                 ACALL _NotifyGameFreeze ; then freeze the game and
  60.                                 LCALL _PowerDownSystem  ; initiate system power down

  61.                                 ACALL _NotifyGameRestore ; Recover game from power down state
  62.                                 LCALL _WaitForAnyKeyPress ; Wait for a user event
  63.                                 MOV CURR_KEY_STATES, #ALL_KEYS_PRESSED
  64.                                 SJMP EndOfKeyScan
  65. BeginKeyScan:
  66.                                 LCALL _ResetSystemIdleTime
  67. ScanGamePauseKey:
  68.                                 MOV A, #PAUSE_KEY_MASK
  69.                                 LCALL ADetectedDepressingEdgeOfKeyMaskInA ; Check whether the pause key is hit
  70.                                 JZ ScanDelaySettingsKey ; If not, check the state of Delay Settings key
  71.                                 ACALL _NotifyGameFreeze ; If yes, initiate a game freeze
  72.                                 LCALL AGamePause ; Enter paused state
  73.                                 JZ GameEnd; If the user wishes to quit, end the game and
  74.                                           ; display the game score
  75.                                 ACALL _NotifyGameRestore ; Else, initiate game resume
  76.                                 LCALL _WaitForAnyKeyPress ; After restoring the display to the state when the user
  77.                                                           ; hit the pause key, wait for a user event
  78.                                 MOV CURR_KEY_STATES, #ALL_KEYS_PRESSED
  79.                                 SJMP EndOfKeyScan ; Perform no more key processing in this iteration
  80. ScanDelaySettingsKey:
  81.                                 MOV A, #DEL_SET_KEY_MASK
  82.                                 LCALL ADetectedDepressingEdgeOfKeyMaskInA ; Check whether the pause key is hit
  83.                                 JZ ScanGameActionKeys ; If not, check the state of Game Action Keys
  84.                                 ACALL _NotifyGameFreeze ; If yes, initiate a game freeze
  85.                                 LCALL _DelaySettings ; Enter the mode that helps the user to adjust the snake's speed
  86.                                 ACALL _NotifyGameRestore ; Restore the game once the user has switched back to game mode
  87.                                 LCALL _WaitForAnyKeyPress ; After restoring the display to the state when the user
  88.                                                           ; hit the pause key, wait for a user event
  89.                                 MOV CURR_KEY_STATES, #ALL_KEYS_PRESSED
  90.                                 SJMP EndOfKeyScan ; Perform no more key processing in this iteration

  91. ScanGameActionKeys:
  92.                                 ACALL _ScanGameActionKeys
  93. EndOfKeyScan:
  94.                                 MOV PREV_KEY_STATES, CURR_KEY_STATES ; Init. PREV_KEY_STATES before next round of processing

  95.                                 MOV A, #GAME_TIME_STEP_PERIOD
  96.                                 LCALL _DelayABy100ms
  97.                                 ACALL ANotifyGameTimeStep ; Initiate a change of game state
  98.                                 JZ GameOver ; Collision detected; So, game over!
  99.                                 SJMP GameRun ; Loop around to Game Block
  100. GameOver:
  101.                                 ACALL _EndOfGameGfx ; Alert user about end of the game
  102. GameEnd:
  103.                                 ACALL _NotifyGameEnd
  104.                                 ACALL _DisplayGameScore
  105.                                 SJMP C51Main ; Loop around to Main Block
  106. END ; End of app.
復(fù)制代碼

所有資料51hei提供下載:
C51Snakes.zip (2.18 MB, 下載次數(shù): 15)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:241152 發(fā)表于 2017-10-20 17:07 | 只看該作者
非常好,謝謝分享
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: av网站免费在线观看 | 欧美激情一区二区三级高清视频 | 精品在线一区二区 | 欧美中文字幕一区二区三区亚洲 | 亚洲五码久久 | 国产在线精品一区二区三区 | 欧美精品一区二区三区四区五区 | 337p日本欧洲亚洲大胆精蜜臀 | 久久精品小视频 | 麻豆一区二区三区 | 天天操天天射综合网 | 99视频在线免费观看 | 岛国一区| 亚洲视频手机在线 | 一区二区免费 | 亚洲成人一区二区三区 | 国产伦精品一区二区三区照片91 | 九色91视频 | 国产99视频精品免费视频7 | 亚洲h在线观看 | 日韩欧美一区二区三区四区 | 日本免费视频在线观看 | 国产成人一区二区三区久久久 | h在线 | 日韩欧美国产精品 | 羞羞的视频在线 | 中文字幕高清在线 | 久久久久国产精品www | 四虎永久免费在线 | 国产美女在线播放 | 欧美成年视频 | 一区二区三区在线看 | 精品国产91 | av网站免费在线观看 | 最新免费黄色网址 | 免费国产一区二区 | 久久久99精品免费观看 | 在线播放国产一区二区三区 | 亚洲一区二区三区在线播放 | 成人免费视频观看 | 成人av免费 |