Hi there. I am trying to make a program that outputs the word "MATRIX" on every line, with the past line being cleared and making some kind of falling word effect. I am beginning learning assembly, and I need some ideas as to how to make this happen. I am using the Irvine32 library. Right now my current code is this:

TITLE Falling Letters Program	       (main.asm)
;This program displays falling letters 

INCLUDE Irvine32.inc

.data
msg BYTE "MATRIX", 0

.code
main PROC
L1:
	mov edx, OFFSET msg
	call WriteString
	mov eax, 1000
	call delay
	call Clrscr
	call crlf
	loop L1
	exit
main ENDP
END main

Right now what it does it print out "MATRIX" on the console, erase that line, wait 1 second, and print the word again on the next line. How can I make it so that instead of doing that forever, it can start at the top of the screen again after reaching the bottom of the screen? If I could get that working, I could the proceed to modify the program so it can resemble the falling letter from the matrix movies (my teacher wants us to do a much less impressive program than the one on the movie haha, hence using the word matrix to test the program before actually using single characters)

Recommended Answers

All 2 Replies

Try to use the MASM library "msvcrt.inc", in this library you can use the C function Printf e ScanF, like this example:

PUSH OFFSET Str1 ;move Str1 to the pill
      CALL crt_printf	;call the printf function
	ADD ESP,4

Thanks for the info. Unfortunately, I am only allowed to use the Irvine Library. I have worked on the code much more, and got it to the point where a line of random characters scrolling from the top to the bottom, and when it reaches the bottom, it starts back up at the top in a different x coordinate. The length of the number of random characters is random. I need one more thing to make this program complete, and that's to have multiple lines of random characters scrolling top to bottom at the same time. Just like the program does, but more than one at a time. Any ideas?

INCLUDE Irvine32.inc

.data
randval DWORD ? ;random x coordinate


.code
main PROC
	mov eax,green +(black*16)
	call SetTextColor
t1:	call RandomXCoordinate
	mov eax, randval
	mov dl, al		;x coordinate. Need a function to get a random x coordinate. We would not need to increase dl because of random number
	mov dh, 0		;y coordinate
	call Clrscr 

	mov eax, 24		;Set loop counter at ramdom  number between 24 and 10 to make varying string lengths
	call RandomRange
	add eax, 10
	mov ecx, eax	

L1:	
	mov eax, randval
	mov dl, al		;x coordinate. Need a function to get a random x coordinate. 
	call gotoxy


	mov eax, 93		;get a random character into eax to display
	call RandomRange
	add eax, 33
	call writechar

	mov eax, 100	;1/10 second printing delay
	call delay
	inc dh			;Increase y-coordinate 
	call gotoxy
	loop L1

	loop t1			;repeat falling animation from start

main ENDP

RandomXCoordinate PROC ;this function gives a random number to use as x coordinate
	mov eax, 79	
	call RandomRange
	mov randval, eax
	ret
RandomXCoordinate ENDP
END main
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.