1. TITLE ASM Routines for maze game
  2.  
  3. ; Description: ASM functions my final project
  4. ; Week 9 SG360
  5. ; by Jeff Yaskus
  6.  
  7. INCLUDE T:\Irvine\Irvine32.inc
  8.  
  9. ; function PROTOTYPES
  10. drawBlock PROTO C, PTx:WORD, PTy:WORD, color:DWORD
  11. clearscreen PROTO C
  12. doWait PROTO C
  13. doWin PROTO C
  14. showScore PROTO C, score:DWORD
  15. getInput PROTO C
  16. showLOC PROTO C, PTx:DWORD, PTy:DWORD
  17. showTimer PROTO C, seconds:DWORD
  18.  
  19.  
  20. ; data definitions
  21. .data
  22. scoreStr BYTE "Score",0
  23. winStr BYTE "You won!",0
  24. timerStr BYTE "Timer",0
  25.  
  26. ; main code
  27. .code
  28. ;;;;;;;;;;;;;;;;;;;
  29. drawBlock PROC C USES eax,
  30.      PTx:WORD, PTy:WORD, color:DWORD
  31. ;;;;;;;;;;;;;;;;;;;;;;;
  32.          
  33.          mov dh,BYTE PTR PTy
  34.          mov dl,BYTE PTR PTx
  35.           call Gotoxy         ;    move cursor      
  36.          
  37.           ; need to determine which color to use here
  38.           mov eax,color
  39.           call SetTextColor
  40.          
  41.           mov al,219     ; for plotting the point
  42.           call WriteChar
  43.        
  44.          ret                  ; cant forget to return
  45. drawBlock ENDP
  46.  
  47. ;;;;;;;;;;;;;;;;;;;;;;;
  48. clearscreen PROC C
  49. ; just clears the screen
  50.      call Clrscr
  51.      ret            ; done
  52. clearscreen ENDP
  53.  
  54. ;;;;;;;;;;;;;;;;;;;;;;;
  55. doWait PROC C
  56.     mov dh,BYTE PTR 21
  57.     mov dl,BYTE PTR 0
  58.      call Gotoxy         ;    move cursor  
  59.      
  60.      call Crlf
  61.      call WaitMsg
  62.      ret            ; done
  63. doWait ENDP
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. doWin PROC C USES edx
  66.     mov dh,BYTE PTR 21
  67.     mov dl,BYTE PTR 0
  68.     call Gotoxy         ;    move cursor    
  69.          
  70.     mov edx, OFFSET winStr
  71.     call WriteString    ; print "You win!"
  72.    
  73.     call Crlf
  74.     call WaitMsg
  75.     ret            ; done
  76. doWin ENDP
  77. ;;;;;;;;;;;;;;;;;;;
  78. showScore PROC C USES eax edx,
  79.      score:DWORD
  80. ;;;;;;;;;;;;;;;;;;;;;;;        
  81.           ; need to determine which color to use here
  82.           mov eax,15
  83.           call SetTextColor  
  84.  
  85.          mov dh,BYTE PTR 1
  86.          mov dl,BYTE PTR 28
  87.           call Gotoxy         ;    move cursor      
  88.          
  89.           mov edx, OFFSET scoreStr
  90.           call WriteString    ; print "score"
  91.  
  92.          mov dh,BYTE PTR 2
  93.          mov dl,BYTE PTR 30
  94.           call Gotoxy         ;    move cursor      
  95.                    
  96.           mov eax,score     ; for plotting the point
  97.           call WriteInt
  98.        
  99.          ret                  ; cant forget to return
  100. showScore ENDP
  101.  
  102. drawAvatar PROC C USES eax,
  103.      PTx:WORD, PTy:WORD
  104. ;;;;;;;;;;;;;;;;;;;;;;;
  105.          
  106.          mov dh,BYTE PTR PTy
  107.          mov dl,BYTE PTR PTx
  108.           call Gotoxy         ;    move cursor      
  109.          
  110.           ; need to determine which color to use here
  111.           mov eax,15          ; WHITE
  112.           call SetTextColor
  113.          
  114.           mov al,2            ; smiley face icon ?
  115.           call WriteChar
  116.        
  117.          ret                  ; cant forget to return
  118. drawAvatar ENDP
  119.  
  120. getInput PROC C
  121.      .data
  122.      char BYTE ?
  123.      .code
  124.      call ReadChar
  125.      mov char,al
  126.      
  127.      ret ;    
  128. getInput ENDP
  129.  
  130. showLOC PROC C USES eax, PTx:DWORD, PTy:DWORD
  131. ;;;;;;;;;;;;;;;;;;;;;;;        
  132.           ; need to determine which color to use here
  133.           mov eax,15
  134.           call SetTextColor  
  135.  
  136.          mov dh,BYTE PTR 3
  137.          mov dl,BYTE PTR 28
  138.           call Gotoxy         ;    move cursor      
  139.                            
  140.           mov eax,ptX     ; for plotting the point
  141.           call WriteInt
  142.          
  143.          mov dh,BYTE PTR 3
  144.          mov dl,BYTE PTR 34
  145.           call Gotoxy         ;    move cursor      
  146.                            
  147.           mov eax,ptY     ; for plotting the point
  148.           call WriteInt
  149.        
  150.          ret                  ; cant forget to return
  151. showLOC ENDP
  152.  
  153. showTimer PROC C USES eax edx,
  154.      seconds:DWORD
  155. ;;;;;;;;;;;;;;;;;;;;;;;        
  156.           ; need to determine which color to use here
  157.           mov eax,15
  158.           call SetTextColor  
  159.  
  160.          mov dh,BYTE PTR 5
  161.          mov dl,BYTE PTR 28
  162.           call Gotoxy          ;    move cursor    
  163.          
  164.           mov edx, OFFSET timerStr
  165.           call WriteString     ; print "Timer"
  166.  
  167.          mov dh,BYTE PTR 6
  168.          mov dl,BYTE PTR 30
  169.           call Gotoxy          ;    move cursor    
  170.                    
  171.           mov eax,seconds      ; for plotting the point
  172.           call WriteInt
  173.        
  174.          ret                   ; cant forget to return
  175. showTimer ENDP
  176.  
  177.