News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Keyboard Driver

Started by Farabi, May 26, 2012, 04:35:16 PM

Previous topic - Next topic

Farabi



PortWait proc a_type:dword

;A read from port 64H gives the following status byte:
;
;   Bit     Function
;    7      1 = Parity error
;    6      1 = General Time Out
;    5      1 = Auxiliary output buffer full
;    4      1 = Inhibit switch
;    3      1 = Command/data
;    2      1 = System flag
;    1      1 = Input buffer full
;    0      1 = Output buffer full
cli
.if a_type==WAIT_READ
wait_type_0:
in al,64h
bt ax,6
jc error
bt ax,7
jc error
bt ax,WAIT_READ ; if bit 3 set data is available at 64h
jnc wait_type_0
xor eax,eax
.elseif a_type==WAIT_WRITE
wait_type_1: ; Bit 1 should be zero before we able to send command
in al,64h
bt ax,6
jc error
bt ax,7
jc error
bt ax,WAIT_WRITE
jc wait_type_1
xor eax,eax
.elseif a_type==WAIT_COMMAND
wait_type_2: ; Bit 0 and 1 should be zero before we able to send command
in al,64h
bt ax,6
jc error
bt ax,7
jc error
bt ax,WAIT_COMMAND
jc wait_type_2
xor eax,eax
.elseif a_type==WAIT_READ60
wait_type_4:
in al,64h
bt ax,6
jc error
bt ax,7
jc error
bt ax,WAIT_READ ; if bit 3 not set data is available at 60h
jc wait_type_4
xor eax,eax
.elseif a_type==WAIT_OUTPUT
wait_type_5:
in al,64h
bt ax,6
jc error
bt ax,7
jc error
bt ax,WAIT_OUTPUT ; if bit 3 set data is available at 64h
jnc wait_type_5
xor eax,eax
.endif

error:
sti
ret
PortWait endp

PortRead proc

invoke PortWait,WAIT_READ
in al,60h

ret
PortRead endp

PortWrite proc a_cmd:byte

invoke PortWait,WAIT_WRITE
mov al,a_cmd
out 64h,al

ret
PortWrite endp

KeyBoardRead proc
LOCAL key:byte

invoke PortWrite,0AEh
invoke PortWrite,0D2h
in al,60h
; invoke PortRead
; mov key,al
; invoke PortWrite,0AEh
; mov al,key
; push eax
; push eax
; invoke dw2bin,eax,base_buffer
; invoke Print,base_buffer
; pop eax
; invoke dw2hex,eax,base_buffer
; invoke Print,base_buffer
; invoke PrintRel,addr crg
; pop eax
; invoke PortWrite,0A7h
ret
KeyBoardRead endp


Worked on my Boot sector Code. I need the information for the "magic byte" for my graphic card.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Rockphorr

Make downloads to your code please.

Farabi

http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

MichaelTripi68

What is it that you are trying to do?  You asked about "magic byte" for your video but post has keyboard attachments.

dedndave

i am not familiar with any "magic byte" for video cards
maybe the terminology is a bit off
you may be refering to an ID byte that windows uses or something
you could look in the INF files in windows\inf

MichaelW

Onan,

If this magic byte is the current video mode, you can read it from the BIOS data area (segment address 40h) at offset 49h. And if you are after the current scan lines per character, you can read it from offset 85h. And the current display page can be read from offset 62h. Although it's a word and not a byte, if you are after the base I/O port address for the active display adapter it can be read from offset 63h. There is other VGA state information available, but most of it is a little more difficult to access, requiring an interrupt call or direct access through port I/O.

Well Microsoft, here's another nice mess you've gotten us into.

dedndave

if you want to get the current video mode
        mov     ah,0Fh
        int     10h
;AL = video mode


:P

MichaelW

Dave,

Assuming that you have the segment address of the BIOS data area loaded into an appropriate segment register, presumably because you need to access multiple values, each access requires only a single instruction, instead of in the case of the current video mode an interrupt call that ultimately reads the value from the same location.

:P
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

i know - i used to use the bios data segment, a lot
instead of loading 40h, i loaded 0 into a segment register, then added 400h to all the bios data offsets
that also gets you the interrupt vector table
and - XOR AX,AX was a little better than MOV AX,40h

i still used INT 21h, AH=25h to set vectors, but i used direct reads to get current vectors