Skip to content

Instantly share code, notes, and snippets.

@Trimad
Created December 9, 2017 21:20
Show Gist options
  • Save Trimad/04ba06dce98c81fc447c1e514b66a945 to your computer and use it in GitHub Desktop.
Save Trimad/04ba06dce98c81fc447c1e514b66a945 to your computer and use it in GitHub Desktop.
;Tristan Madden
;10/24/2017
INCLUDE Irvine32.inc
.data
background Dword ?
foreground Dword ?
spam1 BYTE "CONGRATULATIONS, YOU'RE A WINNER!"
spam2 BYTE "YOU'VE WON!"
spam3 BYTE "You are the 999,999,999th visitor!"
.code
main proc
mov ecx, 1000h
top:
call randomColors ; my procedure
call randomPosition ; my procedure
call Gotoxy
call randomText ; my procedure
call WriteString
call Crlf
loop top
invoke ExitProcess,0
main endp
randomColors proc
mov eax, 16 ; get random background color
call RandomRange ; get random background color
shl eax, 4 ; background colors get multiplied by 16
mov background, eax ; get random background color
mov eax, 16 ; get random foreground color
call RandomRange ; get random foreground color
add eax, background ; combine the foreground and background
call SetTextColor
ret
randomColors endp
randomText proc
mov eax, 3
call RandomRange
CMP eax, 1
JL first
JE second
JG third
first:
mov edx, OFFSET spam1
JMP donezo
second:
mov edx, OFFSET spam2
JMP donezo
third:
mov edx, OFFSET spam3
donezo:
ret
randomText endp
randomPosition proc
mov eax, 69h ; random x-position
call RandomRange ; random number in al
mov dh, al ; set the row
mov eax, 99h ; random y-position
call RandomRange ; random number in al
mov dl, al ; set the col
ret
randomPosition endp
end main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment