Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- mouseX dw ?
- mouseY dw ?
- button dw ?
- myStr db "Vinnie is Great"
- myColor db 1111b
- strLength dw 15
- blank_mes db " "
- row db ?
- col db ?
- key db ?
- .code
- main:
- call init
- call clearScreen
- call disableBlink
- call displayMouse
- call getButtonPress
- call exit
- Proc PrintLeft
- repeater:
- call PrintString
- call Delay
- call PrintBlank
- cmp col, 0
- jz finito
- dec col
- jmp repeater
- finito:
- RET
- ENDP PrintLeft
- Proc Print2Bottom
- repeat:
- call PrintString
- call Delay
- call PrintBlank
- cmp row, 25
- jz finished
- inc row
- jmp repeat
- finished:
- RET
- ENDP Print2Bottom
- Proc PrintString
- ; Print a $ Terminated String
- push ax bx cx dx
- mov ah, 13h
- mov al, 1
- mov bh, 0
- mov bl, myColor
- mov cx, strLength
- mov dh, row
- mov dl, col
- mov bp, OFFSET myStr
- INT 10h
- pop dx cx bx ax
- RET
- ENDP PrintString
- ; === PROC WAIT ===
- PROC Delay
- push si di ; save SI and DI on Stack
- mov si, 0FFFh ; load si with 1000
- reload_di:
- mov di, 0FFFFh ; load di with FFFF (64,000)
- dec_again:
- dec di ; DECrease DI by 1 (di=di-1;)
- jnz dec_again ; JUMP NOT ZERO (di!=0) to
- ; LABEL called dec_again
- dec si ; DECreases SI (si=si-1;)
- jnz reload_di ; JUMP NOT ZERO (si!=0) to
- ; LABEL called reload_di
- pop di si ; restore SI and DI from Stack
- RET
- ENDP Delay
- ;===============
- PROC PrintBlank
- push ax bx cx dx bp
- mov al, 1
- mov bh, 0
- mov bl, myColor
- mov cx, strLength
- mov dl, COL
- mov dh, ROW
- mov bp, offset blank_mes
- mov ah, 13h
- int 10h
- pop bp dx cx bx ax
- RET
- ENDP PrintBlank
- PROC init
- push ax
- mov ax, @DATA
- mov ds, ax
- mov es, ax
- pop ax
- RET
- ENDP init
- PROC disableBlink
- push ax bx
- mov ax, 1003h
- mov bl, 0
- int 10h
- pop bx ax
- RET
- ENDP disableBlink
- PROC displayMouse
- push ax
- mov ax,01h ; display mouse cursorm
- int 33H
- pop ax
- RET
- ENDP displayMouse
- PROC getMousePos
- push ax bx cx dx
- mov ax, 03h
- int 33h
- shr cx, 3
- mov col, cl
- shr dx, 3
- mov row, dl
- mov button, bx
- pop dx cx bx ax
- RET
- ENDP getMousePos
- PROC getKeyPress
- push ax
- mov ah, 01
- int 16h
- jz done
- mov ah, 8
- int 21h
- mov key, al
- cmp KEY, 'r'
- jnz try_y
- mov myColor, 40h
- jmp done
- try_y:
- cmp KEY, 'y'
- jnz try_w
- mov myColor, 0E0h
- jmp done
- try_w:
- cmp KEY, 'w'
- jnz try_c
- mov myColor, 0F0h
- jmp done
- try_c:
- cmp KEY, 'c'
- jnz try_x
- call clearScreen
- jmp done
- try_x:
- cmp KEY, 'x'
- jnz done
- call exit
- done:
- mov key, ?
- pop ax
- RET
- ENDP getKeyPress
- PROC getButtonPress
- push ax
- loopa:
- call getMousePos
- call getKeyPress
- cmp button, 00h
- je loopa
- cmp button, 01h
- jnz try_2
- call Print2Bottom ;Left Pressed. Do this.
- jmp loopa
- try_2:
- cmp button, 02h
- jnz try_3
- call PrintLeft ;Right Pressed. Do something.
- jmp loopa
- try_3:
- cmp button, 03h
- call exit ;Both Pressed. Do something.
- jmp loopa
- pop ax
- RET
- ENDP getButtonPress
- PROC printStr
- push ax bx cx dx
- mov ah, 13h
- mov al, 1
- mov bh, 0
- mov bl, myColor
- mov cx, strLength
- mov dh, row
- mov dl, col
- mov bp, OFFSET myStr
- INT 10h
- pop dx cx bx ax
- RET
- ENDP printStr
- PROC changeCol
- add myColor, 10h
- RET
- ENDP changeCol
- PROC clearScreen
- push ax bx cx dx
- mov bh, 07h
- mov al, 0
- mov cx, 0
- mov dx, 184fh
- mov ah, 7h
- INT 10h
- pop dx cx bx ax
- RET
- ENDP clearScreen
- PROC exit
- push ax
- mov ah, 4ch
- INT 21h
- pop ax
- RET
- ENDP exit
- end main;
Add Comment
Please, Sign In to add comment