Scrolling Text in Asm

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

Scrolling Text in Asm

Post 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...
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

thanks

Post by matias_beretta »

thanks... :)
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post 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 :D
Post Reply