scrolling up help
Re:scrolling up help
Okay before coding write out steps that will achieve what you want ie an algorithm (always helps ;D )
to scroll up
1. set source pointer to line 2
2. set dest pointer to line 1
3. copy data at source ptr to dest pointer
4. increment source pointer to next line
5. increment destination pointer to next line
6. if source pointer > line 25 goto 8
7. goto 3
8. end
but to scroll down
1. set source pointer to line 24
2. set dest pointer to line 25
3. copy data at source ptr to dest pointer
4. decrement source pointer to next line
5. decrement destination pointer to next line
6. if source pointer < line 1 goto 8
7. goto 3
8. end
so in the scroll down code change
mov ebx, 0xb80a0 ; Start of line 2
mov ecx, 0xb8000 ; Start of video memory
to
mov ebx, 0xb8e60 ; Start of line 24
mov ecx, 0xb8f00 ; Start of line 25
change all
cmp ebx, 0xb8fa0 ; Compare for the start
to
cmp ebx,0xb8000
Try this and get back to us!! ;D
to scroll up
1. set source pointer to line 2
2. set dest pointer to line 1
3. copy data at source ptr to dest pointer
4. increment source pointer to next line
5. increment destination pointer to next line
6. if source pointer > line 25 goto 8
7. goto 3
8. end
but to scroll down
1. set source pointer to line 24
2. set dest pointer to line 25
3. copy data at source ptr to dest pointer
4. decrement source pointer to next line
5. decrement destination pointer to next line
6. if source pointer < line 1 goto 8
7. goto 3
8. end
so in the scroll down code change
mov ebx, 0xb80a0 ; Start of line 2
mov ecx, 0xb8000 ; Start of video memory
to
mov ebx, 0xb8e60 ; Start of line 24
mov ecx, 0xb8f00 ; Start of line 25
change all
cmp ebx, 0xb8fa0 ; Compare for the start
to
cmp ebx,0xb8000
Try this and get back to us!! ;D
Re:scrolling up help
_Scroll:
push eax
push ebx
push ecx
push edx
mov ebx, 0xb8e60 ; Start of line 24
mov edx, 0xb8f00 ; Start of line 25
mov ecx, 0x28 ;there a 40 dwords per line
.ScrollLoop:
mov eax, dword [ebx] ; Get the DWORD
mov dword [edx], eax ; Copy it
add ebx, 4 ; Increment address 1
add edx, 4 ; Increment address 2
loop .ScrollLoop
mov ecx,0x28
sub ebx,0x140 ;move ebx one line up
sub edx,0x140 ;move edx one line up
cmp ebx,0xb8000
jne .ScrollLoop
.scrollDone:
mov ecx,0x28
mov dword [ebx], 0x00070007 ; Clear the first dword of line 1(ebx = the start of line 1)
add ebx, 4 ; Increment the address
loop .ScrollDone
pop edx
pop ecx
pop ebx
pop eax
ret
try this one instead (i'm at work so can't compile & test)
push eax
push ebx
push ecx
push edx
mov ebx, 0xb8e60 ; Start of line 24
mov edx, 0xb8f00 ; Start of line 25
mov ecx, 0x28 ;there a 40 dwords per line
.ScrollLoop:
mov eax, dword [ebx] ; Get the DWORD
mov dword [edx], eax ; Copy it
add ebx, 4 ; Increment address 1
add edx, 4 ; Increment address 2
loop .ScrollLoop
mov ecx,0x28
sub ebx,0x140 ;move ebx one line up
sub edx,0x140 ;move edx one line up
cmp ebx,0xb8000
jne .ScrollLoop
.scrollDone:
mov ecx,0x28
mov dword [ebx], 0x00070007 ; Clear the first dword of line 1(ebx = the start of line 1)
add ebx, 4 ; Increment the address
loop .ScrollDone
pop edx
pop ecx
pop ebx
pop eax
ret
try this one instead (i'm at work so can't compile & test)
Re:scrolling up help
When I compiled it with nasm, it gave me a invalid combination of opcodes and operads.
This is for these lines:
.Scrollloop:
inc ebx, 4 ; Increment address 1
inc edx, 4 ; Increment address 2
.ScrollDone:
inc ebx, 4 ; Increment the address
How would I fix this?
This is for these lines:
.Scrollloop:
inc ebx, 4 ; Increment address 1
inc edx, 4 ; Increment address 2
.ScrollDone:
inc ebx, 4 ; Increment the address
How would I fix this?
Re:scrolling up help
change inc to add ( i've done so to the code above)
sorry about that, rushed the coding and no testing done either ;D
sorry about that, rushed the coding and no testing done either ;D
Re:scrolling up help
OK, How hopless is this, as soon as I posted the routines above I realized that they have a bug >:(. Anyway, it is only minor, when you download the code open it up and at the start of both routines there is a test for a number of lines that is > 24, there should also be one that tests for a number of lines < 0 so just add this directly after the test for > 24:
cmp eax, 1 ; Can Only Do 1+ Lines
jl .InvalidLineCount
This will catch negative values passed, you would run into big problems if you pass -1 to these routines (-1 = 4294967295) so you could image trying to scroll 4294967295 lines :-\
cmp eax, 1 ; Can Only Do 1+ Lines
jl .InvalidLineCount
This will catch negative values passed, you would run into big problems if you pass -1 to these routines (-1 = 4294967295) so you could image trying to scroll 4294967295 lines :-\
Re:scrolling up help
Thanks for the code, but I have one problem with it. I added the line that you told me to, which was both of the functions.
Scrollup worked fine, but when I tried the Scrolldown, it reset my computer.
What could be the problem?
Scrollup worked fine, but when I tried the Scrolldown, it reset my computer.
What could be the problem?
Re:scrolling up help
Hmm.. This is not good. I tried it in Bochs and then on a Real PC and both worked fine.
Have you tried it without this test for < 1?
What value are you passing it?
What is the specification of your system?
I am hoping that one of these question holds the answer to the problem.
Have you tried it without this test for < 1?
What value are you passing it?
What is the specification of your system?
I am hoping that one of these question holds the answer to the problem.
Re:scrolling up help
Both functions require 1 argument, that is the number of lines to scroll, this is the value I am talking about, are you passing this argument?