- .global logohack
-logohack:
- pusha
-
- # copy palette
- mov $logo_pal, %esi
- xor %cl, %cl
-
-0: xor %eax, %eax
- mov $0x3c8, %dx
- movb %cl, %al
- outb %al, %dx
- inc %dx
- # red
- movb (%esi), %al
- inc %esi
- shr $2, %al
- outb %al, %dx
- # green
- movb (%esi), %al
- inc %esi
- shr $2, %al
- outb %al, %dx
- # blue
- movb (%esi), %al
- inc %esi
- shr $2, %al
- outb %al, %dx
- add $1, %cl
- jnc 0b
-
- # copy pixels
- mov $sintab, %ebp
- mov $logo_pix, %esi
-frameloop:
- mov $0xa0000, %edi
- movl $0, yval
-yloop:
- movl $0, xval
-xloop:
- # calc src scanline address -> ebx
- xor %ecx, %ecx
- mov yval, %ebx
- shl $2, %ebx
- add frameno, %ebx
- and $0xff, %ebx
- mov (%ebp, %ebx), %cl
- shr $5, %ecx
-
- mov yval, %eax
- add %ecx, %eax
- # bounds check
- cmp $200, %eax
- jl 0f
- mov $199, %eax
-
-0: mov %eax, %ebx
- shl $8, %eax
- shl $6, %ebx
- add %eax, %ebx
-
- # calc src x offset -> eax
- xor %ecx, %ecx
- mov xval, %eax
- shl $2, %eax
- add frameno, %eax
- and $0xff, %eax
- mov (%ebp, %eax), %cl
- shr $5, %ecx
-
- mov xval, %eax
- add %ecx, %eax
- # bounds check
- cmp $320, %eax
- jl 0f
- mov $319, %eax
-
-0: add %eax, %ebx
- mov (%ebx, %esi), %al
-
- mov %al, (%edi)
- inc %edi
-
- incl xval
- cmpl $320, xval
- jnz xloop
-
- incl yval
- cmpl $200, yval
- jnz yloop
-
- incl frameno
-
- call wait_vsync
-
- # check for escape keypress
- call kb_getkey
- cmp $27, %eax
- jz 0f
-
- jmp frameloop
-
-0: popa
+ # this is called once after memory init, to move the protected mode
+ # stack to the top of usable memory, to avoid interference from 16bit
+ # programs (as much as possible)
+ .global move_stack
+move_stack:
+ # calculate the currently used lowest address of the stack (rounded
+ # down to 4-byte alignment), to see where to start copying
+ mov %esp, %esi
+ and $0xfffffffc, %esi
+ # calculate the size we need to copy
+ mov $STACKTOP, %ecx
+ sub %esi, %ecx
+ # load the destination address to edi
+ mov 4(%esp), %edi
+ sub %ecx, %edi
+ # size in longwords
+ shr $2, %ecx
+
+ # change esp to the new stack
+ mov $STACKTOP, %ecx
+ sub %esp, %ecx
+ mov 4(%esp), %eax
+ mov %eax, %esp
+ sub %ecx, %esp
+
+ rep movsd