From: "Michael Stewart" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problems with video class in C++ Date: Tue, 2 Mar 1999 18:35:58 -0000 Organization: Customer of Planet Online Lines: 102 Message-ID: <7bhc9s$gbu$3@news5.svr.pol.co.uk> References: <36d1f59d DOT 0 AT nemo DOT idirect DOT com> NNTP-Posting-Host: modem-115.fluorine.dialup.pol.co.uk X-Trace: news5.svr.pol.co.uk 920401020 16766 62.136.4.115 (2 Mar 1999 18:57:00 GMT) NNTP-Posting-Date: 2 Mar 1999 18:57:00 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Dylan Trotter wrote in message <36d1f59d DOT 0 AT nemo DOT idirect DOT com>... >Hi Hello >/*This is the assignment for the screen pointer which should point to the >VGA segment*/ >screen = (unsigned char *) 0xA0000 + __djgpp_conventional_base; Fine >/*This dynamically allocates memory for the 320x200x8 buffer*/ >buffer = new unsigned char[64000]; > >/*This is the put_pixel routine I am using*/ >inline void video::put_pixel(int x, int y, unsigned char col) >{ > if (col != trans_col[0]) > { > if (x < 0) x = x_resolution + (x % x_resolution); > if (x >= x_resolution) x %= x_resolution; > if (y < 0) y = y_resolution + (y % y_resolution); > if (y >= y_resolution) y %= y_resolution; > > buffer[y * bytes_per_scanline + x] = col; > } >} Surely this would be a little better. void video::put_pixel (int x, int y, unsigned char col) { if (col != trans_col[0]) return; if (x < 0 || x >= x_resolution) return; // No point displaying a pixel that is out of bounds if (y < 0 || y >= y_resolution) return; buffer[y * bytes_per_scanline + x] = col; // Don't forget this will only work like this in 8 bit modes. } >/*And this is the routine to copy the buffer to the screen*/ >inline void video::show_buffer() >{ > wait_for_vertical_retrace(); > > for(int y = 0; y < y_resolution; y++) > memcpy((unsigned char *) (screen + (y * bytes_per_scanline * >bytes_per_pixel)), > (unsigned char *) (buffer + (y * x_resolution * >bytes_per_pixel)), > x_resolution * bytes_per_pixel); >} Don't see any problem here. But I think for a bit more speed you might want to set the buffer to the same size as the screen. That way you could just use, this would cut out all the looping. memcpy (screen, buffer, screen_size); >Another quick question I have is whether there is a software interrupt I >could call to return the current video mode (preferably including extended >SVGA modes). Yup, from the VESA spec Input: AH = 4Fh Super VGA support AL = 02h Set Super VGA video mode BX = Video mode D0-D14 = Video mode D15 = Clear memory flag 0 = Clear video memory 1 = Don't clear video memory Output: AX = Status (All other registers are preserved) The interrupt you need is 0x10. You had better get hold of the VESA spec (www.vesa.org) as there are alot of other functions that you should look at. >video::~video() >{ > if (buffer != NULL) delete [] buffer; >} Can't see a problem here. -- Michael Stewart mike AT reggin DOT freeserve DOT co DOT uk "Just because you're paraniod doesn't mean they aren't after you..."