OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 2:18 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: wrote vdriver 80x25 8 color, works but problem with cursor
PostPosted: Sat Jan 23, 2016 9:32 pm 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
I ported the given simple video driver in order to bypass int21h. Here is the brief summary for this driver:

The driver is written in C but I ported to assembly.
It works and able to process NL, CR (tested) as well as BS (not tested) as well as ordinary chars and maintains offset, col, row and other variables in data segment. So anything I throw out, it prints correctly, but there is one issue: However once everything printed, the cursor always jumps to the beginning of 4rd line of screen no matter how many lines I print: 1 line, 2 line, 3 line or 40 lines. I re-checked everything and after each time the char is printed, it calculates the cursor from offset (offset=row * 80 + col), cursorPos = offset/2 since, offset is buffer offset relative to video buffer address and each char is 2 bytes (1 byte color, 1 byte char value).

When setting cursor it uses Rx = 0E to port 3d4h and sends to cursor value to 3d5h.

I set debugging outputs and can see it is sending right offsets to function.
I am wondering what else I should check? May be there is something I am missing?

Thanks.,

The code is a lot so I took out all of the debug statements as well as special char processing code removed to make it as short as possible:

Code:
data segment para public 'data'
    vidOffset   dw  0
    vidColor    dw  VIDEO_H_YELLOW
    vidOrg      dw  0
    vidRow      dw  0
    vidCol      dw  0
    vidPos      dw  0
data ends

code segment    para public use16 'code'
assume cs:code, ds:data, ss:sta

M_EXTERNDEF

;   helper function for setting the video register to specified value.
;   input   EAX[31:16]=video register to set.
;           AX = video data value to write.
;   output  CX=0 if success.
;           CX=1 if failure.
;   destroys: None

videoSetVideoRx  proc    far
    M_PUSH <dx>
    cli
    mov     dx, VIDEO_CTRL_IDX
    ror     eax, 16
    out     dx, ax

    mov     dx, VIDEO_CTRL_DATA
    ror     eax, 16
    out     dx, ax
    sti
videoSetVideoRxExit:
    M_POP <dx>
    ret
videoSetVideoRx endp

;   Initialize video buffer along with cursor and position and clears screen.
;   input   None
;   output  CX=0 if success.
;           CX=1 if failure.
;   destroys: None

videoInitCtrl proc  far
    M_PUSH  <eax, cx, ds, si>

;   set cursor size to 15.

    mov     eax, VIDEO_RX_CURSIZE SHL 16
    mov     ax, 15
    call    videoSetVideoRx

;   set display address to 0.

    mov     eax, VIDEO_RX_START_ADDR SHL 16
    mov     ax, 0
    call    videoSetVideoRx

;   set cursor position to 0.

    mov     eax, (VIDEO_RX_CURSOR_POS SHL 16)
    mov     ax, 0
    call    videoSetVideoRx

;   clear screen by writing 0700 to every word in video buffer (2000 chars = 25 * 80)

    mov     ax, VIDEO_BUFFER_BASE
    mov     ds, ax
    sub     si, si              ; (DS:SI) = video buffer pointer, b800:0000
    mov     ax, 0700h           ; (AX) = char to write.
    mov     cx, (VIDEO_BUFFER_LINE_WIDTH * VIDEO_BUFFER_LINES_PER_SCREEN) ; (CX) = size of video buffer char.

videoInitCtrlLoop1:
    mov     ds:[si], ax
    add     si, 2
    loop    videoInitCtrlLoop1

    M_POP   <si, ds, cx, eax>
    ret
videoInitCtrl endp

;   scrolls screen by one line
;   input:  None
;   output: None
;   destroys: None

videoScroll     proc  far
    M_PUSH  <ax, cx, ds, si, es, di>

    mov     ax, DATA
    mov     ds, ax              ; (DS) = data segment.

    cmp     word ptr vidOffset, VIDEO_MASK ; buffer is full? if so will scroll
    ja      videoScrollLab1

