Page 1 of 1
Scrolling Text in Asm
Posted: Sun Sep 16, 2007 7:30 am
by matias_beretta
Hello, thanks for reading my topic...
I want to scroll everything one line up so i've to
move the memory 160-4000 to 0
160 (START OF THE SECOND LINE)
4000 = 25 * 80 * 2 (EVERYTHING!)
IS THIS CORRECT?
Well, I'm sorry about my bad english, I'm from Argentina...
Posted: Sun Sep 16, 2007 8:36 am
by frank
Everything looks fine to me, one more thing though you should clear the last line by setting it too spaces when you are done with the move operation.
thanks
Posted: Sun Sep 16, 2007 8:48 am
by matias_beretta
thanks...
Posted: Sun Sep 16, 2007 8:49 am
by mohammed
hope this code help you it's from bran's kernel
http://osdever.net/bkerndev/index.php
Code: Select all
/* These define our textpointer, our background and foreground
* colors (attributes), and x and y cursor coordinates */
unsigned short *textmemptr;
int attrib = 0x0F;
int csr_x = 0, csr_y = 0;
/* Scrolls the screen */
void scroll(void)
{
unsigned blank, temp;
/* A blank is defined as a space... we need to give it
* backcolor too */
blank = 0x20 | (attrib << 8);
/* Row 25 is the end, this means we need to scroll up */
if(csr_y >= 25)
{
/* Move the current text chunk that makes up the screen
* back in the buffer by a line */
temp = csr_y - 25 + 1;
memcpy (textmemptr, textmemptr + temp * 80, (25 - temp) * 80 * 2);
/* Finally, we set the chunk of memory that occupies
* the last line of text to our 'blank' character */
memsetw (textmemptr + (25 - temp) * 80, blank, 80);
csr_y = 25 - 1;
}
}
definition of functions that used
Code: Select all
void *memcpy(void *dest, const void *src, size_t count)
{
const char *sp = (const char *)src;
char *dp = (char *)dest;
for(; count != 0; count--) *dp++ = *sp++;
return dest;
}
void *memset(void *dest, char val, size_t count)
{
char *temp = (char *)dest;
for( ; count != 0; count--) *temp++ = val;
return dest;
}
unsigned short *memsetw(unsigned short *dest, unsigned short val, size_t count)
{
unsigned short *temp = (unsigned short *)dest;
for( ; count != 0; count--) *temp++ = val;
return dest;
}
i know that you asked about asm but understanding the main idea may be helpful