ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/27/20:08:28

Xref: news-dnh.mv.net comp.os.msdos.djgpp:4035
Path: news-dnh.mv.net!mv!news.sprintlink.net!newsfeed.internetmci.com!news.mel.aone.net.au!newshost.pcug.org.au!usenet
From: The Joker <smcdonal AT pcug DOT org DOT au>
Newsgroups: comp.os.msdos.djgpp
Subject: Video axs in v2 which should be in the faq.
Date: 27 Dec 1995 13:10:21 GMT
Organization: AUUG Inc. (Canberra) & PCUG (ACT) Inc.
Lines: 44
Message-ID: <4brgjt$moq@supreme.pcug.org.au>
NNTP-Posting-Host: ts94.pcug.org.au
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ok, fellas, here's how you access the graphics in djgpp v2, without
incuring a speed penalty for having es:[addr] or whatever. It also makes 
it a hell of a lot easier. My way will let you have a normal array-like 
pointer to the vidmem, like we all used to in borland c...

It's simple. In the top(ish) have char *vidmem; and in the initialisation 
part you must do this (psuedo-ish code, I forgot the function names ;)

unsigned short DS; //This might need to be int, not short, can't remember

int startup(void)
{
  asm(" mov %ds,%ax     //Probably only needs mov %ds,_DS, but who cares?
        mov %ax,_DS");  //The startup routines not need to be fast.
  long base_addr=get_segment_base(ds); //Get the base of ds
  set_segment_limit(ds,0xffffffff); //Set ds limit to 4g. This is the    
                                 //trick.
  unsigned long vga_addr=0x0a0000-base_addr;
//^^^^^^^^ Very important you remeber this

  vidmem=(char *)vga_addr; //Don't skip the above line by putting the 
                // math on this one, as it probably won't wrap properly.
  return;
}

Many people might whinge because the DS starts at 0x10000000 (give or 
take a few 0's ;), but because the integer size is the address size (32 
bits) it will wrap to, errrm, (4g+(0x0a000-1m)) (is that right ?), and 
because segment limit is 4gig, and the resultant is > 4g-1m, it wraps 
around to the beginning of memory (before the actual base of ds) and, 
presto, it nows points to the real 0x0a000:0000! This would also work 
with any real mode address, but I only have used it for this purpose.

Oh yeah, if you think it doesn't work, i'll post proof it does.

Unless there is some inherrant danger in doing this (I sure doubt it 
though), this should be added to the faq, because untill a friend and I 
jointly came up with the idea I would have killed to know how to do this.

Besides, I'd just love to see my name next to something good. Oh yeah, 
don't forget to also credit toast[ph00d] if you add it.

Hope I helped, Joker/JAM Aust. 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019