;   less than full buffer (4000h), therefore org += 2 * LINEWIDTH, just increment by one line.

    add     word ptr vidOrg, (VIDEO_BUFFER_LINE_WIDTH SHL 1) ; org increment by one line worth of bytes.
    jmp     videoScrollLab2

;   full buffer, copy last 24 lines to first 24 line and full last line with
;   empty data.

videoScrollLab1:
    mov     cx, (VIDEO_BUFFER_LINE_WIDTH * (VIDEO_BUFFER_LINES_PER_SCREEN - 1))
    mov     di, VIDEO_BUFFER_BASE
    mov     es, di              ; (ES) = base - b800h

    sub     si, si              ; (ES:SI) = first line.

    sub     di, di
    add     di, vidOrg
    add     di, 160             ; (ES:SI) = second line + org.

videoScrollLoop1:
    mov     ax, es:[di]         ; (AX) = char from ES:[DI]
    mov     es:[si], ax         ; char from ES:[DI] to ES:[SI]
    add     si, 2
    add     di, 2
    loop    videoScrollLoop1

;   update org.

videoScrollLab2:
    mov     ax, 2 * (VIDEO_BUFFER_LINE_WIDTH * (VIDEO_BUFFER_LINES_PER_SCREEN - 1))
    add     ax, vidOrg
    mov     vidOffset, ax

;   update last line with blank char-s.

    mov     di, VIDEO_BUFFER_BASE
    mov     es, di              ; (ES) = b800h, video buffer base.
    sub     di, di              ; (ES:DI) = b800h, video buffer base.
    mov     ax, 0c00h           ; HRGB=1100 highlight RED, null char.
    mov     cx, 80h             ; (CX) = char per line.

videoScrollLoop2:
    mov     es:[di], ax         ; update buffer position with blank char.
    add     di, 2
    loop    videoScrollLoop2

    M_POP   <di, es, si, ds, cx, ax>
    ret
videoScroll     endp

;   put one char (print one char on screen), and takes care of
;   details.
;   input   DL = char to print
;   output  CX=0 if success.
;           CX=1 if failure.
;   destroys: None

videoPutChar     proc  far
    M_PUSH  <eax, ebx, cx, dx>

;   c is an ordinary character.
;   pos = 2 * ( row*80 + column )

videoPutCharLab6:
    mov     ax, vidRow
    push    dx
    push    cx
    mov     cx, VIDEO_BUFFER_LINE_WIDTH
    mul     cx                  ; (DX:AX) = product of line width * vidRow
    pop     cx
    pop     dx
    add     ax, vidCol
    shl     ax, 1               ; (AX) = 2 * (vidRow * lineWidth + vidCol)
    mov     vidPos, ax

    mov     ax, vidOrg
    add     ax, vidPos
    and     ax, VIDEO_MASK      ; (AX) = (vidOrg + vidPos) & VIDEO_MASK
    mov     vidOffset, ax

;   w = color; w = (w << 8 ) + c;

    mov     ax, vidColor
    shl     ax, 8
    and     dx, 0ffh
    add     ax, dx

;   place w (in this case ax) into buffer.

    mov     di, 0b800h
    mov     es, di
    mov     di, vidOffset       ; (ES:DI) = b800:offset.

;   will update video buffer with char using 0:32 flat offset in EBX.

    M_1616_TO_FLAT32 es, di, ebx ; (EBX) = flat address of vidOffset.
    call    putWordExtMem

    inc     word ptr vidCol     ; increment col.
    cmp     word ptr vidCol, VIDEO_BUFFER_LINE_WIDTH ; col is past 80?
    jb      videoPutCharLab3

;   column is more than or equal to 80, set column to 0 and increment row by 1.

    mov     word ptr vidCol, 0h
    inc     word ptr vidRow
    cmp     word ptr vidRow, VIDEO_BUFFER_LINES_PER_SCREEN
    jb      videoPutCharLab4

