From 91fc6b749ad3a64c9a2686952eb30be517c6beb9 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 27 Apr 2018 19:46:45 +0300 Subject: [PATCH] logohack exit on escape --- src/kmain.c | 13 +++---------- src/startup.s | 22 ++++++++++++++-------- src/video.c | 30 ++++++++++++++++++++++++++++++ src/video.h | 9 +++++++++ src/video_asm.s | 27 +++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 src/video.c create mode 100644 src/video.h create mode 100644 src/video_asm.s diff --git a/src/kmain.c b/src/kmain.c index fab4e6f..0ffc152 100644 --- a/src/kmain.c +++ b/src/kmain.c @@ -23,16 +23,8 @@ along with this program. If not, see . #include "keyb.h" #include "timer.h" #include "contty.h" -#include "int86.h" +#include "video.h" -static void set_mode13h(void) -{ - struct int86regs regs; - - memset(®s, 0, sizeof regs); - regs.eax = 0x13; - int86(0x10, ®s); -} void logohack(void); @@ -56,8 +48,9 @@ void pcboot_main(void) halt_cpu(); while((c = kb_getkey()) >= 0) { if(c >= KB_F1 && c <= KB_F12) { - set_mode13h(); + set_vga_mode(0x13); logohack(); + set_vga_mode(3); } if(isprint(c)) { printf("key: %d '%c' \n", c, (char)c); diff --git a/src/startup.s b/src/startup.s index 8041c13..0a36b67 100644 --- a/src/startup.s +++ b/src/startup.s @@ -20,6 +20,8 @@ .extern _bss_start .extern _bss_end .extern pcboot_main + .extern wait_vsync + .extern kb_getkey # move the stack to the top of the conventional memory movl $0x80000, %esp @@ -42,6 +44,8 @@ skip_bss_zero: .global logohack logohack: + pusha + # copy palette mov $logo_pal, %esi xor %cl, %cl @@ -131,16 +135,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 diff --git a/src/video.c b/src/video.c new file mode 100644 index 0000000..702273a --- /dev/null +++ b/src/video.c @@ -0,0 +1,30 @@ +/* +pcboot - bootable PC demo/game kernel +Copyright (C) 2018 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 +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY, without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "video.h" +#include +#include "int86.h" + + +void set_vga_mode(int mode) +{ + struct int86regs regs; + + memset(®s, 0, sizeof regs); + regs.eax = mode; + int86(0x10, ®s); +} diff --git a/src/video.h b/src/video.h new file mode 100644 index 0000000..645675a --- /dev/null +++ b/src/video.h @@ -0,0 +1,9 @@ +#ifndef VIDEO_H_ +#define VIDEO_H_ + +void set_vga_mode(int mode); + +/* defined in video_asm.s */ +void wait_vsync(void); + +#endif /* VIDEO_H_ */ diff --git a/src/video_asm.s b/src/video_asm.s new file mode 100644 index 0000000..1f7995c --- /dev/null +++ b/src/video_asm.s @@ -0,0 +1,27 @@ +# pcboot - bootable PC demo/game kernel +# Copyright (C) 2018 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + .text + + .global wait_vsync +wait_vsync: + mov $0x3da, %dx +0: in %dx, %al + and $8, %al + jnz 0b +0: in %dx, %al + and $8, %al + jz 0b + ret -- 1.7.10.4