TITLE ASM Routines for maze game
; Description: ASM functions my final project
; Week 9 SG360
; by Jeff Yaskus
INCLUDE T:\Irvine\Irvine32.inc
; function PROTOTYPES
drawBlock PROTO C, PTx:WORD, PTy:WORD, color:DWORD
clearscreen PROTO C
doWait PROTO C
doWin PROTO C
showScore PROTO C, score:DWORD
getInput PROTO C
showLOC PROTO C, PTx:DWORD, PTy:DWORD
showTimer PROTO C, seconds:DWORD
; data definitions
.data
scoreStr BYTE "Score",0
winStr BYTE "You won!",0
timerStr BYTE "Timer",0
; main code
.code
;;;;;;;;;;;;;;;;;;;
drawBlock PROC C USES eax,
PTx:WORD, PTy:WORD, color:DWORD
;;;;;;;;;;;;;;;;;;;;;;;
mov dh,BYTE PTR PTy
call Gotoxy ; move cursor
; need to determine which color to use here
mov eax,color
call SetTextColor
mov al,219 ; for plotting the point
call WriteChar
ret ; cant forget to return
drawBlock ENDP
;;;;;;;;;;;;;;;;;;;;;;;
clearscreen PROC C
; just clears the screen
call Clrscr
ret ; done
clearscreen ENDP
;;;;;;;;;;;;;;;;;;;;;;;
doWait PROC C
mov dh,BYTE PTR 21
call Gotoxy ; move cursor
call Crlf
call WaitMsg
ret ; done
doWait ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
doWin PROC C USES edx
mov dh,BYTE PTR 21
call Gotoxy ; move cursor
mov edx, OFFSET winStr
call WriteString ; print "You win!"
call Crlf
call WaitMsg
ret ; done
doWin ENDP
;;;;;;;;;;;;;;;;;;;
showScore PROC C USES eax edx,
score:DWORD
;;;;;;;;;;;;;;;;;;;;;;;
; need to determine which color to use here
mov eax,15
call SetTextColor
mov dh,BYTE PTR 1
call Gotoxy ; move cursor
mov edx, OFFSET scoreStr
call WriteString ; print "score"
mov dh,BYTE PTR 2
call Gotoxy ; move cursor
mov eax,score ; for plotting the point
call WriteInt
ret ; cant forget to return
showScore ENDP
drawAvatar PROC C USES eax,
PTx:WORD, PTy:WORD
;;;;;;;;;;;;;;;;;;;;;;;
mov dh,BYTE PTR PTy
call Gotoxy ; move cursor
; need to determine which color to use here
mov eax,15 ; WHITE
call SetTextColor
mov al,2 ; smiley face icon ?
call WriteChar
ret ; cant forget to return
drawAvatar ENDP
getInput PROC C
.data
char BYTE ?
.code
call ReadChar
mov char,al
ret ;
getInput ENDP
showLOC PROC C USES eax, PTx:DWORD, PTy:DWORD
;;;;;;;;;;;;;;;;;;;;;;;
; need to determine which color to use here
mov eax,15
call SetTextColor
mov dh,BYTE PTR 3
call Gotoxy ; move cursor
mov eax,ptX ; for plotting the point
call WriteInt
mov dh,BYTE PTR 3
call Gotoxy ; move cursor
mov eax,ptY ; for plotting the point
call WriteInt
ret ; cant forget to return
showLOC ENDP
showTimer PROC C USES eax edx,
seconds:DWORD
;;;;;;;;;;;;;;;;;;;;;;;
; need to determine which color to use here
mov eax,15
call SetTextColor
mov dh,BYTE PTR 5
call Gotoxy ; move cursor
mov edx, OFFSET timerStr
call WriteString ; print "Timer"
mov dh,BYTE PTR 6
call Gotoxy ; move cursor
mov eax,seconds ; for plotting the point
call WriteInt
ret ; cant forget to return
showTimer ENDP