;   row is more than or equal to 25, therefore, set the row at 24 and scroll 1 line.

    mov     vidRow, 24
    call    videoScroll

;   reached here when ros is less than 25.

videoPutCharLab4:

;   reached here when col is less than 80.

videoPutCharLab3:

;   calculate new offset.
;   vidPos = vidRow * lineWidth + vidCol

    mov     ax, vidRow
    push    dx
    push    cx
    mov     cx, VIDEO_BUFFER_LINE_WIDTH ;
    mul     cx
    pop     cx
    pop     dx

    add     ax, vidCol
    shl     ax, 1               ; (AX) = (vidRow * lineWidth + vidCol) * 2
    mov     vidPos, ax          ; updated the position.

;   offset = (org + post) & vid_mask

    mov     ax, vidOrg
    add     ax, vidPos
    and     ax, VIDEO_MASK      ; (AX) = (vidOrg + vidPos) & VIDEO_MASK
    mov     vidOffset, ax       ; update offset.

;   set_VDC(CURSOR, offset >> 1)

    mov     eax, (VIDEO_RX_CURSOR_POS SHL 16)
    mov     ax, vidOffset
    shr     ax, 1
    call    videoSetVideoRx

videoPutCharExit:
    M_POP   <dx, cx, ebx, eax>
    ret
videoPutChar     endp

videoDbgStatus  proc    far
    M_PRINTF "\noffset, color, org, row, col, pos: "
    IRP     vidVar, <vidOffset, vidColor, vidOrg, vidRow, vidCol, vidPos>
    M_PRINTWORD_SPC &vidVar&
    ENDM
    ret
videoDbgStatus  endp
code    ends
end


video.inc:
Code:

    VIDEO_CTRL_IDX =    3d4h
    VIDEO_CTRL_DATA =   3d5h
    VIDEO_BUFFER_BASE = 0b800h

    VIDEO_RX_CURSIZE =      0ah
    VIDEO_RX_START_ADDR =   0ch
    VIDEO_RX_CURSOR_POS =   0eH

    VIDEO_BUFFER_LINES_PER_SCREEN = 25
    VIDEO_BUFFER_LINE_WIDTH = 80
;   VIDEO_BYTES_PER_SCREEN = VIDEO_BUFFER_LINES_PER_SCREEN * VIDEO_BUFFER_LINE_WIDTH * 2
    VIDEO_RAM_SIZE_BYTE = 16*1024

    VIDEO_CURSOR_SHAPE = 15

    VIDEO_H_GREEN = 0ah
    VIDEO_H_CYAN  = 0bh
    VIDEO_H_RED   = 0ch
    VIDEO_H_PURPLE = 0dh
    VIDEO_H_YELLOW = 0eh
    VIDEO_MASK = VIDEO_RAM_SIZE_BYTE - 1 ; MASK = VIDEO RAM SIZE - 1

;   when enabled, b8000:0000 output is disabled and instead use int21h for debugging output
;   if you enable this switch, also enable OPTION_USE_INT21H otherwise
;   result is unpredictable.

    OPTION_DEBUG_VIDEO = 1
    OPTION_DEBUG_VIDEO_L2 = 0




Here is an debugging output when sending string with NL, CR:
videoModuleTestStr0 db 'Test String1 NL, CR' , 0ah, 0dh, 'Test String2', '$'
The debugg output will print out the value that is being set to videoSetVideoRx function as well as offset, color, org, row, col, pos values after each char print.

Code:

videoPutChar Entered: 54
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0000 000B8000
videoSetVideoRx: rx[31:16], val[0:15] 000E0001
offset, color, org, row, col, pos:  0002 000E 0000 0000 0001 0002
videoPutChar: done.

videoPutChar Entered: 65
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0002 000B8002
videoSetVideoRx: rx[31:16], val[0:15] 000E0002
offset, color, org, row, col, pos:  0004 000E 0000 0000 0002 0004
videoPutChar: done.

