Results 1 to 10 of 10

Thread: Direct Video Memory Access (text) Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    80

    Direct Video Memory Access (text) Question

    All right, I'm writing a few functions for fast text output in DOS. I'm using the pokeb function in order to write to memory B800:offset, so my line basically looks like this:
    pokeb(B800,(y*screen_width)+(x*2),character);
    pokeb(B800,(y*screen_width)+(x*2)+1,color);

    (Actually I use shifting instead of multiplication but this is easier to understand)

    Since the memory is linear the lines are automatically wrapped and the format of the memory is 0:[character], 1:[color], 2:[character], 3:[color],…

    That's pretty simple and works fine. My question is as follows, while those two lines seem to be working fine for most computers, on others (my own for example) the start of the video memory is not B800:0 but B800:32. So with that I need to add 32 to the offset in order for the text to appear in the right place, otherwise if x is less then 32 and y is 0 the letters just don't appear. This seems to be machine specific because all of the computers at my school work fine with B800:0 and so do a number of other computers that I've tested this with, but as I've said before, my own computer needs for me to add 32 to the offset. Does anyone know why this is, and if there is a way to detect which setting is needed automatically without me having to create 2 versions of my program that uses this.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Why are you using DOS still?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    80
    1. Because it's the best route to learning c++
    2. Because that's what we are using at my school
    3. Because I love DOS

  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Ignore Parksie; he doesn't understand why someone would still have a 386 machine and like it. About 30% of all PC's world wide are 486 or earlier still running DOS and/or Windows 3.x. He means well.

    Anyway -
    B000 is weird - most video card memory used to start at A000...
    as I remember.

    Most of the cards running under AMI bios were like this:

    MEMORY MAP / ACCESS:
    Video Memory Address: A000-BFFF
    Video BIOS Address: C000-C7FF
    Video Port Address: 3B0-3DF

    These may vary - but BIOS knows where video memory starts.
    You have to know what BIOS you are looking at, what video card as well.

    So - for example, if you have AMI bios:

    When you system first boots it displays BIOS information. Record it. Then go to www.ami.com. You can download the memory configuration for your particular BIOS from there. Then peek at the correct BIOS offset to get the start of video memory. This is how DOS finds it.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    80
    You're thinking of the 13h mode with A000:0000 as its memory location. In text mode (25x80 or 50x80) the address for the video memory is (or should be) B800:0000, in my case B800:0020.

    So is there a way to get this information directly from BIOS? I mean I wouldn't want to do it "if this bios" -> "use this location" type of thing?

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by jim mcnamara
    Ignore Parksie; he doesn't understand why someone would still have a 386 machine and like it. About 30% of all PC's world wide are 486 or earlier still running DOS and/or Windows 3.x. He means well.
    Actually my aims are purely selfish. As of yet, I have not seen any good *recent* code come out of attempts to program for DOS, in any kind of maintainable way. And invariably, it's people like you and us that end up having to fix it.

    I would happily write code for a 386 if I had one, if it had any kind of decent OS support that was capable of using the CPU to its full potential, and you know as well as I do that 16-bit is limiting even on a 386.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's not the best route for learning C++, but that's not the topic of the thread.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    CB-

    What is the 'VBF Countdown 15' thing in your sig?

  9. #9
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Int 10 gives you BIOS information about video.
    I don't have a reference here on all the int 10 calls but here are a few samples.

    I didn't know you understood interrupts.

    ----------104F00-----------------------------
    INT 10 - VESA SuperVGA BIOS - GET SuperVGA INFORMATION
    AX = 4F00h
    ESI -> 256-byte buffer for SuperVGA information (see below)
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    SeeAlso: AX=4F01h

    Format of SuperVGA information:
    Offset Size Description
    00h 4 BYTEs signature ('VESA')
    04h WORD VESA version number
    06h DWORD pointer to OEM name
    0Ah 4 BYTEs capabilities
    0Eh DWORD pointer to list of supported VESA and OEM video modes
    12h 238 BYTEs reserved
    ----------104F01-----------------------------
    INT 10 - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION
    AX = 4F01h
    CX = SuperVGA video mode
    ESI -> 256-byte buffer mode information (see below)
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    SeeAlso: AX=4F00h,AX=4F02h

    Format of mode information:
    Offset Size Description
    00h WORD mode attributes
    bit 0: mode supported
    bit 1: optional information available
    bit 2: BIOS output supported
    bit 3: set if color, clear if monochrome
    bit 4: set if graphics mode, clear if text mode
    02h BYTE window A attributes
    bit 0: exists
    bit 1: readable
    bit 2: writable
    bits 3-7 reserved
    03h BYTE window B attributes (as for window A)
    04h WORD window granularity in K
    06h WORD window size in K
    08h WORD start segment of window A
    0Ah WORD start segment of window B
    0Ch DWORD -> FAR window positioning function (equivalent to AX=4F05h)
    10h WORD bytes per scan line
    ---remainder is optional for VESA modes, needed for OEM modes---
    12h WORD width in pixels
    14h WORD height in pixels
    16h BYTE width of character cell in pixels
    17h BYTE height if character cell in pixels
    18h BYTE number of memory planes
    19h BYTE number of bits per pixel
    1Ah BYTE number of banks
    1Bh BYTE memory model type
    1Ch BYTE size of bank in K
    ----------104F02-----------------------------
    INT 10 - VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE
    AX = 4F02h
    BX = mode
    bit 15 set means don't clear video memory
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    SeeAlso: AX=4F01h,AX=4F03h

    Values for VESA video mode:
    00h-FFh OEM video modes (see AH=00h)
    100h 640x400x256
    101h 640x480x256
    102h 800x600x16
    103h 800x600x256
    104h 1024x768x16
    105h 1024x768x256
    106h 1280x1024x16
    107h 1280x1024x256
    108h 80x60 text
    109h 132x25 text
    10Ah 132x43 text
    10Bh 132x50 text
    10Ch 132x60 text
    ----------104F03-----------------------------
    INT 10 - VESA SuperVGA BIOS - GET CURRENT VIDEO MODE
    AX = 4F03h
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    BX = video mode (see AX=4F02h)
    SeeAlso: AX=4F02h
    ----------104F04-----------------------------
    INT 10 - VESA SuperVGA BIOS - SAVE/RESTORE SuperVGA VIDEO STATE
    AX = 4F04h
    DL = subfunction
    00h get state buffer size
    Return: BX = number of 64-byte blocks needed
    01h save video states
    ES:BX -> buffer
    02h restore video states
    ES:BX -> buffer
    CX = flags for states to save/restore
    bit 0: video hardware state
    bit 1: video BIOS data state
    bit 2: video DAC state
    bit 3: SuperVGA state
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    ----------104F05-----------------------------
    INT 10 - VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
    AX = 4F05h
    BH = subfunction
    00h select video memory window
    DX = window address in video memory (in granularity units)
    01h get video memory window
    Return: DX = window address in video memory (in gran. units)
    BL = window number
    00h window A
    01h window B
    Return: AL = 4Fh function supported
    AH = status
    00h successful
    01h failed
    SeeAlso: AX=4F06h,AX=4F07h,AX=7000h/BX=0004h
    ----------104F06-----------------------------
    INT 10 - VESA SuperVGA BIOS 1.1 - GET/SET LOGICAL SCAN LINE LENGTH
    AX = 4F06h
    BL = function
    00h set scan line length
    CX = desired width in pixels
    01h get scan line length
    Return: AL = 4Fh if function supported
    AH = status
    00h successful
    01h failed
    BX = bytes per scan line
    CX = number of pixels per scan line
    DX = maximum number of scan lines
    Notes: if the desired width is not achievable, the next larger width will be set
    the scan line may be wider than the visible area of the screen
    this function is valid in text modes, provided that values are
    multiplied by the character cell width/height
    SeeAlso: AX=4F01h,AX=4F05h,AX=4F07h
    ----------104F07BH00-------------------------
    INT 10 - VESA SuperVGA BIOS 1.1 - GET/SET DISPLAY START
    AX = 4F07h
    BH = 00h (reserved)
    BL = 00h set display start
    CX = leftmost displayed pixel in scan line
    DX = first displayed scan line
    = 01h get display start
    Return: BH = 00h
    CX = leftmost displayed pixel in scan line
    DX = first displayed scan line
    Return: AL = 4Fh if function supported
    AH = status
    00h successful
    01h failed
    Note: this function is valid in text modes, provided that values are
    multiplied by the character cell width/height
    SeeAlso: AX=4F01h,AX=4F05h,AX=4F06h
    ----------104FFF-----------------------------
    INT 10 - VESA SuperVGA BIOS - Everex - TURN VESA ON/OFF
    AX = 4FFFh
    DL = new state (00h off, 01h on)

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by jim mcnamara
    CB-

    What is the 'VBF Countdown 15' thing in your sig?
    Everytime something really pisses me off here I'll decrement the countdown. When it reaches 0 I'll leave VBF forever and only answer questions on Galahtech anymore.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width