Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 May 2006
Offline Last Active Sep 02 2015 07:09 PM

Posts I've Made

In Topic: VBE 2.0+ Set Display Start for Page Flipping

02 September 2015 - 08:27 AM

Have you also tried posting this on the osdev forums at osdev.org?

Yep, http://forum.osdev.org/viewtopic.php?f=13&t=29536 - the third post by me is the same (or nearly) as the first post here.


I don't know the reason why GetDisplayStart is returning 0 for you. If you change it to something else with SetDisplayStart, does it return the new values?

Yes it returns the new value (if not way out of memory range - Bochs panics on Y position out of range)

In Topic: VBE 2.0+ Set Display Start for Page Flipping

01 September 2015 - 05:29 PM

Well, I'll try it out soon, I'm stuck somewhere else for now, but IIRC I have tried memory offsets with the same result.


But again I'll test it out in a few days to a week once IPC is fully functioning.


Thanks for your replies, I'll post updates.



P.S. I have also been told that the issue may be in Bochs' VBE, so I'll try other "platforms" - lack of better term - including Physical HW

In Topic: VBE 2.0+ Set Display Start for Page Flipping

01 September 2015 - 03:43 PM

Have you tried doing a GetDisplayStart first, then adding (or subtracting) your screen height to the returned DX, and then passing back the CX and DX values to SetDisplayStart?


Also, take a look at the "Protected Mode considerations" chapter of the VBE dcoument. It seems to say something specific about function 07h. In PM, the CX and DX values are actually a memory address, not the scan line&pixel position as in RM.


I miss VESA. smile.png

GetDisplayStart returns CX = DX = 0

Also only the sub functions of Function 7 that were added in VBE 3.0 use memory locations, the older ones still use legacy values (If I understand the Spec sheet correctly)

I don't know why I cannot copy out the PDF so I'll tell you its page labled 51 (59 in the PDF), second full paragraph - http://www.petesqbsite.com/sections/tutorials/tuts/vbe3.pdf

In Topic: VBE 2.0+ Set Display Start for Page Flipping

21 August 2015 - 02:06 PM

I recall there being bitplanes in some modes, not a nice contiguous buffer, and the pattern looks like that. Sometimes you needed to write to some io ports to choose one. The fun part was activating all planes and clearing memory much faster. You might want to find more information on how the video memory corresponds to pixels in that mode?

Or if you have too much time to waste: try different patterns, like setting 4x the amount of memory to 1 color, then drawing exactly one line, then try drawing every fourth byte of the line and moving the pattern 1 byte or line or 1k bytes, or try changing single pixels at many positions, to find out where it ends up on screen?

Though you may be better off getting text mode to run first or one of the standard VGA modes like 640x480x16colors or 320x200x256colors, not one of the more complicated vendor-dependent SVGA modes.

I have no problem with LFB (in fact in all my systems it is purely flat) The problem comes only when trying to page flip, I can draw all day onto the screen perfectly.


In fact I just enabled the SSE and started moving 128 Bytes of memory at a time instead of 4, which made my double buffer fast enough to work (even at 1024x768x32bpp), though I would still like a buffer in video ram to switch to.

In Topic: Returning a Char Array from function in C

27 September 2013 - 12:18 PM


If you can suggest an easier and\or better way of doing this please point me in the right direction. I'm only on my second build here and I know I have at least two more before I get all the features I want such as fragmentation (yea I know breaking files into parts is a bad idea [Microsoft] but I want the ability if it is needed)

  • Always* keep the null-terminator in mind when dealing with strings: ret isn't large enough to hold 16 characters and the null terminator; sprintf is writing the null terminator in memory that doesn't belong to ret!
  • Always* look for ways to reduce and refactor duplicate code: Notice the format parameter for sprintf in BinHex is twice that of bytes? You can reduce this whole case statement by adding another level of indirection; try using another sprintf to prepare the format parameter. The switch case in HexBin can also be reduced to a loop.
  • Always* enforce parameter constraints. The bytes parameter can only be between 1 and 8, but you have a special behavior defined when it is not. It may be better to throw a fatal error in this case by using assert.
*Be wary of statements such as "always do this" or "never do that", it's "always" situational and may not fit every use case.

Here's the reduced code:

Hope this helps!

EDIT: Formatting/editing


That helped a lot, thanks. I did have to edit your code to the following BinHex was slightly wrong:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include "MyFS.h"

// 17 characters, to make room for the null-terminator
void BinHex(char Bin[17], char ret[17], int bytes)
    // Enforce constraints
    assert( 1 <= bytes && bytes <= 8 );

    // Here, we use pointers to read and write to and from ret and Bin respectively
    char* dst = &ret[0];
    char* src = &Bin[0];

    // Equivalent to "for ( ; bytes > 0; bytes-- )"
    while ( bytes-- )
        // sprintf returns the number of characters written, so can use this
        // to our advantage and move the write pointer 2 characters for 
        // every 2 characters written
        dst += sprintf(dst,"%02x",(unsigned int)(src[bytes]) );   // "src[bytes]" read a charater from src and moves it to the previous character

void DecHex(unsigned int Dec, char ret[17], int bytes)
    assert( 1 <= bytes && bytes <= 8 );

    char fmt[5];
    // "%%" -> "%"
    // "%02i" -> zero-padded bytes*2, width of 2
    // "x" -> "x"
    sprintf(fmt,"%%%02ix",bytes*2); // When bytes=4 and Dec=65534, "%%%02ix" -> "%08x"
    sprintf(ret,fmt,Dec);  // "%08x" -> 0000FFFE

unsigned int HexDec(char* Hx)
    unsigned int ret;
    ret = (unsigned int)strtol(Hx, NULL, 16);
    return ret;

But it defiantly helped with readability 




Brian T Hoover