videoPutChar Entered: 73
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0004 000B8004
videoSetVideoRx: rx[31:16], val[0:15] 000E0003
offset, color, org, row, col, pos:  0006 000E 0000 0000 0003 0006
videoPutChar: done.

videoPutChar Entered: 74
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0006 000B8006
videoSetVideoRx: rx[31:16], val[0:15] 000E0004
offset, color, org, row, col, pos:  0008 000E 0000 0000 0004 0008
videoPutChar: done.

videoPutChar Entered: 20
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0008 000B8008
videoSetVideoRx: rx[31:16], val[0:15] 000E0005
offset, color, org, row, col, pos:  000A 000E 0000 0000 0005 000A
videoPutChar: done.

videoPutChar Entered: 53
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:000A 000B800A
videoSetVideoRx: rx[31:16], val[0:15] 000E0006
offset, color, org, row, col, pos:  000C 000E 0000 0000 0006 000C
videoPutChar: done.

videoPutChar Entered: 74
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:000C 000B800C
videoSetVideoRx: rx[31:16], val[0:15] 000E0007
offset, color, org, row, col, pos:  000E 000E 0000 0000 0007 000E
videoPutChar: done.

videoPutChar Entered: 72
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:000E 000B800E
videoSetVideoRx: rx[31:16], val[0:15] 000E0008
offset, color, org, row, col, pos:  0010 000E 0000 0000 0008 0010
videoPutChar: done.

videoPutChar Entered: 69
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0010 000B8010
videoSetVideoRx: rx[31:16], val[0:15] 000E0009
offset, color, org, row, col, pos:  0012 000E 0000 0000 0009 0012
videoPutChar: done.

videoPutChar Entered: 6E
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0012 000B8012
videoSetVideoRx: rx[31:16], val[0:15] 000E000A
offset, color, org, row, col, pos:  0014 000E 0000 0000 000A 0014
videoPutChar: done.

videoPutChar Entered: 67
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0014 000B8014
videoSetVideoRx: rx[31:16], val[0:15] 000E000B
offset, color, org, row, col, pos:  0016 000E 0000 0000 000B 0016
videoPutChar: done.

videoPutChar Entered: 31
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0016 000B8016
videoSetVideoRx: rx[31:16], val[0:15] 000E000C
offset, color, org, row, col, pos:  0018 000E 0000 0000 000C 0018
videoPutChar: done.

videoPutChar Entered: 20
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0018 000B8018
videoSetVideoRx: rx[31:16], val[0:15] 000E000D
offset, color, org, row, col, pos:  001A 000E 0000 0000 000D 001A
videoPutChar: done.

videoPutChar Entered: 4E
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:001A 000B801A
videoSetVideoRx: rx[31:16], val[0:15] 000E000E
offset, color, org, row, col, pos:  001C 000E 0000 0000 000E 001C
videoPutChar: done.

videoPutChar Entered: 4C
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:001C 000B801C
videoSetVideoRx: rx[31:16], val[0:15] 000E000F
offset, color, org, row, col, pos:  001E 000E 0000 0000 000F 001E
videoPutChar: done.

videoPutChar Entered: 2C
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:001E 000B801E
videoSetVideoRx: rx[31:16], val[0:15] 000E0010
offset, color, org, row, col, pos:  0020 000E 0000 0000 0010 0020
videoPutChar: done.

videoPutChar Entered: 20
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0020 000B8020
videoSetVideoRx: rx[31:16], val[0:15] 000E0011
offset, color, org, row, col, pos:  0022 000E 0000 0000 0011 0022
videoPutChar: done.

videoPutChar Entered: 43
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0022 000B8022
videoSetVideoRx: rx[31:16], val[0:15] 000E0012
offset, color, org, row, col, pos:  0024 000E 0000 0000 0012 0024
videoPutChar: done.

