LtG wrote:Not sure what your issue is, but here's a few notes:
- You don't seem to have ORG anywhere? Maybe it's outside of the code snippet you provided
- Is there a reason you are clearing SP specifically BP? Can't see it affecting your issue though
- Is there a reason you push and pop AX at the bottom of your code? What effect is that supposed to have?
- In your "begin" code you are not initializing BX which I think is used by int 0x10, therefore in VM (Qemu) it might be left at zero while on real hardware it could be anything
Last one being your issue is my guess, or maybe first.. So add to your begin after "xor ax, ax":
mov bx, ax
The orgin point is specified in the linker script. I clear the bx now like you said, didn't change anything. I'd like to add that this simple keyboard loop does work on my friend's laptop even before adding mov bx, ax. However, the VSYNC still doesn't work and I can't even change the colors.
Here's what I'm doing.
Enter the 320x200@256 mode
Enter protected Mode
Setup interrupts..
Fill the framebuffer with color lines (0-15, then it repeats)
Now I'm in an infinite loop and in it I call VSYNC_WAIT and CYCLE_COLORS. Cycle colors just changes the first 16 colors to create a moving bars effect. On a virtual machine it works, but way too fast because the VSYNC fails, on real hardware I can't even change the colors.
Vsync in a virtual machine is a rather unusual requirement. Vsync using a virtual machine's VGA compatibility layer instead of the VM's native graphics device is unheard of.
If that's the case, what should I do to get a stable image ? I have to sync with VSYNC, otherwise I will get tears.
Code: Select all
globl CHANGE_VGA_COLOR
.type CHANGE_VGA_COLOR, @function
CHANGE_VGA_COLOR:
push ebp
mov ebp, esp
mov dx, 0x3C8 /* VGA port for color index */
mov eax, [ebp+8] /* pop the color index from the stack */
out dx, ax /* out it to the port 0x3C8 */
inc dx /* now the port is 0x3C9 */
mov eax, [ebp+12] /* pop the red */
out dx, ax
mov eax, [ebp+16] /* pop green */
out dx, ax
mov eax, [bp+20] /* pop blue */
out dx, ax
mov esp, ebp
pop ebp
ret
.globl CYCLE_COLORS
.type CYCLE_COLORS, @function
CYCLE_COLORS:
push eax
push ebx
push ecx
push edi
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
CYCLE_loop:
cmp ecx, 16
je CYCLE_end_of_loop
movzx ebx, byte ptr [colorcounter]
add ebx, ecx
and ebx, 15
/*add ebx, colortable this will add whatever that is at colortable instead of the address of colortable itself*/
lea edx, colortable
add ebx, edx
movzx eax, byte ptr [ebx+2]
push eax
movzx eax, byte ptr [ebx+1]
push eax
movzx eax, byte ptr [ebx]
push eax
push ecx
call CHANGE_VGA_COLOR
add esp, 16
inc ecx
jmp CYCLE_loop
CYCLE_end_of_loop:
inc byte ptr [colorcounter]
pop edx
pop ecx
pop ebx
pop eax
ret