www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/29/09:18:06

From: tom DOT robinson AT cableol DOT co DOT uk DOT REMOVETHIS (Tom Robinson)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie Needs Help
Date: Sat, 29 Nov 1997 11:46:18 GMT
Organization: TeamOnslaught
Lines: 138
Message-ID: <34815eb2.62354295@news.cableol.co.uk>
References: <19971129 DOT 101142 DOT 16006 DOT 1 DOT matthew DOT krause AT juno DOT com> <65n24n$q6h AT bgtnsc03 DOT worldnet DOT att DOT net>
Reply-To: tom DOT robinson AT cableol DOT co DOT uk DOT REMOVETHIS
NNTP-Posting-Host: p38-condor-gui.tch.cableol.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 28 Nov 1997 18:22:15 GMT, "Steve Patton" <leaphe AT pemail DOT net> wrote:

>To place a single pixel ( in that same mode)
>
>int x, y, c;
>
>x = 3;       // x
>y = 5;      // y
>c = 15;   // color value
>
>_farpokeb ( _dos_ds, 0xA0000 + x + (y*320), c );

Quick note: 

_farpokeb(_dos_ds, 0xA0000+(y<<8)+(y<<6)+x, c);

is a faster way of doing it...

>That requires an odd header file, it might be <sys\farptr.h>, but you
>should look it up in LIBC.INF as well.  That's the second fastest way I
>know how to.  (The fastest way I know how, requires disabling protected
>memory, and is more complicated to get started)

Here you go...I think this one's what you mean.  It might just be
another way of doing it though.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <sys\movedata.h>
#include <sys\nearptr.h>
#include <pc.h>
#include <go32.h>
#include <dpmi.h>

#define SPEEDCOMP       1.3             // speed compensation factor
for moving parts //
                       // don't want to over complicate things //
char *scrptr;

typedef struct 
{
        unsigned char red,green,blue;
} pal;

pal palette[256];
char xbuffer[128], ybuffer[128];
char ScreenBuffer[64000];
union REGS r;

/*--------------------------------------------------------------------------*/
// Sets the graphics mode 320x200 with 256 colours //

void Set320x200(void)
{
   r.h.ah=0;
   r.h.al=0x13;
   int86(0x10, &r, &r);
}

/*--------------------------------------------------------------------------*/
// Sets 80 column text mode, 25 rows //

void SetTextMode(void)
{
   r.h.ah=0;
   r.h.al=0x03;
   int86(0x10, &r, &r);
}

/*--------------------------------------------------------------------------*/
// sets a pixel on the screen with the specified colour //
// Most C setpixel calls are very slow, so we write our own one here.
//

void setpixel(long x, long y, char col)
{
        *(scrptr + (y*320) + x) = col;
}

/*--------------------------------------------------------------------------*/
// sets a pixel on the screen buffer with the specified colour //

void setbpixel(long x, long y, char col)
{
        *((char*) ScreenBuffer + (y*320) + x) = col;    
}

/*--------------------------------------------------------------------------*/
// copies the screen buffer to the real screen, and clears the virtual
screen //

void BuffertoScreen(void)
{
        memcpy(scrptr, ScreenBuffer, 64000);    
        memset(ScreenBuffer, 0, 64000); 
}

/*--------------------------------------------------------------------------*/
// set up what happens when :) //

int main (void)
{
    __djgpp_nearptr_enable();
        scrptr = (char*) (__djgpp_conventional_base + 0xa0000);
 
        Set320x200();
        setpixel(160, 100, 15);
        getch();
                
        SetTextMode();
        return(0);
}       

/*--------------------------------------------------------------------------*/

>Hope that helps!  But I recommend you do try getting the Allegro library. 
>It has many of the functions and more, and is pretty fast for a library. 
>Here's the address to Allegro home page
>
>http://www.talula.demon.co.uk/allegro/
>
>-Steve

---------------------------
Tom Robinson (aka Mystican)
TeamOnslaught member
tom DOT robinson AT cableol DOT co DOT uk

To E-mail me, remove the '.REMOVETHIS' from the end of my address or
use the address above.

-*- !! Visit Our Homepage !! Screenshots of Decamatch out !! -*-
http://www.geocities.com/TimesSquare/Arcade/7286
-*- !! Visit Our Homepage !! Screenshots of Decamatch out !! -*-

- Raw text -


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