videoPutChar Entered: 52
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0024 000B8024
videoSetVideoRx: rx[31:16], val[0:15] 000E0013
offset, color, org, row, col, pos:  0026 000E 0000 0000 0013 0026
videoPutChar: done.

videoPutChar Entered: 0A
videoPutChar: processing new line (0x0a)
offset, color, org, row, col, pos:  00C6 000E 0000 0001 0013 00C6
videoPutChar: done.

videoPutChar Entered: 0D
videoPutChar: processing CR(0x0d)
videoSetVideoRx: rx[31:16], val[0:15] 000E0050
offset, color, org, row, col, pos:  00A0 000E 0000 0001 0000 00A0
videoPutChar: done.

videoPutChar Entered: 54
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00A0 000B80A0
videoSetVideoRx: rx[31:16], val[0:15] 000E0051
offset, color, org, row, col, pos:  00A2 000E 0000 0001 0001 00A2
videoPutChar: done.

videoPutChar Entered: 65
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00A2 000B80A2
videoSetVideoRx: rx[31:16], val[0:15] 000E0052
offset, color, org, row, col, pos:  00A4 000E 0000 0001 0002 00A4
videoPutChar: done.

videoPutChar Entered: 73
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00A4 000B80A4
videoSetVideoRx: rx[31:16], val[0:15] 000E0053
offset, color, org, row, col, pos:  00A6 000E 0000 0001 0003 00A6
videoPutChar: done.

videoPutChar Entered: 74
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00A6 000B80A6
videoSetVideoRx: rx[31:16], val[0:15] 000E0054
offset, color, org, row, col, pos:  00A8 000E 0000 0001 0004 00A8
videoPutChar: done.

videoPutChar Entered: 20
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00A8 000B80A8
videoSetVideoRx: rx[31:16], val[0:15] 000E0055
offset, color, org, row, col, pos:  00AA 000E 0000 0001 0005 00AA
videoPutChar: done.

videoPutChar Entered: 53
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00AA 000B80AA
videoSetVideoRx: rx[31:16], val[0:15] 000E0056
offset, color, org, row, col, pos:  00AC 000E 0000 0001 0006 00AC
videoPutChar: done.

videoPutChar Entered: 74
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00AC 000B80AC
videoSetVideoRx: rx[31:16], val[0:15] 000E0057
offset, color, org, row, col, pos:  00AE 000E 0000 0001 0007 00AE
videoPutChar: done.

videoPutChar Entered: 72
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00AE 000B80AE
videoSetVideoRx: rx[31:16], val[0:15] 000E0058
offset, color, org, row, col, pos:  00B0 000E 0000 0001 0008 00B0
videoPutChar: done.

videoPutChar Entered: 69
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00B0 000B80B0
videoSetVideoRx: rx[31:16], val[0:15] 000E0059
offset, color, org, row, col, pos:  00B2 000E 0000 0001 0009 00B2
videoPutChar: done.

videoPutChar Entered: 6E
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00B2 000B80B2
videoSetVideoRx: rx[31:16], val[0:15] 000E005A
offset, color, org, row, col, pos:  00B4 000E 0000 0001 000A 00B4
videoPutChar: done.

videoPutChar Entered: 67
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00B4 000B80B4
videoSetVideoRx: rx[31:16], val[0:15] 000E005B
offset, color, org, row, col, pos:  00B6 000E 0000 0001 000B 00B6
videoPutChar: done.

videoPutChar Entered: 32
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:00B6 000B80B6
videoSetVideoRx: rx[31:16], val[0:15] 000E005C
offset, color, org, row, col, pos:  00B8 000E 0000 0001 000C 00B8
videoPutChar: done.





_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sat Jan 23, 2016 10:11 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

The VGA's CRT controller registers are all 8-bit registers. You're writing 16-bits, which is not 8-bits, and the device probably ignores "writes of wrong size" instead of trying to jam 16-bits into an 8-bit register (or worse, does something bizarre).

