keyboard input
This commit is contained in:
1 parent
0b492655f6
commit
720595ae80
2 files changed
+83
-11
No files matched your search
+68
-11
@@ -3,9 +3,13 @@
|
||||
%define GDT (GDT_Paragraph*16)
|
||||
%define GDT_CodeSegIndex 1
|
||||
%define GDT_DataSegIndex 2
|
||||
%define GDT_CodeSeg16Index 3
|
||||
%define GDT_DataSeg16Index 4
|
||||
%define GDT_Selector(DescriptorIndex, TableIndicator, RequestorPrivLevel) ((DescriptorIndex << 3) | ((TableIndicator & 1) << 2) | (RequestorPrivLevel & 0x3))
|
||||
%define GDT_CodeSegmentSelector GDT_Selector(GDT_CodeSegIndex, 0, 0)
|
||||
%define GDT_DataSegmentSelector GDT_Selector(GDT_DataSegIndex, 0, 0)
|
||||
%define GDT_CodeSegSelector GDT_Selector(GDT_CodeSegIndex, 0, 0)
|
||||
%define GDT_DataSegSelector GDT_Selector(GDT_DataSegIndex, 0, 0)
|
||||
%define GDT_CodeSeg16Selector GDT_Selector(GDT_CodeSeg16Index, 0, 0)
|
||||
%define GDT_DataSeg16Selector GDT_Selector(GDT_DataSeg16Index, 0, 0)
|
||||
|
||||
%define VIDEO 0xB8000
|
||||
|
||||
@@ -185,17 +189,22 @@ Go32Bit:
|
||||
xor di, di
|
||||
rep movsb
|
||||
|
||||
%assign GDT_SIZE 0
|
||||
%assign GDT_COUNT 0
|
||||
|
||||
GDT_NULL_ENTRY 0
|
||||
%assign GDT_SIZE (GDT_SIZE+8)
|
||||
%assign GDT_COUNT (GDT_COUNT+1)
|
||||
|
||||
GDT_ENTRY (GDT_CodeSegIndex*8), 0x00000000, 0xffffffff, CodeRead, 0, 1
|
||||
%assign GDT_SIZE (GDT_SIZE+8)
|
||||
%assign GDT_COUNT (GDT_COUNT+1)
|
||||
|
||||
GDT_ENTRY (GDT_DataSegIndex*8), 0x00000000, 0xffffffff, DataMutable, 0, 1
|
||||
%assign GDT_SIZE (GDT_SIZE+8)
|
||||
%assign GDT_COUNT (GDT_COUNT+1)
|
||||
|
||||
GDT_ENTRY (GDT_CodeSeg16Index*8), 0x00000000, 0xffffffff, CodeRead, 0, 0
|
||||
%assign GDT_COUNT (GDT_COUNT+1)
|
||||
|
||||
GDT_ENTRY (GDT_DataSeg16Index*8), 0x00000000, 0xffffffff, DataMutable, 0, 0
|
||||
%assign GDT_COUNT (GDT_COUNT+1)
|
||||
|
||||
cli
|
||||
lgdt [GDT_Record]
|
||||
@@ -215,10 +224,10 @@ ClearPrefetchQueue:
|
||||
db 0x66 ; 32bit override
|
||||
db 0xea ; Long jump
|
||||
dd ProtectedModeBaby ; Absolute address
|
||||
dw GDT_CodeSegmentSelector ; Descriptor Selector
|
||||
dw GDT_CodeSegSelector ; Descriptor Selector
|
||||
|
||||
GDT_Record:
|
||||
dw GDT_SIZE - 1 ; Size of GDT in bytes minus 1
|
||||
dw (GDT_COUNT*8) - 1 ; Size of GDT in bytes minus 1
|
||||
dd 0x1000*16 ; Linear address of GDT
|
||||
|
||||
|
||||
@@ -229,12 +238,12 @@ BITS 32
|
||||
GO32_COPY_BEGIN:
|
||||
|
||||
segment Go32Bit vstart=GDT
|
||||
GDT_SPACE: times 3 dq 0
|
||||
GDT_SPACE: times (GDT_COUNT*8) db 0
|
||||
|
||||
ProtectedModeBaby:
|
||||
|
||||
; Update Other Segments
|
||||
mov ax, GDT_DataSegmentSelector
|
||||
mov ax, GDT_DataSegSelector
|
||||
mov ds, ax
|
||||
mov ss, ax
|
||||
mov es, ax
|
||||
@@ -244,6 +253,7 @@ ProtectedModeBaby:
|
||||
; Setup stack
|
||||
mov esp, 0xffffffff
|
||||
|
||||
DrawStuff:
|
||||
mov ecx, 0
|
||||
mov edx, 0
|
||||
lea edi, [VIDEO]
|
||||
@@ -280,7 +290,51 @@ BreakLoopRows:
|
||||
|
||||
WriteProtectedModeString:
|
||||
cld
|
||||
lea esi, [ProtectedWelcomeStr]
|
||||
|
||||
xor eax, eax
|
||||
|
||||
in al, 0x60 ; Get the scan code from the keyboard
|
||||
; mov byte [0x98765], al
|
||||
; cmp al, 0x01
|
||||
; je .ThereWasNothing
|
||||
; cmp al, 0x2A ; Left Shift Make
|
||||
; je .ThereWasNothing
|
||||
; cmp al, 0x36 ; Right Shift Make
|
||||
; je .ThereWasNothing
|
||||
; cmp al, 0xAA ; Left Shift Break
|
||||
; je .ThereWasNothing
|
||||
; cmp al, 0xB6 ; Right Shift Break
|
||||
; je .ThereWasNothing
|
||||
cmp al, 0x4b; left
|
||||
je .KeyLeft
|
||||
cmp al, 0x48; up
|
||||
je .KeyUp
|
||||
cmp al, 0x50; right
|
||||
je .KeyDown
|
||||
cmp al, 0x4d; down
|
||||
je .KeyRight
|
||||
; test al, 0x80
|
||||
; je .ThereWasSomething
|
||||
.ThereWasNothing:
|
||||
mov [Key], byte ' '
|
||||
jmp .AfterThereWasSomething
|
||||
; lea esi, [ProtectedWelcomeStr]
|
||||
|
||||
|
||||
.KeyLeft:
|
||||
mov [Key], byte 'L'
|
||||
jmp .AfterThereWasSomething
|
||||
.KeyUp:
|
||||
mov [Key], byte 'U'
|
||||
jmp .AfterThereWasSomething
|
||||
.KeyRight:
|
||||
mov [Key], byte 'R'
|
||||
jmp .AfterThereWasSomething
|
||||
.KeyDown:
|
||||
mov [Key], byte 'D'
|
||||
.AfterThereWasSomething:
|
||||
lea esi, [ThereWasSomethingStr]
|
||||
|
||||
lea edi, [VIDEO+(80*2)*12+19*2]
|
||||
.print_loop:
|
||||
mov al, BYTE [esi]
|
||||
@@ -294,6 +348,7 @@ WriteProtectedModeString:
|
||||
jmp .print_loop
|
||||
.break_print_loop:
|
||||
|
||||
jmp WriteProtectedModeString
|
||||
HALT:
|
||||
cli
|
||||
hlt
|
||||
@@ -303,4 +358,6 @@ HALT:
|
||||
;; Strings
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
ProtectedWelcomeStr: db " Placeholder for SingOS - 32 bit edition! ", 0
|
||||
ThereWasSomethingStr: db " KEY = '"
|
||||
Key: db " ' ", 0
|
||||
align 512
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
%define IDTGateTypeTask32 5
|
||||
%define IDTGateTypeInt16 6
|
||||
%define IDTGateTypeTrap16 7
|
||||
%define IDTGateTypeInt32 14
|
||||
%define IDTGateTypeTrap32 15
|
||||
|
||||
struc IDTE32 ; Interrupt Descriptor Table Entry 32-bit
|
||||
.OffsetLow: resw ; offset bits 0..15
|
||||
.CodeSegmentSelector: resw ; a code segment selector in GDT or LDT
|
||||
.UnusedZero: resb ; unused, set to 0
|
||||
.GateType: resb ; type and attributes, see below
|
||||
.OffsetHigh: resw ; offset bits 16..31
|
||||
endstruc
|
||||
|
||||
Reference in new issue
Block a user