delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/17/19:31:11

From: waage AT brainerd DOT net (waage)
Newsgroups: comp.os.msdos.djgpp
Subject: wirting to a virtual screen - HELP!
Date: Fri, 17 Oct 1997 00:16:00 GMT
Organization: [poster's organization not specified]
Lines: 58
Message-ID: <3446a9d5.2362988@news.polaristel.net>
NNTP-Posting-Host: cronkite.means.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am having problems copying info from a virtual screen allocated with
malloc and copying it to the VGA 0xa000.  The code looks like this,
when compiled it says no errors but when I try to write to the virtual
screen with my put_pixel it crashes.

This is the function that allocates the virtual screen and (I hope)
returns the address in memory where its located.

unsigned long set_virtual(int w, int h) {
    unsigned long v_size = w * h;
    unsigned long vir_scr;
    (void *)vir_scr = malloc(v_size);

    if(vir_scr != NULL) {
      printf("Allocated memory for virtual screen.\n");
      return vir_scr;
      }
    else {
      printf("Unable to allocate %U bytes for virtual screen.\n",
v_size);
      return 0;
      }
}

This is my put_pixel function, where is the address in memory that it
wants to write to.

void put_pixel(int where, int x, int y, unsigned char *col) {
    _farpokeb(_dos_ds, where*16+(x+(y*320)), col);
    }

This does not work with the virtual screen.  Can anyone tell me if it
is because the virtual screen has a different selector than the a000
(the info said that _dos_de has a limit of 1MB)?  Does malloc(...) use
memory above 1mb and do I need to use a different selector?  I thought
of this and came up with this:

short get_virtual_discriptor(unsigned long vir_scr) {
    return(__dpmi_segment_to_descriptor(vir_scr));
	}

void put_vir_pixel(short sel, unsigned long where, int x, int y,
unsigned char col) {
    _farpokeb(sel, where*16+(x+(y*320)), col);
    }

This didnt work either.. is there something I'm missing?  Any help
would be greatly appreciated!

This is my flip function and I'm not sure if it even works because I
havnt gotten around to even writing to my virtual screen.

void flip(unsigned long dest, unsigned long src) {
    unsigned short *buffer;
    dosmemget(src*16+0x0000, sizeof(src), &buffer);
    dosmemput(buffer, sizeof(buffer), dest);
    }

- Raw text -


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