If the device is awkwardly broken and tries to split a write to one register across 2 completely separate registers (which is at least theoretically possible given that no modern computer actually has a "100% VGA compatible at the hardware level" video card); then 80x86 is little-endian, which means that when updating the cursor position AL would go to the controller's "cursor location high" register and AH would go to the controllers "cursor location low" register.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sat Jan 23, 2016 11:13 pm 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
Oh i see, so this must be the correct one?

http://wiki.osdev.org/Text_Mode_Cursor

Well i followed this exactly and modified my code

For the sake, I decided to keep videoSetVideoRx function but change it to output 8-bit AL to video ports and define new function videoSetCursor where it manipulates the hi and low and callls videoSetRx. Well I can say result is pretty much same, well still not working. Now the caller of function videoSetVideoRx still passes value in AX but AH is just going to be ignored and I made sure nothing important is in AH.

I see tutorial above outputs low byte of cursor value to high part of video cursor register (0x0f) and high byte of cursor value to low part of video cursor register (0x0e) and I exactly followed it.

I also added option to use INT10 to use and when tested, it worked perfectly. Still looking

Code:
videoSetCursor  proc    far

    IF      OPTION_DEBUG_VIDEO
    M_PRINTF "\nvideoSetCursor entered: AX:"
    M_PRINTWORD ax
    ENDIF   ; OPTION_DEBUG_VIDEO

    IF      CONFIG_VIDEO_USE_INT10H_CURSOR
    push    ax
    push    bx
    push    dx

    mov     dx, vidCol          ; (DL) = col.
    mov     ax, vidRow          ; (AL) = row.
    mov     dh, al              ; (DH) = row

    mov     ah, 02h             ; (AH) = int10h cursor update function.
    mov     bh, 0               ; (BH) = page = 0.

    int     10h

    pop     dx
    pop     bx
    pop     ax
    ELSE;   CONFIG_VIDEO_USE_INT10H_CURSOR
    push    eax
    and     eax, 0ffffh
    or      eax, (VIDEO_RX_CURSOR_POS_LOW SHL 16) ; (EAX[31:16] = cursor position register update.
    call    videoSetVideoRx      ; write cursor position LOW register.
    pop     eax
    jmp     $+2

    push    eax
    and     eax, 0ffffh
    or      eax, (VIDEO_RX_CURSOR_POS_HIGH SHL 16) ; (EAX[31:16] = cursor position register update.
    shr     ax, 8               ; (AL) = hi byte of cursor.
    call    videoSetVideoRx     ; write cursor position LOW register.
    pop     eax
    jmp     $+2
    ENDIF   ; CONFIG_VIDEO_USE_INT10H_CURSOR
    ret
videoSetCursor  endp

videoSetVideoRx  proc    far
    M_PUSH <dx>

    IF      OPTION_DEBUG_VIDEO
    M_PRINTF "\nvideoSetVideoRx entered: rx[31:16], val[0:15] "
    M_PRINTDWORD eax
    ELSE    ; OPTION_DEBUG_VIDEO
    cli
    mov     dx, VIDEO_CTRL_IDX
    ror     eax, 16
    out     dx, al

    mov     dx, VIDEO_CTRL_DATA
    ror     eax, 16
    out     dx, al
    sti
    ENDIF



and here is the debug output of newly updated code:

Code:
Done setting video cur size to 15, display address, buffer base to 0 and cleared the screen

videoPutChar Entered: 54
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0000 000B8000
videoSetCursor entered: AX:0001
videoSetVideoRx entered: rx[31:16], val[0:15] 000F0001
videoSetVideoRx entered: rx[31:16], val[0:15] 000E0000
offset, color, org, row, col, pos:  0002 000E 0000 0000 0001 0002
videoPutChar: done.

videoPutChar Entered: 65
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0002 000B8002
videoSetCursor entered: AX:0002
videoSetVideoRx entered: rx[31:16], val[0:15] 000F0002
videoSetVideoRx entered: rx[31:16], val[0:15] 000E0000
offset, color, org, row, col, pos:  0004 000E 0000 0000 0002 0004
videoPutChar: done.

videoPutChar Entered: 73
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0004 000B8004
videoSetCursor entered: AX:0003
videoSetVideoRx entered: rx[31:16], val[0:15] 000F0003
videoSetVideoRx entered: rx[31:16], val[0:15] 000E0000
offset, color, org, row, col, pos:  0006 000E 0000 0000 0003 0006
videoPutChar: done.

videoPutChar Entered: 74
videoPutChar: processing ordinary char.
vidOffset 16:16 0:32:  B800:0006 000B8006
videoSetCursor entered: AX:0004
videoSetVideoRx entered: rx[31:16], val[0:15] 000F0004
videoSetVideoRx entered: rx[31:16], val[0:15] 000E0000
offset, color, org, row, col, pos:  0008 000E 0000 0000 0004 0008
videoPutChar: done.

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sun Jan 24, 2016 12:33 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

ggodw000 wrote:
and here is the debug output of newly updated code:


That looks perfectly correct to me.

I think it's time to have a talk about the amount and different types of VGA compatibility. I mentioned last post that no modern computer actually has a "100% VGA compatible at the hardware level" video card. Instead, what they actually are is "anywhere from 75% to 95% VGA compatible at the hardware level because nobody has really cared for 20+ years; and about 99% VGA compatible at the BIOS function level". ;)


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sun Jan 24, 2016 1:33 am 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
i even narrowed down to this level:
Code:
    mov     dx, 3d4h
    mov     al, 0eh
    out     dx, al
    inc     dx
    mov     al, 80h
    out     dx, al

    mov     dx, 3d4h
    mov     al, 0fh
    out     dx, al
    inc     dx
    mov     al, 00h
    out     dx, al


This does not even work.
So you are using int10h is the most sure way of having it to work which I would like to. But the issue I am having is I could probably not call it in protected mode, unless I can correctly set up the IDT all the way. I am assuming this is what i supposed to do. Issue I am trying to get the IDT to work and this is the reason I am writing video driver. So a circular loop of death.

Earlier I had issue with pmode: either I setup stack segment and load different stack in protected mode it triple faulted,
second triple fault i am experiencing was setup IDT all the way and enter pmode and it triple faulted. Perhaps I should make my binary directly bootable from disk (i was launching from DOS) to see symptoms remain.

tried this code on both hyper-v vm and amd simnow simulator, both did not work. :(

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sun Jan 24, 2016 2:23 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

ggodw000 wrote:
i even narrowed down to this level:
Code:
    mov     dx, 3d4h
    mov     al, 0eh
    out     dx, al
    inc     dx
    mov     al, 80h
    out     dx, al

    mov     dx, 3d4h
    mov     al, 0fh
    out     dx, al
    inc     dx
    mov     al, 00h
    out     dx, al


This does not even work.


Now you're writing the data to the "index" port (and not the "data" port).

ggodw000 wrote:
So you are using int10h is the most sure way of having it to work which I would like to. But the issue I am having is I could probably not call it in protected mode, unless I can correctly set up the IDT all the way. I am assuming this is what i supposed to do. Issue I am trying to get the IDT to work and this is the reason I am writing video driver. So a circular loop of death.


I only have 2 cases - in early boot code (where it's easy to use the firmware), or in graphics mode using a "frame buffer" (where there's no hardware cursor). For both of these cases (up until "user login" at the very end of boot code) the system isn't waiting for user input and therefore the cursor shouldn't be displayed.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: wrote vdriver 80x25 8 color, works but problem with curs
PostPosted: Sun Jan 24, 2016 2:42 am 
Offline
Member
Member

Joined: Wed Nov 18, 2015 3:04 pm
Posts: 396
Location: San Jose San Francisco Bay Area
okay, just hide the cursor and not bother with it then. Well that is what i am going to do and move on. it is just headache. #-o

_________________
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 481 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group