Author Topic: SVGA Banks  (Read 4001 times)

Offline alexBishop

  • Jr. Member
  • *
  • Posts: 10
SVGA Banks
« on: December 27, 2010, 12:30:09 AM »
I have read that it is possible to set up a vesa svga mode where all the video memory is in memory (so you don't have to use int 10h to change the active window). Can someone tell me if this is possible and if so show me some example code.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2384
  • Country: us
Re: SVGA Banks
« Reply #1 on: December 27, 2010, 09:05:04 AM »
I guess you're speaking of a "Linear Frame Buffer"(?). This used to work for me.

Code: [Select]
; in .bss
; dunno why I called this "Ptr", it's just a buffer
ModeInfoBlockPtr resb 200h

section .text
        call    FLAT_install            ; Enable 4Gb address space

mov ax,4F01h                    ; Get VBE Mode Information
        mov cx,103h                     ; Mode : 800x600, 256 colours
        mov di,ModeInfoBlockPtr         ; ES:DI now points to ModeInfoBlock
                                        ; structure
int 10h                         ; Do it!
cmp ax,4Fh                      ; Error?
        jne near VBE_error
mov ax,4F02h                    ; Set VBE Mode
        mov bx,0C103h                   ; Mode : 800x600, 256 colours,
         mov edi,dword [es:di+28h]       ; ModeInfoBlock[28h] = 'PhysBasePtr'

xor eax,eax                     ; Clear EAX
mov es,ax                       ; ES:EDI now points to first address
                                        ; linear/flat, don't clear display
int 10h                         ; Do it!
cmp ax,4Fh                      ; Error?
        jne near VBE_error

; this doesn't look right!
;        mov di,ModeInfoBlockPtr         ; ES:DI now points to ModeInfoBlock
                                       ; of video buffer

        push edi
        mov ecx,1D4C0h             ; 800 x 600 /4 dwords
a32     rep stosd                  ; Clear video buffer
        pop edi

The issue is accessing that memory! The only way I know how to do it is in "Flat Real Mode". I use Herman Dullink's code - I'll attach the whole thing...

Good Luck!

Best,
Frank




Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2384
  • Country: us
Re: SVGA Banks
« Reply #2 on: December 27, 2010, 09:16:44 AM »
That got scrambled, somehow... try again...

Code: [Select]
section .text
        call    FLAT_install            ; Enable 4Gb address space

        mov si, goodflat
        call write
        mov ah, 0
        int 16h

mov ax,4F01h                    ; Get VBE Mode Information
        mov cx,103h                     ; Mode : 800x600, 256 colours
        mov di,ModeInfoBlockPtr         ; ES:DI now points to ModeInfoBlock
                                        ; structure
int 10h                         ; Do it!
cmp ax,4Fh                      ; Error?
        jne near VBE_error
mov ax,4F02h                    ; Set VBE Mode
        mov bx,0C103h                   ; Mode : 800x600, 256 colours,
                                        ; linear/flat, don't clear display
int 10h                         ; Do it!
cmp ax,4Fh                      ; Error?
        jne near VBE_error
        mov di,ModeInfoBlockPtr         ; ES:DI now points to ModeInfoBlock
        mov edi,dword [es:di+28h]       ; ModeInfoBlock[28h] = 'PhysBasePtr'

xor eax,eax                     ; Clear EAX
mov es,ax                       ; ES:EDI now points to first address
                                        ; of video buffer
;        mov [scr_buf],edi

        push edi
        mov ecx,1D4C0h             ; 800 x 600 /4 dwords
a32     rep stosd                  ; Clear video buffer
        pop edi

You probably don't want to have to reboot to "real real-mode dos" anyway... There may be a way to do it using dpmi, or such. I don't know how...

Best,
Frank


Offline alexBishop

  • Jr. Member
  • *
  • Posts: 10
Re: SVGA Banks
« Reply #3 on: December 27, 2010, 10:02:14 AM »
thankyou Frank Kotler  :)