X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Fstartup.s;h=01090cd69c3fb15e81052074a423d24f5a4a092d;hp=82f548e5ae7261405f6c89390bcdb93e6fb1539b;hb=81c11bdd80190ec319a82b0402173cfb65fcbf72;hpb=53c886d3298b58a7859d3141e95b7a0e6fc6c9e8 diff --git a/src/startup.s b/src/startup.s index 82f548e..01090cd 100644 --- a/src/startup.s +++ b/src/startup.s @@ -1,5 +1,5 @@ # pcboot - bootable PC demo/game kernel -# Copyright (C) 2018 John Tsiombikas +# Copyright (C) 2018-2019 John Tsiombikas # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,6 +20,16 @@ .extern _bss_start .extern _bss_end .extern pcboot_main + .extern wait_vsync + .extern kb_getkey + + .equ STACKTOP,0x80000 + + # move the stack to the top of the conventional memory + cli + movl $STACKTOP, %esp + # push a 0 ret-addr to terminate gdb backtraces + pushl $0 # zero the BSS section xor %eax, %eax @@ -37,8 +47,38 @@ skip_bss_zero: hlt jmp 0b + # 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 + ret + .global logohack logohack: + pusha + # copy palette mov $logo_pal, %esi xor %cl, %cl @@ -128,16 +168,18 @@ xloop: incl frameno - # wait vsync - mov $0x3da, %dx -0: in %dx, %al - and $8, %al - jnz 0b -0: in %dx, %al - and $8, %al - jz 0b + call wait_vsync + + # check for escape keypress + call kb_getkey + cmp $27, %eax + jz 0f + jmp frameloop +0: popa + ret + xval: .long 0 yval: .long 0 frameno: .long 0