Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another question :) Getting data back from the display

Status
Not open for further replies.

SmileeTiger

Programmer
Mar 13, 2000
200
0
0
US
I am in the process of printing some data to the screen in Assembly. Basically what I am doing is making a happy face slowly run accross the screen. The problem with this is that it deletes the text that was there before the happy face was so I end up with a black line on the screen. How would I go about getting the character that was displayed before I erase it so I could print it back to the screen when I am done?

Below you will find my program:

.model small
.stack 100h
.data
.code
drive proc
call clear ;clears the entire screen
call move ;Moves the smile around on the screen!
mov ax,4C00h
int 21h
drive endp




clear proc
mov ax,0b800h
mov ds,ax
mov ax, 0FDBh ;WHITE BLOCK character on a black backgroubd
next:

mov [bx],ax ;Places blank character onthe screen
add bx,2 ;Moves over one loaction
cmp bx,0FA0h ;Checks to see if we are at the end of the display
jl next ;if we aren't at the end keep moving
ret
clear endp


move proc
mov ax,0B800h ;The start of the display
mov ds,ax
mov ax,02001h ;AH=Blank character AL=:)
mov bx,0A00h ;BX points the the leftmost possition
again:
***I want to get the character from the screen here
mov [bx],al ;Draws a smile on the loaction
call delay
***I want to write the old character to the screen now
add bx,2
cmp bx,0AA0h
jl again
ret
move endp

delay proc
mov cx,070h
outer:
dec cx
jl done
mov dx,0
inner:
inc dx
jne inner
jmp outer
done:
ret
delay endp
end drive


Thanks for your help
Smilee
 
Hi SmileeTiger,

From what I gather from your code, you are writing directly to screen memory. So to get the already-displayed character, simply read from that particular memory location and store it in a variable before printing the smiley to the screen.

Hope that helps.
 
Actually that's what I want to do but I am not sure how to do it :p
 
Hi,

I will try to modify it for you below:

oldchar db ?

move proc
mov ax,0B800h ;The start of the display
mov ds,ax
mov bx,0A00h ;BX points the the leftmost possition
again:
mov al, [bx]
mov oldchar, al
mov ax, 2001h
mov [bx],al ;Draws a smile on the loaction
call delay
mov al, oldchar
mov [bx], al
add bx,2
cmp bx,0AA0h
jl again
ret
move endp

I hope the above helps. :))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top